Less strict handling of faulty rpc req params and syntax improvement

This commit is contained in:
Emilia Hane 2023-01-18 14:17:11 +01:00
parent 9445ac70d8
commit b4ec4c1ccf
No known key found for this signature in database
GPG Key ID: E73394F9C09206FA

View File

@ -440,7 +440,10 @@ impl<T: BeaconChainTypes> Worker<T> {
oldest_block_slot, oldest_block_slot,
}, },
)) => { )) => {
debug!(self.log, "Range request failed during backfill"; "requested_slot" => slot, "oldest_known_slot" => oldest_block_slot); debug!(self.log, "Range request failed during backfill";
"requested_slot" => slot,
"oldest_known_slot" => oldest_block_slot
);
return self.send_error_response( return self.send_error_response(
peer_id, peer_id,
RPCResponseErrorCode::ResourceUnavailable, RPCResponseErrorCode::ResourceUnavailable,
@ -616,6 +619,8 @@ impl<T: BeaconChainTypes> Worker<T> {
let start_epoch = start_slot.epoch(T::EthSpec::slots_per_epoch()); let start_epoch = start_slot.epoch(T::EthSpec::slots_per_epoch());
let data_availability_boundary = self.chain.data_availability_boundary(); let data_availability_boundary = self.chain.data_availability_boundary();
let serve_blobs_from_slot = match data_availability_boundary {
Some(data_availability_boundary_epoch) => {
if Some(start_epoch) < data_availability_boundary { if Some(start_epoch) < data_availability_boundary {
let oldest_blob_slot = self let oldest_blob_slot = self
.chain .chain
@ -623,22 +628,32 @@ impl<T: BeaconChainTypes> Worker<T> {
.get_blob_info() .get_blob_info()
.map(|blob_info| blob_info.oldest_blob_slot); .map(|blob_info| blob_info.oldest_blob_slot);
debug!(self.log, "Range request start slot is older than data availability boundary"; "requested_slot" => req.start_slot, "oldest_known_slot" => ?oldest_blob_slot, "data_availability_boundary" => data_availability_boundary); debug!(
self.log,
return self.send_error_response( "Range request start slot is older than data availability boundary";
peer_id, "requested_slot" => req.start_slot,
RPCResponseErrorCode::ResourceUnavailable, "oldest_known_slot" => ?oldest_blob_slot,
format!("Requested start slot in epoch {}. Data availability boundary is currently at epoch {:?}", start_epoch, data_availability_boundary), "data_availability_boundary" => data_availability_boundary
request_id,
); );
data_availability_boundary_epoch.start_slot(T::EthSpec::slots_per_epoch())
} else {
start_slot
} }
}
None => {
debug!(self.log, "Eip4844 fork is disabled");
return;
}
};
// Should not send more than max request blocks // Should not send more than max request blocks
if req.count > MAX_REQUEST_BLOBS_SIDECARS { if req.count > MAX_REQUEST_BLOBS_SIDECARS {
req.count = MAX_REQUEST_BLOBS_SIDECARS; req.count = MAX_REQUEST_BLOBS_SIDECARS;
} }
let forwards_block_root_iter = match self.chain.forwards_iter_block_roots(start_slot) { let forwards_block_root_iter =
match self.chain.forwards_iter_block_roots(serve_blobs_from_slot) {
Ok(iter) => iter, Ok(iter) => iter,
Err(BeaconChainError::HistoricalBlockError( Err(BeaconChainError::HistoricalBlockError(
HistoricalBlockError::BlockOutOfRange { HistoricalBlockError::BlockOutOfRange {
@ -646,7 +661,10 @@ impl<T: BeaconChainTypes> Worker<T> {
oldest_block_slot, oldest_block_slot,
}, },
)) => { )) => {
debug!(self.log, "Range request failed during backfill"; "requested_slot" => slot, "oldest_known_slot" => oldest_block_slot); debug!(self.log, "Range request failed during backfill";
"requested_slot" => slot,
"oldest_known_slot" => oldest_block_slot
);
return self.send_error_response( return self.send_error_response(
peer_id, peer_id,
RPCResponseErrorCode::ResourceUnavailable, RPCResponseErrorCode::ResourceUnavailable,