This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
grandpa: cleaner RPC API for proving finality #7115
Labels
J0-enhancement
An additional feature request.
U2-some_time_soon
Issue is worth doing soon.
Z2-medium
Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase.
In #6215 we introduced an RPC API for proving finality of arbitrary blocks by using the existing
FinalityProofProvider
infrastructure but the current API is rather cumbersome to use. The existing API is:It requires that a user of the API keep track of the authorities set id and also of block ranges spanning a given set. I think we should be able to implement the following API:
The way this API would work is that it would always generate a finality proof based on the justification from the last block in the set (which is always guaranteed to be persisted).
If a user wants to prove finality for block #52 we figure out what the set id is for that block and what the last block in the session was. Then we have all the data needed for
FinalityProofProvider
to generate the proof. I think the only thing we need to do is to start persisting the block number of the last block of the authority set so we get aVec<BlockNumber>
. Given any block number we could then perform binary search on this array to figure out what the last block in the set was (and implicitly the set id given by the index in the array).For some service that is trying to sync and check for finality they would:
prove_finality(#1)
, for which they would get a finality proof that proves finality of all blocks up until the last block in the set;None
finality proof, which means they'll be on the latest authority set;The text was updated successfully, but these errors were encountered: