From ad846ad280e5ded016d97bcd658c4de359d4773b Mon Sep 17 00:00:00 2001 From: divma Date: Tue, 27 Oct 2020 11:46:38 +0000 Subject: [PATCH] Inform peers of requests that exceed the maximum rate limit + log downgrade (#1830) ## Issue Addressed #1825 ## Proposed Changes Since we penalize more blocks by range requests that have large steps, it is possible to get requests that will never be processed. We were not informing peers about this requests and also logging CRIT that is no longer relevant. Later we should check if more sophisticated handling for those requests is needed --- beacon_node/eth2_libp2p/src/rpc/mod.rs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/beacon_node/eth2_libp2p/src/rpc/mod.rs b/beacon_node/eth2_libp2p/src/rpc/mod.rs index 6ced9b2f1..477f76d8e 100644 --- a/beacon_node/eth2_libp2p/src/rpc/mod.rs +++ b/beacon_node/eth2_libp2p/src/rpc/mod.rs @@ -233,9 +233,23 @@ where })) } Err(RateLimitedErr::TooLarge) => { - // we set the batch sizes, so this is a coding/config err - crit!(self.log, "Batch too large to ever be processed"; - "protocol" => format!("{}", req.protocol())); + // we set the batch sizes, so this is a coding/config err for most protocols + let protocol = req.protocol(); + if matches!(protocol, Protocol::BlocksByRange) { + debug!(self.log, "Blocks by range request will never be processed"; "request" => %req); + } else { + crit!(self.log, "Request size too large to ever be processed"; "protocol" => %protocol); + } + // send an error code to the peer. + // the handler upon receiving the error code will send it back to the behaviour + self.send_response( + peer_id, + (conn_id, *id), + RPCCodedResponse::Error( + RPCResponseErrorCode::RateLimited, + "Rate limited. Request too large".into(), + ), + ); } Err(RateLimitedErr::TooSoon(wait_time)) => { debug!(self.log, "Request exceeds the rate limit";