mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-16 18:55:42 +00:00
grandpa: track multiple live rounds in voter set state (#3298)
* grandpa: track multiple live rounds in voter set state * grandpa: don't assume rounds are completed in-order * grandpa: fix tests * grandpa: don't assume round is being tracked on Environment::completed * grandpa: fix missing import in test
This commit is contained in:
@@ -20,7 +20,7 @@ use futures::prelude::*;
|
||||
use futures::future::{self, Loop as FutureLoop};
|
||||
|
||||
use grandpa::{
|
||||
BlockNumberOps, Error as GrandpaError, round::State as RoundState, voter, voter_set::VoterSet
|
||||
BlockNumberOps, Error as GrandpaError, voter, voter_set::VoterSet
|
||||
};
|
||||
use log::{debug, info, warn};
|
||||
|
||||
@@ -36,7 +36,6 @@ use crate::{
|
||||
use crate::authorities::SharedAuthoritySet;
|
||||
use crate::communication::NetworkBridge;
|
||||
use crate::consensus_changes::SharedConsensusChanges;
|
||||
use crate::environment::{CompletedRound, CompletedRounds, HasVoted};
|
||||
use fg_primitives::AuthorityId;
|
||||
|
||||
struct ObserverChain<'a, Block: BlockT, B, E, RA>(&'a Client<B, E, Block, RA>);
|
||||
@@ -238,22 +237,11 @@ pub fn run_grandpa_observer<B, E, Block: BlockT<Hash=H256>, N, RA, SC>(
|
||||
VoterCommand::ChangeAuthorities(new) => {
|
||||
// start the new authority set using the block where the
|
||||
// set changed (not where the signal happened!) as the base.
|
||||
let genesis_state = RoundState::genesis((new.canon_hash, new.canon_number));
|
||||
|
||||
let set_state = VoterSetState::Live::<Block> {
|
||||
// always start at round 0 when changing sets.
|
||||
completed_rounds: CompletedRounds::new(
|
||||
CompletedRound {
|
||||
number: 0,
|
||||
state: genesis_state,
|
||||
base: (new.canon_hash, new.canon_number),
|
||||
votes: Vec::new(),
|
||||
},
|
||||
new.set_id,
|
||||
&*authority_set.inner().read(),
|
||||
),
|
||||
current_round: HasVoted::No,
|
||||
};
|
||||
let set_state = VoterSetState::live(
|
||||
new.set_id,
|
||||
&*authority_set.inner().read(),
|
||||
(new.canon_hash, new.canon_number),
|
||||
);
|
||||
|
||||
#[allow(deprecated)]
|
||||
crate::aux_schema::write_voter_set_state(&**client.backend(), &set_state)?;
|
||||
|
||||
Reference in New Issue
Block a user