Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 30 additions & 21 deletions crates/common/types/src/beacon/containers/altair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,19 @@ pub type SyncSubcommitteeBits =
/// needs one regardless of how many attestations or other operations it
/// includes.
#[derive(
Debug, Clone, Default, PartialEq, Eq, serde::Serialize, SszEncode, SszDecode, HashTreeRoot,
Debug,
Clone,
Default,
PartialEq,
Eq,
serde::Serialize,
serde::Deserialize,
SszEncode,
SszDecode,
HashTreeRoot,
)]
pub struct SyncAggregate {
#[serde(serialize_with = "crate::beacon::serde_helpers::ssz_hex::serialize")]
#[serde(with = "crate::beacon::serde_helpers::ssz_hex")]
pub sync_committee_bits: SyncCommitteeBits,
/// The aggregate of every signature from a member set in
/// `sync_committee_bits`, over the previous slot's block root.
Expand All @@ -85,7 +94,7 @@ pub struct SyncAggregate {
/// participates.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, SszEncode, SszDecode, HashTreeRoot)]
pub struct SyncCommittee {
#[serde(serialize_with = "crate::beacon::serde_helpers::seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::seq")]
pub pubkeys: SyncCommitteePubkeys,
/// The aggregate of every key in `pubkeys`, so `process_sync_aggregate` does
/// not have to re-aggregate from scratch when the whole committee signs.
Expand All @@ -109,15 +118,15 @@ pub struct BeaconBlockBody {
pub eth1_data: Eth1Data,
/// Arbitrary proposer-chosen bytes, which consensus never reads.
pub graffiti: Bytes32,
#[serde(serialize_with = "crate::beacon::serde_helpers::seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::seq")]
pub proposer_slashings: SszList<ProposerSlashing, { preset::MAX_PROPOSER_SLASHINGS }>,
#[serde(serialize_with = "crate::beacon::serde_helpers::seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::seq")]
pub attester_slashings: SszList<AttesterSlashing, { preset::MAX_ATTESTER_SLASHINGS }>,
#[serde(serialize_with = "crate::beacon::serde_helpers::seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::seq")]
pub attestations: SszList<Attestation, { preset::MAX_ATTESTATIONS }>,
#[serde(serialize_with = "crate::beacon::serde_helpers::seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::seq")]
pub deposits: SszList<Deposit, { preset::MAX_DEPOSITS }>,
#[serde(serialize_with = "crate::beacon::serde_helpers::seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::seq")]
pub voluntary_exits: SszList<SignedVoluntaryExit, { preset::MAX_VOLUNTARY_EXITS }>,
/// The aggregated sync committee signature over the previous slot's block
/// root, plus which members contributed. This is what lets a light client
Expand Down Expand Up @@ -180,34 +189,34 @@ pub struct BeaconState {
/// slot advances, since a block cannot commit to the root of the state
/// containing it.
pub latest_block_header: BeaconBlockHeader,
#[serde(serialize_with = "crate::beacon::serde_helpers::seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::seq")]
pub block_roots: BlockRoots,
#[serde(serialize_with = "crate::beacon::serde_helpers::seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::seq")]
pub state_roots: StateRoots,
#[serde(serialize_with = "crate::beacon::serde_helpers::seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::seq")]
pub historical_roots: HistoricalRoots,

// -- Eth1 --
pub eth1_data: Eth1Data,
#[serde(serialize_with = "crate::beacon::serde_helpers::seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::seq")]
pub eth1_data_votes: Eth1DataVotes,
/// How many deposits from the contract have been processed, which is where
/// the next one will be read from.
#[serde(with = "crate::beacon::serde_helpers::quoted_or_bare")]
pub eth1_deposit_index: u64,

// -- Registry --
#[serde(serialize_with = "crate::beacon::serde_helpers::seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::seq")]
pub validators: Validators,
#[serde(serialize_with = "crate::beacon::serde_helpers::quoted_u64_seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::quoted_u64_seq")]
pub balances: Balances,

// -- Randomness --
#[serde(serialize_with = "crate::beacon::serde_helpers::seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::seq")]
pub randao_mixes: RandaoMixes,

// -- Slashings --
#[serde(serialize_with = "crate::beacon::serde_helpers::quoted_u64_seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::quoted_u64_seq")]
pub slashings: Slashings,

// -- Participation --
Expand All @@ -217,15 +226,15 @@ pub struct BeaconState {
/// it is processed instead of deferring to the epoch boundary, so there is
/// no longer a backlog of whole attestations to keep around, only a flag
/// per validator per epoch.
#[serde(serialize_with = "crate::beacon::serde_helpers::quoted_u64_seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::quoted_u64_seq")]
pub previous_epoch_participation: EpochParticipation,
/// Flags for the current epoch, which become `previous_epoch_participation`
/// at the next epoch boundary.
#[serde(serialize_with = "crate::beacon::serde_helpers::quoted_u64_seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::quoted_u64_seq")]
pub current_epoch_participation: EpochParticipation,

// -- Finality --
#[serde(serialize_with = "crate::beacon::serde_helpers::ssz_hex::serialize")]
#[serde(with = "crate::beacon::serde_helpers::ssz_hex")]
pub justification_bits: JustificationBits,
pub previous_justified_checkpoint: Checkpoint,
pub current_justified_checkpoint: Checkpoint,
Expand All @@ -237,7 +246,7 @@ pub struct BeaconState {
/// non-finalizing epoch and falls otherwise, which is what lets the
/// inactivity leak single out validators who are actually offline rather
/// than penalizing everyone during a stall.
#[serde(serialize_with = "crate::beacon::serde_helpers::quoted_u64_seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::quoted_u64_seq")]
pub inactivity_scores: InactivityScores,

// -- Sync committees --
Expand Down Expand Up @@ -289,7 +298,7 @@ pub struct SyncCommitteeContribution {
pub beacon_block_root: Root,
#[serde(with = "crate::beacon::serde_helpers::quoted_or_bare")]
pub subcommittee_index: u64,
#[serde(serialize_with = "crate::beacon::serde_helpers::ssz_hex::serialize")]
#[serde(with = "crate::beacon::serde_helpers::ssz_hex")]
pub aggregation_bits: SyncSubcommitteeBits,
/// The aggregate signature of every member set in `aggregation_bits`, over
/// `beacon_block_root`.
Expand Down
44 changes: 22 additions & 22 deletions crates/common/types/src/beacon/containers/bellatrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub struct ExecutionPayload {
/// own `state_root`.
pub state_root: Bytes32,
pub receipts_root: Bytes32,
#[serde(serialize_with = "crate::beacon::serde_helpers::ssz_hex::serialize")]
#[serde(with = "crate::beacon::serde_helpers::ssz_hex")]
pub logs_bloom: LogsBloom,
/// The randomness the beacon chain exposes to the EVM for this block;
/// `difficulty` in the yellow paper before the merge repurposed the
Expand All @@ -105,15 +105,15 @@ pub struct ExecutionPayload {
pub gas_used: u64,
#[serde(with = "crate::beacon::serde_helpers::quoted_or_bare")]
pub timestamp: u64,
#[serde(serialize_with = "crate::beacon::serde_helpers::ssz_hex::serialize")]
#[serde(with = "crate::beacon::serde_helpers::ssz_hex")]
pub extra_data: ExtraData,
/// This block's EIP-1559 base fee, a `uint256` because the execution
/// layer's fee market is not bounded to fit a `uint64`.
pub base_fee_per_gas: Uint256,
/// This payload's own hash, which the next payload's `parent_hash` must
/// equal.
pub block_hash: ExecutionBlockHash,
#[serde(serialize_with = "crate::beacon::serde_helpers::ssz_hex_seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::ssz_hex_seq")]
pub transactions: Transactions,
}

Expand All @@ -127,7 +127,7 @@ pub struct ExecutionPayloadHeader {
pub fee_recipient: ExecutionAddress,
pub state_root: Bytes32,
pub receipts_root: Bytes32,
#[serde(serialize_with = "crate::beacon::serde_helpers::ssz_hex::serialize")]
#[serde(with = "crate::beacon::serde_helpers::ssz_hex")]
pub logs_bloom: LogsBloom,
pub prev_randao: Bytes32,
#[serde(with = "crate::beacon::serde_helpers::quoted_or_bare")]
Expand All @@ -138,7 +138,7 @@ pub struct ExecutionPayloadHeader {
pub gas_used: u64,
#[serde(with = "crate::beacon::serde_helpers::quoted_or_bare")]
pub timestamp: u64,
#[serde(serialize_with = "crate::beacon::serde_helpers::ssz_hex::serialize")]
#[serde(with = "crate::beacon::serde_helpers::ssz_hex")]
pub extra_data: ExtraData,
pub base_fee_per_gas: Uint256,
/// The hash of the execution block this header summarizes.
Expand Down Expand Up @@ -177,15 +177,15 @@ pub struct BeaconBlockBody {
pub eth1_data: Eth1Data,
/// Arbitrary proposer-chosen bytes, which consensus never reads.
pub graffiti: Bytes32,
#[serde(serialize_with = "crate::beacon::serde_helpers::seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::seq")]
pub proposer_slashings: SszList<ProposerSlashing, { preset::MAX_PROPOSER_SLASHINGS }>,
#[serde(serialize_with = "crate::beacon::serde_helpers::seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::seq")]
pub attester_slashings: SszList<AttesterSlashing, { preset::MAX_ATTESTER_SLASHINGS }>,
#[serde(serialize_with = "crate::beacon::serde_helpers::seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::seq")]
pub attestations: SszList<Attestation, { preset::MAX_ATTESTATIONS }>,
#[serde(serialize_with = "crate::beacon::serde_helpers::seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::seq")]
pub deposits: SszList<Deposit, { preset::MAX_DEPOSITS }>,
#[serde(serialize_with = "crate::beacon::serde_helpers::seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::seq")]
pub voluntary_exits: SszList<SignedVoluntaryExit, { preset::MAX_VOLUNTARY_EXITS }>,
/// The aggregated sync committee signature over the previous slot's block
/// root, plus which members contributed.
Expand Down Expand Up @@ -292,56 +292,56 @@ pub struct BeaconState {
/// slot advances, since a block cannot commit to the root of the state
/// containing it.
pub latest_block_header: BeaconBlockHeader,
#[serde(serialize_with = "crate::beacon::serde_helpers::seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::seq")]
pub block_roots: BlockRoots,
#[serde(serialize_with = "crate::beacon::serde_helpers::seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::seq")]
pub state_roots: StateRoots,
#[serde(serialize_with = "crate::beacon::serde_helpers::seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::seq")]
pub historical_roots: HistoricalRoots,

// -- Eth1 --
pub eth1_data: Eth1Data,
#[serde(serialize_with = "crate::beacon::serde_helpers::seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::seq")]
pub eth1_data_votes: Eth1DataVotes,
/// How many deposits from the contract have been processed, which is where
/// the next one will be read from.
#[serde(with = "crate::beacon::serde_helpers::quoted_or_bare")]
pub eth1_deposit_index: u64,

// -- Registry --
#[serde(serialize_with = "crate::beacon::serde_helpers::seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::seq")]
pub validators: Validators,
#[serde(serialize_with = "crate::beacon::serde_helpers::quoted_u64_seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::quoted_u64_seq")]
pub balances: Balances,

// -- Randomness --
#[serde(serialize_with = "crate::beacon::serde_helpers::seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::seq")]
pub randao_mixes: RandaoMixes,

// -- Slashings --
#[serde(serialize_with = "crate::beacon::serde_helpers::quoted_u64_seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::quoted_u64_seq")]
pub slashings: Slashings,

// -- Participation --
/// Per-validator participation flags for the previous epoch, positionally
/// parallel to `validators`.
#[serde(serialize_with = "crate::beacon::serde_helpers::quoted_u64_seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::quoted_u64_seq")]
pub previous_epoch_participation: EpochParticipation,
/// Flags for the current epoch, which become `previous_epoch_participation`
/// at the next epoch boundary.
#[serde(serialize_with = "crate::beacon::serde_helpers::quoted_u64_seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::quoted_u64_seq")]
pub current_epoch_participation: EpochParticipation,

// -- Finality --
#[serde(serialize_with = "crate::beacon::serde_helpers::ssz_hex::serialize")]
#[serde(with = "crate::beacon::serde_helpers::ssz_hex")]
pub justification_bits: JustificationBits,
pub previous_justified_checkpoint: Checkpoint,
pub current_justified_checkpoint: Checkpoint,
pub finalized_checkpoint: Checkpoint,

// -- Inactivity --
/// Per-validator inactivity score, positionally parallel to `validators`.
#[serde(serialize_with = "crate::beacon::serde_helpers::quoted_u64_seq::serialize")]
#[serde(with = "crate::beacon::serde_helpers::quoted_u64_seq")]
pub inactivity_scores: InactivityScores,

// -- Sync committees --
Expand Down
Loading
Loading