Ensure lookup sync checks caches correctly (#5840)

* Ensure lookup sync checks caches correctly

* fix tests and remove unused method

* Simplify BlockProcessStatus
This commit is contained in:
Lion - dapplion
2024-05-25 16:56:51 +02:00
committed by GitHub
parent f187ad8bb4
commit e4984217a6
9 changed files with 106 additions and 56 deletions

View File

@@ -44,7 +44,7 @@ use ssz_types::{FixedVector, VariableList};
use std::num::NonZeroUsize;
use std::{collections::HashSet, sync::Arc};
use types::blob_sidecar::BlobIdentifier;
use types::{BlobSidecar, ChainSpec, Epoch, EthSpec, Hash256};
use types::{BlobSidecar, ChainSpec, Epoch, EthSpec, Hash256, SignedBeaconBlock};
/// This represents the components of a partially available block
///
@@ -544,12 +544,19 @@ impl<T: BeaconChainTypes> OverflowLRUCache<T> {
}
/// Returns true if the block root is known, without altering the LRU ordering
pub fn has_execution_valid_block(&self, block_root: &Hash256) -> bool {
if let Some(pending_components) = self.critical.read().peek_pending_components(block_root) {
pending_components.executed_block.is_some()
} else {
false
}
pub fn get_execution_valid_block(
&self,
block_root: &Hash256,
) -> Option<Arc<SignedBeaconBlock<T::EthSpec>>> {
self.critical
.read()
.peek_pending_components(block_root)
.and_then(|pending_components| {
pending_components
.executed_block
.as_ref()
.map(|block| block.block_cloned())
})
}
/// Fetch a blob from the cache without affecting the LRU ordering

View File

@@ -37,6 +37,10 @@ impl<E: EthSpec> DietAvailabilityPendingExecutedBlock<E> {
&self.block
}
pub fn block_cloned(&self) -> Arc<SignedBeaconBlock<E>> {
self.block.clone()
}
pub fn num_blobs_expected(&self) -> usize {
self.block
.message()