babe: support online configuration upgrades (#5514)

* babe: support online configuration upgrades

* 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 migration tests

* 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 unused imports

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
This commit is contained in:
Wei Tang
2020-04-24 15:59:14 +02:00
committed by GitHub
parent a01e608dff
commit 770cc24c47
12 changed files with 300 additions and 86 deletions
@@ -118,7 +118,7 @@ impl<B, C, SC> BabeApi for BabeRPCHandler<B, C, SC>
for slot_number in epoch_start..epoch_end {
let epoch = epoch_data(&shared_epoch, &client, &babe_config, slot_number, &select_chain)?;
if let Some((claim, key)) = authorship::claim_slot(slot_number, &epoch, &babe_config, &keystore) {
if let Some((claim, key)) = authorship::claim_slot(slot_number, &epoch, &keystore) {
match claim {
PreDigest::Primary { .. } => {
claims.entry(key.public()).or_default().primary.push(slot_number);
@@ -184,7 +184,7 @@ fn epoch_data<B, C, SC>(
&parent.hash(),
parent.number().clone(),
slot_number,
|slot| babe_config.genesis_epoch(slot),
|slot| Epoch::genesis(&babe_config, slot),
)
.map_err(|e| Error::Consensus(ConsensusError::ChainLookup(format!("{:?}", e))))?
.ok_or(Error::Consensus(ConsensusError::InvalidAuthoritiesSet))