From 22d1c4b922c1a96ed604978bbeed2851450bfe55 Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Thu, 6 Jun 2024 14:59:35 +1000 Subject: [PATCH] Allow all RPC messages on disconnect (#5876) Squashed commit of the following: commit de97efc7a4538509daf10de4e1628884936676db Author: Michael Sproul Date: Thu Jun 6 12:13:28 2024 +1000 Use or instead of and commit 6d42ebcc19504691d749ef588744e8d22f68448f Author: Age Manning Date: Fri May 31 20:21:26 2024 +1000 Permit rpc messages on disconnect --- .../lighthouse_network/src/service/mod.rs | 31 +++++++------------ 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/beacon_node/lighthouse_network/src/service/mod.rs b/beacon_node/lighthouse_network/src/service/mod.rs index 3870fb6572d..dbf7c382268 100644 --- a/beacon_node/lighthouse_network/src/service/mod.rs +++ b/beacon_node/lighthouse_network/src/service/mod.rs @@ -1389,26 +1389,17 @@ impl Network { ) -> Option> { let peer_id = event.peer_id; - if !self.peer_manager().is_connected(&peer_id) { - // Sync expects a RPCError::Disconnected to drop associated lookups with this peer. - // Silencing this event breaks the API contract with RPC where every request ends with - // - A stream termination event, or - // - An RPCError event - return if let HandlerEvent::Err(HandlerErr::Outbound { - id: RequestId::Application(id), - error, - .. - }) = event.event - { - Some(NetworkEvent::RPCFailed { peer_id, id, error }) - } else { - debug!( - self.log, - "Ignoring rpc message of disconnecting peer"; - event - ); - None - }; + // Do not permit Inbound events from peers that are being disconnected, or RPC requests. + if !self.peer_manager().is_connected(&peer_id) + && (matches!(event.event, HandlerEvent::Err(HandlerErr::Inbound { .. })) + || matches!(event.event, HandlerEvent::Ok(RPCReceived::Request(..)))) + { + debug!( + self.log, + "Ignoring rpc message of disconnecting peer"; + event + ); + return None; } let handler_id = event.conn_id;