make explicity BlobsUnavailable error and handle it directly

This commit is contained in:
realbigsean 2023-01-18 17:47:32 -05:00 committed by Emilia Hane
parent f7f64eb007
commit e1ce4e5b78
No known key found for this signature in database
GPG Key ID: E73394F9C09206FA
3 changed files with 35 additions and 7 deletions

View File

@ -1063,12 +1063,12 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
Some(blobs) => Ok(Some(blobs)), Some(blobs) => Ok(Some(blobs)),
None => { None => {
// Check for the corresponding block to understand whether we *should* have blobs. // Check for the corresponding block to understand whether we *should* have blobs.
self self.get_blinded_block(block_root)?
.get_blinded_block(block_root)?
.map(|block| { .map(|block| {
// If there are no KZG commitments in the block, we know the sidecar should // If there are no KZG commitments in the block, we know the sidecar should
// be empty. // be empty.
let expected_kzg_commitments = block.message().body().blob_kzg_commitments()?; let expected_kzg_commitments =
block.message().body().blob_kzg_commitments()?;
if expected_kzg_commitments.is_empty() { if expected_kzg_commitments.is_empty() {
Ok(Some(BlobsSidecar::empty_from_parts( Ok(Some(BlobsSidecar::empty_from_parts(
*block_root, *block_root,
@ -1078,10 +1078,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
if let Some(boundary) = self.data_availability_boundary() { if let Some(boundary) = self.data_availability_boundary() {
// We should have blobs for all blocks after the boundary. // We should have blobs for all blocks after the boundary.
if boundary <= block.epoch() { if boundary <= block.epoch() {
return Err(Error::DBInconsistent(format!( return Err(Error::BlobsUnavailable);
"Expected kzg commitments but no blobs stored for block root {}",
block_root
)))
} }
} }
Ok(None) Ok(None)

View File

@ -209,6 +209,7 @@ pub enum BeaconChainError {
BlsToExecutionChangeBadFork(ForkName), BlsToExecutionChangeBadFork(ForkName),
InconsistentFork(InconsistentFork), InconsistentFork(InconsistentFork),
ProposerHeadForkChoiceError(fork_choice::Error<proto_array::Error>), ProposerHeadForkChoiceError(fork_choice::Error<proto_array::Error>),
BlobsUnavailable,
} }
easy_from_to!(SlotProcessingError, BeaconChainError); easy_from_to!(SlotProcessingError, BeaconChainError);

View File

@ -293,6 +293,21 @@ impl<T: BeaconChainTypes> Worker<T> {
"request_root" => ?root "request_root" => ?root
); );
} }
Err(BeaconChainError::BlobsUnavailable) => {
error!(
self.log,
"No blobs in the store for block root";
"block_root" => ?root
);
self.send_error_response(
peer_id,
RPCResponseErrorCode::ResourceUnavailable,
"Blobs unavailable".into(),
request_id,
);
send_response = false;
break;
}
Err(BeaconChainError::BlockHashMissingFromExecutionLayer(_)) => { Err(BeaconChainError::BlockHashMissingFromExecutionLayer(_)) => {
debug!( debug!(
self.log, self.log,
@ -747,6 +762,21 @@ impl<T: BeaconChainTypes> Worker<T> {
send_response = false; send_response = false;
break; break;
} }
Err(BeaconChainError::BlobsUnavailable) => {
error!(
self.log,
"No blobs in the store for block root";
"block_root" => ?root
);
self.send_error_response(
peer_id,
RPCResponseErrorCode::ResourceUnavailable,
"Blobs unavailable".into(),
request_id,
);
send_response = false;
break;
}
Err(e) => { Err(e) => {
error!( error!(
self.log, self.log,