-
Notifications
You must be signed in to change notification settings - Fork 5
Grandpa protocols #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 4 commits
4d33321
9d5ba21
bc84a3e
a756666
356bc8d
feabc80
d470644
68d4070
2ad5f1f
3cf902a
be569e3
257246c
03df0db
555c272
7666d23
737b8ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -149,6 +149,7 @@ Epoch Index = u32 (Slot / E) | |
| Validator Index = u16 | ||
| Core Index = u16 | ||
|
|
||
| Ed25519 Public = [u8; 32] | ||
| Ed25519 Signature = [u8; 64] | ||
|
|
||
| Erasure-Root = [u8; 32] | ||
|
|
@@ -157,6 +158,21 @@ Bundle Shard = [u8] | |
| Segment Shard = [u8; 12] | ||
| ``` | ||
|
|
||
| ### Grandpa types | ||
|
|
||
| Common types used in Grandpa and Justification request protocols. | ||
|
|
||
| ``` | ||
| Round Number = u64 | ||
| Set Id = u32 | ||
| Prevote = Header Hash ++ Slot | ||
| Precommit = Header Hash ++ Slot | ||
| PrimaryPropose = Header Hash ++ Slot | ||
|
||
| Signed Prevote = Prevote ++ Ed25519 Signature ++ Ed25519 Public | ||
|
||
| Signed Precommit = Precommit ++ Ed25519 Signature ++ Ed25519 Public | ||
| Commit = Header Hash ++ Slot ++ len++[Signed Precommit] | ||
| ``` | ||
|
|
||
| ### Grid structure | ||
|
|
||
| Primarily for the purpose of block and preimage announcements, the previous, current, and next | ||
|
|
@@ -270,6 +286,30 @@ Node -> Node | |
| <-- FIN | ||
| ``` | ||
|
|
||
| ### CE 130: Justification request | ||
|
||
|
|
||
| Request for justifications associated with a block. | ||
|
|
||
| Justification Type is an enum where 0 is Grandpa and 1 is Beefy (not implemented yet). | ||
| Encoded Justification is the encoding of the specific justification based on type. If the type is Grandpa then this decodes to Grandpa Justification. | ||
|
|
||
| Votes Ancestries is the set of headers routing all precommit target blocks to the commit target block. In normal operation this will be empty as validators will vote for the same proposed block that will then be the committed block. | ||
|
|
||
| ``` | ||
| Votes Ancestries = len++[Header] | ||
| Grandpa Justification = Round Number ++ Commit ++ Votes Ancestries | ||
|
||
|
|
||
| Justification Type = 0 OR 1 | ||
| Encoded Justification = len++[u8] | ||
|
||
| Justification = Justification Type ++ Encoded Justification | ||
| Justifications = len++[Justification] | ||
|
||
|
|
||
| --> Header Hash | ||
| --> FIN | ||
| <-- Justifications | ||
| <-- FIN | ||
| ``` | ||
|
|
||
| ### CE 131/132: Safrole ticket distribution | ||
|
|
||
| Sharing of a Safrole ticket for inclusion in a block. | ||
|
|
@@ -703,3 +743,64 @@ Auditor -> Validator | |
| --> FIN | ||
| <-- FIN | ||
| ``` | ||
|
|
||
| ### CE 146: GRANDPA Vote | ||
|
|
||
| GRANDPA voter sets match validator sets for each epoch. | ||
| This is sent by each voting validator to all other voting validators. | ||
|
|
||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A summary of the vote types here and when they are sent would be good. Ideally it should be possible to implement this using only the GRANDPA paper and this document. So in particular, I think |
||
| ``` | ||
| Message = 0 ++ Prevote OR 1 ++ Precommit OR 2 ++ PrimaryPropose | ||
| Signed Message = Message ++ Ed25519 Signature ++ Ed25519 Public | ||
|
||
|
|
||
| Validator -> Validator | ||
|
|
||
| --> Round Number ++ Set Id ++ Signed Message | ||
| --> FIN | ||
| <-- FIN | ||
| ``` | ||
|
|
||
| ### CE 147: GRANDPA Commit | ||
|
|
||
| This is sent by each voting validator to all other voting validators. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to be clearer about the sending behaviour here. The paper says that to reduce spam, we should:
I assume this is implemented in the Rust crate? Although it doesn't seem critical that all implementations do exactly the same thing here, we should probably still document the expected behaviour. |
||
|
|
||
| ``` | ||
| Precommits = len++[Precommit] | ||
| Multi Auth Data = len++[Ed25519 Signature ++ Ed25519 Public] | ||
|
||
| Compact Commit = Header Hash ++ Slot ++ Precommits ++ Multi Auth Data | ||
|
||
|
|
||
| Validator -> Validator | ||
|
|
||
| --> Round Number ++ Set Id ++ Compact Commit | ||
| --> FIN | ||
| <-- FIN | ||
| ``` | ||
|
|
||
| ### CE 148: GRANDPA State | ||
|
|
||
| This is sent by each voting validator to all other voting validators and informs them of the latest round it is participating in. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should clarify when this is sent. Is it sent once the validator "starts the round" as defined in the paper? |
||
|
|
||
| ``` | ||
| Validator -> Validator | ||
|
|
||
| --> Round Number ++ Set Id ++ Slot | ||
| --> FIN | ||
| <-- FIN | ||
| ``` | ||
|
|
||
| ### CE 149: GRANDPA CatchUp | ||
|
|
||
| Catchup Request. This is sent by a voting validator to another validator. The response includes all votes required to catch up state to that of the responding voter. | ||
|
||
|
|
||
| ``` | ||
| Base Hash = Header Hash | ||
| Base Number = Slot | ||
| Catchup = Round Number ++ len++[Signed Prevote] ++ len++[Signed Precommit] ++ Base Hash ++ Base Number | ||
|
|
||
| Validator -> Validator | ||
|
|
||
| --> Round Number ++ Set Id | ||
| --> FIN | ||
| <-- Set Id ++ Catchup | ||
| <-- FIN | ||
| ``` | ||
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.
I assume
Set Idrefers to the validator/voter set? I think we need to be explicit here about what it actually is, eg is it an epoch index or something?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.
Clarified this. It starts at 0 at genesis and increments after each set change block is finalized. So it normally increments with epoch but it is not strictly the same as epoch index.