Less strict handling of faulty rpc req params and syntax improvement
This commit is contained in:
parent
9445ac70d8
commit
b4ec4c1ccf
@ -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,46 +619,61 @@ 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();
|
||||||
|
|
||||||
if Some(start_epoch) < data_availability_boundary {
|
let serve_blobs_from_slot = match data_availability_boundary {
|
||||||
let oldest_blob_slot = self
|
Some(data_availability_boundary_epoch) => {
|
||||||
.chain
|
if Some(start_epoch) < data_availability_boundary {
|
||||||
.store
|
let oldest_blob_slot = self
|
||||||
.get_blob_info()
|
.chain
|
||||||
.map(|blob_info| blob_info.oldest_blob_slot);
|
.store
|
||||||
|
.get_blob_info()
|
||||||
|
.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,
|
||||||
|
"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
|
||||||
|
);
|
||||||
|
|
||||||
return self.send_error_response(
|
data_availability_boundary_epoch.start_slot(T::EthSpec::slots_per_epoch())
|
||||||
peer_id,
|
} else {
|
||||||
RPCResponseErrorCode::ResourceUnavailable,
|
start_slot
|
||||||
format!("Requested start slot in epoch {}. Data availability boundary is currently at epoch {:?}", start_epoch, data_availability_boundary),
|
}
|
||||||
request_id,
|
}
|
||||||
);
|
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 =
|
||||||
Ok(iter) => iter,
|
match self.chain.forwards_iter_block_roots(serve_blobs_from_slot) {
|
||||||
Err(BeaconChainError::HistoricalBlockError(
|
Ok(iter) => iter,
|
||||||
HistoricalBlockError::BlockOutOfRange {
|
Err(BeaconChainError::HistoricalBlockError(
|
||||||
slot,
|
HistoricalBlockError::BlockOutOfRange {
|
||||||
oldest_block_slot,
|
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(
|
debug!(self.log, "Range request failed during backfill";
|
||||||
peer_id,
|
"requested_slot" => slot,
|
||||||
RPCResponseErrorCode::ResourceUnavailable,
|
"oldest_known_slot" => oldest_block_slot
|
||||||
"Backfilling".into(),
|
);
|
||||||
request_id,
|
return self.send_error_response(
|
||||||
);
|
peer_id,
|
||||||
}
|
RPCResponseErrorCode::ResourceUnavailable,
|
||||||
Err(e) => return error!(self.log, "Unable to obtain root iter"; "error" => ?e),
|
"Backfilling".into(),
|
||||||
};
|
request_id,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Err(e) => return error!(self.log, "Unable to obtain root iter"; "error" => ?e),
|
||||||
|
};
|
||||||
|
|
||||||
// Pick out the required blocks, ignoring skip-slots.
|
// Pick out the required blocks, ignoring skip-slots.
|
||||||
let mut last_block_root = req
|
let mut last_block_root = req
|
||||||
|
Loading…
Reference in New Issue
Block a user