Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert #2363 (More stringent dialling) #2374

Closed
wants to merge 1 commit into from
Closed
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
21 changes: 16 additions & 5 deletions beacon_node/eth2_libp2p/src/peer_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,16 +668,18 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
.cached_enrs()
.filter_map(|(peer_id, enr)| {
let peers = self.network_globals.peers.read();
if predicate(enr) && peers.should_dial(peer_id) {
if predicate(enr)
&& !peers.is_connected_or_dialing(peer_id)
&& !peers.is_banned(peer_id)
{
Some(*peer_id)
} else {
None
}
})
.collect();
for peer_id in &peers_to_dial {
debug!(self.log, "Dialing cached ENR peer"; "peer_id" => %peer_id);
self.dial_peer(peer_id);
for peer in &peers_to_dial {
self.dial_peer(peer);
}
}

Expand All @@ -696,7 +698,16 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
// we attempt a connection if this peer is a subnet peer or if the max peer count
// is not yet filled (including dialing peers)
if (min_ttl.is_some() || connected_or_dialing + to_dial_peers.len() < self.max_peers)
&& self.network_globals.peers.read().should_dial(&peer_id)
&& !self
.network_globals
.peers
.read()
.is_connected_or_dialing(&peer_id)
&& !self
.network_globals
.peers
.read()
.is_banned_or_disconnected(&peer_id)
{
// This should be updated with the peer dialing. In fact created once the peer is
// dialed
Expand Down
12 changes: 1 addition & 11 deletions beacon_node/eth2_libp2p/src/peer_manager/peerdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,6 @@ impl<TSpec: EthSpec> PeerDB<TSpec> {
)
}

/// Returns true if the peer should be dialed. This checks the connection state and the
/// score state and determines if the peer manager should dial this peer.
pub fn should_dial(&self, peer_id: &PeerId) -> bool {
matches!(
self.connection_status(peer_id),
Some(PeerConnectionStatus::Disconnected { .. })
| Some(PeerConnectionStatus::Unknown { .. })
) && !self.is_banned_or_disconnected(peer_id)
}

/// Returns true if the peer is synced at least to our current head.
pub fn is_synced(&self, peer_id: &PeerId) -> bool {
match self.peers.get(peer_id).map(|info| &info.sync_status) {
Expand Down Expand Up @@ -351,7 +341,7 @@ impl<TSpec: EthSpec> PeerDB<TSpec> {
}

if let Err(e) = info.dialing_peer() {
error!(self.log, "{}", e; "peer_id" => %peer_id);
error!(self.log, "{}", e);
}
}

Expand Down