Truncated Display impl for ExecutionBlockHash (#9108)

- #6689


  The intention is to only modify the INFO logs that's emitted regularly to reduce the verbosity. But I understand that this change will affect other display in the logs too that uses the `ExecutionBlockHash` display. So would love some feedbacks about the change.


Co-Authored-By: Tan Chee Keong <tanck@sigmaprime.io>

Co-Authored-By: Mac L <mjladson@pm.me>
This commit is contained in:
chonghe
2026-04-09 20:00:53 +08:00
committed by GitHub
parent 7c2dcfc0d6
commit c615210fef
2 changed files with 13 additions and 7 deletions

View File

@@ -374,7 +374,7 @@ pub fn spawn_notifier<T: BeaconChainTypes>(
warn!( warn!(
info = "chain not fully verified, \ info = "chain not fully verified, \
block and attestation production disabled until execution engine syncs", block and attestation production disabled until execution engine syncs",
execution_block_hash = ?hash, execution_block_hash = ?hash,
"Head is optimistic" "Head is optimistic"
); );
format!("{} (unverified)", hash) format!("{} (unverified)", hash)

View File

@@ -18,6 +18,18 @@ impl fmt::Debug for ExecutionBlockHash {
} }
} }
impl fmt::Display for ExecutionBlockHash {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let hash = format!("{}", self.0);
write!(
f,
"{}…{}",
&hash[..6],
&hash[hash.len().saturating_sub(4)..]
)
}
}
impl ExecutionBlockHash { impl ExecutionBlockHash {
pub fn zero() -> Self { pub fn zero() -> Self {
Self(Hash256::zero()) Self(Hash256::zero())
@@ -102,12 +114,6 @@ impl std::str::FromStr for ExecutionBlockHash {
} }
} }
impl fmt::Display for ExecutionBlockHash {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.0)
}
}
impl From<Hash256> for ExecutionBlockHash { impl From<Hash256> for ExecutionBlockHash {
fn from(hash: Hash256) -> Self { fn from(hash: Hash256) -> Self {
Self(hash) Self(hash)