Skip to content

Commit

Permalink
Allow all RPC messages on disconnect (#5876)
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 6d42ebc
Author: Age Manning <Age@AgeManning.com>
Date:   Fri May 31 20:21:26 2024 +1000

    Permit rpc messages on disconnect
  • Loading branch information
jimmygchen committed Jun 3, 2024
1 parent 1711836 commit f8398a8
Showing 1 changed file with 11 additions and 20 deletions.
31 changes: 11 additions & 20 deletions beacon_node/lighthouse_network/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1389,26 +1389,17 @@ impl<AppReqId: ReqId, E: EthSpec> Network<AppReqId, E> {
) -> Option<NetworkEvent<AppReqId, E>> {
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
};
if !self.peer_manager().is_connected(&peer_id)
// Do not permit Inbound events from peers that are being disconnected
&& 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;
Expand Down

0 comments on commit f8398a8

Please sign in to comment.