grandpa: fix warp sync proof on missing data (#8795)

* grandpa: check for missing data when iterating through authority set changes

* grandpa-warp-sync: handle missing data
This commit is contained in:
André Silva
2021-05-22 18:12:42 +01:00
committed by GitHub
parent 77eba1351a
commit 00328dca24
3 changed files with 39 additions and 19 deletions
@@ -173,4 +173,6 @@ pub enum HandleRequestError {
InvalidProof(String),
#[display(fmt = "Failed to send response.")]
SendResponse,
#[display(fmt = "Missing required data to be able to answer request.")]
MissingData,
}
@@ -91,7 +91,10 @@ impl<Block: BlockT> WarpSyncProof<Block> {
let mut proofs_encoded_len = 0;
let mut proof_limit_reached = false;
for (_, last_block) in set_changes.iter_from(begin_number) {
let set_changes = set_changes.iter_from(begin_number)
.ok_or(HandleRequestError::MissingData)?;
for (_, last_block) in set_changes {
let header = blockchain.header(BlockId::Number(*last_block))?.expect(
"header number comes from previously applied set changes; must exist in db; qed.",
);