From 230e9a8582b3464b40774f5938d7d6cc3a531b88 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Tue, 19 Mar 2024 13:41:11 +0200 Subject: [PATCH] add network globals to da checker --- .../beacon_chain/src/data_availability_checker.rs | 10 +++++++++- beacon_node/tests/test.rs | 10 ++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/beacon_node/beacon_chain/src/data_availability_checker.rs b/beacon_node/beacon_chain/src/data_availability_checker.rs index a6439c06858..ed3115c9043 100644 --- a/beacon_node/beacon_chain/src/data_availability_checker.rs +++ b/beacon_node/beacon_chain/src/data_availability_checker.rs @@ -10,7 +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 lighthouse_network::{Enr, NetworkGlobals}; use parking_lot::RwLock; pub use processing_cache::ProcessingComponents; use slasher::test_utils::E; @@ -113,6 +113,14 @@ impl DataAvailabilityChecker { let _ = self.network_globals.write().insert(network_globals); } + pub fn get_local_enr(&self) -> Option { + if let Some(network_globals) = self.network_globals.read().as_ref().or(None) { + return Some(network_globals.local_enr()); + } + + None + } + /// Get the processing info for a block. pub fn get_processing_components( &self, diff --git a/beacon_node/tests/test.rs b/beacon_node/tests/test.rs index bbec70330b7..aa547ad5952 100644 --- a/beacon_node/tests/test.rs +++ b/beacon_node/tests/test.rs @@ -37,6 +37,16 @@ fn http_server_genesis_state() { let node = build_node(&mut env); + let beacon_chain = node + .client + .beacon_chain() + .expect("client should have beacon chain"); + + beacon_chain + .data_availability_checker + .get_local_enr() + .expect("da checker should have access to network globals"); + let remote_node = node.remote_node().expect("should produce remote node"); let api_state = env