Add method to Hash256 to display shortened hashes (#9118)

#6689


  Inspired by the initial implementation of #9108, credit to @chong-he.
This adds an extension trait to `Hash256` and add a `short` method to provide smaller formatted hashes for logging.


Co-Authored-By: Mac L <mjladson@pm.me>
This commit is contained in:
Mac L
2026-04-28 11:01:13 +04:00
committed by GitHub
parent 028b5a42a9
commit 949c027dfd
3 changed files with 34 additions and 11 deletions

View File

@@ -360,7 +360,7 @@ pub fn spawn_notifier<T: BeaconChainTypes>(
let block_info = if current_slot > head_slot {
" … empty".to_string()
} else {
head_root.to_string()
head_root.short().to_string()
};
let block_hash = match beacon_chain.canonical_head.head_execution_status() {
@@ -393,7 +393,7 @@ pub fn spawn_notifier<T: BeaconChainTypes>(
info!(
peers = peer_count_pretty(connected_peer_count),
exec_hash = block_hash,
finalized_root = %finalized_checkpoint.root,
finalized_root = %finalized_checkpoint.root.short(),
finalized_epoch = %finalized_checkpoint.epoch,
epoch = %current_epoch,
block = block_info,
@@ -404,7 +404,7 @@ pub fn spawn_notifier<T: BeaconChainTypes>(
metrics::set_gauge(&metrics::IS_SYNCED, 0);
info!(
peers = peer_count_pretty(connected_peer_count),
finalized_root = %finalized_checkpoint.root,
finalized_root = %finalized_checkpoint.root.short(),
finalized_epoch = %finalized_checkpoint.epoch,
%head_slot,
%current_slot,