From 3a5888e53d03e4cdd8f52639ffcee06ea24fb1c0 Mon Sep 17 00:00:00 2001 From: Divma Date: Mon, 24 Oct 2022 21:39:30 +0000 Subject: [PATCH] Ban and unban peers at the swarm level (#3653) ## Issue Addressed I missed this from https://github.com/sigp/lighthouse/pull/3491. peers were being banned at the behaviour level only. The identify errors are explained by this as well ## Proposed Changes Add banning and unbanning ## Additional Info Befor,e having tests that catch this was hard because the swarm was outside the behaviour. We could now have tests that prevent something like this in the future --- beacon_node/lighthouse_network/src/service/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/beacon_node/lighthouse_network/src/service/mod.rs b/beacon_node/lighthouse_network/src/service/mod.rs index 53d29ccb2..97d96d171 100644 --- a/beacon_node/lighthouse_network/src/service/mod.rs +++ b/beacon_node/lighthouse_network/src/service/mod.rs @@ -1342,10 +1342,12 @@ impl Network { Some(NetworkEvent::PeerDisconnected(peer_id)) } PeerManagerEvent::Banned(peer_id, associated_ips) => { + self.swarm.ban_peer_id(peer_id); self.discovery_mut().ban_peer(&peer_id, associated_ips); Some(NetworkEvent::PeerBanned(peer_id)) } PeerManagerEvent::UnBanned(peer_id, associated_ips) => { + self.swarm.unban_peer_id(peer_id); self.discovery_mut().unban_peer(&peer_id, associated_ips); Some(NetworkEvent::PeerUnbanned(peer_id)) }