Skip to content

Commit 0f2bdf8

Browse files
authored
Merge of #7359
2 parents 93ec9df + e997a1e commit 0f2bdf8

File tree

3 files changed

+20
-23
lines changed

3 files changed

+20
-23
lines changed

beacon_node/network/src/sync/range_sync/chain.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use logging::crit;
1313
use rand::seq::SliceRandom;
1414
use rand::Rng;
1515
use std::collections::{btree_map::Entry, BTreeMap, HashSet};
16-
use std::fmt;
1716
use strum::IntoStaticStr;
1817
use tracing::{debug, instrument, warn};
1918
use types::{Epoch, EthSpec, Hash256, Slot};
@@ -116,16 +115,6 @@ pub struct SyncingChain<T: BeaconChainTypes> {
116115
current_processing_batch: Option<BatchId>,
117116
}
118117

119-
impl<T: BeaconChainTypes> fmt::Display for SyncingChain<T> {
120-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
121-
match self.chain_type {
122-
SyncingChainType::Head => write!(f, "Head"),
123-
SyncingChainType::Finalized => write!(f, "Finalized"),
124-
SyncingChainType::Backfill => write!(f, "Backfill"),
125-
}
126-
}
127-
}
128-
129118
#[derive(PartialEq, Debug)]
130119
pub enum ChainSyncingState {
131120
/// The chain is not being synced.
@@ -177,7 +166,7 @@ impl<T: BeaconChainTypes> SyncingChain<T> {
177166

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

beacon_node/network/src/sync/range_sync/chain_collection.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,8 @@ impl<T: BeaconChainTypes> ChainCollection<T> {
293293
.expect("Chain exists");
294294

295295
match old_id {
296-
Some(Some(old_id)) => debug!(old_id, %chain, "Switching finalized chains"),
297-
None => debug!(%chain, "Syncing new finalized chain"),
296+
Some(Some(old_id)) => debug!(old_id, id = chain.id(), "Switching finalized chains"),
297+
None => debug!(id = chain.id(), "Syncing new finalized chain"),
298298
Some(None) => {
299299
// this is the same chain. We try to advance it.
300300
}
@@ -359,7 +359,7 @@ impl<T: BeaconChainTypes> ChainCollection<T> {
359359
if syncing_chains.len() < PARALLEL_HEAD_CHAINS {
360360
// start this chain if it's not already syncing
361361
if !chain.is_syncing() {
362-
debug!(%chain, "New head chain started syncing");
362+
debug!(id = chain.id(), "New head chain started syncing");
363363
}
364364
if let Err(remove_reason) =
365365
chain.start_syncing(network, local_epoch, local_head_epoch)
@@ -421,7 +421,7 @@ impl<T: BeaconChainTypes> ChainCollection<T> {
421421
if is_outdated(&chain.target_head_slot, &chain.target_head_root)
422422
|| chain.available_peers() == 0
423423
{
424-
debug!(%chain, "Purging out of finalized chain");
424+
debug!(id, "Purging out of finalized chain");
425425
Some((*id, chain.is_syncing(), RangeSyncType::Finalized))
426426
} else {
427427
None
@@ -432,7 +432,7 @@ impl<T: BeaconChainTypes> ChainCollection<T> {
432432
if is_outdated(&chain.target_head_slot, &chain.target_head_root)
433433
|| chain.available_peers() == 0
434434
{
435-
debug!(%chain, "Purging out of date head chain");
435+
debug!(id, "Purging out of date head chain");
436436
Some((*id, chain.is_syncing(), RangeSyncType::Head))
437437
} else {
438438
None
@@ -478,9 +478,9 @@ impl<T: BeaconChainTypes> ChainCollection<T> {
478478
debug_assert_eq!(chain.target_head_slot, target_head_slot);
479479
if let Err(remove_reason) = chain.add_peer(network, peer) {
480480
if remove_reason.is_critical() {
481-
crit!(chain = %id, reason = ?remove_reason, "Chain removed after adding peer");
481+
crit!(id, reason = ?remove_reason, "Chain removed after adding peer");
482482
} else {
483-
error!(chain = %id, reason = ?remove_reason, "Chain removed after adding peer");
483+
error!(id, reason = ?remove_reason, "Chain removed after adding peer");
484484
}
485485
let is_syncing = chain.is_syncing();
486486
collection.remove(&id);
@@ -499,7 +499,15 @@ impl<T: BeaconChainTypes> ChainCollection<T> {
499499
sync_type.into(),
500500
);
501501

502-
debug!(peer_id = peer_rpr, ?sync_type, %new_chain, "New chain added to sync");
502+
debug!(
503+
peer_id = peer_rpr,
504+
?sync_type,
505+
id,
506+
%start_epoch,
507+
%target_head_slot,
508+
?target_head_root,
509+
"New chain added to sync"
510+
);
503511
collection.insert(id, new_chain);
504512
metrics::inc_counter_vec(&metrics::SYNCING_CHAINS_ADDED, &[sync_type.as_str()]);
505513
self.update_metrics();

beacon_node/network/src/sync/range_sync/range.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,15 +386,15 @@ where
386386
op: &'static str,
387387
) {
388388
if remove_reason.is_critical() {
389-
crit!(?sync_type, %chain, reason = ?remove_reason,op, "Chain removed");
389+
crit!(id = chain.id(), ?sync_type, reason = ?remove_reason, op, "Chain removed");
390390
} else {
391-
debug!(?sync_type, %chain, reason = ?remove_reason,op, "Chain removed");
391+
debug!(id = chain.id(), ?sync_type, reason = ?remove_reason, op, "Chain removed");
392392
}
393393

394394
if let RemoveChain::ChainFailed { blacklist, .. } = remove_reason {
395395
if RangeSyncType::Finalized == sync_type && blacklist {
396396
warn!(
397-
%chain,
397+
id = chain.id(),
398398
"Chain failed! Syncing to its head won't be retried for at least the next {} seconds",
399399
FAILED_CHAINS_EXPIRY_SECONDS
400400
);

0 commit comments

Comments
 (0)