Return HTTP 404 for pruned blob requests (#6331)

* Return HTTP 404 for pruned blob requests
This commit is contained in:
Michael Sproul
2024-08-30 15:28:21 +10:00
committed by GitHub
parent ae8390150d
commit e3d2d38497
2 changed files with 137 additions and 3 deletions

View File

@@ -274,10 +274,27 @@ impl BlockId {
warp_utils::reject::custom_not_found(format!("beacon block with root {}", root))
})?;
// Error if the block is pre-Deneb and lacks blobs.
let blob_kzg_commitments = block.message().body().blob_kzg_commitments().map_err(|_| {
warp_utils::reject::custom_bad_request(
"block is pre-Deneb and has no blobs".to_string(),
)
})?;
// Return the `BlobSidecarList` identified by `self`.
let blob_sidecar_list = chain
.get_blobs(&root)
.map_err(warp_utils::reject::beacon_chain_error)?;
let blob_sidecar_list = if !blob_kzg_commitments.is_empty() {
chain
.store
.get_blobs(&root)
.map_err(|e| warp_utils::reject::beacon_chain_error(e.into()))?
.ok_or_else(|| {
warp_utils::reject::custom_not_found(format!(
"no blobs stored for block {root}"
))
})?
} else {
BlobSidecarList::default()
};
let blob_sidecar_list_filtered = match indices.indices {
Some(vec) => {