diff --git a/beacon_node/network/src/sync/block_lookups/single_block_lookup.rs b/beacon_node/network/src/sync/block_lookups/single_block_lookup.rs index 2febc4cd4e..21dcfb44fc 100644 --- a/beacon_node/network/src/sync/block_lookups/single_block_lookup.rs +++ b/beacon_node/network/src/sync/block_lookups/single_block_lookup.rs @@ -288,6 +288,7 @@ enum DataDownload { }, Columns { block_root: Hash256, + slot: Slot, state: SingleLookupRequestState>, }, } @@ -309,9 +310,13 @@ impl DataDownload { let eb = *expected_blobs; state.make_request(|| cx.blob_lookup_request(id, peers, br, eb)) } - DataDownload::Columns { block_root, state } => { + DataDownload::Columns { + block_root, + slot, + state, + } => { let br = *block_root; - state.make_request(|| cx.custody_lookup_request(id, br, peers)) + state.make_request(|| cx.custody_lookup_request(id, br, *slot, peers)) } } } @@ -447,6 +452,7 @@ impl DataRequestState { if expected_blobs > 0 { Self::Downloading(DataDownload::Columns { block_root, + slot, state: SingleLookupRequestState::new_with_processing_failures( failed_processing, ), @@ -459,6 +465,7 @@ impl DataRequestState { if expected_blobs > 0 { Self::Downloading(DataDownload::Columns { block_root, + slot, state: SingleLookupRequestState::new_with_processing_failures( failed_processing, ), diff --git a/beacon_node/network/src/sync/network_context.rs b/beacon_node/network/src/sync/network_context.rs index 86435dd549..a987fd94f6 100644 --- a/beacon_node/network/src/sync/network_context.rs +++ b/beacon_node/network/src/sync/network_context.rs @@ -1179,34 +1179,18 @@ impl SyncNetworkContext { &mut self, lookup_id: SingleLookupId, block_root: Hash256, + block_slot: Slot, lookup_peers: Arc>>, ) -> Result { - let slot = self - .chain - .canonical_head - .fork_choice_read_lock() - .get_block(&block_root) - .map(|block| block.slot) - .or_else(|| self.chain.slot().ok()) - .ok_or_else(|| { - RpcRequestSendError::InternalError(format!( - "Unable to determine slot for block {block_root:?}" - )) - })?; - let custody_indexes_imported = self .chain - .cached_data_column_indexes(&block_root, slot) + .cached_data_column_indexes(&block_root, block_slot) .unwrap_or_default(); - let current_epoch = self.chain.epoch().map_err(|e| { - RpcRequestSendError::InternalError(format!("Unable to read slot clock {:?}", e)) - })?; - // Include only the blob indexes not yet imported (received through gossip) let mut custody_indexes_to_fetch = self .chain - .sampling_columns_for_epoch(current_epoch) + .sampling_columns_for_epoch(block_slot.epoch(T::EthSpec::slots_per_epoch())) .iter() .copied() .filter(|index| !custody_indexes_imported.contains(index))