From e1ce4e5b7851f7d18c4d74758d5a3ec213aa794d Mon Sep 17 00:00:00 2001 From: realbigsean Date: Wed, 18 Jan 2023 17:47:32 -0500 Subject: [PATCH] make explicity BlobsUnavailable error and handle it directly --- beacon_node/beacon_chain/src/beacon_chain.rs | 11 +++---- beacon_node/beacon_chain/src/errors.rs | 1 + .../beacon_processor/worker/rpc_methods.rs | 30 +++++++++++++++++++ 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index dac3dee8d9..a43d82ff32 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -1063,12 +1063,12 @@ impl BeaconChain { Some(blobs) => Ok(Some(blobs)), None => { // Check for the corresponding block to understand whether we *should* have blobs. - self - .get_blinded_block(block_root)? + self.get_blinded_block(block_root)? .map(|block| { // If there are no KZG commitments in the block, we know the sidecar should // 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() { Ok(Some(BlobsSidecar::empty_from_parts( *block_root, @@ -1078,10 +1078,7 @@ impl BeaconChain { if let Some(boundary) = self.data_availability_boundary() { // We should have blobs for all blocks after the boundary. if boundary <= block.epoch() { - return Err(Error::DBInconsistent(format!( - "Expected kzg commitments but no blobs stored for block root {}", - block_root - ))) + return Err(Error::BlobsUnavailable); } } Ok(None) diff --git a/beacon_node/beacon_chain/src/errors.rs b/beacon_node/beacon_chain/src/errors.rs index 25f2554f3d..e744e2af5b 100644 --- a/beacon_node/beacon_chain/src/errors.rs +++ b/beacon_node/beacon_chain/src/errors.rs @@ -209,6 +209,7 @@ pub enum BeaconChainError { BlsToExecutionChangeBadFork(ForkName), InconsistentFork(InconsistentFork), ProposerHeadForkChoiceError(fork_choice::Error), + BlobsUnavailable, } easy_from_to!(SlotProcessingError, BeaconChainError); diff --git a/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs b/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs index 6e48389b55..8888e6f9f7 100644 --- a/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs +++ b/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs @@ -293,6 +293,21 @@ impl Worker { "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(_)) => { debug!( self.log, @@ -747,6 +762,21 @@ impl Worker { send_response = false; 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) => { error!( self.log,