handle empty blocks gracefully

This commit is contained in:
qu0b 2023-07-24 15:12:48 +02:00
parent 8c341bb9cc
commit 97bffd03d0
2 changed files with 14 additions and 2 deletions

View File

@ -1189,7 +1189,19 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
&self,
block_root: &Hash256,
) -> Result<Option<BlobSidecarList<T::EthSpec>>, Error> {
Ok(self.store.get_blobs(block_root)?)
let blobs = self.store.get_blobs(block_root)?;
match Some(blobs) {
Some(blobs) => Ok(blobs),
None => {
// if there are no blobs, but a block exists return an empty list
if let Some(_) = self.store.try_get_full_block(block_root)? {
return Ok(Some(BlobSidecarList::default()))
}
// if there is no blob and no block return none.
Ok(None)
}
}
}
pub fn get_blinded_block(

View File

@ -261,7 +261,7 @@ impl BlockId {
match chain.get_blobs(&root) {
Ok(Some(blob_sidecar_list)) => Ok(blob_sidecar_list),
Ok(None) => Err(warp_utils::reject::custom_not_found(format!(
"No blobs with block root {} found in the store",
"Block not found {} in the store",
root
))),
Err(e) => Err(warp_utils::reject::beacon_chain_error(e)),