mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-16 11:22:56 +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:
@@ -1065,11 +1065,33 @@ where
|
||||
// propagate the STATUS message upwards
|
||||
self.propagate_request(peer_request_id, peer_id, Request::Status(msg))
|
||||
}
|
||||
InboundRequest::BlocksByRange(req) => self.propagate_request(
|
||||
peer_request_id,
|
||||
peer_id,
|
||||
Request::BlocksByRange(req),
|
||||
),
|
||||
InboundRequest::BlocksByRange(req) => {
|
||||
let methods::OldBlocksByRangeRequest {
|
||||
start_slot,
|
||||
mut count,
|
||||
step,
|
||||
} = req;
|
||||
// Still disconnect the peer if the request is naughty.
|
||||
if step == 0 {
|
||||
self.peer_manager.handle_rpc_error(
|
||||
&peer_id,
|
||||
Protocol::BlocksByRange,
|
||||
&RPCError::InvalidData(
|
||||
"Blocks by range with 0 step parameter".into(),
|
||||
),
|
||||
ConnectionDirection::Incoming,
|
||||
);
|
||||
}
|
||||
// return just one block in case the step parameter is used. https://github.com/ethereum/consensus-specs/pull/2856
|
||||
if step > 1 {
|
||||
count = 1;
|
||||
}
|
||||
self.propagate_request(
|
||||
peer_request_id,
|
||||
peer_id,
|
||||
Request::BlocksByRange(BlocksByRangeRequest { start_slot, count }),
|
||||
);
|
||||
}
|
||||
InboundRequest::BlocksByRoot(req) => {
|
||||
self.propagate_request(peer_request_id, peer_id, Request::BlocksByRoot(req))
|
||||
}
|
||||
@@ -1313,7 +1335,13 @@ impl<TSpec: EthSpec> std::convert::From<Request> for OutboundRequest<TSpec> {
|
||||
fn from(req: Request) -> OutboundRequest<TSpec> {
|
||||
match req {
|
||||
Request::BlocksByRoot(r) => OutboundRequest::BlocksByRoot(r),
|
||||
Request::BlocksByRange(r) => OutboundRequest::BlocksByRange(r),
|
||||
Request::BlocksByRange(BlocksByRangeRequest { start_slot, count }) => {
|
||||
OutboundRequest::BlocksByRange(methods::OldBlocksByRangeRequest {
|
||||
start_slot,
|
||||
count,
|
||||
step: 1,
|
||||
})
|
||||
}
|
||||
Request::Status(s) => OutboundRequest::Status(s),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user