mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-01 05:41:03 +00:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user