From 5b602dd8d7b8d622bd640f7b29299d29f53eac10 Mon Sep 17 00:00:00 2001 From: Alexandru Gheorghe Date: Thu, 3 Jul 2025 18:14:01 +0300 Subject: [PATCH 1/3] bitfield_distribution: fix subsystem clogged at begining of a session Signed-off-by: Alexandru Gheorghe --- polkadot/node/network/bitfield-distribution/src/lib.rs | 8 +++++++- polkadot/node/network/protocol/src/grid_topology.rs | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/polkadot/node/network/bitfield-distribution/src/lib.rs b/polkadot/node/network/bitfield-distribution/src/lib.rs index fffe715afd4c5..487fb3598765b 100644 --- a/polkadot/node/network/bitfield-distribution/src/lib.rs +++ b/polkadot/node/network/bitfield-distribution/src/lib.rs @@ -789,9 +789,11 @@ async fn handle_peer_view_change( }; let added = peer_data.view.replace_difference(view).cloned().collect::>(); + let current_session_index = state.topologies.get_current_session_index(); let topology = state.topologies.get_current_topology().local_grid_neighbors(); let is_gossip_peer = topology.route_to_peer(RequiredRouting::GridXY, &origin); + let lucky = is_gossip_peer || util::gen_ratio_rng( util::MIN_GOSSIP_PEERS.saturating_sub(topology.len()), @@ -809,7 +811,11 @@ async fn handle_peer_view_change( let delta_set: Vec<(ValidatorId, BitfieldGossipMessage)> = added .into_iter() .filter_map(|new_relay_parent_interest| { - if let Some(job_data) = state.per_relay_parent.get(&new_relay_parent_interest) { + if let Some(job_data) = state + .per_relay_parent + .get(&new_relay_parent_interest) + .filter(|job_data| job_data.signing_context.session_index == current_session_index) + { // Send all jointly known messages for a validator (given the current relay parent) // to the peer `origin`... let one_per_validator = job_data.one_per_validator.clone(); diff --git a/polkadot/node/network/protocol/src/grid_topology.rs b/polkadot/node/network/protocol/src/grid_topology.rs index f4c1a07ba3c2a..41fef5bbabfb7 100644 --- a/polkadot/node/network/protocol/src/grid_topology.rs +++ b/polkadot/node/network/protocol/src/grid_topology.rs @@ -496,6 +496,11 @@ impl SessionBoundGridTopologyStorage { &self.current_topology.entry } + /// Returns the current session index. + pub fn get_current_session_index(&self) -> SessionIndex { + self.current_topology.session_index + } + /// Access the current grid topology mutably. Dangerous and intended /// to be used in tests. pub fn get_current_topology_mut(&mut self) -> &mut SessionGridTopologyEntry { From 34fd2eda87b63cd661931fa127219c841def47b9 Mon Sep 17 00:00:00 2001 From: "cmd[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 7 Jul 2025 15:51:02 +0000 Subject: [PATCH 2/3] Update from github-actions[bot] running command 'prdoc --audience node_dev --bump patch' --- prdoc/pr_9094.prdoc | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 prdoc/pr_9094.prdoc diff --git a/prdoc/pr_9094.prdoc b/prdoc/pr_9094.prdoc new file mode 100644 index 0000000000000..a7e83cd5f6063 --- /dev/null +++ b/prdoc/pr_9094.prdoc @@ -0,0 +1,12 @@ +title: 'bitfield_distribution: fix subsystem clogged at begining of a session' +doc: +- audience: Node Dev + description: |- + `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. +crates: +- name: polkadot-availability-bitfield-distribution + bump: patch +- name: polkadot-node-network-protocol + bump: patch From a7499d7f1b3a494bf4774dbf668612b298c9ed87 Mon Sep 17 00:00:00 2001 From: Alexandru Gheorghe <49718502+alexggh@users.noreply.github.com> Date: Tue, 8 Jul 2025 11:18:22 +0300 Subject: [PATCH 3/3] Update pr_9094.prdoc --- prdoc/pr_9094.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prdoc/pr_9094.prdoc b/prdoc/pr_9094.prdoc index a7e83cd5f6063..754fc3eb33d7e 100644 --- a/prdoc/pr_9094.prdoc +++ b/prdoc/pr_9094.prdoc @@ -9,4 +9,4 @@ crates: - name: polkadot-availability-bitfield-distribution bump: patch - name: polkadot-node-network-protocol - bump: patch + bump: minor