Skip to content

Commit

Permalink
add network globals field to da checker
Browse files Browse the repository at this point in the history
  • Loading branch information
eserilev committed Mar 19, 2024
1 parent 1317f70 commit 63548b9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions beacon_node/beacon_chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ hex = { workspace = true }
oneshot_broadcast = { path = "../../common/oneshot_broadcast/" }
slog-term = { workspace = true }
slog-async = { workspace = true }
lighthouse_network = { workspace = true }

[[test]]
name = "beacon_chain_tests"
Expand Down
7 changes: 7 additions & 0 deletions beacon_node/beacon_chain/src/data_availability_checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::data_availability_checker::overflow_lru_cache::OverflowLRUCache;
use crate::data_availability_checker::processing_cache::ProcessingCache;
use crate::{BeaconChain, BeaconChainTypes, BeaconStore};
use kzg::Kzg;
use lighthouse_network::NetworkGlobals;
use parking_lot::RwLock;
pub use processing_cache::ProcessingComponents;
use slasher::test_utils::E;
Expand Down Expand Up @@ -55,6 +56,7 @@ pub const STATE_LRU_CAPACITY: usize = STATE_LRU_CAPACITY_NON_ZERO.get();
pub struct DataAvailabilityChecker<T: BeaconChainTypes> {
processing_cache: RwLock<ProcessingCache<T::EthSpec>>,
availability_cache: Arc<OverflowLRUCache<T>>,
network_globals: RwLock<Option<Arc<NetworkGlobals<T::EthSpec>>>>,
slot_clock: T::SlotClock,
kzg: Option<Arc<Kzg>>,
log: Logger,
Expand Down Expand Up @@ -94,6 +96,7 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
Ok(Self {
processing_cache: <_>::default(),
availability_cache: Arc::new(overflow_cache),
network_globals: <_>::default(),
slot_clock,
log: log.clone(),
kzg,
Expand All @@ -106,6 +109,10 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
self.processing_cache.read().has_block(block_root)
}

pub fn set_network_globals(&self, network_globals: Arc<NetworkGlobals<T::EthSpec>>) {
let _ = self.network_globals.write().insert(network_globals);
}

/// Get the processing info for a block.
pub fn get_processing_components(
&self,
Expand Down
7 changes: 5 additions & 2 deletions beacon_node/client/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ where
};

let (network_globals, network_senders) = NetworkService::start(
beacon_chain,
beacon_chain.clone(),
config,
context.executor,
libp2p_registry.as_mut(),
Expand All @@ -652,9 +652,12 @@ where
.await
.map_err(|e| format!("Failed to start network: {:?}", e))?;

self.network_globals = Some(network_globals);
self.network_globals = Some(network_globals.clone());
self.network_senders = Some(network_senders);
self.libp2p_registry = libp2p_registry;
beacon_chain
.data_availability_checker
.set_network_globals(network_globals);

Ok(self)
}
Expand Down

0 comments on commit 63548b9

Please sign in to comment.