mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-15 10:52:43 +00:00
Fork aware max values in rpc (#6847)
N/A In https://github.com/sigp/lighthouse/pull/6329 we changed `max_blobs_per_block` from a preset to a config value. We weren't using the right value based on fork in that PR. This is a follow up PR to use the fork dependent values. In the proces, I also updated other places where we weren't using fork dependent values from the ChainSpec. Note to reviewer: easier to go through by commit
This commit is contained in:
@@ -855,6 +855,45 @@ where
|
||||
}
|
||||
|
||||
let (req, substream) = substream;
|
||||
let current_fork = self.fork_context.current_fork();
|
||||
let spec = &self.fork_context.spec;
|
||||
|
||||
match &req {
|
||||
RequestType::BlocksByRange(request) => {
|
||||
let max_allowed = spec.max_request_blocks(current_fork) as u64;
|
||||
if *request.count() > max_allowed {
|
||||
self.events_out.push(HandlerEvent::Err(HandlerErr::Inbound {
|
||||
id: self.current_inbound_substream_id,
|
||||
proto: Protocol::BlocksByRange,
|
||||
error: RPCError::InvalidData(format!(
|
||||
"requested exceeded limit. allowed: {}, requested: {}",
|
||||
max_allowed,
|
||||
request.count()
|
||||
)),
|
||||
}));
|
||||
return self.shutdown(None);
|
||||
}
|
||||
}
|
||||
RequestType::BlobsByRange(request) => {
|
||||
let max_requested_blobs = request
|
||||
.count
|
||||
.saturating_mul(spec.max_blobs_per_block_by_fork(current_fork));
|
||||
let max_allowed = spec.max_request_blob_sidecars(current_fork) as u64;
|
||||
if max_requested_blobs > max_allowed {
|
||||
self.events_out.push(HandlerEvent::Err(HandlerErr::Inbound {
|
||||
id: self.current_inbound_substream_id,
|
||||
proto: Protocol::BlobsByRange,
|
||||
error: RPCError::InvalidData(format!(
|
||||
"requested exceeded limit. allowed: {}, requested: {}",
|
||||
max_allowed, max_requested_blobs
|
||||
)),
|
||||
}));
|
||||
return self.shutdown(None);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
|
||||
let max_responses =
|
||||
req.max_responses(self.fork_context.current_fork(), &self.fork_context.spec);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user