Correct multiple dial bug (#5113)
* Dialing the same peer-id error fix * Improve dialing logging * Update beacon_node/lighthouse_network/src/peer_manager/mod.rs Co-authored-by: Lion - dapplion <35266934+dapplion@users.noreply.github.com> --------- Co-authored-by: Lion - dapplion <35266934+dapplion@users.noreply.github.com>
This commit is contained in:
parent
b55b58b3c6
commit
a36a12a8d2
@ -326,8 +326,10 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
|||||||
// considered a priority. We have pre-allocated some extra priority slots for these
|
// considered a priority. We have pre-allocated some extra priority slots for these
|
||||||
// peers as specified by PRIORITY_PEER_EXCESS. Therefore we dial these peers, even
|
// peers as specified by PRIORITY_PEER_EXCESS. Therefore we dial these peers, even
|
||||||
// if we are already at our max_peer limit.
|
// if we are already at our max_peer limit.
|
||||||
if min_ttl.is_some() && connected_or_dialing + to_dial_peers < self.max_priority_peers()
|
if !self.peers_to_dial.contains(&enr)
|
||||||
|| connected_or_dialing + to_dial_peers < self.max_peers()
|
&& ((min_ttl.is_some()
|
||||||
|
&& connected_or_dialing + to_dial_peers < self.max_priority_peers())
|
||||||
|
|| connected_or_dialing + to_dial_peers < self.max_peers())
|
||||||
{
|
{
|
||||||
// This should be updated with the peer dialing. In fact created once the peer is
|
// This should be updated with the peer dialing. In fact created once the peer is
|
||||||
// dialed
|
// dialed
|
||||||
@ -337,9 +339,11 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
|||||||
.write()
|
.write()
|
||||||
.update_min_ttl(&enr.peer_id(), min_ttl);
|
.update_min_ttl(&enr.peer_id(), min_ttl);
|
||||||
}
|
}
|
||||||
debug!(self.log, "Dialing discovered peer"; "peer_id" => %enr.peer_id());
|
let peer_id = enr.peer_id();
|
||||||
self.dial_peer(enr);
|
if self.dial_peer(enr) {
|
||||||
to_dial_peers += 1;
|
debug!(self.log, "Dialing discovered peer"; "peer_id" => %peer_id);
|
||||||
|
to_dial_peers += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,7 +405,8 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
|||||||
/* Notifications from the Swarm */
|
/* Notifications from the Swarm */
|
||||||
|
|
||||||
/// A peer is being dialed.
|
/// A peer is being dialed.
|
||||||
pub fn dial_peer(&mut self, peer: Enr) {
|
/// Returns true, if this peer will be dialed.
|
||||||
|
pub fn dial_peer(&mut self, peer: Enr) -> bool {
|
||||||
if self
|
if self
|
||||||
.network_globals
|
.network_globals
|
||||||
.peers
|
.peers
|
||||||
@ -409,6 +414,9 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
|||||||
.should_dial(&peer.peer_id())
|
.should_dial(&peer.peer_id())
|
||||||
{
|
{
|
||||||
self.peers_to_dial.push(peer);
|
self.peers_to_dial.push(peer);
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1161,9 +1161,11 @@ impl<AppReqId: ReqId, TSpec: EthSpec> Network<AppReqId, TSpec> {
|
|||||||
|
|
||||||
// Remove the ENR from the cache to prevent continual re-dialing on disconnects
|
// Remove the ENR from the cache to prevent continual re-dialing on disconnects
|
||||||
for enr in peers_to_dial {
|
for enr in peers_to_dial {
|
||||||
debug!(self.log, "Dialing cached ENR peer"; "peer_id" => %enr.peer_id());
|
|
||||||
self.discovery_mut().remove_cached_enr(&enr.peer_id());
|
self.discovery_mut().remove_cached_enr(&enr.peer_id());
|
||||||
self.peer_manager_mut().dial_peer(enr);
|
let peer_id = enr.peer_id();
|
||||||
|
if self.peer_manager_mut().dial_peer(enr) {
|
||||||
|
debug!(self.log, "Dialing cached ENR peer"; "peer_id" => %peer_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user