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
@@ -292,12 +292,32 @@ fn good_commit_leads_to_relay() {
});
// Add a random peer which will be the recipient of this message
let receiver_id = sc_network::PeerId::random();
let _ = sender.unbounded_send(NetworkEvent::NotificationStreamOpened {
remote: sc_network::PeerId::random(),
remote: receiver_id.clone(),
engine_id: GRANDPA_ENGINE_ID,
roles: Roles::FULL,
});
// Announce its local set has being on the current set id through a neighbor
// packet, otherwise it won't be eligible to receive the commit
let _ = {
let update = gossip::VersionedNeighborPacket::V1(
gossip::NeighborPacket {
round: Round(round),
set_id: SetId(set_id),
commit_finalized_height: 1,
}
);
let msg = gossip::GossipMessage::<Block>::Neighbor(update);
sender.unbounded_send(NetworkEvent::NotificationsReceived {
remote: receiver_id,
messages: vec![(GRANDPA_ENGINE_ID, msg.encode().into())],
})
};
true
}
_ => false,