Merge remote-tracking branch 'origin/gloas-filter-conflicting-voluntairy-exits' into glamsterdam-devnet-0

This commit is contained in:
Eitan Seri-Levi
2026-04-28 10:39:26 +02:00
4 changed files with 73 additions and 22 deletions

View File

@@ -5,7 +5,10 @@ use rand::RngCore;
use serde::{Deserialize, Serialize};
use ssz::{Decode, DecodeError, Encode};
use crate::{core::Hash256, test_utils::TestRandom};
use crate::{
core::{Hash256, Hash256Ext},
test_utils::TestRandom,
};
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[derive(Default, Clone, Copy, Serialize, Deserialize, Eq, PartialEq, Hash)]
@@ -20,13 +23,7 @@ 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)..]
)
self.0.short().fmt(f)
}
}

View File

@@ -49,3 +49,29 @@ pub type Hash64 = alloy_primitives::B64;
pub type Address = alloy_primitives::Address;
pub type VersionedHash = Hash256;
pub type MerkleProof = Vec<Hash256>;
/// Extension trait for `Hash256` to allow us to implement additional methods on it.
pub trait Hash256Ext {
fn short(&self) -> ShortenedHash<'_>;
}
impl Hash256Ext for Hash256 {
fn short(&self) -> ShortenedHash<'_> {
ShortenedHash(self)
}
}
pub struct ShortenedHash<'a>(&'a Hash256);
impl<'a> std::fmt::Display for ShortenedHash<'a> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
let hash: &[u8; 32] = self.0.as_ref();
write!(
f,
// Format as hex, padded to 2 digits per byte.
// This outputs a consistent "0x1234...abcd" format.
"0x{:02x}{:02x}…{:02x}{:02x}",
hash[0], hash[1], hash[30], hash[31]
)
}
}