Skip to content
Snippets Groups Projects
Unverified Commit d0c8a073 authored by Bastian Köcher's avatar Bastian Köcher Committed by GitHub
Browse files

grandpa: Ensure `WarpProof` stays in its limits (#6963)

There was the chance that a `WarpProof` was bigger than the maximum warp
sync proof size. This could have happened when inserting the last
justification, which then may pushed the total proof size above the
maximum. The solution is simply to ensure that the last justfication
also fits into the limits.

Close: https://github.com/paritytech/polkadot-sdk/issues/6957

---------

Co-authored-by: command-bot <>
parent 97d3b860
No related merge requests found
Pipeline #510191 waiting for manual action with stages
in 1 hour, 20 minutes, and 16 seconds
title: 'grandpa: Ensure `WarpProof` stays in its limits'
doc:
- audience: Node Dev
description: |-
There was the chance that a `WarpProof` was bigger than the maximum warp sync proof size. This could have happened when inserting the last justification, which then may pushed the total proof size above the maximum. The solution is simply to ensure that the last justfication also fits into the limits.
Close: https://github.com/paritytech/polkadot-sdk/issues/6957
crates:
- name: sc-consensus-grandpa
bump: patch
......@@ -174,10 +174,20 @@ impl<Block: BlockT> WarpSyncProof<Block> {
let header = blockchain.header(latest_justification.target().1)?
.expect("header hash corresponds to a justification in db; must exist in db as well; qed.");
proofs.push(WarpSyncFragment { header, justification: latest_justification })
let proof = WarpSyncFragment { header, justification: latest_justification };
// Check for the limit. We remove some bytes from the maximum size, because we're
// only counting the size of the `WarpSyncFragment`s. The extra margin is here
// to leave room for rest of the data (the size of the `Vec` and the boolean).
if proofs_encoded_len + proof.encoded_size() >= MAX_WARP_SYNC_PROOF_SIZE - 50 {
false
} else {
proofs.push(proof);
true
}
} else {
true
}
true
};
let final_outcome = WarpSyncProof { proofs, is_finished };
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment