Return empty blobs sidecar when no kzg commitments in block

This commit is contained in:
Emilia Hane 2023-01-05 10:17:59 +01:00
parent 92c4e99305
commit 01ac7ad23c
No known key found for this signature in database
GPG Key ID: E73394F9C09206FA

View File

@ -1052,7 +1052,28 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
&self, &self,
block_root: &Hash256, block_root: &Hash256,
) -> Result<Option<BlobsSidecar<T::EthSpec>>, Error> { ) -> Result<Option<BlobsSidecar<T::EthSpec>>, 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( pub fn get_blinded_block(