Use correct slot in custody request (#9380)

Co-Authored-By: dapplion <35266934+dapplion@users.noreply.github.com>
This commit is contained in:
Lion - dapplion
2026-06-01 08:17:00 +02:00
committed by GitHub
parent 74a5609ab1
commit f0aaf65553
3 changed files with 8 additions and 22 deletions

View File

@@ -172,7 +172,7 @@ impl<T: BeaconChainTypes> RequestState<T> for CustodyRequestState<T::EthSpec> {
_: usize, _: usize,
cx: &mut SyncNetworkContext<T>, cx: &mut SyncNetworkContext<T>,
) -> Result<LookupRequestResult, LookupRequestError> { ) -> Result<LookupRequestResult, LookupRequestError> {
cx.custody_lookup_request(id, self.block_root, lookup_peers) cx.custody_lookup_request(id, self.block_root, self.slot, lookup_peers)
.map_err(LookupRequestError::SendFailedNetwork) .map_err(LookupRequestError::SendFailedNetwork)
} }

View File

@@ -239,7 +239,7 @@ impl<T: BeaconChainTypes> SingleBlockLookup<T> {
); );
} else if cx.chain.should_fetch_custody_columns(block_epoch) { } else if cx.chain.should_fetch_custody_columns(block_epoch) {
self.component_requests = ComponentRequests::ActiveCustodyRequest( self.component_requests = ComponentRequests::ActiveCustodyRequest(
CustodyRequestState::new(self.block_root), CustodyRequestState::new(self.block_root, block.slot()),
); );
} else { } else {
self.component_requests = ComponentRequests::NotNeeded("outside da window"); self.component_requests = ComponentRequests::NotNeeded("outside da window");
@@ -397,13 +397,15 @@ impl<E: EthSpec> BlobRequestState<E> {
pub struct CustodyRequestState<E: EthSpec> { pub struct CustodyRequestState<E: EthSpec> {
#[educe(Debug(ignore))] #[educe(Debug(ignore))]
pub block_root: Hash256, pub block_root: Hash256,
pub slot: Slot,
pub state: SingleLookupRequestState<DataColumnSidecarList<E>>, pub state: SingleLookupRequestState<DataColumnSidecarList<E>>,
} }
impl<E: EthSpec> CustodyRequestState<E> { impl<E: EthSpec> CustodyRequestState<E> {
pub fn new(block_root: Hash256) -> Self { pub fn new(block_root: Hash256, slot: Slot) -> Self {
Self { Self {
block_root, block_root,
slot,
state: SingleLookupRequestState::new(), state: SingleLookupRequestState::new(),
} }
} }

View File

@@ -1174,34 +1174,18 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
&mut self, &mut self,
lookup_id: SingleLookupId, lookup_id: SingleLookupId,
block_root: Hash256, block_root: Hash256,
block_slot: Slot,
lookup_peers: Arc<RwLock<HashSet<PeerId>>>, lookup_peers: Arc<RwLock<HashSet<PeerId>>>,
) -> Result<LookupRequestResult, RpcRequestSendError> { ) -> Result<LookupRequestResult, RpcRequestSendError> {
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 let custody_indexes_imported = self
.chain .chain
.cached_data_column_indexes(&block_root, slot) .cached_data_column_indexes(&block_root, block_slot)
.unwrap_or_default(); .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) // Include only the blob indexes not yet imported (received through gossip)
let mut custody_indexes_to_fetch = self let mut custody_indexes_to_fetch = self
.chain .chain
.sampling_columns_for_epoch(current_epoch) .sampling_columns_for_epoch(block_slot.epoch(T::EthSpec::slots_per_epoch()))
.iter() .iter()
.copied() .copied()
.filter(|index| !custody_indexes_imported.contains(index)) .filter(|index| !custody_indexes_imported.contains(index))