Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion polkadot/node/network/bitfield-distribution/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -789,9 +789,11 @@ async fn handle_peer_view_change<Context>(
};

let added = peer_data.view.replace_difference(view).cloned().collect::<Vec<_>>();
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()),
Expand All @@ -809,7 +811,11 @@ async fn handle_peer_view_change<Context>(
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();
Expand Down
5 changes: 5 additions & 0 deletions polkadot/node/network/protocol/src/grid_topology.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 12 additions & 0 deletions prdoc/pr_9094.prdoc
Original file line number Diff line number Diff line change
@@ -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: minor
Loading