Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

validator_discovery: pass PeerSet to the request #2372

Merged
merged 24 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion node/network/availability-recovery/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use polkadot_subsystem::{
},
};
use polkadot_node_network_protocol::{
v1 as protocol_v1, PeerId, ReputationChange as Rep, RequestId,
peer_set::PeerSet, v1 as protocol_v1, PeerId, ReputationChange as Rep, RequestId,
};
use polkadot_node_subsystem_util::{
Timeout, TimeoutExt,
Expand Down Expand Up @@ -579,6 +579,7 @@ async fn handle_from_interaction(

let message = NetworkBridgeMessage::ConnectToValidators {
validator_ids: vec![id.clone()],
peer_set: PeerSet::Validation,
connected: tx,
};

Expand Down
3 changes: 3 additions & 0 deletions node/network/bridge/src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub(crate) enum Action {
/// Ask network to connect to validators.
ConnectToValidators {
validator_ids: Vec<AuthorityDiscoveryId>,
peer_set: PeerSet,
connected: mpsc::Sender<(AuthorityDiscoveryId, PeerId)>,
},

Expand Down Expand Up @@ -133,9 +134,11 @@ impl From<polkadot_subsystem::SubsystemResult<FromOverseer<NetworkBridgeMessage>
}
NetworkBridgeMessage::ConnectToValidators {
validator_ids,
peer_set,
connected,
} => Action::ConnectToValidators {
validator_ids,
peer_set,
connected,
},
},
Expand Down
21 changes: 14 additions & 7 deletions node/network/bridge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,18 @@ where

Action::ConnectToValidators {
validator_ids,
peer_set,
connected,
} => {
tracing::debug!(
target: LOG_TARGET,
peer_set = ?peer_set,
ids = ?validator_ids,
"Received a validator connection request",
);
let (ns, ads) = validator_discovery.on_request(
validator_ids,
peer_set,
connected,
bridge.network_service,
bridge.authority_discovery_service,
Expand All @@ -257,11 +265,6 @@ where
},

Action::ReportPeer(peer, rep) => {
tracing::debug!(
target: LOG_TARGET,
peer = ?peer,
"Peer sent us an invalid request",
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we want to remove this exactly?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This says "invalid request", whereas ReportPeer can be also used for increasing reputation, so the message is confusing.
In addition to that, we log it in on a higher level in subsystems.

bridge.network_service.report_peer(peer, rep).await?
}

Expand Down Expand Up @@ -296,7 +299,11 @@ where
PeerSet::Collation => &mut collation_peers,
};

validator_discovery.on_peer_connected(&peer, &mut bridge.authority_discovery_service).await;
validator_discovery.on_peer_connected(
peer.clone(),
peer_set,
&mut bridge.authority_discovery_service,
).await;

match peer_map.entry(peer.clone()) {
hash_map::Entry::Occupied(_) => continue,
Expand Down Expand Up @@ -358,7 +365,7 @@ where
PeerSet::Collation => &mut collation_peers,
};

validator_discovery.on_peer_disconnected(&peer);
validator_discovery.on_peer_disconnected(&peer, peer_set);

if peer_map.remove(&peer).is_some() {
match peer_set {
Expand Down
Loading