Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 1 addition & 12 deletions beacon_node/network/src/sync/range_sync/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use logging::crit;
use rand::seq::SliceRandom;
use rand::Rng;
use std::collections::{btree_map::Entry, BTreeMap, HashSet};
use std::fmt;
use strum::IntoStaticStr;
use tracing::{debug, instrument, warn};
use types::{Epoch, EthSpec, Hash256, Slot};
Expand Down Expand Up @@ -116,16 +115,6 @@ pub struct SyncingChain<T: BeaconChainTypes> {
current_processing_batch: Option<BatchId>,
}

impl<T: BeaconChainTypes> fmt::Display for SyncingChain<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.chain_type {
SyncingChainType::Head => write!(f, "Head"),
SyncingChainType::Finalized => write!(f, "Finalized"),
SyncingChainType::Backfill => write!(f, "Backfill"),
}
}
}

#[derive(PartialEq, Debug)]
pub enum ChainSyncingState {
/// The chain is not being synced.
Expand Down Expand Up @@ -177,7 +166,7 @@ impl<T: BeaconChainTypes> SyncingChain<T> {

/// Get the chain's id.
#[instrument(parent = None,level = "info", fields(chain = self.id , service = "range_sync"), skip_all)]
pub fn get_id(&self) -> ChainId {
pub fn id(&self) -> ChainId {
self.id
}

Expand Down
24 changes: 16 additions & 8 deletions beacon_node/network/src/sync/range_sync/chain_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ impl<T: BeaconChainTypes> ChainCollection<T> {
.expect("Chain exists");

match old_id {
Some(Some(old_id)) => debug!(old_id, %chain, "Switching finalized chains"),
None => debug!(%chain, "Syncing new finalized chain"),
Some(Some(old_id)) => debug!(old_id, id = chain.id(), "Switching finalized chains"),
None => debug!(id = chain.id(), "Syncing new finalized chain"),
Some(None) => {
// this is the same chain. We try to advance it.
}
Expand Down Expand Up @@ -359,7 +359,7 @@ impl<T: BeaconChainTypes> ChainCollection<T> {
if syncing_chains.len() < PARALLEL_HEAD_CHAINS {
// start this chain if it's not already syncing
if !chain.is_syncing() {
debug!(%chain, "New head chain started syncing");
debug!(id = chain.id(), "New head chain started syncing");
}
if let Err(remove_reason) =
chain.start_syncing(network, local_epoch, local_head_epoch)
Expand Down Expand Up @@ -421,7 +421,7 @@ impl<T: BeaconChainTypes> ChainCollection<T> {
if is_outdated(&chain.target_head_slot, &chain.target_head_root)
|| chain.available_peers() == 0
{
debug!(%chain, "Purging out of finalized chain");
debug!(id, "Purging out of finalized chain");
Some((*id, chain.is_syncing(), RangeSyncType::Finalized))
} else {
None
Expand All @@ -432,7 +432,7 @@ impl<T: BeaconChainTypes> ChainCollection<T> {
if is_outdated(&chain.target_head_slot, &chain.target_head_root)
|| chain.available_peers() == 0
{
debug!(%chain, "Purging out of date head chain");
debug!(id, "Purging out of date head chain");
Some((*id, chain.is_syncing(), RangeSyncType::Head))
} else {
None
Expand Down Expand Up @@ -478,9 +478,9 @@ impl<T: BeaconChainTypes> ChainCollection<T> {
debug_assert_eq!(chain.target_head_slot, target_head_slot);
if let Err(remove_reason) = chain.add_peer(network, peer) {
if remove_reason.is_critical() {
crit!(chain = %id, reason = ?remove_reason, "Chain removed after adding peer");
crit!(id, reason = ?remove_reason, "Chain removed after adding peer");
} else {
error!(chain = %id, reason = ?remove_reason, "Chain removed after adding peer");
error!(id, reason = ?remove_reason, "Chain removed after adding peer");
}
let is_syncing = chain.is_syncing();
collection.remove(&id);
Expand All @@ -499,7 +499,15 @@ impl<T: BeaconChainTypes> ChainCollection<T> {
sync_type.into(),
);

debug!(peer_id = peer_rpr, ?sync_type, %new_chain, "New chain added to sync");
debug!(
peer_id = peer_rpr,
?sync_type,
id,
%start_epoch,
%target_head_slot,
?target_head_root,
"New chain added to sync"
);
collection.insert(id, new_chain);
metrics::inc_counter_vec(&metrics::SYNCING_CHAINS_ADDED, &[sync_type.as_str()]);
self.update_metrics();
Expand Down
6 changes: 3 additions & 3 deletions beacon_node/network/src/sync/range_sync/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,15 +386,15 @@ where
op: &'static str,
) {
if remove_reason.is_critical() {
crit!(?sync_type, %chain, reason = ?remove_reason,op, "Chain removed");
crit!(id = chain.id(), ?sync_type, reason = ?remove_reason, op, "Chain removed");
} else {
debug!(?sync_type, %chain, reason = ?remove_reason,op, "Chain removed");
debug!(id = chain.id(), ?sync_type, reason = ?remove_reason, op, "Chain removed");
}

if let RemoveChain::ChainFailed { blacklist, .. } = remove_reason {
if RangeSyncType::Finalized == sync_type && blacklist {
warn!(
%chain,
id = chain.id(),
"Chain failed! Syncing to its head won't be retried for at least the next {} seconds",
FAILED_CHAINS_EXPIRY_SECONDS
);
Expand Down
Loading