Skip to content

Commit ef88e87

Browse files
committed
Update getBlobsV2 response type and update handling of missing blobs.
1 parent e29b607 commit ef88e87

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

beacon_node/beacon_chain/src/fetch_blobs.rs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use ssz_types::FixedVector;
2222
use state_processing::per_block_processing::deneb::kzg_commitment_to_versioned_hash;
2323
use std::collections::HashSet;
2424
use std::sync::Arc;
25-
use tracing::debug;
25+
use tracing::{debug, warn};
2626
use types::blob_sidecar::{BlobSidecarError, FixedBlobSidecarList};
2727
use types::data_column_sidecar::DataColumnSidecarError;
2828
use types::{
@@ -212,31 +212,37 @@ async fn fetch_and_process_blobs_v2<T: BeaconChainTypes>(
212212
})
213213
.map_err(FetchEngineBlobError::RequestFailed)?;
214214

215-
let (blobs, proofs): (Vec<_>, Vec<_>) = response
215+
let Some(blobs_and_proofs) = response else {
216+
debug!(num_expected_blobs, "No blobs fetched from the EL");
217+
inc_counter(&metrics::BLOBS_FROM_EL_MISS_TOTAL);
218+
return Ok(None);
219+
};
220+
221+
let (blobs, proofs): (Vec<_>, Vec<_>) = blobs_and_proofs
216222
.into_iter()
217-
.filter_map(|blob_and_proof_opt| {
218-
blob_and_proof_opt.map(|blob_and_proof| {
219-
let BlobAndProofV2 { blob, proofs } = blob_and_proof;
220-
(blob, proofs)
221-
})
223+
.map(|blob_and_proof| {
224+
let BlobAndProofV2 { blob, proofs } = blob_and_proof;
225+
(blob, proofs)
222226
})
223227
.unzip();
224228

225229
let num_fetched_blobs = blobs.len();
226230
metrics::observe(&metrics::BLOBS_FROM_EL_RECEIVED, num_fetched_blobs as f64);
227231

228-
// Partial blobs response isn't useful for PeerDAS, so we don't bother building and publishing data columns.
229232
if num_fetched_blobs != num_expected_blobs {
230-
debug!(
231-
info = "Unable to compute data columns",
232-
num_fetched_blobs, num_expected_blobs, "Not all blobs fetched from the EL"
233+
// This scenario is not supposed to happen if the EL is spec compliant.
234+
// It should either return all requested blobs or none, but NOT partial responses.
235+
// If we attempt to compute columns with partial blobs, we'd end up with invalid columns.
236+
warn!(
237+
num_fetched_blobs,
238+
num_expected_blobs, "The EL did not return all requested blobs"
233239
);
234240
inc_counter(&metrics::BLOBS_FROM_EL_MISS_TOTAL);
235241
return Ok(None);
236-
} else {
237-
inc_counter(&metrics::BLOBS_FROM_EL_HIT_TOTAL);
238242
}
239243

244+
inc_counter(&metrics::BLOBS_FROM_EL_HIT_TOTAL);
245+
240246
if chain
241247
.canonical_head
242248
.fork_choice_read_lock()

beacon_node/execution_layer/src/engine_api/http.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ impl HttpJsonRpc {
727727
pub async fn get_blobs_v2<E: EthSpec>(
728728
&self,
729729
versioned_hashes: Vec<Hash256>,
730-
) -> Result<Vec<Option<BlobAndProofV2<E>>>, Error> {
730+
) -> Result<Option<Vec<BlobAndProofV2<E>>>, Error> {
731731
let params = json!([versioned_hashes]);
732732

733733
self.rpc_request(

beacon_node/execution_layer/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1861,7 +1861,7 @@ impl<E: EthSpec> ExecutionLayer<E> {
18611861
pub async fn get_blobs_v2(
18621862
&self,
18631863
query: Vec<Hash256>,
1864-
) -> Result<Vec<Option<BlobAndProofV2<E>>>, Error> {
1864+
) -> Result<Option<Vec<BlobAndProofV2<E>>>, Error> {
18651865
let capabilities = self.get_engine_capabilities(None).await?;
18661866

18671867
if capabilities.get_blobs_v2 {

0 commit comments

Comments
 (0)