@@ -124,7 +124,7 @@ async fn fetch_and_process_engine_blobs_inner<T: BeaconChainTypes>(
124124 . spec ( )
125125 . is_peer_das_enabled_for_epoch ( block. epoch ( ) )
126126 {
127- fetch_and_process_blobs_v2 (
127+ fetch_and_process_blobs_v2_or_v3 (
128128 chain_adapter,
129129 block_root,
130130 block,
@@ -239,7 +239,7 @@ async fn fetch_and_process_blobs_v1<T: BeaconChainTypes>(
239239}
240240
241241#[ instrument( skip_all, level = "debug" ) ]
242- async fn fetch_and_process_blobs_v2 < T : BeaconChainTypes > (
242+ async fn fetch_and_process_blobs_v2_or_v3 < T : BeaconChainTypes > (
243243 chain_adapter : FetchBlobsBeaconAdapter < T > ,
244244 block_root : Hash256 ,
245245 block : Arc < SignedBeaconBlock < T :: EthSpec > > ,
@@ -250,14 +250,25 @@ async fn fetch_and_process_blobs_v2<T: BeaconChainTypes>(
250250 let num_expected_blobs = versioned_hashes. len ( ) ;
251251
252252 metrics:: observe ( & metrics:: BLOBS_FROM_EL_EXPECTED , num_expected_blobs as f64 ) ;
253- // TODO(dknopik): implement fallback to get_blobs_v2
254- debug ! ( num_expected_blobs, "Fetching blobs from the EL" ) ;
255- let response = chain_adapter
256- . get_blobs_v3 ( versioned_hashes)
257- . await
258- . inspect_err ( |_| {
259- inc_counter ( & metrics:: BLOBS_FROM_EL_ERROR_TOTAL ) ;
260- } ) ?;
253+
254+ let response = if chain_adapter. supports_get_blobs_v3 ( ) . await ? {
255+ debug ! ( num_expected_blobs, "Fetching available blobs from the EL" ) ;
256+ chain_adapter
257+ . get_blobs_v3 ( versioned_hashes)
258+ . await
259+ . inspect_err ( |_| {
260+ inc_counter ( & metrics:: BLOBS_FROM_EL_ERROR_TOTAL ) ;
261+ } ) ?
262+ } else {
263+ debug ! ( num_expected_blobs, "Fetching all blobs from the EL" ) ;
264+ chain_adapter
265+ . get_blobs_v2 ( versioned_hashes)
266+ . await
267+ . inspect_err ( |_| {
268+ inc_counter ( & metrics:: BLOBS_FROM_EL_ERROR_TOTAL ) ;
269+ } ) ?
270+ . map ( |vec| vec. into_iter ( ) . map ( Some ) . collect ( ) )
271+ } ;
261272
262273 let Some ( blobs_and_proofs) = response else {
263274 debug ! ( num_expected_blobs, "No blobs fetched from the EL" ) ;
0 commit comments