Skip to main content

DiffSource

Trait DiffSource 

Source
pub trait DiffSource {
Show 23 methods // Required methods fn fork(&self) -> ForkName; fn slot(&self) -> (u64, u64); fn capella_fork_slot(&self) -> u64; fn scalar_header(&self) -> Vec<u8> ; fn balances( &self, ) -> (impl ExactSizeIterator<Item = u64>, impl ExactSizeIterator<Item = u64>); fn validators( &self, ) -> (impl ExactSizeIterator<Item = impl ValidatorSnapshot>, impl ExactSizeIterator<Item = impl ValidatorSnapshot>); fn block_roots(&self) -> &[[u8; 32]]; fn state_roots(&self) -> &[[u8; 32]]; fn randao_mixes(&self) -> &[[u8; 32]]; fn slashings(&self) -> (&[u64], &[u64]); fn eth1_data_votes(&self) -> (&[u8], &[u8]); fn historical_roots(&self) -> Option<&[u8]>; fn previous_epoch_attestations(&self) -> Option<(&[u8], &[u8])>; fn current_epoch_attestations(&self) -> Option<(&[u8], &[u8])>; fn previous_participation( &self, ) -> Option<(impl ExactSizeIterator<Item = u8>, impl ExactSizeIterator<Item = u8>)>; fn current_participation( &self, ) -> Option<(impl ExactSizeIterator<Item = u8>, impl ExactSizeIterator<Item = u8>)>; fn inactivity_scores(&self) -> Option<(&[u64], &[u64])>; fn current_sync_committee(&self) -> Option<(&[u8], &[u8])>; fn next_sync_committee(&self) -> Option<(&[u8], &[u8])>; fn historical_summaries(&self) -> Option<&[u8]>; fn pending_deposits(&self) -> Option<(&[u8], &[u8])>; fn pending_partial_withdrawals(&self) -> Option<(&[u8], &[u8])>; fn pending_consolidations(&self) -> Option<(&[u8], &[u8])>;
}
Expand description

Read-only state interface used by create.

Implement this trait to expose the base and target beacon states to the specialized delta algorithms without requiring a particular state-storage implementation.

Each accessor returns either:

  • the state component itself when it exists for the current fork, or
  • None for fork-specific fields that do not exist.

The first value returned by a pair of iterators or slices represents the base state and the second represents the target state.

§Base and target state

The implementation must ensure that all returned components refer to the same pair of states. Mixing components from different state transitions produces a delta that cannot correctly reconstruct the target.

§Slots

slot returns (base_slot, target_slot). These slots are used to reconstruct slot- and epoch-indexed circular buffers.

§Scalar header

scalar_header must contain exactly the state bytes that are not handled by the specialized delta encoders.

Fields already represented by dedicated delta fields must not also appear in the scalar header.

§Fork-specific fields

Accessors for fields introduced by later forks must return None when the source state belongs to an earlier fork.

Required Methods§

Source

fn fork(&self) -> ForkName

Source

fn slot(&self) -> (u64, u64)

Source

fn capella_fork_slot(&self) -> u64

Source

fn scalar_header(&self) -> Vec<u8>

Returns the serialized SSZ bytes for consensus state fields that are not covered by specialized diffing algorithms.

§Required SSZ Layout

To ensure deterministic reconstruction across clients, the bytes MUST be concatenated in the exact order defined by the consensus spec for the target state’s fork. The fields generally include:

  • genesis_time (8 bytes)
  • genesis_validators_root (32 bytes)
  • slot (8 bytes)
  • fork (Fork struct, variable bytes)
  • latest_block_header (BeaconBlockHeader struct)
  • eth1_data (Eth1Data struct)
  • eth1_deposit_index (8 bytes)
  • justification_bits (BitVector)
  • Checkpoints: previous_justified, current_justified, finalized
  • latest_execution_payload_header (ExecutionPayloadHeader struct)
  • Electra+ scalar fields: next_withdrawal_index, next_withdrawal_validator_index, deposit_requests_start_index, deposit_balance_to_consume, etc.

Note: Fields that have dedicated diffing algorithms (e.g., balances, historical_summaries, pending_deposits) MUST NOT be included in this blob.

Source

fn balances( &self, ) -> (impl ExactSizeIterator<Item = u64>, impl ExactSizeIterator<Item = u64>)

Source

fn validators( &self, ) -> (impl ExactSizeIterator<Item = impl ValidatorSnapshot>, impl ExactSizeIterator<Item = impl ValidatorSnapshot>)

Source

fn block_roots(&self) -> &[[u8; 32]]

Source

fn state_roots(&self) -> &[[u8; 32]]

Source

fn randao_mixes(&self) -> &[[u8; 32]]

Source

fn slashings(&self) -> (&[u64], &[u64])

Source

fn eth1_data_votes(&self) -> (&[u8], &[u8])

Source

fn historical_roots(&self) -> Option<&[u8]>

Source

fn previous_epoch_attestations(&self) -> Option<(&[u8], &[u8])>

Source

fn current_epoch_attestations(&self) -> Option<(&[u8], &[u8])>

Source

fn previous_participation( &self, ) -> Option<(impl ExactSizeIterator<Item = u8>, impl ExactSizeIterator<Item = u8>)>

Source

fn current_participation( &self, ) -> Option<(impl ExactSizeIterator<Item = u8>, impl ExactSizeIterator<Item = u8>)>

Source

fn inactivity_scores(&self) -> Option<(&[u64], &[u64])>

Source

fn current_sync_committee(&self) -> Option<(&[u8], &[u8])>

Source

fn next_sync_committee(&self) -> Option<(&[u8], &[u8])>

Source

fn historical_summaries(&self) -> Option<&[u8]>

Source

fn pending_deposits(&self) -> Option<(&[u8], &[u8])>

Source

fn pending_partial_withdrawals(&self) -> Option<(&[u8], &[u8])>

Source

fn pending_consolidations(&self) -> Option<(&[u8], &[u8])>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§