From 01ac7ad23c36be08e11b02b4859c70e67877bf1d Mon Sep 17 00:00:00 2001 From: Emilia Hane Date: Thu, 5 Jan 2023 10:17:59 +0100 Subject: [PATCH] Return empty blobs sidecar when no kzg commitments in block --- beacon_node/beacon_chain/src/beacon_chain.rs | 23 +++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index dd2be88b0..3ecccd1cc 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -1052,7 +1052,28 @@ impl BeaconChain { &self, block_root: &Hash256, ) -> Result>, Error> { - Ok(self.store.get_blobs(block_root)?) + match self.store.get_blobs(block_root)? { + Some(blobs) => Ok(Some(blobs)), + None => { + if let Some(block) = self.get_block(block_root).await? { + let expected_kzg_commitments = block.message().body().blob_kzg_commitments()?; + + if expected_kzg_commitments.len() > 0 { + Err(Error::DBInconsistent(format!( + "expected kzg_commitments but no blobs stored for block_root {}", + block_root + ))) + } else { + Ok(Some(BlobsSidecar::empty_from_parts( + *block_root, + block.slot(), + ))) + } + } else { + Ok(None) + } + } + } } pub fn get_blinded_block(