From 0b319d492695daf11cd8fc0712b602b63ee5ed50 Mon Sep 17 00:00:00 2001 From: Age Manning Date: Fri, 19 Nov 2021 04:42:33 +0000 Subject: [PATCH] Inform dialing via the behaviour (#2814) I had this change but it seems to have been lost in chaos of network upgrades. The swarm dialing event seems to miss some cases where we dial via the behaviour. This causes an error to be logged as the peer manager doesn't know about some dialing events. This shifts the logic to the behaviour to inform the peer manager. --- beacon_node/lighthouse_network/src/behaviour/mod.rs | 4 ++++ beacon_node/lighthouse_network/src/service.rs | 13 +------------ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/beacon_node/lighthouse_network/src/behaviour/mod.rs b/beacon_node/lighthouse_network/src/behaviour/mod.rs index 29f5197616..1276db5e7e 100644 --- a/beacon_node/lighthouse_network/src/behaviour/mod.rs +++ b/beacon_node/lighthouse_network/src/behaviour/mod.rs @@ -1088,6 +1088,10 @@ impl Behaviour { if let Some(event) = self.internal_events.pop_front() { match event { InternalBehaviourMessage::DialPeer(peer_id) => { + // For any dial event, inform the peer manager + let enr = self.discovery_mut().enr_of_peer(&peer_id); + self.peer_manager.inject_dialing(&peer_id, enr); + // Submit the event let handler = self.new_handler(); return Poll::Ready(NBAction::Dial { opts: DialOpts::peer_id(peer_id) diff --git a/beacon_node/lighthouse_network/src/service.rs b/beacon_node/lighthouse_network/src/service.rs index 03732e8e61..3ecd32f3d9 100644 --- a/beacon_node/lighthouse_network/src/service.rs +++ b/beacon_node/lighthouse_network/src/service.rs @@ -367,18 +367,7 @@ impl Service { return Libp2pEvent::ZeroListeners; } } - SwarmEvent::Dialing(peer_id) => { - // We require the ENR to inject into the peer db, if it exists. - let enr = self - .swarm - .behaviour_mut() - .discovery_mut() - .enr_of_peer(&peer_id); - self.swarm - .behaviour_mut() - .peer_manager_mut() - .inject_dialing(&peer_id, enr); - } + SwarmEvent::Dialing(_peer_id) => {} } } }