babe: secondary blocks with VRF (#5501)

* babe: secondary blocks with VRF

* Fix node runtime compile

* Fix test-utils runtime interface

* Fix babe tests

* typo: v == 2

* babe: support online configuration upgrades

* Fix rpc tests

* Fix runtime version tests

* Switch to use NextConfigDescriptor instead of changing runtime interface

* Fix tests

* epoch-changes: map function that allows converting with different epoch types

* Add migration script for the epoch config change

* Fix docs for PrimaryAndSecondaryVRFSlots

* Add docs of `SecondaryVRF` in babe crate

* babe-primitives: Secondary -> SecondaryPlain

* babe-client: Secondary -> SecondaryPlain

* Fix migration tests

* test-utils-runtime: Secondary -> SecondaryPlain

* Fix missing name change in test-utils-runtime

* Fix migration: Epoch should be EpochV0

* Update client/consensus/babe/src/lib.rs

Co-Authored-By: André Silva <123550+andresilva@users.noreply.github.com>

* Fix new epochChanges version

* Fix babe-primitives naming changes

* Fix merge issues in babe-client

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
Co-authored-by: André Silva <andre.beat@gmail.com>
This commit is contained in:
Wei Tang
2020-04-24 17:03:03 +02:00
committed by GitHub
parent 8a3dcd6862
commit 969720c2ad
12 changed files with 265 additions and 52 deletions
+5 -5
View File
@@ -22,7 +22,7 @@
use super::*;
use authorship::claim_slot;
use sp_consensus_babe::{AuthorityPair, SlotNumber};
use sp_consensus_babe::{AuthorityPair, SlotNumber, AllowedSlots};
use sc_block_builder::{BlockBuilder, BlockBuilderProvider};
use sp_consensus::{
NoNetwork as DummyOracle, Proposal, RecordProof,
@@ -507,7 +507,7 @@ fn can_author_block() {
duration: 100,
config: BabeEpochConfiguration {
c: (3, 10),
secondary_slots: true,
allowed_slots: AllowedSlots::PrimaryAndSecondaryPlainSlots,
},
};
@@ -517,7 +517,7 @@ fn can_author_block() {
c: (3, 10),
genesis_authorities: Vec::new(),
randomness: [0; 32],
secondary_slots: true,
allowed_slots: AllowedSlots::PrimaryAndSecondaryPlainSlots,
};
// with secondary slots enabled it should never be empty
@@ -528,7 +528,7 @@ fn can_author_block() {
// otherwise with only vrf-based primary slots we might need to try a couple
// of times.
config.secondary_slots = false;
config.allowed_slots = AllowedSlots::PrimarySlots;
loop {
match claim_slot(i, &epoch, &keystore) {
None => i += 1,
@@ -557,7 +557,7 @@ fn propose_and_import_block<Transaction>(
let pre_digest = sp_runtime::generic::Digest {
logs: vec![
Item::babe_pre_digest(
PreDigest::Secondary(SecondaryPreDigest {
PreDigest::SecondaryPlain(SecondaryPlainPreDigest {
authority_index: 0,
slot_number,
}),