diff --git a/substrate/core/finality-grandpa/src/communication/mod.rs b/substrate/core/finality-grandpa/src/communication/mod.rs index 3d60af700a..4707dede78 100644 --- a/substrate/core/finality-grandpa/src/communication/mod.rs +++ b/substrate/core/finality-grandpa/src/communication/mod.rs @@ -309,17 +309,12 @@ impl> NetworkBridge { (bridge, startup_work) } - /// Get the round messages for a round in the current set ID. These are signature-checked. - pub(crate) fn round_communication( + /// Note the beginning of a new round to the `GossipValidator`. + pub(crate) fn note_round( &self, round: Round, set_id: SetId, - voters: Arc>, - local_key: Option>, - has_voted: HasVoted, - ) -> ( - impl Stream,Error=Error>, - impl Sink,SinkError=Error>, + voters: &VoterSet, ) { // is a no-op if currently in that set. self.validator.note_set( @@ -338,6 +333,25 @@ impl> NetworkBridge { GossipMessage::::from(neighbor).encode() ), ); + } + + /// Get the round messages for a round in the current set ID. These are signature-checked. + pub(crate) fn round_communication( + &self, + round: Round, + set_id: SetId, + voters: Arc>, + local_key: Option>, + has_voted: HasVoted, + ) -> ( + impl Stream,Error=Error>, + impl Sink,SinkError=Error>, + ) { + self.note_round( + round, + set_id, + &*voters, + ); let locals = local_key.and_then(|pair| { let public = pair.public(); diff --git a/substrate/core/finality-grandpa/src/observer.rs b/substrate/core/finality-grandpa/src/observer.rs index cd55211cfe..2c0818c2d7 100644 --- a/substrate/core/finality-grandpa/src/observer.rs +++ b/substrate/core/finality-grandpa/src/observer.rs @@ -57,13 +57,14 @@ impl<'a, Block: BlockT, B, E, RA> grandpa::Chain, RA, S>( +fn grandpa_observer, RA, S, F>( client: &Arc>, authority_set: &SharedAuthoritySet>, consensus_changes: &SharedConsensusChanges>, voters: &Arc>, last_finalized_number: NumberFor, commits: S, + note_round: F, ) -> impl Future>> where NumberFor: BlockNumberOps, B: Backend, @@ -73,6 +74,7 @@ fn grandpa_observer, RA, S>( Item = CommunicationIn, Error = CommandOrError>, >, + F: Fn(u64), { let authority_set = authority_set.clone(); let consensus_changes = consensus_changes.clone(); @@ -124,6 +126,10 @@ fn grandpa_observer, RA, S>( Err(e) => return future::err(e), }; + // note that we've observed completion of this round through the commit, + // and that implies that the next round has started. + note_round(round + 1); + grandpa::process_commit_validation_result(validation_result, callback); // proceed processing with new finalized block number @@ -188,6 +194,21 @@ pub fn run_grandpa_observer, N, RA, SC>( let last_finalized_number = client.info().chain.finalized_number; + // NOTE: since we are not using `round_communication` we have to + // manually note the round with the gossip validator, otherwise we won't + // relay round messages. we want all full nodes to contribute to vote + // availability. + let note_round = { + let network = network.clone(); + let voters = voters.clone(); + + move |round| network.note_round( + crate::communication::Round(round), + crate::communication::SetId(set_id), + &*voters, + ) + }; + // create observer for the current set let observer = grandpa_observer( &client, @@ -196,6 +217,7 @@ pub fn run_grandpa_observer, N, RA, SC>( &voters, last_finalized_number, global_in, + note_round, ); let handle_voter_command = move |command, voter_commands_rx| {