mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-30 20:57:10 +00:00
use slot so we dont hit the cache twice
This commit is contained in:
@@ -1208,6 +1208,24 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn cached_data_column_indexes(
|
||||||
|
&self,
|
||||||
|
block_root: &Hash256,
|
||||||
|
slot: Slot,
|
||||||
|
) -> Option<Vec<ColumnIndex>> {
|
||||||
|
if self
|
||||||
|
.spec
|
||||||
|
.fork_name_at_slot::<T::EthSpec>(slot)
|
||||||
|
.gloas_enabled()
|
||||||
|
{
|
||||||
|
self.pending_payload_cache
|
||||||
|
.cached_data_column_indexes(block_root)
|
||||||
|
} else {
|
||||||
|
self.data_availability_checker
|
||||||
|
.cached_data_column_indexes(block_root)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the block at the given root, if any.
|
/// Returns the block at the given root, if any.
|
||||||
///
|
///
|
||||||
/// ## Errors
|
/// ## Errors
|
||||||
@@ -3561,17 +3579,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
if let Some(event_handler) = self.event_handler.as_ref()
|
if let Some(event_handler) = self.event_handler.as_ref()
|
||||||
&& event_handler.has_data_column_sidecar_subscribers()
|
&& event_handler.has_data_column_sidecar_subscribers()
|
||||||
{
|
{
|
||||||
let imported_data_columns = if self
|
let imported_data_columns = self
|
||||||
.spec
|
.cached_data_column_indexes(block_root, slot)
|
||||||
.fork_name_at_slot::<T::EthSpec>(slot)
|
|
||||||
.gloas_enabled()
|
|
||||||
{
|
|
||||||
self.pending_payload_cache
|
|
||||||
.cached_data_column_indexes(block_root)
|
|
||||||
} else {
|
|
||||||
self.data_availability_checker
|
|
||||||
.cached_data_column_indexes(block_root)
|
|
||||||
}
|
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let new_data_columns =
|
let new_data_columns =
|
||||||
data_columns_iter.filter(|b| !imported_data_columns.contains(b.index()));
|
data_columns_iter.filter(|b| !imported_data_columns.contains(b.index()));
|
||||||
|
|||||||
@@ -119,15 +119,12 @@ impl<T: BeaconChainTypes> FetchBlobsBeaconAdapter<T> {
|
|||||||
.cached_blob_indexes(block_root)
|
.cached_blob_indexes(block_root)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn cached_data_column_indexes(&self, block_root: &Hash256) -> Option<Vec<u64>> {
|
pub(crate) fn cached_data_column_indexes(
|
||||||
self.chain
|
&self,
|
||||||
.data_availability_checker
|
block_root: &Hash256,
|
||||||
.cached_data_column_indexes(block_root)
|
slot: Slot,
|
||||||
.or_else(|| {
|
) -> Option<Vec<u64>> {
|
||||||
self.chain
|
self.chain.cached_data_column_indexes(block_root, slot)
|
||||||
.pending_payload_cache
|
|
||||||
.cached_data_column_indexes(block_root)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn process_engine_blobs(
|
pub(crate) async fn process_engine_blobs(
|
||||||
|
|||||||
@@ -445,7 +445,7 @@ async fn compute_custody_columns_to_import<T: BeaconChainTypes>(
|
|||||||
|
|
||||||
// Only consider columns that are not already known to data availability.
|
// Only consider columns that are not already known to data availability.
|
||||||
if let Some(known_columns) =
|
if let Some(known_columns) =
|
||||||
chain_adapter_cloned.cached_data_column_indexes(&block_root)
|
chain_adapter_cloned.cached_data_column_indexes(&block_root, header.slot())
|
||||||
{
|
{
|
||||||
custody_columns.retain(|col| !known_columns.contains(&col.index()));
|
custody_columns.retain(|col| !known_columns.contains(&col.index()));
|
||||||
if custody_columns.is_empty() {
|
if custody_columns.is_empty() {
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ mod get_blobs_v2 {
|
|||||||
.returning(|_| None);
|
.returning(|_| None);
|
||||||
mock_adapter
|
mock_adapter
|
||||||
.expect_cached_data_column_indexes()
|
.expect_cached_data_column_indexes()
|
||||||
.returning(|_| None);
|
.returning(|_, _| None);
|
||||||
mock_process_engine_blobs_result(
|
mock_process_engine_blobs_result(
|
||||||
&mut mock_adapter,
|
&mut mock_adapter,
|
||||||
Ok(AvailabilityProcessingStatus::Imported(block_root)),
|
Ok(AvailabilityProcessingStatus::Imported(block_root)),
|
||||||
|
|||||||
@@ -1085,15 +1085,17 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
|
|||||||
block_root: Hash256,
|
block_root: Hash256,
|
||||||
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)
|
||||||
|
.unwrap_or_else(|| self.chain.slot().unwrap_or_default());
|
||||||
|
|
||||||
let custody_indexes_imported = self
|
let custody_indexes_imported = self
|
||||||
.chain
|
.chain
|
||||||
.data_availability_checker
|
.cached_data_column_indexes(&block_root, slot)
|
||||||
.cached_data_column_indexes(&block_root)
|
|
||||||
.or_else(|| {
|
|
||||||
self.chain
|
|
||||||
.pending_payload_cache
|
|
||||||
.cached_data_column_indexes(&block_root)
|
|
||||||
})
|
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
let current_epoch = self.chain.epoch().map_err(|e| {
|
let current_epoch = self.chain.epoch().map_err(|e| {
|
||||||
|
|||||||
Reference in New Issue
Block a user