mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-21 13:54:44 +00:00
Deprecate step param in BlocksByRange RPC request (#3275)
## Issue Addressed Deprecates the step parameter in the blocks by range request ## Proposed Changes - Modifies the BlocksByRangeRequest type to remove the step parameter and everywhere we took it into account before - Adds a new type to still handle coding and decoding of requests that use the parameter ## Additional Info I went with a deprecation over the type itself so that requests received outside `lighthouse_network` don't even need to deal with this parameter. After the deprecation period just removing the Old blocks by range request should be straightforward
This commit is contained in:
@@ -188,29 +188,7 @@ impl RPCRateLimiter {
|
||||
request: &InboundRequest<T>,
|
||||
) -> Result<(), RateLimitedErr> {
|
||||
let time_since_start = self.init_time.elapsed();
|
||||
let mut tokens = request.expected_responses().max(1);
|
||||
|
||||
// Increase the rate limit for blocks by range requests with large step counts.
|
||||
// We count to tokens as a quadratic increase with step size.
|
||||
// Using (step_size/5)^2 + 1 as penalty factor allows step sizes of 1-4 to have no penalty
|
||||
// but step sizes higher than this add a quadratic penalty.
|
||||
// Penalty's go:
|
||||
// Step size | Penalty Factor
|
||||
// 1 | 1
|
||||
// 2 | 1
|
||||
// 3 | 1
|
||||
// 4 | 1
|
||||
// 5 | 2
|
||||
// 6 | 2
|
||||
// 7 | 2
|
||||
// 8 | 3
|
||||
// 9 | 4
|
||||
// 10 | 5
|
||||
|
||||
if let InboundRequest::BlocksByRange(bbr_req) = request {
|
||||
let penalty_factor = (bbr_req.step as f64 / 5.0).powi(2) as u64 + 1;
|
||||
tokens *= penalty_factor;
|
||||
}
|
||||
let tokens = request.expected_responses().max(1);
|
||||
|
||||
let check =
|
||||
|limiter: &mut Limiter<PeerId>| limiter.allows(time_since_start, peer_id, tokens);
|
||||
|
||||
Reference in New Issue
Block a user