Skip to content

Commit

Permalink
Try Lion's solution
Browse files Browse the repository at this point in the history
Merge commit '32c8fcec191f5f7b74319f2dcd2447cf016b1441' into permit-rpc-on-disconnect
  • Loading branch information
michaelsproul committed Jun 6, 2024
2 parents de97efc + 32c8fce commit c4f7811
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions beacon_node/lighthouse_network/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1378,19 +1378,6 @@ impl<AppReqId: ReqId, E: EthSpec> Network<AppReqId, E> {
) -> Option<NetworkEvent<AppReqId, E>> {
let peer_id = event.peer_id;

// 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;
// The METADATA and PING RPC responses are handled within the behaviour and not propagated
match event.event {
Expand Down Expand Up @@ -1430,6 +1417,13 @@ impl<AppReqId: ReqId, E: EthSpec> Network<AppReqId, E> {
}
}
HandlerEvent::Ok(RPCReceived::Request(id, request)) => {
// Ignore Inbound requests from peers that are being disconnected. No point in doing
// work to retrieve data that can't be delivered.
if !self.peer_manager().is_connected(&peer_id) {
debug!(self.log, "Ignoring rpc request of disconnecting peer"; "request" => ?request);
return None;
}

let peer_request_id = (handler_id, id);
match request {
/* Behaviour managed protocols: Ping and Metadata */
Expand Down

0 comments on commit c4f7811

Please sign in to comment.