-
Notifications
You must be signed in to change notification settings - Fork 2.6k
grandpa: rewrite warp sync proof generation #8148
Conversation
The current interface just returns a warp sync proof which could be limited due to:
For 1) it probably makes sense that we somehow note in the response that we can still prove more and that the client should then request for another proof with a higher begin block. For 2) we really have to defer to the client regarding how to proceed. If it's a light client it could keep importing blocks until it applies the forced change and then ask for another warp sync proof. When we do a forced change we are essentially hard forking the GRANDPA authority set, so any security assumptions regarding the authority set handoffs are broken. On production chains forced changes should not happen often so ideally the light client would just start from a checkpoint that is past any forced change. Edit: to make 2) more clear:
|
I will still add some tests and code to verify the warp sync proof, but this should be good for some basic testing with smoldot :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A small nitpick but otherwise looks good!
But yeah, otherwise it works 🎉 :
|
I added a test for generating / verifying a warp sync proof and added docs. I think this should be good to go now. |
One thing we were considering adding is a This can be done in a further PR, I guess? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good!
The companion pr for polkadot is pretty simple: https://github.com/paritytech/polkadot/compare/ashley-andre-fast-warp-sync-proofs?expand=1 |
Let's merge this? |
bot merge |
Trying merge. |
* grandpa: use AuthoritySetChanges to generate warp sync proof * node: init grandpa warp sync protocol * grandpa: iterator for AuthoritySetChanges * grandpa: rewrite warp sync proof generation * grandpa: remove old code for warp sync generation * grandpa: fix indentation * grandpa: fix off by one * grandpa: use binary search to find start idx when generating warp sync proof * grandpa: add method to verify warp sync proofs * grandpa: remove unnecessary code to skip authority set changes * grandpa: add test for warp sync proof generation and verification * grandpa: add missing docs * grandpa: remove trailing comma
Part of the upgrade to substrate 3.0 Updating some of the cargo dependencies that the original packages in substrate 3.0 release are no longer available. Unbreak browser test CI (paritytech#8148) Update to libp2p-0.35.1 (paritytech#8141) Update to libp2p-0.36 (paritytech#8420) * Update to libp2p-0.36 * Some more Cargo.lock updates. Update to libp2p-0.35.1 (paritytech#8141) This commit can be dropped in future upgrades
This PR rewrites the existing code for warp sync proof generation. After #7339 we now have a way of figuring out the last block for every authority set, this block should contain a digest that signals the next set and most importantly we must have stored a justification for its finalization. By iterating through this index we can easily build a warp sync proof without having to search random blocks on the DB for justifications.
I made a basic benchmark on Kusama for this:
polkadot companion: paritytech/polkadot#2523