Skip to content

Commit

Permalink
Propagate old topologies only to approval-distribution
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
  • Loading branch information
alexggh committed Jan 9, 2025
1 parent 10a9d87 commit e854c15
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 27 deletions.
74 changes: 51 additions & 23 deletions polkadot/node/network/bridge/src/rx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ use polkadot_primitives::{AuthorityDiscoveryId, BlockNumber, Hash, ValidatorInde
use std::{
collections::{hash_map, HashMap},
iter::ExactSizeIterator,
u32,
};

use super::validator_discovery;
Expand Down Expand Up @@ -750,7 +751,7 @@ where
// This is kept sorted, descending, by block number.
let mut live_heads: Vec<ActivatedLeaf> = Vec::with_capacity(MAX_VIEW_HEADS);
let mut finalized_number = 0;

let mut newest_session = u32::MIN;
let mut mode = Mode::Syncing(sync_oracle);
loop {
match ctx.recv().fuse().await? {
Expand All @@ -775,15 +776,29 @@ where
flesh_out_topology_peers(&mut authority_discovery_service, canonical_shuffling)
.await;

dispatch_validation_event_to_all_unbounded(
NetworkBridgeEvent::NewGossipTopology(NewGossipTopology {
session,
topology: SessionGridTopology::new(shuffled_indices, topology_peers),
local_index,
}),
ctx.sender(),
approval_voting_parallel_enabled,
);
if session >= newest_session {
dispatch_validation_event_to_all_unbounded(
NetworkBridgeEvent::NewGossipTopology(NewGossipTopology {
session,
topology: SessionGridTopology::new(shuffled_indices, topology_peers),
local_index,
}),
ctx.sender(),
approval_voting_parallel_enabled,
);
} else {
dispatch_validation_event_to_approval_unbounded(
&NetworkBridgeEvent::NegowGossipTopology(NewGossipTopology {
session,
topology: SessionGridTopology::new(shuffled_indices, topology_peers),
local_index,
}),
ctx.sender(),
approval_voting_parallel_enabled,
);
}

newest_session = newest_session.max(session);
},
FromOrchestra::Communication {
msg: NetworkBridgeRxMessage::UpdatedAuthorityIds { peer_id, authority_ids },
Expand Down Expand Up @@ -1123,22 +1138,11 @@ async fn dispatch_collation_event_to_all(
dispatch_collation_events_to_all(std::iter::once(event), ctx).await
}

fn dispatch_validation_event_to_all_unbounded(
event: NetworkBridgeEvent<net_protocol::VersionedValidationProtocol>,
fn dispatch_validation_event_to_approval_unbounded(
event: &NetworkBridgeEvent<net_protocol::VersionedValidationProtocol>,
sender: &mut impl overseer::NetworkBridgeRxSenderTrait,
approval_voting_parallel_enabled: bool,
) {
event
.focus()
.ok()
.map(StatementDistributionMessage::from)
.and_then(|msg| Some(sender.send_unbounded_message(msg)));
event
.focus()
.ok()
.map(BitfieldDistributionMessage::from)
.and_then(|msg| Some(sender.send_unbounded_message(msg)));

if approval_voting_parallel_enabled {
event
.focus()
Expand All @@ -1152,6 +1156,30 @@ fn dispatch_validation_event_to_all_unbounded(
.map(ApprovalDistributionMessage::from)
.and_then(|msg| Some(sender.send_unbounded_message(msg)));
}
}

fn dispatch_validation_event_to_all_unbounded(
event: NetworkBridgeEvent<net_protocol::VersionedValidationProtocol>,
sender: &mut impl overseer::NetworkBridgeRxSenderTrait,
approval_voting_parallel_enabled: bool,
) {
event
.focus()
.ok()
.map(StatementDistributionMessage::from)
.and_then(|msg| Some(sender.send_unbounded_message(msg)));
event
.focus()
.ok()
.map(BitfieldDistributionMessage::from)
.and_then(|msg| Some(sender.send_unbounded_message(msg)));

dispatch_validation_event_to_approval_unbounded(
&event,
sender,
approval_voting_parallel_enabled,
);

event
.focus()
.ok()
Expand Down
4 changes: 0 additions & 4 deletions polkadot/node/network/protocol/src/grid_topology.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,6 @@ impl SessionBoundGridTopologyStorage {
topology: SessionGridTopology,
local_index: Option<ValidatorIndex>,
) {
if self.current_topology.session_index > session_index {
return
}

let local_neighbors = local_index
.and_then(|l| topology.compute_grid_neighbors_for(l))
.unwrap_or_else(GridNeighbors::empty);
Expand Down

0 comments on commit e854c15

Please sign in to comment.