grandpa: improve handling of global gossip messages (#5133)

* grandpa: only gossip commits to peers on the same set

* grandpa: track commits uniquely by round and set

* grandpa: fix communication test

* grandpa: add tests for commit gossip handling

* grandpa: add missing docs
This commit is contained in:
André Silva
2020-03-09 23:46:03 +00:00
committed by GitHub
parent 2aac500d61
commit cfd6824e57
3 changed files with 237 additions and 34 deletions
@@ -497,7 +497,8 @@ fn incoming_global<B: BlockT>(
return None;
}
let round = msg.round.0;
let round = msg.round;
let set_id = msg.set_id;
let commit = msg.message;
let finalized_number = commit.target_number;
let gossip_validator = gossip_validator.clone();
@@ -509,6 +510,8 @@ fn incoming_global<B: BlockT>(
// any discrepancy between the actual ghost and the claimed
// finalized number.
gossip_validator.note_commit_finalized(
round,
set_id,
finalized_number,
|to, neighbor| neighbor_sender.send(to, neighbor),
);
@@ -525,7 +528,7 @@ fn incoming_global<B: BlockT>(
let cb = voter::Callback::Work(Box::new(cb));
Some(voter::CommunicationIn::Commit(round, commit, cb))
Some(voter::CommunicationIn::Commit(round.0, commit, cb))
};
let process_catch_up = move |
@@ -1015,7 +1018,7 @@ impl<Block: BlockT> Sink<(RoundNumber, Commit<Block>)> for CommitsOut<Block> {
};
let message = GossipMessage::Commit(FullCommitMessage::<Block> {
round: round,
round,
set_id: self.set_id,
message: compact_commit,
});
@@ -1025,6 +1028,8 @@ impl<Block: BlockT> Sink<(RoundNumber, Commit<Block>)> for CommitsOut<Block> {
// the gossip validator needs to be made aware of the best commit-height we know of
// before gossiping
self.gossip_validator.note_commit_finalized(
round,
self.set_id,
commit.target_number,
|to, neighbor| self.neighbor_sender.send(to, neighbor),
);