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 de97efc
Author: Michael Sproul <michael@sigmaprime.io>
Date:   Thu Jun 6 12:13:28 2024 +1000

    Use or instead of and

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
michaelsproul committed Jun 6, 2024
1 parent f7c3186 commit 22d1c4b
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
};
// 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;
Expand Down

0 comments on commit 22d1c4b

Please sign in to comment.