-
Notifications
You must be signed in to change notification settings - Fork 2.7k
babe: Introduce secondary slots (Aurababeous) #3380
Conversation
cabb01a to
6b8c40b
Compare
|
I agree with keeping the same name, but.. Any way we can easily support the aura-like blocks running on a much slower bock time than the babe slots? We should keep a testnet running with babe's erratic block times because anything that breaks indicates deeper problems. |
👍 - the term "primary" has some pedigree for this purpose in the literature as well. extending to "secondary" makes sense. |
c3d2a3e to
ca6b9a0
Compare
Co-Authored-By: joe petrowski <[email protected]>
core/consensus/babe/src/lib.rs
Outdated
| } | ||
|
|
||
| let rand = { | ||
| let mut data = [0u8; 40]; |
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.
and remove this block :)
core/consensus/babe/src/lib.rs
Outdated
| return None; | ||
| } | ||
|
|
||
| let rand = { |
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.
| let rand = { | |
| let rand = U256::from((randomness, slot_number).using_encoded(blake2_256)); |
gavofyork
left a comment
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.
Minor remark but looks good otherwise
|
@andresilva just needs resolving then good to merge. |
868e3fa to
4f75dd8
Compare
Depends on #3377.
This PR extends the BABE consensus engine into Aurababeous. There are now two kinds of slot assignments: Primary (VRF-based) and Secondary (Slot-number based). Primary slots take precedence over secondary slots, when authoring the node starts by trying to claim a primary slot and falls back to a secondary slot claim attempt. The fork choice rule is weight-based, where weight equals the number of primary blocks in the chain. We will pick the heaviest chain and will go with the longest one in case of a tie.
The primary block author is chosen using the BABE VRF function threshold calculation. The secondary block author is chosen using:
blake2_256(epoch_randomness ++ slot_number) % authorities_len.I decided to keep the same name for the engine instead of renaming it or duplicating it. There are currently open PRs for BABE (#3301) that we want to include for Kusama and the rename would create unnecessary conflicts. I also decided not to create a new standalone engine because re-using the runtime module code is not trivial, and if we disable secondary slot assignment the engine should behave exactly like straight BABE. Additionally, I think we should keep the name BABE and just extend the spec (the slot assignment rule for secondary proposals isn't related to Aura at this point anyway).
@bkchr Suggested naming it backup slot instead. What do you think? I actually prefer primary/secondary.
TODO