clean up blobs by range response (#4137)
This commit is contained in:
parent
da7fab5188
commit
d24e5cc22a
@ -1971,7 +1971,6 @@ impl<T: BeaconChainTypes> BeaconProcessor<T> {
|
|||||||
request,
|
request,
|
||||||
} => task_spawner.spawn_blocking_with_manual_send_idle(move |send_idle_on_drop| {
|
} => task_spawner.spawn_blocking_with_manual_send_idle(move |send_idle_on_drop| {
|
||||||
worker.handle_blobs_by_range_request(
|
worker.handle_blobs_by_range_request(
|
||||||
sub_executor,
|
|
||||||
send_idle_on_drop,
|
send_idle_on_drop,
|
||||||
peer_id,
|
peer_id,
|
||||||
request_id,
|
request_id,
|
||||||
|
@ -682,7 +682,6 @@ impl<T: BeaconChainTypes> Worker<T> {
|
|||||||
/// Handle a `BlobsByRange` request from the peer.
|
/// Handle a `BlobsByRange` request from the peer.
|
||||||
pub fn handle_blobs_by_range_request(
|
pub fn handle_blobs_by_range_request(
|
||||||
self,
|
self,
|
||||||
_executor: TaskExecutor,
|
|
||||||
send_on_drop: SendOnDrop,
|
send_on_drop: SendOnDrop,
|
||||||
peer_id: PeerId,
|
peer_id: PeerId,
|
||||||
request_id: PeerRequestId,
|
request_id: PeerRequestId,
|
||||||
@ -704,13 +703,15 @@ impl<T: BeaconChainTypes> Worker<T> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let data_availability_boundary = match self.chain.data_availability_boundary() {
|
let request_start_slot = Slot::from(req.start_slot);
|
||||||
Some(boundary) => boundary,
|
|
||||||
|
let data_availability_boundary_slot = match self.chain.data_availability_boundary() {
|
||||||
|
Some(boundary) => boundary.start_slot(T::EthSpec::slots_per_epoch()),
|
||||||
None => {
|
None => {
|
||||||
debug!(self.log, "Deneb fork is disabled");
|
debug!(self.log, "Deneb fork is disabled");
|
||||||
self.send_error_response(
|
self.send_error_response(
|
||||||
peer_id,
|
peer_id,
|
||||||
RPCResponseErrorCode::ServerError,
|
RPCResponseErrorCode::InvalidRequest,
|
||||||
"Deneb fork is disabled".into(),
|
"Deneb fork is disabled".into(),
|
||||||
request_id,
|
request_id,
|
||||||
);
|
);
|
||||||
@ -718,47 +719,40 @@ impl<T: BeaconChainTypes> Worker<T> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let start_slot = Slot::from(req.start_slot);
|
let oldest_blob_slot = self
|
||||||
let start_epoch = start_slot.epoch(T::EthSpec::slots_per_epoch());
|
.chain
|
||||||
|
.store
|
||||||
// If the peer requests data from beyond the data availability boundary we altruistically
|
.get_blob_info()
|
||||||
// cap to the right time range.
|
.oldest_blob_slot
|
||||||
let serve_blobs_from_slot = if start_epoch < data_availability_boundary {
|
.unwrap_or(data_availability_boundary_slot);
|
||||||
// Attempt to serve from the earliest block in our database, falling back to the data
|
if request_start_slot < oldest_blob_slot {
|
||||||
// availability boundary
|
|
||||||
let oldest_blob_slot =
|
|
||||||
self.chain.store.get_blob_info().oldest_blob_slot.unwrap_or(
|
|
||||||
data_availability_boundary.start_slot(T::EthSpec::slots_per_epoch()),
|
|
||||||
);
|
|
||||||
|
|
||||||
debug!(
|
debug!(
|
||||||
self.log,
|
self.log,
|
||||||
"Range request start slot is older than data availability boundary";
|
"Range request start slot is older than data availability boundary.";
|
||||||
"requested_slot" => req.start_slot,
|
"requested_slot" => request_start_slot,
|
||||||
"oldest_known_slot" => oldest_blob_slot,
|
"oldest_blob_slot" => oldest_blob_slot,
|
||||||
"data_availability_boundary" => data_availability_boundary
|
"data_availability_boundary" => data_availability_boundary_slot
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check if the request is entirely out of the data availability period. The
|
return if data_availability_boundary_slot < oldest_blob_slot {
|
||||||
// `oldest_blob_slot` is the oldest slot in the database, so includes a margin of error
|
self.send_error_response(
|
||||||
// controlled by our prune margin.
|
peer_id,
|
||||||
let end_request_slot = start_slot + req.count;
|
RPCResponseErrorCode::ResourceUnavailable,
|
||||||
if oldest_blob_slot < end_request_slot {
|
"blobs pruned within boundary".into(),
|
||||||
return self.send_error_response(
|
request_id,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
self.send_error_response(
|
||||||
peer_id,
|
peer_id,
|
||||||
RPCResponseErrorCode::InvalidRequest,
|
RPCResponseErrorCode::InvalidRequest,
|
||||||
"Request outside of data availability period".into(),
|
"Req outside availability period".into(),
|
||||||
request_id,
|
request_id,
|
||||||
);
|
)
|
||||||
}
|
};
|
||||||
std::cmp::max(oldest_blob_slot, start_slot)
|
}
|
||||||
} else {
|
|
||||||
start_slot
|
|
||||||
};
|
|
||||||
|
|
||||||
// If the peer requests data from beyond the data availability boundary we altruistically cap to the right time range
|
|
||||||
let forwards_block_root_iter =
|
let forwards_block_root_iter =
|
||||||
match self.chain.forwards_iter_block_roots(serve_blobs_from_slot) {
|
match self.chain.forwards_iter_block_roots(request_start_slot) {
|
||||||
Ok(iter) => iter,
|
Ok(iter) => iter,
|
||||||
Err(BeaconChainError::HistoricalBlockError(
|
Err(BeaconChainError::HistoricalBlockError(
|
||||||
HistoricalBlockError::BlockOutOfRange {
|
HistoricalBlockError::BlockOutOfRange {
|
||||||
@ -849,21 +843,13 @@ impl<T: BeaconChainTypes> Worker<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(None) => {
|
Ok(None) => {
|
||||||
error!(
|
debug!(
|
||||||
self.log,
|
self.log,
|
||||||
"No blobs or block in the store for block root";
|
"No blobs in the store for block root";
|
||||||
"request" => ?req,
|
"request" => ?req,
|
||||||
"peer" => %peer_id,
|
"peer" => %peer_id,
|
||||||
"block_root" => ?root
|
"block_root" => ?root
|
||||||
);
|
);
|
||||||
self.send_error_response(
|
|
||||||
peer_id,
|
|
||||||
RPCResponseErrorCode::ServerError,
|
|
||||||
"Database inconsistency".into(),
|
|
||||||
request_id,
|
|
||||||
);
|
|
||||||
send_response = false;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
Err(BeaconChainError::BlobsUnavailable) => {
|
Err(BeaconChainError::BlobsUnavailable) => {
|
||||||
error!(
|
error!(
|
||||||
@ -885,7 +871,7 @@ impl<T: BeaconChainTypes> Worker<T> {
|
|||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!(
|
error!(
|
||||||
self.log,
|
self.log,
|
||||||
"Error fetching blinded block for block root";
|
"Error fetching blobs block root";
|
||||||
"request" => ?req,
|
"request" => ?req,
|
||||||
"peer" => %peer_id,
|
"peer" => %peer_id,
|
||||||
"block_root" => ?root,
|
"block_root" => ?root,
|
||||||
|
Loading…
Reference in New Issue
Block a user