-
Notifications
You must be signed in to change notification settings - Fork 2.7k
GRANDPA finality proof draft #1268
Conversation
|
This might be well-coupled with a change to create justifications for authority-changing blocks. |
| // now that we know that the block is finalized, we can generate finalization proof | ||
|
|
||
| // we need to prove grandpa authorities set that has generated justification | ||
| let authorities_proof = generate_execution_proof(&block_id, "GrandpaApi_grandpa_authorities", &[])?; |
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.
We should rather get a proof of this execution on the parent block -- it's undocumented at this point but what grandpa_authorities really tells you is which set of authorities is responsible for finalizing children of this block.
This is because when we do a set change at block X, grandpa_authorities(at: X) will give you the new set, but it's actually the old set who is responsible for finalizing X and completing the handoff.
Adding extra documentation to the GrandpaApi trait would be really helpful as well
9740d2f to
720951b
Compare
|
@rphmeier I see that first version of your first comment was about generating justification every N blocks. Isn't that better than generating it only "for authority-changing blocks"? I could see that this makes proof-of-finality for these blocks minimal, but for other blocks it still could be large, right? So if the authorities set isn't changing at all, we will never generate justification => won't be able to prove finality to light clients. Or maybe combined approach (every N blocks + when authorities-set changes) will work? |
|
@svyatonik yep, that seems reasonable. We can use a slightly larger N for sure if we do both. |
|
@rphmeier I've altered PR with additional justification-generation cases:
Not sure about #1208 - did you mean that proof-of-finality described there supersede proof-of-finality implemented here? What's the "big" ancestry proof then? |
|
Just as an alternate approach to generating ancestry proofs. The idea is to go back further than one block at a time by storing log2 ancestors in the state. |
| let parent_block_id = BlockId::Hash(*current_header.parent_hash()); | ||
| let authorities_proof = generate_execution_proof( | ||
| &parent_block_id, | ||
| "GrandpaApi_grandpa_authorities", |
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.
|
Seems fine. It would be nice to "traitify" the |
* grandpa finality proof * prove GrandpaApi::grandpa_authorities using parent block + some docs * create justification when consensus data is changed * generate justifications periodically * test for ConsensusChanges
…otocol Disable unused gossipsub protocol in the DSN stack.
This is a draft for generating GRANDPA finality proof + its validation. In brief:
GrandpaJustification::verifyinvolves checking signatures of messages that include current GRANDPA authoritiesset_idAND it isn't stored in the runtime storage, I assume that light client will be able to track thisset_idsomehow. It is enough to track only the latest id, because of (1). The tracking-strategy is probably reflectset_idchanges in the GRANDPA-specificHeader::DigestItem? Are there any plans to do this? Anyway - it is for the future PRs;Bis the:B...F], whereFis the earliest known block with GRANDPA justification which is>= B;F;GrandpaApi::grandpa_authoritiesat the blockF. Since we require blocks that are enacting new GRANDPA authorities set to have justification, this means that the set in blocksBandFare the same. Having this 'subproof' is somewhat questionable and depends on how we're going to track the GRANDPA authoritiesset_id- if there'll beDigestItemfor every change, we could just take bothauthoritiesandset_idfrom thisDigestItem=> proof-of-execution is not required;check_finality_proofonly checks that justification is valid with respect to passedset_idandauthorities. Validity of the headers subchain [B...F] should be checked outside => this proof is valid iff the whole range of block [B...F] is imported at once and imports succeed.So the approximate import queue for light client will look like: when it tries to import block
BwithDigestItem::AuthoritiesChange, it pauses until proof-of-finality of theBis received. When it is received, all blocks [B...F] are imported at once and then sync continues.