Documentation ¶
Overview ¶
Package state_native defines how the beacon chain state for Ethereum functions in the running beacon node, using an advanced, immutable implementation of the state data structure.
BeaconState getters may be accessed from inside or outside the package. To avoid duplicating locks, we have internal and external versions of the getter. The external function obtains a read lock, then calls the internal function. The internal function returns the required data without further locking, allowing it to be used by other package-level functions that already hold a lock. Hence the functions look something like this:
func (b *BeaconState) Foo() uint64 { // Read lock. b.lock.RLock() defer b.lock.RUnlock() // Internal getter. return b.foo() } func (b *BeaconState) foo() uint64 { (...) // Some processing logic. return b.foo }
Although it is technically possible to remove the short-circuit conditions from the external function, that would require every read to obtain a lock even if the data was not present, leading to potential slowdowns.
Index ¶
- Constants
- Variables
- func ComputeFieldRootsWithHasher(ctx context.Context, state *BeaconState) ([][]byte, error)
- func FinalizedRootGeneralizedIndex() uint64
- func InitializeFromProtoAltair(st *ethpb.BeaconStateAltair) (state.BeaconState, error)
- func InitializeFromProtoBellatrix(st *ethpb.BeaconStateBellatrix) (state.BeaconState, error)
- func InitializeFromProtoCapella(st *ethpb.BeaconStateCapella) (state.BeaconState, error)
- func InitializeFromProtoDeneb(st *ethpb.BeaconStateDeneb) (state.BeaconState, error)
- func InitializeFromProtoElectra(st *ethpb.BeaconStateElectra) (state.BeaconState, error)
- func InitializeFromProtoPhase0(st *ethpb.BeaconState) (state.BeaconState, error)
- func InitializeFromProtoUnsafeAltair(st *ethpb.BeaconStateAltair) (state.BeaconState, error)
- func InitializeFromProtoUnsafeBellatrix(st *ethpb.BeaconStateBellatrix) (state.BeaconState, error)
- func InitializeFromProtoUnsafeCapella(st *ethpb.BeaconStateCapella) (state.BeaconState, error)
- func InitializeFromProtoUnsafeDeneb(st *ethpb.BeaconStateDeneb) (state.BeaconState, error)
- func InitializeFromProtoUnsafeElectra(st *ethpb.BeaconStateElectra) (state.BeaconState, error)
- func InitializeFromProtoUnsafePhase0(st *ethpb.BeaconState) (state.BeaconState, error)
- func NewValidator(v *ethpb.Validator) (state.ReadOnlyValidator, error)
- func ProtobufBeaconStateAltair(s interface{}) (*ethpb.BeaconStateAltair, error)
- func ProtobufBeaconStateBellatrix(s interface{}) (*ethpb.BeaconStateBellatrix, error)
- func ProtobufBeaconStateCapella(s interface{}) (*ethpb.BeaconStateCapella, error)
- func ProtobufBeaconStateDeneb(s interface{}) (*ethpb.BeaconStateDeneb, error)
- func ProtobufBeaconStateElectra(s interface{}) (*ethpb.BeaconStateElectra, error)
- func ProtobufBeaconStatePhase0(s interface{}) (*ethpb.BeaconState, error)
- type BeaconState
- func (b *BeaconState) AggregateKeyFromIndices(idxs []uint64) (bls.PublicKey, error)
- func (b *BeaconState) AppendBalance(bal uint64) error
- func (b *BeaconState) AppendCurrentEpochAttestations(val *ethpb.PendingAttestation) error
- func (b *BeaconState) AppendCurrentParticipationBits(val byte) error
- func (b *BeaconState) AppendEth1DataVotes(val *ethpb.Eth1Data) error
- func (b *BeaconState) AppendHistoricalRoots(root [32]byte) error
- func (b *BeaconState) AppendHistoricalSummaries(summary *ethpb.HistoricalSummary) error
- func (b *BeaconState) AppendInactivityScore(s uint64) error
- func (b *BeaconState) AppendPendingConsolidation(val *ethpb.PendingConsolidation) error
- func (b *BeaconState) AppendPendingDeposit(pd *ethpb.PendingDeposit) error
- func (b *BeaconState) AppendPendingPartialWithdrawal(ppw *eth.PendingPartialWithdrawal) error
- func (b *BeaconState) AppendPreviousEpochAttestations(val *ethpb.PendingAttestation) error
- func (b *BeaconState) AppendPreviousParticipationBits(val byte) error
- func (b *BeaconState) AppendValidator(val *ethpb.Validator) error
- func (b *BeaconState) ApplyToEveryValidator(f func(idx int, val state.ReadOnlyValidator) (*ethpb.Validator, error)) error
- func (b *BeaconState) BalanceAtIndex(idx primitives.ValidatorIndex) (uint64, error)
- func (b *BeaconState) Balances() []uint64
- func (b *BeaconState) BalancesLength() int
- func (b *BeaconState) BlockRootAtIndex(idx uint64) ([]byte, error)
- func (b *BeaconState) BlockRoots() [][]byte
- func (b *BeaconState) ConsolidationBalanceToConsume() (primitives.Gwei, error)
- func (b *BeaconState) Copy() state.BeaconState
- func (b *BeaconState) CopyAllTries()
- func (b *BeaconState) CurrentEpochAttestations() ([]*ethpb.PendingAttestation, error)
- func (b *BeaconState) CurrentEpochParticipation() ([]byte, error)
- func (b *BeaconState) CurrentJustifiedCheckpoint() *ethpb.Checkpoint
- func (b *BeaconState) CurrentSyncCommittee() (*ethpb.SyncCommittee, error)
- func (b *BeaconState) CurrentSyncCommitteeGeneralizedIndex() (uint64, error)
- func (b *BeaconState) CurrentSyncCommitteeProof(ctx context.Context) ([][]byte, error)
- func (b *BeaconState) Defragment()
- func (b *BeaconState) DepositBalanceToConsume() (primitives.Gwei, error)
- func (b *BeaconState) DepositRequestsStartIndex() (uint64, error)
- func (b *BeaconState) DequeuePendingPartialWithdrawals(n uint64) error
- func (b *BeaconState) EarliestConsolidationEpoch() (primitives.Epoch, error)
- func (b *BeaconState) EarliestExitEpoch() (primitives.Epoch, error)
- func (b *BeaconState) Eth1Data() *ethpb.Eth1Data
- func (b *BeaconState) Eth1DataVotes() []*ethpb.Eth1Data
- func (b *BeaconState) Eth1DepositIndex() uint64
- func (b *BeaconState) ExitBalanceToConsume() (primitives.Gwei, error)
- func (b *BeaconState) ExitEpochAndUpdateChurn(exitBalance primitives.Gwei) (primitives.Epoch, error)
- func (b *BeaconState) ExpectedWithdrawals() ([]*enginev1.Withdrawal, uint64, error)
- func (b *BeaconState) FieldReferencesCount() map[string]uint64
- func (b *BeaconState) FinalizedCheckpoint() *ethpb.Checkpoint
- func (b *BeaconState) FinalizedCheckpointEpoch() primitives.Epoch
- func (b *BeaconState) FinalizedRootProof(ctx context.Context) ([][]byte, error)
- func (b *BeaconState) Fork() *ethpb.Fork
- func (b *BeaconState) GenesisTime() uint64
- func (b *BeaconState) GenesisValidatorsRoot() []byte
- func (b *BeaconState) HasPendingBalanceToWithdraw(idx primitives.ValidatorIndex) (bool, error)
- func (b *BeaconState) HashTreeRoot(ctx context.Context) ([32]byte, error)
- func (b *BeaconState) HistoricalRoots() ([][]byte, error)
- func (b *BeaconState) HistoricalSummaries() ([]*ethpb.HistoricalSummary, error)
- func (b *BeaconState) Id() uint64
- func (b *BeaconState) InactivityPenaltyQuotient() (uint64, error)
- func (b *BeaconState) InactivityScores() ([]uint64, error)
- func (b *BeaconState) IsNil() bool
- func (b *BeaconState) JustificationBits() bitfield.Bitvector4
- func (b *BeaconState) LatestBlockHeader() *ethpb.BeaconBlockHeader
- func (b *BeaconState) LatestExecutionPayloadHeader() (interfaces.ExecutionData, error)
- func (b *BeaconState) MarshalJSON() ([]byte, error)
- func (b *BeaconState) MarshalSSZ() ([]byte, error)
- func (b *BeaconState) MatchCurrentJustifiedCheckpoint(c *ethpb.Checkpoint) bool
- func (b *BeaconState) MatchPreviousJustifiedCheckpoint(c *ethpb.Checkpoint) bool
- func (b *BeaconState) ModifyCurrentParticipationBits(mutator func(val []byte) ([]byte, error)) error
- func (b *BeaconState) ModifyPreviousParticipationBits(mutator func(val []byte) ([]byte, error)) error
- func (b *BeaconState) NextSyncCommittee() (*ethpb.SyncCommittee, error)
- func (b *BeaconState) NextSyncCommitteeGeneralizedIndex() (uint64, error)
- func (b *BeaconState) NextSyncCommitteeProof(ctx context.Context) ([][]byte, error)
- func (b *BeaconState) NextWithdrawalIndex() (uint64, error)
- func (b *BeaconState) NextWithdrawalValidatorIndex() (primitives.ValidatorIndex, error)
- func (b *BeaconState) NumPendingConsolidations() (uint64, error)
- func (b *BeaconState) NumPendingPartialWithdrawals() (uint64, error)
- func (b *BeaconState) NumValidators() int
- func (b *BeaconState) PendingBalanceToWithdraw(idx primitives.ValidatorIndex) (uint64, error)
- func (b *BeaconState) PendingConsolidations() ([]*ethpb.PendingConsolidation, error)
- func (b *BeaconState) PendingDeposits() ([]*ethpb.PendingDeposit, error)
- func (b *BeaconState) PendingPartialWithdrawals() ([]*ethpb.PendingPartialWithdrawal, error)
- func (b *BeaconState) PreviousEpochAttestations() ([]*ethpb.PendingAttestation, error)
- func (b *BeaconState) PreviousEpochParticipation() ([]byte, error)
- func (b *BeaconState) PreviousJustifiedCheckpoint() *ethpb.Checkpoint
- func (b *BeaconState) ProportionalSlashingMultiplier() (uint64, error)
- func (b *BeaconState) PubkeyAtIndex(idx primitives.ValidatorIndex) [fieldparams.BLSPubkeyLength]byte
- func (b *BeaconState) PublicKeys() ([][fieldparams.BLSPubkeyLength]byte, error)
- func (b *BeaconState) RandaoMixAtIndex(idx uint64) ([]byte, error)
- func (b *BeaconState) RandaoMixes() [][]byte
- func (b *BeaconState) RandaoMixesLength() int
- func (b *BeaconState) ReadFromEveryValidator(f func(idx int, val state.ReadOnlyValidator) error) error
- func (b *BeaconState) RecordStateMetrics()
- func (b *BeaconState) RotateAttestations() error
- func (b *BeaconState) SetBalances(val []uint64) error
- func (b *BeaconState) SetBlockRoots(val [][]byte) error
- func (b *BeaconState) SetConsolidationBalanceToConsume(balance primitives.Gwei) error
- func (b *BeaconState) SetCurrentEpochAttestations(a []*ethpb.PendingAttestation) error
- func (b *BeaconState) SetCurrentJustifiedCheckpoint(val *ethpb.Checkpoint) error
- func (b *BeaconState) SetCurrentParticipationBits(val []byte) error
- func (b *BeaconState) SetCurrentSyncCommittee(val *ethpb.SyncCommittee) error
- func (b *BeaconState) SetDepositBalanceToConsume(dbtc primitives.Gwei) error
- func (b *BeaconState) SetDepositRequestsStartIndex(index uint64) error
- func (b *BeaconState) SetEarliestConsolidationEpoch(epoch primitives.Epoch) error
- func (b *BeaconState) SetEth1Data(val *ethpb.Eth1Data) error
- func (b *BeaconState) SetEth1DataVotes(val []*ethpb.Eth1Data) error
- func (b *BeaconState) SetEth1DepositIndex(val uint64) error
- func (b *BeaconState) SetFinalizedCheckpoint(val *ethpb.Checkpoint) error
- func (b *BeaconState) SetFork(val *ethpb.Fork) error
- func (b *BeaconState) SetGenesisTime(val uint64) error
- func (b *BeaconState) SetGenesisValidatorsRoot(val []byte) error
- func (b *BeaconState) SetHistoricalRoots(val [][]byte) error
- func (b *BeaconState) SetInactivityScores(val []uint64) error
- func (b *BeaconState) SetJustificationBits(val bitfield.Bitvector4) error
- func (b *BeaconState) SetLatestBlockHeader(val *ethpb.BeaconBlockHeader) error
- func (b *BeaconState) SetLatestExecutionPayloadHeader(val interfaces.ExecutionData) error
- func (b *BeaconState) SetNextSyncCommittee(val *ethpb.SyncCommittee) error
- func (b *BeaconState) SetNextWithdrawalIndex(i uint64) error
- func (b *BeaconState) SetNextWithdrawalValidatorIndex(i primitives.ValidatorIndex) error
- func (b *BeaconState) SetPendingConsolidations(val []*ethpb.PendingConsolidation) error
- func (b *BeaconState) SetPendingDeposits(val []*ethpb.PendingDeposit) error
- func (b *BeaconState) SetPreviousEpochAttestations(a []*ethpb.PendingAttestation) error
- func (b *BeaconState) SetPreviousJustifiedCheckpoint(val *ethpb.Checkpoint) error
- func (b *BeaconState) SetPreviousParticipationBits(val []byte) error
- func (b *BeaconState) SetRandaoMixes(val [][]byte) error
- func (b *BeaconState) SetSlashings(val []uint64) error
- func (b *BeaconState) SetSlot(val primitives.Slot) error
- func (b *BeaconState) SetStateRoots(val [][]byte) error
- func (b *BeaconState) SetValidators(val []*ethpb.Validator) error
- func (b *BeaconState) Slashings() []uint64
- func (b *BeaconState) Slot() primitives.Slot
- func (b *BeaconState) StateRootAtIndex(idx uint64) ([]byte, error)
- func (b *BeaconState) StateRoots() [][]byte
- func (b *BeaconState) ToProto() interface{}
- func (b *BeaconState) ToProtoUnsafe() interface{}
- func (b *BeaconState) UnrealizedCheckpointBalances() (uint64, uint64, uint64, error)
- func (b *BeaconState) UpdateBalancesAtIndex(idx primitives.ValidatorIndex, val uint64) error
- func (b *BeaconState) UpdateBlockRootAtIndex(idx uint64, blockRoot [32]byte) error
- func (b *BeaconState) UpdateRandaoMixesAtIndex(idx uint64, val [32]byte) error
- func (b *BeaconState) UpdateSlashingsAtIndex(idx, val uint64) error
- func (b *BeaconState) UpdateStateRootAtIndex(idx uint64, stateRoot [32]byte) error
- func (b *BeaconState) UpdateValidatorAtIndex(idx primitives.ValidatorIndex, val *ethpb.Validator) error
- func (b *BeaconState) ValidatorAtIndex(idx primitives.ValidatorIndex) (*ethpb.Validator, error)
- func (b *BeaconState) ValidatorAtIndexReadOnly(idx primitives.ValidatorIndex) (state.ReadOnlyValidator, error)
- func (b *BeaconState) ValidatorIndexByPubkey(key [fieldparams.BLSPubkeyLength]byte) (primitives.ValidatorIndex, bool)
- func (b *BeaconState) Validators() []*ethpb.Validator
- func (b *BeaconState) ValidatorsReadOnly() []state.ReadOnlyValidator
- func (b *BeaconState) Version() int
- type MultiValueBalances
- type MultiValueBlockRoots
- type MultiValueInactivityScores
- type MultiValueRandaoMixes
- type MultiValueStateRoots
- type MultiValueValidators
Constants ¶
const ETH1AddressOffset = 12
Variables ¶
var ErrNilParticipation = errors.New("nil epoch participation in state")
var ( // ErrNilWrappedValidator returns when caller attempts to wrap a nil pointer validator. ErrNilWrappedValidator = errors.New("nil validator cannot be wrapped as readonly") )
Functions ¶
func ComputeFieldRootsWithHasher ¶
func ComputeFieldRootsWithHasher(ctx context.Context, state *BeaconState) ([][]byte, error)
ComputeFieldRootsWithHasher hashes the provided state and returns its respective field roots.
func FinalizedRootGeneralizedIndex ¶
func FinalizedRootGeneralizedIndex() uint64
FinalizedRootGeneralizedIndex for the beacon state.
func InitializeFromProtoAltair ¶
func InitializeFromProtoAltair(st *ethpb.BeaconStateAltair) (state.BeaconState, error)
InitializeFromProtoAltair the beacon state from a protobuf representation.
func InitializeFromProtoBellatrix ¶
func InitializeFromProtoBellatrix(st *ethpb.BeaconStateBellatrix) (state.BeaconState, error)
InitializeFromProtoBellatrix the beacon state from a protobuf representation.
func InitializeFromProtoCapella ¶
func InitializeFromProtoCapella(st *ethpb.BeaconStateCapella) (state.BeaconState, error)
InitializeFromProtoCapella the beacon state from a protobuf representation.
func InitializeFromProtoDeneb ¶
func InitializeFromProtoDeneb(st *ethpb.BeaconStateDeneb) (state.BeaconState, error)
InitializeFromProtoDeneb the beacon state from a protobuf representation.
func InitializeFromProtoElectra ¶ added in v5.1.0
func InitializeFromProtoElectra(st *ethpb.BeaconStateElectra) (state.BeaconState, error)
func InitializeFromProtoPhase0 ¶
func InitializeFromProtoPhase0(st *ethpb.BeaconState) (state.BeaconState, error)
InitializeFromProtoPhase0 the beacon state from a protobuf representation.
func InitializeFromProtoUnsafeAltair ¶
func InitializeFromProtoUnsafeAltair(st *ethpb.BeaconStateAltair) (state.BeaconState, error)
InitializeFromProtoUnsafeAltair directly uses the beacon state protobuf fields and sets them as fields of the BeaconState type.
func InitializeFromProtoUnsafeBellatrix ¶
func InitializeFromProtoUnsafeBellatrix(st *ethpb.BeaconStateBellatrix) (state.BeaconState, error)
InitializeFromProtoUnsafeBellatrix directly uses the beacon state protobuf fields and sets them as fields of the BeaconState type.
func InitializeFromProtoUnsafeCapella ¶
func InitializeFromProtoUnsafeCapella(st *ethpb.BeaconStateCapella) (state.BeaconState, error)
InitializeFromProtoUnsafeCapella directly uses the beacon state protobuf fields and sets them as fields of the BeaconState type.
func InitializeFromProtoUnsafeDeneb ¶
func InitializeFromProtoUnsafeDeneb(st *ethpb.BeaconStateDeneb) (state.BeaconState, error)
InitializeFromProtoUnsafeDeneb directly uses the beacon state protobuf fields and sets them as fields of the BeaconState type.
func InitializeFromProtoUnsafeElectra ¶ added in v5.1.0
func InitializeFromProtoUnsafeElectra(st *ethpb.BeaconStateElectra) (state.BeaconState, error)
InitializeFromProtoUnsafeElectra directly uses the beacon state protobuf fields and sets them as fields of the BeaconState type.
func InitializeFromProtoUnsafePhase0 ¶
func InitializeFromProtoUnsafePhase0(st *ethpb.BeaconState) (state.BeaconState, error)
InitializeFromProtoUnsafePhase0 directly uses the beacon state protobuf fields and sets them as fields of the BeaconState type.
func NewValidator ¶
func NewValidator(v *ethpb.Validator) (state.ReadOnlyValidator, error)
NewValidator initializes the read only wrapper for validator.
func ProtobufBeaconStateAltair ¶
func ProtobufBeaconStateAltair(s interface{}) (*ethpb.BeaconStateAltair, error)
ProtobufBeaconStateAltair transforms an input into beacon state Altair in the form of protobuf. Error is returned if the input is not type protobuf beacon state.
func ProtobufBeaconStateBellatrix ¶
func ProtobufBeaconStateBellatrix(s interface{}) (*ethpb.BeaconStateBellatrix, error)
ProtobufBeaconStateBellatrix transforms an input into beacon state Bellatrix in the form of protobuf. Error is returned if the input is not type protobuf beacon state.
func ProtobufBeaconStateCapella ¶
func ProtobufBeaconStateCapella(s interface{}) (*ethpb.BeaconStateCapella, error)
ProtobufBeaconStateCapella transforms an input into beacon state Capella in the form of protobuf. Error is returned if the input is not type protobuf beacon state.
func ProtobufBeaconStateDeneb ¶
func ProtobufBeaconStateDeneb(s interface{}) (*ethpb.BeaconStateDeneb, error)
ProtobufBeaconStateDeneb transforms an input into beacon state Deneb in the form of protobuf. Error is returned if the input is not type protobuf beacon state.
func ProtobufBeaconStateElectra ¶ added in v5.1.0
func ProtobufBeaconStateElectra(s interface{}) (*ethpb.BeaconStateElectra, error)
ProtobufBeaconStateElectra transforms an input into beacon state Electra in the form of protobuf. Error is returned if the input is not type protobuf beacon state.
func ProtobufBeaconStatePhase0 ¶
func ProtobufBeaconStatePhase0(s interface{}) (*ethpb.BeaconState, error)
ProtobufBeaconStatePhase0 transforms an input into beacon state in the form of protobuf. Error is returned if the input is not type protobuf beacon state.
Types ¶
type BeaconState ¶
type BeaconState struct {
// contains filtered or unexported fields
}
BeaconState defines a struct containing utilities for the Ethereum Beacon Chain state, defining getters and setters for its respective values and helpful functions such as HashTreeRoot().
func (*BeaconState) AggregateKeyFromIndices ¶ added in v5.1.0
func (b *BeaconState) AggregateKeyFromIndices(idxs []uint64) (bls.PublicKey, error)
AggregateKeyFromIndices builds an aggregated public key from the provided validator indices.
func (*BeaconState) AppendBalance ¶
func (b *BeaconState) AppendBalance(bal uint64) error
AppendBalance for the beacon state. Appends the new value to the end of list.
func (*BeaconState) AppendCurrentEpochAttestations ¶
func (b *BeaconState) AppendCurrentEpochAttestations(val *ethpb.PendingAttestation) error
AppendCurrentEpochAttestations for the beacon state. Appends the new value to the end of list.
func (*BeaconState) AppendCurrentParticipationBits ¶
func (b *BeaconState) AppendCurrentParticipationBits(val byte) error
AppendCurrentParticipationBits for the beacon state. Appends the new value to the end of list.
func (*BeaconState) AppendEth1DataVotes ¶
func (b *BeaconState) AppendEth1DataVotes(val *ethpb.Eth1Data) error
AppendEth1DataVotes for the beacon state. Appends the new value to the end of list.
func (*BeaconState) AppendHistoricalRoots ¶
func (b *BeaconState) AppendHistoricalRoots(root [32]byte) error
AppendHistoricalRoots for the beacon state. Appends the new value to the end of list.
func (*BeaconState) AppendHistoricalSummaries ¶
func (b *BeaconState) AppendHistoricalSummaries(summary *ethpb.HistoricalSummary) error
AppendHistoricalSummaries for the beacon state. Appends the new value to the end of list.
func (*BeaconState) AppendInactivityScore ¶
func (b *BeaconState) AppendInactivityScore(s uint64) error
AppendInactivityScore for the beacon state.
func (*BeaconState) AppendPendingConsolidation ¶ added in v5.1.0
func (b *BeaconState) AppendPendingConsolidation(val *ethpb.PendingConsolidation) error
AppendPendingConsolidation is a mutating call to the beacon state which appends the provided pending consolidation to the end of the slice on the state. This method requires access to the Lock on the state and only applies in electra or later.
func (*BeaconState) AppendPendingDeposit ¶ added in v5.2.0
func (b *BeaconState) AppendPendingDeposit(pd *ethpb.PendingDeposit) error
AppendPendingDeposit is a mutating call to the beacon state to create and append a pending balance deposit object on to the state. This method requires access to the Lock on the state and only applies in electra or later.
func (*BeaconState) AppendPendingPartialWithdrawal ¶ added in v5.1.0
func (b *BeaconState) AppendPendingPartialWithdrawal(ppw *eth.PendingPartialWithdrawal) error
AppendPendingPartialWithdrawal is a mutating call to the beacon state which appends the given value to the end of the pending partial withdrawals slice in the state. This method requires access to the Lock on the state and only applies in electra or later.
func (*BeaconState) AppendPreviousEpochAttestations ¶
func (b *BeaconState) AppendPreviousEpochAttestations(val *ethpb.PendingAttestation) error
AppendPreviousEpochAttestations for the beacon state. Appends the new value to the end of list.
func (*BeaconState) AppendPreviousParticipationBits ¶
func (b *BeaconState) AppendPreviousParticipationBits(val byte) error
AppendPreviousParticipationBits for the beacon state. Appends the new value to the end of list.
func (*BeaconState) AppendValidator ¶
func (b *BeaconState) AppendValidator(val *ethpb.Validator) error
AppendValidator for the beacon state. Appends the new value to the end of list.
func (*BeaconState) ApplyToEveryValidator ¶
func (b *BeaconState) ApplyToEveryValidator(f func(idx int, val state.ReadOnlyValidator) (*ethpb.Validator, error)) error
ApplyToEveryValidator applies the provided callback function to each validator in the validator registry.
func (*BeaconState) BalanceAtIndex ¶
func (b *BeaconState) BalanceAtIndex(idx primitives.ValidatorIndex) (uint64, error)
BalanceAtIndex of validator with the provided index.
func (*BeaconState) Balances ¶
func (b *BeaconState) Balances() []uint64
Balances of validators participating in consensus on the beacon chain.
func (*BeaconState) BalancesLength ¶
func (b *BeaconState) BalancesLength() int
BalancesLength returns the length of the balances slice.
func (*BeaconState) BlockRootAtIndex ¶
func (b *BeaconState) BlockRootAtIndex(idx uint64) ([]byte, error)
BlockRootAtIndex retrieves a specific block root based on an input index value.
func (*BeaconState) BlockRoots ¶
func (b *BeaconState) BlockRoots() [][]byte
BlockRoots kept track of in the beacon state.
func (*BeaconState) ConsolidationBalanceToConsume ¶ added in v5.1.0
func (b *BeaconState) ConsolidationBalanceToConsume() (primitives.Gwei, error)
ConsolidationBalanceToConsume is a non-mutating call to the beacon state which returns the value of the consolidation balance to consume field. This method requires access to the RLock on the state and only applies in electra or later.
func (*BeaconState) Copy ¶
func (b *BeaconState) Copy() state.BeaconState
Copy returns a deep copy of the beacon state.
func (*BeaconState) CopyAllTries ¶
func (b *BeaconState) CopyAllTries()
CopyAllTries copies our field tries from the state. This is used to remove shared field tries which have references to other states and only have this copied set referencing to the current state.
func (*BeaconState) CurrentEpochAttestations ¶
func (b *BeaconState) CurrentEpochAttestations() ([]*ethpb.PendingAttestation, error)
CurrentEpochAttestations corresponding to blocks on the beacon chain.
func (*BeaconState) CurrentEpochParticipation ¶
func (b *BeaconState) CurrentEpochParticipation() ([]byte, error)
CurrentEpochParticipation corresponding to participation bits on the beacon chain.
func (*BeaconState) CurrentJustifiedCheckpoint ¶
func (b *BeaconState) CurrentJustifiedCheckpoint() *ethpb.Checkpoint
CurrentJustifiedCheckpoint denoting an epoch and block root.
func (*BeaconState) CurrentSyncCommittee ¶
func (b *BeaconState) CurrentSyncCommittee() (*ethpb.SyncCommittee, error)
CurrentSyncCommittee of the current sync committee in beacon chain state.
func (*BeaconState) CurrentSyncCommitteeGeneralizedIndex ¶
func (b *BeaconState) CurrentSyncCommitteeGeneralizedIndex() (uint64, error)
CurrentSyncCommitteeGeneralizedIndex for the beacon state.
func (*BeaconState) CurrentSyncCommitteeProof ¶
func (b *BeaconState) CurrentSyncCommitteeProof(ctx context.Context) ([][]byte, error)
CurrentSyncCommitteeProof from the state's Merkle trie representation.
func (*BeaconState) Defragment ¶
func (b *BeaconState) Defragment()
Defragment checks whether each individual multi-value field in our state is fragmented and if it is, it will 'reset' the field to create a new multivalue object.
func (*BeaconState) DepositBalanceToConsume ¶ added in v5.1.0
func (b *BeaconState) DepositBalanceToConsume() (primitives.Gwei, error)
DepositBalanceToConsume is a non-mutating call to the beacon state which returns the value of the deposit balance to consume field. This method requires access to the RLock on the state and only applies in electra or later.
func (*BeaconState) DepositRequestsStartIndex ¶ added in v5.1.0
func (b *BeaconState) DepositRequestsStartIndex() (uint64, error)
DepositRequestsStartIndex is used for returning the deposit requests start index which is used for eip6110
func (*BeaconState) DequeuePendingPartialWithdrawals ¶ added in v5.2.0
func (b *BeaconState) DequeuePendingPartialWithdrawals(n uint64) error
DequeuePendingPartialWithdrawals removes the partial withdrawals from the beginning of the partial withdrawals list.
func (*BeaconState) EarliestConsolidationEpoch ¶ added in v5.1.0
func (b *BeaconState) EarliestConsolidationEpoch() (primitives.Epoch, error)
EarliestConsolidationEpoch is a non-mutating call to the beacon state which returns the value of the earliest consolidation epoch field. This method requires access to the RLock on the state and only applies in electra or later.
func (*BeaconState) EarliestExitEpoch ¶ added in v5.1.0
func (b *BeaconState) EarliestExitEpoch() (primitives.Epoch, error)
EarliestExitEpoch is used for returning the EarliestExitEpoch as part of eip 7251
func (*BeaconState) Eth1Data ¶
func (b *BeaconState) Eth1Data() *ethpb.Eth1Data
Eth1Data corresponding to the proof-of-work chain information stored in the beacon state.
func (*BeaconState) Eth1DataVotes ¶
func (b *BeaconState) Eth1DataVotes() []*ethpb.Eth1Data
Eth1DataVotes corresponds to votes from Ethereum on the canonical proof-of-work chain data retrieved from eth1.
func (*BeaconState) Eth1DepositIndex ¶
func (b *BeaconState) Eth1DepositIndex() uint64
Eth1DepositIndex corresponds to the index of the deposit made to the validator deposit contract at the time of this state's eth1 data.
func (*BeaconState) ExitBalanceToConsume ¶ added in v5.1.0
func (b *BeaconState) ExitBalanceToConsume() (primitives.Gwei, error)
ExitBalanceToConsume is used for returning the ExitBalanceToConsume as part of eip 7251
func (*BeaconState) ExitEpochAndUpdateChurn ¶ added in v5.1.0
func (b *BeaconState) ExitEpochAndUpdateChurn(exitBalance primitives.Gwei) (primitives.Epoch, error)
ExitEpochAndUpdateChurn computes the exit epoch and updates the churn. This method mutates the state.
Spec definition:
def compute_exit_epoch_and_update_churn(state: BeaconState, exit_balance: Gwei) -> Epoch: earliest_exit_epoch = max(state.earliest_exit_epoch, compute_activation_exit_epoch(get_current_epoch(state))) per_epoch_churn = get_activation_exit_churn_limit(state) # New epoch for exits. if state.earliest_exit_epoch < earliest_exit_epoch: exit_balance_to_consume = per_epoch_churn else: exit_balance_to_consume = state.exit_balance_to_consume # Exit doesn't fit in the current earliest epoch. if exit_balance > exit_balance_to_consume: balance_to_process = exit_balance - exit_balance_to_consume additional_epochs = (balance_to_process - 1) // per_epoch_churn + 1 earliest_exit_epoch += additional_epochs exit_balance_to_consume += additional_epochs * per_epoch_churn # Consume the balance and update state variables. state.exit_balance_to_consume = exit_balance_to_consume - exit_balance state.earliest_exit_epoch = earliest_exit_epoch return state.earliest_exit_epoch
func (*BeaconState) ExpectedWithdrawals ¶
func (b *BeaconState) ExpectedWithdrawals() ([]*enginev1.Withdrawal, uint64, error)
ExpectedWithdrawals returns the withdrawals that a proposer will need to pack in the next block applied to the current state. It is also used by validators to check that the execution payload carried the right number of withdrawals. Note: The number of partial withdrawals will be zero before EIP-7251.
Spec definition:
def get_expected_withdrawals(state: BeaconState) -> Tuple[Sequence[Withdrawal], uint64]: epoch = get_current_epoch(state) withdrawal_index = state.next_withdrawal_index validator_index = state.next_withdrawal_validator_index withdrawals: List[Withdrawal] = [] processed_partial_withdrawals_count = 0 # [New in Electra:EIP7251] Consume pending partial withdrawals for withdrawal in state.pending_partial_withdrawals: if withdrawal.withdrawable_epoch > epoch or len(withdrawals) == MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP: break validator = state.validators[withdrawal.index] has_sufficient_effective_balance = validator.effective_balance >= MIN_ACTIVATION_BALANCE has_excess_balance = state.balances[withdrawal.index] > MIN_ACTIVATION_BALANCE if validator.exit_epoch == FAR_FUTURE_EPOCH and has_sufficient_effective_balance and has_excess_balance: withdrawable_balance = min(state.balances[withdrawal.index] - MIN_ACTIVATION_BALANCE, withdrawal.amount) withdrawals.append(Withdrawal( index=withdrawal_index, validator_index=withdrawal.index, address=ExecutionAddress(validator.withdrawal_credentials[12:]), amount=withdrawable_balance, )) withdrawal_index += WithdrawalIndex(1) processed_partial_withdrawals_count += 1 # Sweep for remaining. bound = min(len(state.validators), MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP) for _ in range(bound): validator = state.validators[validator_index] # [Modified in Electra:EIP7251] partially_withdrawn_balance = sum(withdrawal.amount for withdrawal in withdrawals if withdrawal.validator_index == validator_index) balance = state.balances[validator_index] - partially_withdrawn_balance if is_fully_withdrawable_validator(validator, balance, epoch): withdrawals.append(Withdrawal( index=withdrawal_index, validator_index=validator_index, address=ExecutionAddress(validator.withdrawal_credentials[12:]), amount=balance, )) withdrawal_index += WithdrawalIndex(1) elif is_partially_withdrawable_validator(validator, balance): withdrawals.append(Withdrawal( index=withdrawal_index, validator_index=validator_index, address=ExecutionAddress(validator.withdrawal_credentials[12:]), amount=balance - get_validator_max_effective_balance(validator), # [Modified in Electra:EIP7251] )) withdrawal_index += WithdrawalIndex(1) if len(withdrawals) == MAX_WITHDRAWALS_PER_PAYLOAD: break validator_index = ValidatorIndex((validator_index + 1) % len(state.validators)) return withdrawals, processed_partial_withdrawals_count
func (*BeaconState) FieldReferencesCount ¶
func (b *BeaconState) FieldReferencesCount() map[string]uint64
FieldReferencesCount returns the reference count held by each field. This also includes the field trie held by each field.
func (*BeaconState) FinalizedCheckpoint ¶
func (b *BeaconState) FinalizedCheckpoint() *ethpb.Checkpoint
FinalizedCheckpoint denoting an epoch and block root.
func (*BeaconState) FinalizedCheckpointEpoch ¶
func (b *BeaconState) FinalizedCheckpointEpoch() primitives.Epoch
FinalizedCheckpointEpoch returns the epoch value of the finalized checkpoint.
func (*BeaconState) FinalizedRootProof ¶
func (b *BeaconState) FinalizedRootProof(ctx context.Context) ([][]byte, error)
FinalizedRootProof crafts a Merkle proof for the finalized root contained within the finalized checkpoint of a beacon state.
func (*BeaconState) Fork ¶
func (b *BeaconState) Fork() *ethpb.Fork
Fork version of the beacon chain.
func (*BeaconState) GenesisTime ¶
func (b *BeaconState) GenesisTime() uint64
GenesisTime of the beacon state as a uint64.
func (*BeaconState) GenesisValidatorsRoot ¶
func (b *BeaconState) GenesisValidatorsRoot() []byte
GenesisValidatorsRoot of the beacon state.
func (*BeaconState) HasPendingBalanceToWithdraw ¶ added in v5.1.0
func (b *BeaconState) HasPendingBalanceToWithdraw(idx primitives.ValidatorIndex) (bool, error)
func (*BeaconState) HashTreeRoot ¶
func (b *BeaconState) HashTreeRoot(ctx context.Context) ([32]byte, error)
HashTreeRoot of the beacon state retrieves the Merkle root of the trie representation of the beacon state based on the Ethereum Simple Serialize specification.
func (*BeaconState) HistoricalRoots ¶
func (b *BeaconState) HistoricalRoots() ([][]byte, error)
HistoricalRoots based on epochs stored in the beacon state.
func (*BeaconState) HistoricalSummaries ¶
func (b *BeaconState) HistoricalSummaries() ([]*ethpb.HistoricalSummary, error)
HistoricalSummaries of the beacon state.
func (*BeaconState) Id ¶
func (b *BeaconState) Id() uint64
Id is the identifier of the beacon state.
func (*BeaconState) InactivityPenaltyQuotient ¶
func (b *BeaconState) InactivityPenaltyQuotient() (uint64, error)
func (*BeaconState) InactivityScores ¶
func (b *BeaconState) InactivityScores() ([]uint64, error)
InactivityScores of validators participating in consensus on the beacon chain.
func (*BeaconState) IsNil ¶
func (b *BeaconState) IsNil() bool
IsNil checks if the state and the underlying proto object are nil.
func (*BeaconState) JustificationBits ¶
func (b *BeaconState) JustificationBits() bitfield.Bitvector4
JustificationBits marking which epochs have been justified in the beacon chain.
func (*BeaconState) LatestBlockHeader ¶
func (b *BeaconState) LatestBlockHeader() *ethpb.BeaconBlockHeader
LatestBlockHeader stored within the beacon state.
func (*BeaconState) LatestExecutionPayloadHeader ¶
func (b *BeaconState) LatestExecutionPayloadHeader() (interfaces.ExecutionData, error)
LatestExecutionPayloadHeader of the beacon state.
func (*BeaconState) MarshalJSON ¶
func (b *BeaconState) MarshalJSON() ([]byte, error)
func (*BeaconState) MarshalSSZ ¶
func (b *BeaconState) MarshalSSZ() ([]byte, error)
func (*BeaconState) MatchCurrentJustifiedCheckpoint ¶
func (b *BeaconState) MatchCurrentJustifiedCheckpoint(c *ethpb.Checkpoint) bool
MatchCurrentJustifiedCheckpoint returns true if input justified checkpoint matches the current justified checkpoint in state.
func (*BeaconState) MatchPreviousJustifiedCheckpoint ¶
func (b *BeaconState) MatchPreviousJustifiedCheckpoint(c *ethpb.Checkpoint) bool
MatchPreviousJustifiedCheckpoint returns true if the input justified checkpoint matches the previous justified checkpoint in state.
func (*BeaconState) ModifyCurrentParticipationBits ¶
func (b *BeaconState) ModifyCurrentParticipationBits(mutator func(val []byte) ([]byte, error)) error
ModifyCurrentParticipationBits modifies the current participation bitfield via the provided mutator function.
func (*BeaconState) ModifyPreviousParticipationBits ¶
func (b *BeaconState) ModifyPreviousParticipationBits(mutator func(val []byte) ([]byte, error)) error
ModifyPreviousParticipationBits modifies the previous participation bitfield via the provided mutator function.
func (*BeaconState) NextSyncCommittee ¶
func (b *BeaconState) NextSyncCommittee() (*ethpb.SyncCommittee, error)
NextSyncCommittee of the next sync committee in beacon chain state.
func (*BeaconState) NextSyncCommitteeGeneralizedIndex ¶
func (b *BeaconState) NextSyncCommitteeGeneralizedIndex() (uint64, error)
NextSyncCommitteeGeneralizedIndex for the beacon state.
func (*BeaconState) NextSyncCommitteeProof ¶
func (b *BeaconState) NextSyncCommitteeProof(ctx context.Context) ([][]byte, error)
NextSyncCommitteeProof from the state's Merkle trie representation.
func (*BeaconState) NextWithdrawalIndex ¶
func (b *BeaconState) NextWithdrawalIndex() (uint64, error)
NextWithdrawalIndex returns the index that will be assigned to the next withdrawal.
func (*BeaconState) NextWithdrawalValidatorIndex ¶
func (b *BeaconState) NextWithdrawalValidatorIndex() (primitives.ValidatorIndex, error)
NextWithdrawalValidatorIndex returns the index of the validator which is next in line for a withdrawal.
func (*BeaconState) NumPendingConsolidations ¶ added in v5.1.0
func (b *BeaconState) NumPendingConsolidations() (uint64, error)
NumPendingConsolidations is a non-mutating call to the beacon state which returns the number of pending consolidations in the beacon state. This method requires access to the RLock on the state and only applies in electra or later.
func (*BeaconState) NumPendingPartialWithdrawals ¶ added in v5.1.0
func (b *BeaconState) NumPendingPartialWithdrawals() (uint64, error)
func (*BeaconState) NumValidators ¶
func (b *BeaconState) NumValidators() int
NumValidators returns the size of the validator registry.
func (*BeaconState) PendingBalanceToWithdraw ¶ added in v5.1.0
func (b *BeaconState) PendingBalanceToWithdraw(idx primitives.ValidatorIndex) (uint64, error)
PendingBalanceToWithdraw returns the sum of all pending withdrawals for the given validator.
Spec definition:
def get_pending_balance_to_withdraw(state: BeaconState, validator_index: ValidatorIndex) -> Gwei: return sum( withdrawal.amount for withdrawal in state.pending_partial_withdrawals if withdrawal.index == validator_index)
func (*BeaconState) PendingConsolidations ¶ added in v5.1.0
func (b *BeaconState) PendingConsolidations() ([]*ethpb.PendingConsolidation, error)
PendingConsolidations is a non-mutating call to the beacon state which returns a deep copy of the pending consolidations slice. This method requires access to the RLock on the state and only applies in electra or later.
func (*BeaconState) PendingDeposits ¶ added in v5.2.0
func (b *BeaconState) PendingDeposits() ([]*ethpb.PendingDeposit, error)
PendingDeposits is a non-mutating call to the beacon state which returns a deep copy of the pending balance deposit slice. This method requires access to the RLock on the state and only applies in electra or later.
func (*BeaconState) PendingPartialWithdrawals ¶ added in v5.1.1
func (b *BeaconState) PendingPartialWithdrawals() ([]*ethpb.PendingPartialWithdrawal, error)
func (*BeaconState) PreviousEpochAttestations ¶
func (b *BeaconState) PreviousEpochAttestations() ([]*ethpb.PendingAttestation, error)
PreviousEpochAttestations corresponding to blocks on the beacon chain.
func (*BeaconState) PreviousEpochParticipation ¶
func (b *BeaconState) PreviousEpochParticipation() ([]byte, error)
PreviousEpochParticipation corresponding to participation bits on the beacon chain.
func (*BeaconState) PreviousJustifiedCheckpoint ¶
func (b *BeaconState) PreviousJustifiedCheckpoint() *ethpb.Checkpoint
PreviousJustifiedCheckpoint denoting an epoch and block root.
func (*BeaconState) ProportionalSlashingMultiplier ¶
func (b *BeaconState) ProportionalSlashingMultiplier() (uint64, error)
func (*BeaconState) PubkeyAtIndex ¶
func (b *BeaconState) PubkeyAtIndex(idx primitives.ValidatorIndex) [fieldparams.BLSPubkeyLength]byte
PubkeyAtIndex returns the pubkey at the given validator index.
func (*BeaconState) PublicKeys ¶
func (b *BeaconState) PublicKeys() ([][fieldparams.BLSPubkeyLength]byte, error)
PublicKeys builds a list of all validator public keys, with each key's index aligned to its validator index.
func (*BeaconState) RandaoMixAtIndex ¶
func (b *BeaconState) RandaoMixAtIndex(idx uint64) ([]byte, error)
RandaoMixAtIndex retrieves a specific block root based on an input index value.
func (*BeaconState) RandaoMixes ¶
func (b *BeaconState) RandaoMixes() [][]byte
RandaoMixes of block proposers on the beacon chain.
func (*BeaconState) RandaoMixesLength ¶
func (b *BeaconState) RandaoMixesLength() int
RandaoMixesLength returns the length of the randao mixes slice.
func (*BeaconState) ReadFromEveryValidator ¶
func (b *BeaconState) ReadFromEveryValidator(f func(idx int, val state.ReadOnlyValidator) error) error
ReadFromEveryValidator reads values from every validator and applies it to the provided function.
WARNING: This method is potentially unsafe, as it exposes the actual validator registry.
func (*BeaconState) RecordStateMetrics ¶
func (b *BeaconState) RecordStateMetrics()
RecordStateMetrics proceeds to record any state related metrics data.
func (*BeaconState) RotateAttestations ¶
func (b *BeaconState) RotateAttestations() error
RotateAttestations sets the previous epoch attestations to the current epoch attestations and then clears the current epoch attestations.
func (*BeaconState) SetBalances ¶
func (b *BeaconState) SetBalances(val []uint64) error
SetBalances for the beacon state. Updates the entire list to a new value by overwriting the previous one.
func (*BeaconState) SetBlockRoots ¶
func (b *BeaconState) SetBlockRoots(val [][]byte) error
SetBlockRoots for the beacon state. Updates the entire list to a new value by overwriting the previous one.
func (*BeaconState) SetConsolidationBalanceToConsume ¶ added in v5.1.0
func (b *BeaconState) SetConsolidationBalanceToConsume(balance primitives.Gwei) error
SetConsolidationBalanceToConsume is a mutating call to the beacon state which sets the value of the consolidation balance to consume to the provided value. This method requires access to the Lock on the state and only applies in electra or later.
func (*BeaconState) SetCurrentEpochAttestations ¶
func (b *BeaconState) SetCurrentEpochAttestations(a []*ethpb.PendingAttestation) error
func (*BeaconState) SetCurrentJustifiedCheckpoint ¶
func (b *BeaconState) SetCurrentJustifiedCheckpoint(val *ethpb.Checkpoint) error
SetCurrentJustifiedCheckpoint for the beacon state.
func (*BeaconState) SetCurrentParticipationBits ¶
func (b *BeaconState) SetCurrentParticipationBits(val []byte) error
SetCurrentParticipationBits for the beacon state. Updates the entire list to a new value by overwriting the previous one.
func (*BeaconState) SetCurrentSyncCommittee ¶
func (b *BeaconState) SetCurrentSyncCommittee(val *ethpb.SyncCommittee) error
SetCurrentSyncCommittee for the beacon state.
func (*BeaconState) SetDepositBalanceToConsume ¶ added in v5.1.0
func (b *BeaconState) SetDepositBalanceToConsume(dbtc primitives.Gwei) error
SetDepositBalanceToConsume is a mutating call to the beacon state which sets the deposit balance to consume value to the given value. This method requires access to the Lock on the state and only applies in electra or later.
func (*BeaconState) SetDepositRequestsStartIndex ¶ added in v5.1.0
func (b *BeaconState) SetDepositRequestsStartIndex(index uint64) error
SetDepositRequestsStartIndex for the beacon state. Updates the DepositRequestsStartIndex
func (*BeaconState) SetEarliestConsolidationEpoch ¶ added in v5.1.0
func (b *BeaconState) SetEarliestConsolidationEpoch(epoch primitives.Epoch) error
SetEarliestConsolidationEpoch is a mutating call to the beacon state which sets the earliest consolidation epoch value. This method requires access to the Lock on the state and only applies in electra or later.
func (*BeaconState) SetEth1Data ¶
func (b *BeaconState) SetEth1Data(val *ethpb.Eth1Data) error
SetEth1Data for the beacon state.
func (*BeaconState) SetEth1DataVotes ¶
func (b *BeaconState) SetEth1DataVotes(val []*ethpb.Eth1Data) error
SetEth1DataVotes for the beacon state. Updates the entire list to a new value by overwriting the previous one.
func (*BeaconState) SetEth1DepositIndex ¶
func (b *BeaconState) SetEth1DepositIndex(val uint64) error
SetEth1DepositIndex for the beacon state.
func (*BeaconState) SetFinalizedCheckpoint ¶
func (b *BeaconState) SetFinalizedCheckpoint(val *ethpb.Checkpoint) error
SetFinalizedCheckpoint for the beacon state.
func (*BeaconState) SetFork ¶
func (b *BeaconState) SetFork(val *ethpb.Fork) error
SetFork version for the beacon chain.
func (*BeaconState) SetGenesisTime ¶
func (b *BeaconState) SetGenesisTime(val uint64) error
SetGenesisTime for the beacon state.
func (*BeaconState) SetGenesisValidatorsRoot ¶
func (b *BeaconState) SetGenesisValidatorsRoot(val []byte) error
SetGenesisValidatorsRoot for the beacon state.
func (*BeaconState) SetHistoricalRoots ¶
func (b *BeaconState) SetHistoricalRoots(val [][]byte) error
SetHistoricalRoots for the beacon state. Updates the entire list to a new value by overwriting the previous one.
func (*BeaconState) SetInactivityScores ¶
func (b *BeaconState) SetInactivityScores(val []uint64) error
SetInactivityScores for the beacon state. Updates the entire list to a new value by overwriting the previous one.
func (*BeaconState) SetJustificationBits ¶
func (b *BeaconState) SetJustificationBits(val bitfield.Bitvector4) error
SetJustificationBits for the beacon state.
func (*BeaconState) SetLatestBlockHeader ¶
func (b *BeaconState) SetLatestBlockHeader(val *ethpb.BeaconBlockHeader) error
SetLatestBlockHeader in the beacon state.
func (*BeaconState) SetLatestExecutionPayloadHeader ¶
func (b *BeaconState) SetLatestExecutionPayloadHeader(val interfaces.ExecutionData) error
SetLatestExecutionPayloadHeader for the beacon state.
func (*BeaconState) SetNextSyncCommittee ¶
func (b *BeaconState) SetNextSyncCommittee(val *ethpb.SyncCommittee) error
SetNextSyncCommittee for the beacon state.
func (*BeaconState) SetNextWithdrawalIndex ¶
func (b *BeaconState) SetNextWithdrawalIndex(i uint64) error
SetNextWithdrawalIndex sets the index that will be assigned to the next withdrawal.
func (*BeaconState) SetNextWithdrawalValidatorIndex ¶
func (b *BeaconState) SetNextWithdrawalValidatorIndex(i primitives.ValidatorIndex) error
SetNextWithdrawalValidatorIndex sets the index of the validator which is next in line for a partial withdrawal.
func (*BeaconState) SetPendingConsolidations ¶ added in v5.1.0
func (b *BeaconState) SetPendingConsolidations(val []*ethpb.PendingConsolidation) error
SetPendingConsolidations is a mutating call to the beacon state which replaces the slice on the state with the given value. This method requires access to the Lock on the state and only applies in electra or later.
func (*BeaconState) SetPendingDeposits ¶ added in v5.2.0
func (b *BeaconState) SetPendingDeposits(val []*ethpb.PendingDeposit) error
SetPendingDeposits is a mutating call to the beacon state which replaces the pending balance deposit slice with the provided value. This method requires access to the Lock on the state and only applies in electra or later.
func (*BeaconState) SetPreviousEpochAttestations ¶
func (b *BeaconState) SetPreviousEpochAttestations(a []*ethpb.PendingAttestation) error
func (*BeaconState) SetPreviousJustifiedCheckpoint ¶
func (b *BeaconState) SetPreviousJustifiedCheckpoint(val *ethpb.Checkpoint) error
SetPreviousJustifiedCheckpoint for the beacon state.
func (*BeaconState) SetPreviousParticipationBits ¶
func (b *BeaconState) SetPreviousParticipationBits(val []byte) error
SetPreviousParticipationBits for the beacon state. Updates the entire list to a new value by overwriting the previous one.
func (*BeaconState) SetRandaoMixes ¶
func (b *BeaconState) SetRandaoMixes(val [][]byte) error
SetRandaoMixes for the beacon state. Updates the entire randao mixes to a new value by overwriting the previous one.
func (*BeaconState) SetSlashings ¶
func (b *BeaconState) SetSlashings(val []uint64) error
SetSlashings for the beacon state. Updates the entire list to a new value by overwriting the previous one.
func (*BeaconState) SetSlot ¶
func (b *BeaconState) SetSlot(val primitives.Slot) error
SetSlot for the beacon state.
func (*BeaconState) SetStateRoots ¶
func (b *BeaconState) SetStateRoots(val [][]byte) error
SetStateRoots for the beacon state. Updates the state roots to a new value by overwriting the previous value.
func (*BeaconState) SetValidators ¶
func (b *BeaconState) SetValidators(val []*ethpb.Validator) error
SetValidators for the beacon state. Updates the entire to a new value by overwriting the previous one.
func (*BeaconState) Slashings ¶
func (b *BeaconState) Slashings() []uint64
Slashings of validators on the beacon chain.
func (*BeaconState) Slot ¶
func (b *BeaconState) Slot() primitives.Slot
Slot of the current beacon chain state.
func (*BeaconState) StateRootAtIndex ¶
func (b *BeaconState) StateRootAtIndex(idx uint64) ([]byte, error)
StateRootAtIndex retrieves a specific state root based on an input index value.
func (*BeaconState) StateRoots ¶
func (b *BeaconState) StateRoots() [][]byte
StateRoots kept track of in the beacon state.
func (*BeaconState) ToProto ¶
func (b *BeaconState) ToProto() interface{}
ToProto the beacon state into a protobuf for usage.
func (*BeaconState) ToProtoUnsafe ¶
func (b *BeaconState) ToProtoUnsafe() interface{}
ToProtoUnsafe returns the pointer value of the underlying beacon state proto object, bypassing immutability. Use with care.
func (*BeaconState) UnrealizedCheckpointBalances ¶
func (b *BeaconState) UnrealizedCheckpointBalances() (uint64, uint64, uint64, error)
UnrealizedCheckpointBalances returns the total balances: active, target attested in current epoch and target attested in previous epoch. This function is used to compute the "unrealized justification" that a synced Beacon Block will have.
func (*BeaconState) UpdateBalancesAtIndex ¶
func (b *BeaconState) UpdateBalancesAtIndex(idx primitives.ValidatorIndex, val uint64) error
UpdateBalancesAtIndex for the beacon state. This method updates the balance at a specific index to a new value.
func (*BeaconState) UpdateBlockRootAtIndex ¶
func (b *BeaconState) UpdateBlockRootAtIndex(idx uint64, blockRoot [32]byte) error
UpdateBlockRootAtIndex for the beacon state. Updates the block root at a specific index to a new value.
func (*BeaconState) UpdateRandaoMixesAtIndex ¶
func (b *BeaconState) UpdateRandaoMixesAtIndex(idx uint64, val [32]byte) error
UpdateRandaoMixesAtIndex for the beacon state. Updates the randao mixes at a specific index to a new value.
func (*BeaconState) UpdateSlashingsAtIndex ¶
func (b *BeaconState) UpdateSlashingsAtIndex(idx, val uint64) error
UpdateSlashingsAtIndex for the beacon state. Updates the slashings at a specific index to a new value.
func (*BeaconState) UpdateStateRootAtIndex ¶
func (b *BeaconState) UpdateStateRootAtIndex(idx uint64, stateRoot [32]byte) error
UpdateStateRootAtIndex for the beacon state. Updates the state root at a specific index to a new value.
func (*BeaconState) UpdateValidatorAtIndex ¶
func (b *BeaconState) UpdateValidatorAtIndex(idx primitives.ValidatorIndex, val *ethpb.Validator) error
UpdateValidatorAtIndex for the beacon state. Updates the validator at a specific index to a new value.
func (*BeaconState) ValidatorAtIndex ¶
func (b *BeaconState) ValidatorAtIndex(idx primitives.ValidatorIndex) (*ethpb.Validator, error)
ValidatorAtIndex is the validator at the provided index.
func (*BeaconState) ValidatorAtIndexReadOnly ¶
func (b *BeaconState) ValidatorAtIndexReadOnly(idx primitives.ValidatorIndex) (state.ReadOnlyValidator, error)
ValidatorAtIndexReadOnly is the validator at the provided index. This method doesn't clone the validator.
func (*BeaconState) ValidatorIndexByPubkey ¶
func (b *BeaconState) ValidatorIndexByPubkey(key [fieldparams.BLSPubkeyLength]byte) (primitives.ValidatorIndex, bool)
ValidatorIndexByPubkey returns a given validator by its 48-byte public key.
func (*BeaconState) Validators ¶
func (b *BeaconState) Validators() []*ethpb.Validator
Validators participating in consensus on the beacon chain.
func (*BeaconState) ValidatorsReadOnly ¶ added in v5.0.4
func (b *BeaconState) ValidatorsReadOnly() []state.ReadOnlyValidator
ValidatorsReadOnly participating in consensus on the beacon chain.
func (*BeaconState) Version ¶
func (b *BeaconState) Version() int
Version of the beacon state. This method is strictly meant to be used without a lock internally.
type MultiValueBalances ¶
type MultiValueBalances = multi_value_slice.Slice[uint64]
MultiValueBalances is a multi-value slice of balances.
func NewMultiValueBalances ¶
func NewMultiValueBalances(balances []uint64) *MultiValueBalances
NewMultiValueBalances creates a new slice whose shared items will be populated with copies of input values.
type MultiValueBlockRoots ¶
type MultiValueBlockRoots = multi_value_slice.Slice[[32]byte]
MultiValueBlockRoots is a multi-value slice of block roots.
func NewMultiValueBlockRoots ¶
func NewMultiValueBlockRoots(roots [][]byte) *MultiValueBlockRoots
NewMultiValueBlockRoots creates a new slice whose shared items will be populated with copies of input values.
type MultiValueInactivityScores ¶
type MultiValueInactivityScores = multi_value_slice.Slice[uint64]
MultiValueInactivityScores is a multi-value slice of inactivity scores.
func NewMultiValueInactivityScores ¶
func NewMultiValueInactivityScores(scores []uint64) *MultiValueInactivityScores
NewMultiValueInactivityScores creates a new slice whose shared items will be populated with copies of input values.
type MultiValueRandaoMixes ¶
type MultiValueRandaoMixes = multi_value_slice.Slice[[32]byte]
MultiValueRandaoMixes is a multi-value slice of randao mixes.
func NewMultiValueRandaoMixes ¶
func NewMultiValueRandaoMixes(mixes [][]byte) *MultiValueRandaoMixes
NewMultiValueRandaoMixes creates a new slice whose shared items will be populated with copies of input values.
type MultiValueStateRoots ¶
type MultiValueStateRoots = multi_value_slice.Slice[[32]byte]
MultiValueStateRoots is a multi-value slice of state roots.
func NewMultiValueStateRoots ¶
func NewMultiValueStateRoots(roots [][]byte) *MultiValueStateRoots
NewMultiValueStateRoots creates a new slice whose shared items will be populated with copies of input values.
type MultiValueValidators ¶
type MultiValueValidators = multi_value_slice.Slice[*ethpb.Validator]
MultiValueValidators is a multi-value slice of validator references.
func NewMultiValueValidators ¶
func NewMultiValueValidators(vals []*ethpb.Validator) *MultiValueValidators
NewMultiValueValidators creates a new slice whose shared items will be populated with input values.
Source Files ¶
- beacon_state.go
- doc.go
- error.go
- getters_attestation.go
- getters_block.go
- getters_checkpoint.go
- getters_consolidation.go
- getters_deposit_requests.go
- getters_deposits.go
- getters_eth1.go
- getters_exit.go
- getters_misc.go
- getters_participation.go
- getters_payload_header.go
- getters_randao.go
- getters_state.go
- getters_sync_committee.go
- getters_validator.go
- getters_withdrawal.go
- hasher.go
- multi_value_slices.go
- proofs.go
- readonly_validator.go
- setters_attestation.go
- setters_block.go
- setters_checkpoint.go
- setters_churn.go
- setters_consolidation.go
- setters_deposit_requests.go
- setters_deposits.go
- setters_eth1.go
- setters_misc.go
- setters_participation.go
- setters_payload_header.go
- setters_randao.go
- setters_state.go
- setters_sync_committee.go
- setters_validator.go
- setters_withdrawal.go
- spec_parameters.go
- ssz.go
- state_trie.go
- types.go