Skip to content

Commit f975a0c

Browse files
alexgghgithub-actions[bot]
authored andcommitted
bitfield_distribution: fix subsystem clogged at begining of a session (#9094)
`handle_peer_view_change` gets called on NewGossipTopology with the existing view of the peer to cover for the case when the topology might arrive late, but in that case in the view will contain old blocks from previous session, so since the X/Y neighbour change because of the topology change you end up sending a lot of messages for blocks before the session changed. Fix it by checking the send message only for relay chains that are in the same session as the current topology. --------- Signed-off-by: Alexandru Gheorghe <[email protected]> Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent ff3f3a0 commit f975a0c

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

polkadot/node/network/bitfield-distribution/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,9 +789,11 @@ async fn handle_peer_view_change<Context>(
789789
};
790790

791791
let added = peer_data.view.replace_difference(view).cloned().collect::<Vec<_>>();
792+
let current_session_index = state.topologies.get_current_session_index();
792793

793794
let topology = state.topologies.get_current_topology().local_grid_neighbors();
794795
let is_gossip_peer = topology.route_to_peer(RequiredRouting::GridXY, &origin);
796+
795797
let lucky = is_gossip_peer ||
796798
util::gen_ratio_rng(
797799
util::MIN_GOSSIP_PEERS.saturating_sub(topology.len()),
@@ -809,7 +811,11 @@ async fn handle_peer_view_change<Context>(
809811
let delta_set: Vec<(ValidatorId, BitfieldGossipMessage)> = added
810812
.into_iter()
811813
.filter_map(|new_relay_parent_interest| {
812-
if let Some(job_data) = state.per_relay_parent.get(&new_relay_parent_interest) {
814+
if let Some(job_data) = state
815+
.per_relay_parent
816+
.get(&new_relay_parent_interest)
817+
.filter(|job_data| job_data.signing_context.session_index == current_session_index)
818+
{
813819
// Send all jointly known messages for a validator (given the current relay parent)
814820
// to the peer `origin`...
815821
let one_per_validator = job_data.one_per_validator.clone();

polkadot/node/network/protocol/src/grid_topology.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,11 @@ impl SessionBoundGridTopologyStorage {
496496
&self.current_topology.entry
497497
}
498498

499+
/// Returns the current session index.
500+
pub fn get_current_session_index(&self) -> SessionIndex {
501+
self.current_topology.session_index
502+
}
503+
499504
/// Access the current grid topology mutably. Dangerous and intended
500505
/// to be used in tests.
501506
pub fn get_current_topology_mut(&mut self) -> &mut SessionGridTopologyEntry {

prdoc/pr_9094.prdoc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
title: 'bitfield_distribution: fix subsystem clogged at begining of a session'
2+
doc:
3+
- audience: Node Dev
4+
description: |-
5+
`handle_peer_view_change` gets called on NewGossipTopology with the existing view of the peer to cover for the case when the topology might arrive late, but in that case in the view will contain old blocks from previous session, so since the X/Y neighbour change because of the topology change you end up sending a lot of messages for blocks before the session changed.
6+
7+
Fix it by checking the send message only for relay chains that are in the same session as the current topology.
8+
crates:
9+
- name: polkadot-availability-bitfield-distribution
10+
bump: patch
11+
- name: polkadot-node-network-protocol
12+
bump: minor

0 commit comments

Comments
 (0)