2021-03-15 14:11:51 +00:00
|
|
|
# beacon_chain
|
2023-01-09 14:15:43 +00:00
|
|
|
# Copyright (c) 2021-2023 Status Research & Development GmbH
|
2021-03-15 14:11:51 +00:00
|
|
|
# Licensed and distributed under either of
|
|
|
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
|
|
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
|
|
|
|
2023-01-20 14:14:37 +00:00
|
|
|
{.push raises: [].}
|
2021-03-15 14:11:51 +00:00
|
|
|
|
|
|
|
import
|
2022-01-07 17:10:40 +00:00
|
|
|
./spec/datatypes/[base, altair, bellatrix],
|
2021-08-18 18:57:58 +00:00
|
|
|
./spec/[eth2_ssz_serialization, eth2_merkleization]
|
2021-03-15 14:11:51 +00:00
|
|
|
|
2023-01-09 14:15:43 +00:00
|
|
|
from ./spec/datatypes/capella import
|
|
|
|
ExecutionPayloadHeader, HistoricalSummary, Withdrawal
|
2023-02-25 01:03:34 +00:00
|
|
|
from ./spec/datatypes/deneb import ExecutionPayloadHeader
|
2022-11-09 17:32:10 +00:00
|
|
|
|
2021-03-26 14:11:06 +00:00
|
|
|
type
|
2023-07-05 16:02:55 +00:00
|
|
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.0/specs/phase0/beacon-chain.md#beaconstate
|
2023-05-03 11:05:46 +00:00
|
|
|
# Memory-representation-equivalent to a phase0 BeaconState for in-place SSZ
|
|
|
|
# reading and writing
|
2021-11-05 07:34:34 +00:00
|
|
|
Phase0BeaconStateNoImmutableValidators* = object
|
2021-03-15 14:11:51 +00:00
|
|
|
# Versioning
|
|
|
|
genesis_time*: uint64
|
|
|
|
genesis_validators_root*: Eth2Digest
|
|
|
|
slot*: Slot
|
|
|
|
fork*: Fork
|
|
|
|
|
|
|
|
# History
|
2023-05-03 11:05:46 +00:00
|
|
|
latest_block_header*: BeaconBlockHeader
|
|
|
|
## `latest_block_header.state_root == ZERO_HASH` temporarily
|
2021-03-15 14:11:51 +00:00
|
|
|
|
2023-05-03 11:05:46 +00:00
|
|
|
block_roots*: HashArray[Limit SLOTS_PER_HISTORICAL_ROOT, Eth2Digest]
|
|
|
|
## Needed to process attestations, older to newer
|
2021-03-15 14:11:51 +00:00
|
|
|
|
|
|
|
state_roots*: HashArray[Limit SLOTS_PER_HISTORICAL_ROOT, Eth2Digest]
|
|
|
|
historical_roots*: HashList[Eth2Digest, Limit HISTORICAL_ROOTS_LIMIT]
|
|
|
|
|
|
|
|
# Eth1
|
|
|
|
eth1_data*: Eth1Data
|
|
|
|
eth1_data_votes*:
|
|
|
|
HashList[Eth1Data, Limit(EPOCHS_PER_ETH1_VOTING_PERIOD * SLOTS_PER_EPOCH)]
|
|
|
|
eth1_deposit_index*: uint64
|
|
|
|
|
|
|
|
# Registry
|
|
|
|
validators*: HashList[ValidatorStatus, Limit VALIDATOR_REGISTRY_LIMIT]
|
|
|
|
balances*: HashList[uint64, Limit VALIDATOR_REGISTRY_LIMIT]
|
|
|
|
|
|
|
|
# Randomness
|
|
|
|
randao_mixes*: HashArray[Limit EPOCHS_PER_HISTORICAL_VECTOR, Eth2Digest]
|
|
|
|
|
|
|
|
# Slashings
|
2023-05-03 11:05:46 +00:00
|
|
|
slashings*: HashArray[Limit EPOCHS_PER_SLASHINGS_VECTOR, uint64]
|
|
|
|
## Per-epoch sums of slashed effective balances
|
2021-03-15 14:11:51 +00:00
|
|
|
|
|
|
|
# Attestations
|
|
|
|
previous_epoch_attestations*:
|
|
|
|
HashList[PendingAttestation, Limit(MAX_ATTESTATIONS * SLOTS_PER_EPOCH)]
|
|
|
|
current_epoch_attestations*:
|
|
|
|
HashList[PendingAttestation, Limit(MAX_ATTESTATIONS * SLOTS_PER_EPOCH)]
|
|
|
|
|
|
|
|
# Finality
|
2022-01-06 07:38:40 +00:00
|
|
|
justification_bits*: JustificationBits
|
2023-05-03 11:05:46 +00:00
|
|
|
## Bit set for every recent justified epoch
|
2021-03-15 14:11:51 +00:00
|
|
|
|
2023-05-03 11:05:46 +00:00
|
|
|
previous_justified_checkpoint*: Checkpoint
|
|
|
|
## Previous epoch snapshot
|
2021-03-15 14:11:51 +00:00
|
|
|
|
|
|
|
current_justified_checkpoint*: Checkpoint
|
|
|
|
finalized_checkpoint*: Checkpoint
|
|
|
|
|
2023-06-30 16:12:54 +00:00
|
|
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.0/specs/altair/beacon-chain.md#beaconstate
|
2021-06-24 07:11:47 +00:00
|
|
|
# Memory-representation-equivalent to an Altair BeaconState for in-place SSZ
|
|
|
|
# reading and writing
|
|
|
|
AltairBeaconStateNoImmutableValidators* = object
|
|
|
|
# Versioning
|
|
|
|
genesis_time*: uint64
|
|
|
|
genesis_validators_root*: Eth2Digest
|
|
|
|
slot*: Slot
|
|
|
|
fork*: Fork
|
|
|
|
|
|
|
|
# History
|
2023-05-03 11:05:46 +00:00
|
|
|
latest_block_header*: BeaconBlockHeader
|
|
|
|
## `latest_block_header.state_root == ZERO_HASH` temporarily
|
2021-06-24 07:11:47 +00:00
|
|
|
|
2023-05-03 11:05:46 +00:00
|
|
|
block_roots*: HashArray[Limit SLOTS_PER_HISTORICAL_ROOT, Eth2Digest]
|
|
|
|
## Needed to process attestations, older to newer
|
2021-06-24 07:11:47 +00:00
|
|
|
|
|
|
|
state_roots*: HashArray[Limit SLOTS_PER_HISTORICAL_ROOT, Eth2Digest]
|
|
|
|
historical_roots*: HashList[Eth2Digest, Limit HISTORICAL_ROOTS_LIMIT]
|
|
|
|
|
|
|
|
# Eth1
|
|
|
|
eth1_data*: Eth1Data
|
|
|
|
eth1_data_votes*:
|
|
|
|
HashList[Eth1Data, Limit(EPOCHS_PER_ETH1_VOTING_PERIOD * SLOTS_PER_EPOCH)]
|
|
|
|
eth1_deposit_index*: uint64
|
|
|
|
|
|
|
|
# Registry
|
|
|
|
validators*: HashList[ValidatorStatus, Limit VALIDATOR_REGISTRY_LIMIT]
|
|
|
|
balances*: HashList[uint64, Limit VALIDATOR_REGISTRY_LIMIT]
|
|
|
|
|
|
|
|
# Randomness
|
|
|
|
randao_mixes*: HashArray[Limit EPOCHS_PER_HISTORICAL_VECTOR, Eth2Digest]
|
|
|
|
|
|
|
|
# Slashings
|
2023-05-03 11:05:46 +00:00
|
|
|
slashings*: HashArray[Limit EPOCHS_PER_SLASHINGS_VECTOR, uint64]
|
|
|
|
## Per-epoch sums of slashed effective balances
|
2021-06-24 07:11:47 +00:00
|
|
|
|
|
|
|
# Participation
|
2021-12-29 02:50:49 +00:00
|
|
|
previous_epoch_participation*: EpochParticipationFlags
|
2023-05-03 11:05:46 +00:00
|
|
|
## [Modified in Altair]
|
2021-12-29 02:50:49 +00:00
|
|
|
current_epoch_participation*: EpochParticipationFlags
|
2023-05-03 11:05:46 +00:00
|
|
|
## [Modified in Altair]
|
2021-06-24 07:11:47 +00:00
|
|
|
|
|
|
|
# Finality
|
2022-01-06 07:38:40 +00:00
|
|
|
justification_bits*: JustificationBits
|
2023-05-03 11:05:46 +00:00
|
|
|
## Bit set for every recent justified epoch
|
2021-06-24 07:11:47 +00:00
|
|
|
|
2023-05-03 11:05:46 +00:00
|
|
|
previous_justified_checkpoint*: Checkpoint
|
2021-06-24 07:11:47 +00:00
|
|
|
current_justified_checkpoint*: Checkpoint
|
|
|
|
finalized_checkpoint*: Checkpoint
|
|
|
|
|
|
|
|
# Inactivity
|
|
|
|
inactivity_scores*: HashList[uint64, Limit VALIDATOR_REGISTRY_LIMIT] # [New in Altair]
|
|
|
|
|
|
|
|
# Light client sync committees
|
|
|
|
current_sync_committee*: SyncCommittee # [New in Altair]
|
|
|
|
next_sync_committee*: SyncCommittee # [New in Altair]
|
2021-09-30 01:07:24 +00:00
|
|
|
|
2023-04-21 18:52:43 +00:00
|
|
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/beacon-chain.md#beaconstate
|
2022-03-03 16:08:14 +00:00
|
|
|
# Memory-representation-equivalent to a Bellatrix BeaconState for in-place SSZ
|
2021-09-30 01:07:24 +00:00
|
|
|
# reading and writing
|
2022-02-21 11:55:56 +00:00
|
|
|
BellatrixBeaconStateNoImmutableValidators* = object
|
2021-09-30 01:07:24 +00:00
|
|
|
# Versioning
|
|
|
|
genesis_time*: uint64
|
|
|
|
genesis_validators_root*: Eth2Digest
|
|
|
|
slot*: Slot
|
|
|
|
fork*: Fork
|
|
|
|
|
|
|
|
# History
|
2023-05-03 11:05:46 +00:00
|
|
|
latest_block_header*: BeaconBlockHeader
|
|
|
|
## `latest_block_header.state_root == ZERO_HASH` temporarily
|
2021-09-30 01:07:24 +00:00
|
|
|
|
2023-05-03 11:05:46 +00:00
|
|
|
block_roots*: HashArray[Limit SLOTS_PER_HISTORICAL_ROOT, Eth2Digest]
|
|
|
|
## Needed to process attestations, older to newer
|
2021-09-30 01:07:24 +00:00
|
|
|
|
|
|
|
state_roots*: HashArray[Limit SLOTS_PER_HISTORICAL_ROOT, Eth2Digest]
|
|
|
|
historical_roots*: HashList[Eth2Digest, Limit HISTORICAL_ROOTS_LIMIT]
|
|
|
|
|
|
|
|
# Eth1
|
|
|
|
eth1_data*: Eth1Data
|
|
|
|
eth1_data_votes*:
|
|
|
|
HashList[Eth1Data, Limit(EPOCHS_PER_ETH1_VOTING_PERIOD * SLOTS_PER_EPOCH)]
|
|
|
|
eth1_deposit_index*: uint64
|
|
|
|
|
|
|
|
# Registry
|
|
|
|
validators*: HashList[ValidatorStatus, Limit VALIDATOR_REGISTRY_LIMIT]
|
|
|
|
balances*: HashList[uint64, Limit VALIDATOR_REGISTRY_LIMIT]
|
|
|
|
|
|
|
|
# Randomness
|
|
|
|
randao_mixes*: HashArray[Limit EPOCHS_PER_HISTORICAL_VECTOR, Eth2Digest]
|
|
|
|
|
|
|
|
# Slashings
|
2023-05-03 11:05:46 +00:00
|
|
|
slashings*: HashArray[Limit EPOCHS_PER_SLASHINGS_VECTOR, uint64]
|
|
|
|
## Per-epoch sums of slashed effective balances
|
2021-09-30 01:07:24 +00:00
|
|
|
|
|
|
|
# Participation
|
2021-12-29 02:50:49 +00:00
|
|
|
previous_epoch_participation*: EpochParticipationFlags
|
|
|
|
current_epoch_participation*: EpochParticipationFlags
|
2021-09-30 01:07:24 +00:00
|
|
|
|
|
|
|
# Finality
|
2022-01-06 07:38:40 +00:00
|
|
|
justification_bits*: JustificationBits
|
2023-05-03 11:05:46 +00:00
|
|
|
## Bit set for every recent justified epoch
|
2021-09-30 01:07:24 +00:00
|
|
|
|
2023-05-03 11:05:46 +00:00
|
|
|
previous_justified_checkpoint*: Checkpoint
|
2021-09-30 01:07:24 +00:00
|
|
|
current_justified_checkpoint*: Checkpoint
|
|
|
|
finalized_checkpoint*: Checkpoint
|
|
|
|
|
|
|
|
# Inactivity
|
|
|
|
inactivity_scores*: HashList[uint64, Limit VALIDATOR_REGISTRY_LIMIT]
|
|
|
|
|
|
|
|
# Sync
|
|
|
|
current_sync_committee*: SyncCommittee
|
|
|
|
next_sync_committee*: SyncCommittee
|
|
|
|
|
|
|
|
# Execution
|
2022-11-09 17:32:10 +00:00
|
|
|
latest_execution_payload_header*: bellatrix.ExecutionPayloadHeader # [New in Bellatrix]
|
|
|
|
|
2023-06-24 15:43:30 +00:00
|
|
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.0/specs/capella/beacon-chain.md#beaconstate
|
2022-12-07 16:47:23 +00:00
|
|
|
# with indirect changes via ExecutionPayload
|
2022-11-09 17:32:10 +00:00
|
|
|
# Memory-representation-equivalent to a Capella BeaconState for in-place SSZ
|
|
|
|
# reading and writing
|
|
|
|
CapellaBeaconStateNoImmutableValidators* = object
|
|
|
|
# Versioning
|
|
|
|
genesis_time*: uint64
|
|
|
|
genesis_validators_root*: Eth2Digest
|
|
|
|
slot*: Slot
|
|
|
|
fork*: Fork
|
|
|
|
|
|
|
|
# History
|
|
|
|
latest_block_header*: BeaconBlockHeader
|
|
|
|
## `latest_block_header.state_root == ZERO_HASH` temporarily
|
|
|
|
|
|
|
|
block_roots*: HashArray[Limit SLOTS_PER_HISTORICAL_ROOT, Eth2Digest]
|
|
|
|
## Needed to process attestations, older to newer
|
|
|
|
|
|
|
|
state_roots*: HashArray[Limit SLOTS_PER_HISTORICAL_ROOT, Eth2Digest]
|
|
|
|
historical_roots*: HashList[Eth2Digest, Limit HISTORICAL_ROOTS_LIMIT]
|
2023-05-03 11:05:46 +00:00
|
|
|
## Frozen in Capella, replaced by historical_summaries
|
2022-11-09 17:32:10 +00:00
|
|
|
|
|
|
|
# Eth1
|
|
|
|
eth1_data*: Eth1Data
|
|
|
|
eth1_data_votes*:
|
|
|
|
HashList[Eth1Data, Limit(EPOCHS_PER_ETH1_VOTING_PERIOD * SLOTS_PER_EPOCH)]
|
|
|
|
eth1_deposit_index*: uint64
|
|
|
|
|
|
|
|
# Registry
|
2023-01-03 19:04:59 +00:00
|
|
|
validators*:
|
|
|
|
HashList[ValidatorStatusCapella, Limit VALIDATOR_REGISTRY_LIMIT]
|
2022-11-09 17:32:10 +00:00
|
|
|
balances*: HashList[Gwei, Limit VALIDATOR_REGISTRY_LIMIT]
|
|
|
|
|
|
|
|
# Randomness
|
|
|
|
randao_mixes*: HashArray[Limit EPOCHS_PER_HISTORICAL_VECTOR, Eth2Digest]
|
|
|
|
|
|
|
|
# Slashings
|
|
|
|
slashings*: HashArray[Limit EPOCHS_PER_SLASHINGS_VECTOR, Gwei]
|
|
|
|
## Per-epoch sums of slashed effective balances
|
|
|
|
|
|
|
|
# Participation
|
|
|
|
previous_epoch_participation*: EpochParticipationFlags
|
|
|
|
current_epoch_participation*: EpochParticipationFlags
|
|
|
|
|
|
|
|
# Finality
|
|
|
|
justification_bits*: JustificationBits
|
2023-05-03 11:05:46 +00:00
|
|
|
## Bit set for every recent justified epoch
|
2022-11-09 17:32:10 +00:00
|
|
|
|
|
|
|
previous_justified_checkpoint*: Checkpoint
|
|
|
|
current_justified_checkpoint*: Checkpoint
|
|
|
|
finalized_checkpoint*: Checkpoint
|
|
|
|
|
|
|
|
# Inactivity
|
|
|
|
inactivity_scores*: HashList[uint64, Limit VALIDATOR_REGISTRY_LIMIT]
|
|
|
|
|
|
|
|
# Light client sync committees
|
|
|
|
current_sync_committee*: SyncCommittee
|
|
|
|
next_sync_committee*: SyncCommittee
|
|
|
|
|
|
|
|
# Execution
|
|
|
|
latest_execution_payload_header*: capella.ExecutionPayloadHeader
|
2023-05-03 11:05:46 +00:00
|
|
|
## [Modified in Capella]
|
2022-11-09 17:32:10 +00:00
|
|
|
|
|
|
|
# Withdrawals
|
2023-05-03 11:05:46 +00:00
|
|
|
next_withdrawal_index*: WithdrawalIndex # [New in Capella]
|
2022-11-21 07:44:49 +00:00
|
|
|
next_withdrawal_validator_index*: uint64 # [New in Capella]
|
2022-12-07 16:47:23 +00:00
|
|
|
|
2023-01-09 14:15:43 +00:00
|
|
|
# Deep history valid from Capella onwards
|
|
|
|
historical_summaries*:
|
|
|
|
HashList[HistoricalSummary,
|
|
|
|
Limit HISTORICAL_ROOTS_LIMIT] # [New in Capella]
|
|
|
|
|
2023-07-05 16:02:55 +00:00
|
|
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.0/specs/capella/beacon-chain.md#beaconstate
|
2022-12-07 16:47:23 +00:00
|
|
|
# with indirect changes via ExecutionPayloadHeader
|
2023-03-10 17:15:08 +00:00
|
|
|
# Memory-representation-equivalent to a Deneb BeaconState for in-place SSZ
|
2022-12-07 16:47:23 +00:00
|
|
|
# reading and writing
|
2023-03-10 17:15:08 +00:00
|
|
|
DenebBeaconStateNoImmutableValidators* = object
|
2022-12-07 16:47:23 +00:00
|
|
|
# Versioning
|
|
|
|
genesis_time*: uint64
|
|
|
|
genesis_validators_root*: Eth2Digest
|
|
|
|
slot*: Slot
|
|
|
|
fork*: Fork
|
|
|
|
|
|
|
|
# History
|
|
|
|
latest_block_header*: BeaconBlockHeader
|
|
|
|
## `latest_block_header.state_root == ZERO_HASH` temporarily
|
|
|
|
|
|
|
|
block_roots*: HashArray[Limit SLOTS_PER_HISTORICAL_ROOT, Eth2Digest]
|
|
|
|
## Needed to process attestations, older to newer
|
|
|
|
|
|
|
|
state_roots*: HashArray[Limit SLOTS_PER_HISTORICAL_ROOT, Eth2Digest]
|
|
|
|
historical_roots*: HashList[Eth2Digest, Limit HISTORICAL_ROOTS_LIMIT]
|
2023-05-03 11:05:46 +00:00
|
|
|
## Frozen in Capella, replaced by historical_summaries
|
2022-12-07 16:47:23 +00:00
|
|
|
|
|
|
|
# Eth1
|
|
|
|
eth1_data*: Eth1Data
|
|
|
|
eth1_data_votes*:
|
|
|
|
HashList[Eth1Data, Limit(EPOCHS_PER_ETH1_VOTING_PERIOD * SLOTS_PER_EPOCH)]
|
|
|
|
eth1_deposit_index*: uint64
|
|
|
|
|
|
|
|
# Registry
|
2023-01-03 19:04:59 +00:00
|
|
|
validators*:
|
|
|
|
HashList[ValidatorStatusCapella, Limit VALIDATOR_REGISTRY_LIMIT]
|
2022-12-07 16:47:23 +00:00
|
|
|
balances*: HashList[Gwei, Limit VALIDATOR_REGISTRY_LIMIT]
|
|
|
|
|
|
|
|
# Randomness
|
|
|
|
randao_mixes*: HashArray[Limit EPOCHS_PER_HISTORICAL_VECTOR, Eth2Digest]
|
|
|
|
|
|
|
|
# Slashings
|
|
|
|
slashings*: HashArray[Limit EPOCHS_PER_SLASHINGS_VECTOR, Gwei]
|
|
|
|
## Per-epoch sums of slashed effective balances
|
|
|
|
|
|
|
|
# Participation
|
|
|
|
previous_epoch_participation*: EpochParticipationFlags
|
|
|
|
current_epoch_participation*: EpochParticipationFlags
|
|
|
|
|
|
|
|
# Finality
|
|
|
|
justification_bits*: JustificationBits
|
2023-05-03 11:05:46 +00:00
|
|
|
## Bit set for every recent justified epoch
|
2022-12-07 16:47:23 +00:00
|
|
|
|
|
|
|
previous_justified_checkpoint*: Checkpoint
|
|
|
|
current_justified_checkpoint*: Checkpoint
|
|
|
|
finalized_checkpoint*: Checkpoint
|
|
|
|
|
|
|
|
# Inactivity
|
|
|
|
inactivity_scores*: HashList[uint64, Limit VALIDATOR_REGISTRY_LIMIT]
|
|
|
|
|
|
|
|
# Light client sync committees
|
|
|
|
current_sync_committee*: SyncCommittee
|
|
|
|
next_sync_committee*: SyncCommittee
|
|
|
|
|
|
|
|
# Execution
|
2023-02-25 01:03:34 +00:00
|
|
|
latest_execution_payload_header*: deneb.ExecutionPayloadHeader
|
2022-12-07 16:47:23 +00:00
|
|
|
|
|
|
|
# Withdrawals
|
|
|
|
next_withdrawal_index*: WithdrawalIndex
|
|
|
|
next_withdrawal_validator_index*: uint64
|
2023-01-09 14:15:43 +00:00
|
|
|
|
|
|
|
# Deep history valid from Capella onwards
|
|
|
|
historical_summaries*:
|
|
|
|
HashList[HistoricalSummary, Limit HISTORICAL_ROOTS_LIMIT]
|