Skip to content

Commit 066f96a

Browse files
committed
Prevent very long log line
1 parent c5b4293 commit 066f96a

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

beacon_node/beacon_chain/src/migrate.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,10 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BackgroundMigrator<E, Ho
690690
}
691691
}
692692

693+
// Sort states to prune to make it more readable
694+
let mut states_to_prune = states_to_prune.into_iter().collect::<Vec<_>>();
695+
states_to_prune.sort_by_key(|(slot, _)| *slot);
696+
693697
debug!(
694698
log,
695699
"Extra pruning information";
@@ -702,11 +706,17 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BackgroundMigrator<E, Ho
702706
"state_summaries_dag_roots" => ?state_summaries_dag_roots,
703707
"finalized_and_descendant_state_roots_of_finalized_checkpoint" => finalized_and_descendant_state_roots_of_finalized_checkpoint.len(),
704708
"finalized_and_descendant_state_roots_of_finalized_checkpoint" => finalized_and_descendant_state_roots_of_finalized_checkpoint.len(),
705-
"blocks_to_prune_count" => blocks_to_prune.len(),
706-
"states_to_prune_count" => states_to_prune.len(),
707-
"blocks_to_prune" => ?blocks_to_prune,
708-
"states_to_prune" => ?states_to_prune,
709+
"blocks_to_prune" => blocks_to_prune.len(),
710+
"states_to_prune" => states_to_prune.len(),
709711
);
712+
// Don't log the full `states_to_prune` in the log statement above as it can result in a
713+
// single log line of +1Kb and break logging setups.
714+
for block_root in &blocks_to_prune {
715+
debug!(log, "block to prune"; "block_root" => ?block_root);
716+
}
717+
for (slot, state_root) in &states_to_prune {
718+
debug!(log, "state to prune"; "state_root" => ?state_root, "slot" => slot);
719+
}
710720

711721
let mut batch: Vec<StoreOp<E>> = blocks_to_prune
712722
.into_iter()

0 commit comments

Comments
 (0)