Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions beacon_node/network/src/sync/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,16 @@ impl<T: BeaconChainTypes> SyncManager<T> {
self.range_sync.state()
}

#[cfg(test)]
pub(crate) fn range_sync_state(&self) -> super::range_sync::SyncChainStatus {
self.range_sync.state()
}

#[cfg(test)]
pub(crate) fn __range_failed_chains(&mut self) -> Vec<Hash256> {
self.range_sync.__failed_chains()
}

#[cfg(test)]
pub(crate) fn get_failed_chains(&mut self) -> Vec<Hash256> {
self.block_lookups.get_failed_chains()
Expand All @@ -369,13 +379,13 @@ impl<T: BeaconChainTypes> SyncManager<T> {
}

#[cfg(test)]
pub(crate) fn range_sync_state(&self) -> super::range_sync::SyncChainStatus {
self.range_sync.state()
pub(crate) fn update_execution_engine_state(&mut self, state: EngineState) {
self.handle_new_execution_engine_state(state);
}

#[cfg(test)]
pub(crate) fn update_execution_engine_state(&mut self, state: EngineState) {
self.handle_new_execution_engine_state(state);
pub fn resolve_range_block_components_requests(&self, id: Id) -> Option<RangeRequestId> {
self.network.resolve_range_block_components_requests(id)
}

fn network_globals(&self) -> &NetworkGlobals<T::EthSpec> {
Expand Down
7 changes: 7 additions & 0 deletions beacon_node/network/src/sync/network_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,13 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
}
}

#[cfg(test)]
pub fn resolve_range_block_components_requests(&self, id: Id) -> Option<RangeRequestId> {
self.range_block_components_requests
.get(&id)
.map(|req| req.0)
}

pub fn send_sync_message(&mut self, sync_message: SyncMessage<T::EthSpec>) {
self.network_beacon_processor
.send_sync_message(sync_message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ impl<T: BeaconChainTypes> ChainCollection<T> {
.find(|(_, chain)| chain.has_same_target(target_head_slot, target_head_root))
{
Some((&id, chain)) => {
debug!(self.log, "Adding peer to known chain"; "peer_id" => %peer, "sync_type" => ?sync_type, &chain);
debug!(self.log, "Adding peer to known chain"; "peer_id" => %peer, "sync_type" => ?sync_type, "id" => id);
debug_assert_eq!(chain.target_head_root, target_head_root);
debug_assert_eq!(chain.target_head_slot, target_head_slot);
if let Err(remove_reason) = chain.add_peer(network, peer) {
Expand Down
5 changes: 5 additions & 0 deletions beacon_node/network/src/sync/range_sync/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ where
}
}

#[cfg(test)]
pub(crate) fn __failed_chains(&mut self) -> Vec<Hash256> {
self.failed_chains.keys().copied().collect()
}

pub fn state(&self) -> SyncChainStatus {
self.chains.state()
}
Expand Down
12 changes: 5 additions & 7 deletions beacon_node/network/src/sync/tests/lookups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,16 @@ use lighthouse_network::{
use slog::info;
use slot_clock::{SlotClock, TestingSlotClock};
use tokio::sync::mpsc;
use types::ForkContext;
use types::{
data_column_sidecar::ColumnIndex,
test_utils::{SeedableRng, TestRandom, XorShiftRng},
BeaconState, BeaconStateBase, BlobSidecar, DataColumnSidecar, EthSpec, ForkName, Hash256,
MinimalEthSpec as E, SignedBeaconBlock, Slot,
BeaconState, BeaconStateBase, BlobSidecar, DataColumnSidecar, EthSpec, ForkContext, ForkName,
Hash256, MinimalEthSpec as E, SignedBeaconBlock, Slot,
};

const D: Duration = Duration::new(0, 0);
const PARENT_FAIL_TOLERANCE: u8 = SINGLE_BLOCK_LOOKUP_MAX_ATTEMPTS;
const SAMPLING_REQUIRED_SUCCESSES: usize = 2;

type DCByRootIds = Vec<DCByRootId>;
type DCByRootId = (SyncRequestId, Vec<ColumnIndex>);

Expand Down Expand Up @@ -154,7 +152,7 @@ impl TestRig {
}
}

fn test_setup_after_fulu() -> Option<Self> {
pub fn test_setup_after_fulu() -> Option<Self> {
let r = Self::test_setup();
if r.fork_name.fulu_enabled() {
Some(r)
Expand Down Expand Up @@ -382,7 +380,7 @@ impl TestRig {
.__add_connected_peer_testing_only(true, &self.harness.spec)
}

fn new_connected_peers_for_peerdas(&mut self) {
pub fn new_connected_peers_for_peerdas(&mut self) {
// Enough sampling peers with few columns
for _ in 0..100 {
self.new_connected_peer();
Expand Down Expand Up @@ -1113,7 +1111,7 @@ impl TestRig {
}

#[track_caller]
fn expect_empty_network(&mut self) {
pub fn expect_empty_network(&mut self) {
self.drain_network_rx();
if !self.network_rx_queue.is_empty() {
let n = self.network_rx_queue.len();
Expand Down
Loading