diff --git a/beacon_node/network/src/subnet_service/sync_subnets.rs b/beacon_node/network/src/subnet_service/sync_subnets.rs index 1bb57221d26..af9136030b2 100644 --- a/beacon_node/network/src/subnet_service/sync_subnets.rs +++ b/beacon_node/network/src/subnet_service/sync_subnets.rs @@ -218,6 +218,7 @@ impl SyncCommitteeService { .collect(); if !discovery_subnets.is_empty() { + trace!(self.log, "Making a discovery query"); self.events .push_back(SubnetServiceMessage::DiscoverPeers(discovery_subnets)); } @@ -252,6 +253,7 @@ impl SyncCommitteeService { let slots_per_epoch = T::EthSpec::slots_per_epoch(); let until_slot = exact_subnet.until_epoch.end_slot(slots_per_epoch); + dbg!(&until_slot); // Calculate the duration to the unsubscription event. let expected_end_subscription_duration = if current_slot >= until_slot { warn!( diff --git a/beacon_node/network/src/subnet_service/tests/mod.rs b/beacon_node/network/src/subnet_service/tests/mod.rs index 23a6827b761..eb44176562c 100644 --- a/beacon_node/network/src/subnet_service/tests/mod.rs +++ b/beacon_node/network/src/subnet_service/tests/mod.rs @@ -10,7 +10,7 @@ use genesis::{generate_deterministic_keypairs, interop_genesis_state}; use lazy_static::lazy_static; use matches::assert_matches; use slog::Logger; -use sloggers::{null::NullLoggerBuilder, Build}; +use slog::{o, Drain}; use slot_clock::{SlotClock, SystemTimeSlotClock}; use std::sync::Arc; use std::time::{Duration, SystemTime}; @@ -41,7 +41,7 @@ impl TestBeaconChain { let keypairs = generate_deterministic_keypairs(1); - let log = get_logger(); + let log = get_logger(false); let store = HotColdDB::open_ephemeral(StoreConfig::default(), spec.clone(), log.clone()).unwrap(); @@ -80,8 +80,17 @@ pub fn recent_genesis_time() -> u64 { .as_secs() } -fn get_logger() -> Logger { - NullLoggerBuilder.build().expect("logger should build") +fn get_logger(enabled: bool) -> Logger { + let level = slog::Level::Trace; + let decorator = slog_term::TermDecorator::new().build(); + let drain = slog_term::FullFormat::new(decorator).build().fuse(); + let drain = slog_async::Async::new(drain).build().fuse(); + + if enabled { + slog::Logger::root(drain.filter_level(level).fuse(), o!()) + } else { + slog::Logger::root(drain.filter(|_| false).fuse(), o!()) + } } lazy_static! { @@ -89,7 +98,7 @@ lazy_static! { } fn get_attestation_service() -> AttestationService { - let log = get_logger(); + let log = get_logger(false); let config = NetworkConfig::default(); let beacon_chain = CHAIN.chain.clone(); @@ -98,7 +107,7 @@ fn get_attestation_service() -> AttestationService { } fn get_sync_committee_service() -> SyncCommitteeService { - let log = get_logger(); + let log = get_logger(true); let config = NetworkConfig::default(); let beacon_chain = CHAIN.chain.clone(); @@ -456,7 +465,7 @@ mod sync_committee_service { async fn subscribe_and_unsubscribe() { // subscription config let validator_index = 1; - let until_epoch = Epoch::new(0); + let until_epoch = Epoch::new(1); let sync_committee_indices = vec![1]; // create the attestation service and subscriptions @@ -480,10 +489,11 @@ mod sync_committee_service { let subnet_id = subnet_ids.iter().next().unwrap(); // Note: the unsubscription event takes a full epoch (8 * 0.2 secs = 1.6 secs) + dbg!(MinimalEthSpec::slots_per_epoch()); let events = get_events( &mut sync_committee_service, Some(5), - MinimalEthSpec::slots_per_epoch() as u32, + (MinimalEthSpec::slots_per_epoch() * 2) as u32, ) .await; assert_eq!(