mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 20:31:13 +00:00
Try to fix out of view statements (#5177)
This issue happens when some peer sends a good but already known Seconded statement and the statement-distribution code does not update the statements_received field in the peer_knowledge structure. Subsequently, a Valid statement causes out-of-view message that is incorrectly emitted and causes reputation lose. This PR also introduces a concept of passing the specific pseudo-random generator to subsystems to make it easier to write deterministic tests. This functionality is not really necessary for the specific issue and unit test but it can be useful for other tests and subsystems.
This commit is contained in:
@@ -720,7 +720,7 @@ impl State {
|
||||
// to all peers in the BlockEntry's known_by set who know about the block,
|
||||
// excluding the peer in the source, if source has kind MessageSource::Peer.
|
||||
let maybe_peer_id = source.peer_id();
|
||||
let peers = entry
|
||||
let mut peers = entry
|
||||
.known_by
|
||||
.keys()
|
||||
.cloned()
|
||||
@@ -729,8 +729,7 @@ impl State {
|
||||
|
||||
let assignments = vec![(assignment, claimed_candidate_index)];
|
||||
let gossip_peers = &self.gossip_peers;
|
||||
let peers =
|
||||
util::choose_random_subset(|e| gossip_peers.contains(e), peers, MIN_GOSSIP_PEERS);
|
||||
util::choose_random_subset(|e| gossip_peers.contains(e), &mut peers, MIN_GOSSIP_PEERS);
|
||||
|
||||
// Add the fingerprint of the assignment to the knowledge of each peer.
|
||||
for peer in peers.iter() {
|
||||
@@ -943,7 +942,7 @@ impl State {
|
||||
// to all peers in the BlockEntry's known_by set who know about the block,
|
||||
// excluding the peer in the source, if source has kind MessageSource::Peer.
|
||||
let maybe_peer_id = source.peer_id();
|
||||
let peers = entry
|
||||
let mut peers = entry
|
||||
.known_by
|
||||
.keys()
|
||||
.cloned()
|
||||
@@ -951,8 +950,7 @@ impl State {
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let gossip_peers = &self.gossip_peers;
|
||||
let peers =
|
||||
util::choose_random_subset(|e| gossip_peers.contains(e), peers, MIN_GOSSIP_PEERS);
|
||||
util::choose_random_subset(|e| gossip_peers.contains(e), &mut peers, MIN_GOSSIP_PEERS);
|
||||
|
||||
// Add the fingerprint of the assignment to the knowledge of each peer.
|
||||
for peer in peers.iter() {
|
||||
|
||||
Reference in New Issue
Block a user