pub struct ValidatorState {
pub pubkey: [u8; 48],
pub last_signed_block_slot: Option<u64>,
pub block_signing_roots: BTreeMap<u64, [u8; 32]>,
pub highest_source_epoch: u64,
pub highest_target_epoch: u64,
pub attestation_history: AttestationHistory,
pub chain_state: Option<ChainState>,
}Expand description
Safety state for a single validator
Supports multiple chain types (Ethereum, Cosmos) with chain-specific state. For backward compatibility, checkpoints without chain_state are assumed to be Ethereum.
Fields§
§pubkey: [u8; 48]Validator’s public key (48 bytes for BLS, 32 bytes for Ed25519) For Ethereum: 48-byte BLS public key For Cosmos: 32-byte Ed25519 public key (padded to 48 bytes for compatibility)
last_signed_block_slot: Option<u64>Highest slot for which a block was signed (Ethereum legacy)
block_signing_roots: BTreeMap<u64, [u8; 32]>Map of slot -> signing_root for block proposals (Ethereum legacy)
highest_source_epoch: u64Highest source epoch in any signed attestation (Ethereum legacy)
highest_target_epoch: u64Highest target epoch in any signed attestation (Ethereum legacy)
attestation_history: AttestationHistoryAttestation history for surround vote detection (Ethereum legacy)
chain_state: Option<ChainState>Chain-specific state (new format) If None, uses legacy Ethereum fields above
Implementations§
Source§impl ValidatorState
impl ValidatorState
Sourcepub fn new(pubkey: [u8; 48]) -> Self
pub fn new(pubkey: [u8; 48]) -> Self
Create a new Ethereum validator state with the given public key
Sourcepub fn new_ethereum(pubkey: [u8; 48]) -> Self
pub fn new_ethereum(pubkey: [u8; 48]) -> Self
Create a new Ethereum validator state (explicit)
Sourcepub fn new_cosmos(pubkey: [u8; 32]) -> Self
pub fn new_cosmos(pubkey: [u8; 32]) -> Self
Create a new Cosmos validator state
Note: Ed25519 pubkeys are 32 bytes, so they are zero-padded to 48 bytes
Sourcepub fn chain_type(&self) -> ChainType
pub fn chain_type(&self) -> ChainType
Get the chain type for this validator
Sourcepub fn ethereum_state(&self) -> Option<EthereumState>
pub fn ethereum_state(&self) -> Option<EthereumState>
Get the Ethereum state for this validator
Returns the chain_state if it’s Ethereum, otherwise uses legacy fields
Sourcepub fn cosmos_state(&self) -> Option<&CosmosState>
pub fn cosmos_state(&self) -> Option<&CosmosState>
Get the Cosmos state for this validator
Sourcepub fn cosmos_state_mut(&mut self) -> Option<&mut CosmosState>
pub fn cosmos_state_mut(&mut self) -> Option<&mut CosmosState>
Get the Cosmos state mutably
Sourcepub fn get_block_signing_root(&self, slot: u64) -> Option<&[u8; 32]>
pub fn get_block_signing_root(&self, slot: u64) -> Option<&[u8; 32]>
Get the signing root for a block at the given slot, if any
Sourcepub fn record_block_signing(&mut self, slot: u64, signing_root: [u8; 32])
pub fn record_block_signing(&mut self, slot: u64, signing_root: [u8; 32])
Record that a block was signed for the given slot
Sourcepub fn get_attestation_signing_root(
&self,
source_epoch: u64,
target_epoch: u64,
) -> Option<&[u8; 32]>
pub fn get_attestation_signing_root( &self, source_epoch: u64, target_epoch: u64, ) -> Option<&[u8; 32]>
Get the signing root for an attestation with the given source/target, if any
Trait Implementations§
Source§impl Clone for ValidatorState
impl Clone for ValidatorState
Source§fn clone(&self) -> ValidatorState
fn clone(&self) -> ValidatorState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more