Documentation ¶
Overview ¶
Package stateV0 defines how the beacon chain state for eth2 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 carries out the short-circuit conditions, obtains a read lock, then calls the internal function. The internal function carries out the short-circuit conditions and 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 { // Short-circuit conditions. if !b.hasInnerState() { return 0 } // Read lock. b.lock.RLock() defer b.lock.RUnlock() // Internal getter. return b.foo() } func (b *BeaconState) foo() uint64 { // Short-circuit conditions. if !b.hasInnerState() { return 0 } return b.state.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 ¶
- Variables
- func CopyAttestation(att *ethpb.Attestation) *ethpb.Attestation
- func CopyAttestationData(attData *ethpb.AttestationData) *ethpb.AttestationData
- func CopyAttestations(attestations []*ethpb.Attestation) []*ethpb.Attestation
- func CopyAttesterSlashings(slashings []*ethpb.AttesterSlashing) []*ethpb.AttesterSlashing
- func CopyBeaconBlock(block *ethpb.BeaconBlock) *ethpb.BeaconBlock
- func CopyBeaconBlockBody(body *ethpb.BeaconBlockBody) *ethpb.BeaconBlockBody
- func CopyBeaconBlockHeader(header *ethpb.BeaconBlockHeader) *ethpb.BeaconBlockHeader
- func CopyCheckpoint(cp *ethpb.Checkpoint) *ethpb.Checkpoint
- func CopyDeposit(deposit *ethpb.Deposit) *ethpb.Deposit
- func CopyDepositData(depData *ethpb.Deposit_Data) *ethpb.Deposit_Data
- func CopyDeposits(deposits []*ethpb.Deposit) []*ethpb.Deposit
- func CopyETH1Data(data *ethpb.Eth1Data) *ethpb.Eth1Data
- func CopyIndexedAttestation(indexedAtt *ethpb.IndexedAttestation) *ethpb.IndexedAttestation
- func CopyPendingAttestation(att *pbp2p.PendingAttestation) *pbp2p.PendingAttestation
- func CopyProposerSlashing(slashing *ethpb.ProposerSlashing) *ethpb.ProposerSlashing
- func CopyProposerSlashings(slashings []*ethpb.ProposerSlashing) []*ethpb.ProposerSlashing
- func CopySignedBeaconBlock(sigBlock *ethpb.SignedBeaconBlock) *ethpb.SignedBeaconBlock
- func CopySignedBeaconBlockHeader(header *ethpb.SignedBeaconBlockHeader) *ethpb.SignedBeaconBlockHeader
- func CopySignedVoluntaryExit(exit *ethpb.SignedVoluntaryExit) *ethpb.SignedVoluntaryExit
- func CopySignedVoluntaryExits(exits []*ethpb.SignedVoluntaryExit) []*ethpb.SignedVoluntaryExit
- func CopyValidator(val *ethpb.Validator) *ethpb.Validator
- func ProtobufBeaconState(s interface{}) (*pbp2p.BeaconState, error)
- func RootsArrayHashTreeRoot(vals [][]byte, length uint64, fieldName string) ([32]byte, error)
- func ValidatorRegistryRoot(vals []*ethpb.Validator) ([32]byte, error)
- type BeaconState
- func (b *BeaconState) AppendBalance(bal uint64) error
- func (b *BeaconState) AppendCurrentEpochAttestations(val *pbp2p.PendingAttestation) error
- func (b *BeaconState) AppendEth1DataVotes(val *ethpb.Eth1Data) error
- func (b *BeaconState) AppendHistoricalRoots(root [32]byte) error
- func (b *BeaconState) AppendPreviousEpochAttestations(val *pbp2p.PendingAttestation) error
- func (b *BeaconState) AppendValidator(val *ethpb.Validator) error
- func (b *BeaconState) ApplyToEveryValidator(f func(idx int, val *ethpb.Validator) (bool, *ethpb.Validator, error)) error
- func (b *BeaconState) BalanceAtIndex(idx types.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) CloneInnerState() interface{}
- func (b *BeaconState) Copy() iface.BeaconState
- func (b *BeaconState) CurrentEpochAttestations() ([]*pbp2p.PendingAttestation, error)
- func (b *BeaconState) CurrentJustifiedCheckpoint() *ethpb.Checkpoint
- func (b *BeaconState) Eth1Data() *ethpb.Eth1Data
- func (b *BeaconState) Eth1DataVotes() []*ethpb.Eth1Data
- func (b *BeaconState) Eth1DepositIndex() uint64
- func (b *BeaconState) FieldReferencesCount() map[string]uint64
- func (b *BeaconState) FinalizedCheckpoint() *ethpb.Checkpoint
- func (b *BeaconState) FinalizedCheckpointEpoch() types.Epoch
- func (b *BeaconState) Fork() *pbp2p.Fork
- func (b *BeaconState) GenesisTime() uint64
- func (b *BeaconState) GenesisValidatorRoot() []byte
- func (b *BeaconState) HashTreeRoot(ctx context.Context) ([32]byte, error)
- func (b *BeaconState) HistoricalRoots() [][]byte
- func (b *BeaconState) InnerStateUnsafe() interface{}
- func (b *BeaconState) JustificationBits() bitfield.Bitvector4
- func (b *BeaconState) LatestBlockHeader() *ethpb.BeaconBlockHeader
- 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) NumValidators() int
- func (b *BeaconState) PreviousEpochAttestations() ([]*pbp2p.PendingAttestation, error)
- func (b *BeaconState) PreviousJustifiedCheckpoint() *ethpb.Checkpoint
- func (b *BeaconState) PubkeyAtIndex(idx types.ValidatorIndex) [48]byte
- 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 iface.ReadOnlyValidator) error) error
- func (b *BeaconState) RotateAttestations() error
- func (b *BeaconState) SetBalances(val []uint64) error
- func (b *BeaconState) SetBlockRoots(val [][]byte) error
- func (b *BeaconState) SetCurrentJustifiedCheckpoint(val *ethpb.Checkpoint) 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 *pbp2p.Fork) error
- func (b *BeaconState) SetGenesisTime(val uint64) error
- func (b *BeaconState) SetGenesisValidatorRoot(val []byte) error
- func (b *BeaconState) SetHistoricalRoots(val [][]byte) error
- func (b *BeaconState) SetJustificationBits(val bitfield.Bitvector4) error
- func (b *BeaconState) SetLatestBlockHeader(val *ethpb.BeaconBlockHeader) error
- func (b *BeaconState) SetPreviousJustifiedCheckpoint(val *ethpb.Checkpoint) error
- func (b *BeaconState) SetRandaoMixes(val [][]byte) error
- func (b *BeaconState) SetSlashings(val []uint64) error
- func (b *BeaconState) SetSlot(val types.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() types.Slot
- func (b *BeaconState) StateRootAtIndex(idx uint64) ([]byte, error)
- func (b *BeaconState) StateRoots() [][]byte
- func (b *BeaconState) ToProto() (*v1.BeaconState, error)
- func (b *BeaconState) UpdateBalancesAtIndex(idx types.ValidatorIndex, val uint64) error
- func (b *BeaconState) UpdateBlockRootAtIndex(idx uint64, blockRoot [32]byte) error
- func (b *BeaconState) UpdateRandaoMixesAtIndex(idx uint64, val []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 types.ValidatorIndex, val *ethpb.Validator) error
- func (b *BeaconState) ValidatorAtIndex(idx types.ValidatorIndex) (*ethpb.Validator, error)
- func (b *BeaconState) ValidatorAtIndexReadOnly(idx types.ValidatorIndex) (iface.ReadOnlyValidator, error)
- func (b *BeaconState) ValidatorIndexByPubkey(key [48]byte) (types.ValidatorIndex, bool)
- func (b *BeaconState) Validators() []*ethpb.Validator
- type FieldTrie
- type ReadOnlyValidator
- func (v ReadOnlyValidator) ActivationEligibilityEpoch() types.Epoch
- func (v ReadOnlyValidator) ActivationEpoch() types.Epoch
- func (v ReadOnlyValidator) EffectiveBalance() uint64
- func (v ReadOnlyValidator) ExitEpoch() types.Epoch
- func (v ReadOnlyValidator) IsNil() bool
- func (v ReadOnlyValidator) PublicKey() [48]byte
- func (v ReadOnlyValidator) Slashed() bool
- func (v ReadOnlyValidator) WithdrawableEpoch() types.Epoch
- func (v ReadOnlyValidator) WithdrawalCredentials() []byte
Constants ¶
This section is empty.
Variables ¶
var ErrNilInnerState = errors.New("nil inner state")
ErrNilInnerState returns when the inner state is nil and no copy set or get operations can be performed on state.
Functions ¶
func CopyAttestation ¶
func CopyAttestation(att *ethpb.Attestation) *ethpb.Attestation
CopyAttestation copies the provided attestation object.
func CopyAttestationData ¶
func CopyAttestationData(attData *ethpb.AttestationData) *ethpb.AttestationData
CopyAttestationData copies the provided AttestationData object.
func CopyAttestations ¶
func CopyAttestations(attestations []*ethpb.Attestation) []*ethpb.Attestation
CopyAttestations copies the provided Attestation array.
func CopyAttesterSlashings ¶
func CopyAttesterSlashings(slashings []*ethpb.AttesterSlashing) []*ethpb.AttesterSlashing
CopyAttesterSlashings copies the provided AttesterSlashings array.
func CopyBeaconBlock ¶
func CopyBeaconBlock(block *ethpb.BeaconBlock) *ethpb.BeaconBlock
CopyBeaconBlock copies the provided BeaconBlock.
func CopyBeaconBlockBody ¶
func CopyBeaconBlockBody(body *ethpb.BeaconBlockBody) *ethpb.BeaconBlockBody
CopyBeaconBlockBody copies the provided BeaconBlockBody.
func CopyBeaconBlockHeader ¶
func CopyBeaconBlockHeader(header *ethpb.BeaconBlockHeader) *ethpb.BeaconBlockHeader
CopyBeaconBlockHeader copies the provided BeaconBlockHeader.
func CopyCheckpoint ¶
func CopyCheckpoint(cp *ethpb.Checkpoint) *ethpb.Checkpoint
CopyCheckpoint copies the provided checkpoint.
func CopyDeposit ¶
CopyDeposit copies the provided deposit.
func CopyDepositData ¶
func CopyDepositData(depData *ethpb.Deposit_Data) *ethpb.Deposit_Data
CopyDepositData copies the provided deposit data.
func CopyDeposits ¶
CopyDeposits copies the provided deposit array.
func CopyETH1Data ¶
CopyETH1Data copies the provided eth1data object.
func CopyIndexedAttestation ¶
func CopyIndexedAttestation(indexedAtt *ethpb.IndexedAttestation) *ethpb.IndexedAttestation
CopyIndexedAttestation copies the provided IndexedAttestation.
func CopyPendingAttestation ¶
func CopyPendingAttestation(att *pbp2p.PendingAttestation) *pbp2p.PendingAttestation
CopyPendingAttestation copies the provided pending attestation object.
func CopyProposerSlashing ¶
func CopyProposerSlashing(slashing *ethpb.ProposerSlashing) *ethpb.ProposerSlashing
CopyProposerSlashing copies the provided ProposerSlashing.
func CopyProposerSlashings ¶
func CopyProposerSlashings(slashings []*ethpb.ProposerSlashing) []*ethpb.ProposerSlashing
CopyProposerSlashings copies the provided ProposerSlashing array.
func CopySignedBeaconBlock ¶
func CopySignedBeaconBlock(sigBlock *ethpb.SignedBeaconBlock) *ethpb.SignedBeaconBlock
CopySignedBeaconBlock copies the provided SignedBeaconBlock.
func CopySignedBeaconBlockHeader ¶
func CopySignedBeaconBlockHeader(header *ethpb.SignedBeaconBlockHeader) *ethpb.SignedBeaconBlockHeader
CopySignedBeaconBlockHeader copies the provided SignedBeaconBlockHeader.
func CopySignedVoluntaryExit ¶
func CopySignedVoluntaryExit(exit *ethpb.SignedVoluntaryExit) *ethpb.SignedVoluntaryExit
CopySignedVoluntaryExit copies the provided SignedVoluntaryExit.
func CopySignedVoluntaryExits ¶
func CopySignedVoluntaryExits(exits []*ethpb.SignedVoluntaryExit) []*ethpb.SignedVoluntaryExit
CopySignedVoluntaryExits copies the provided SignedVoluntaryExits array.
func CopyValidator ¶
CopyValidator copies the provided validator.
func ProtobufBeaconState ¶
func ProtobufBeaconState(s interface{}) (*pbp2p.BeaconState, error)
ProtobufBeaconState transforms an input into beacon state in the form of protobuf. Error is returned if the input is not type protobuf beacon state.
func RootsArrayHashTreeRoot ¶
RootsArrayHashTreeRoot computes the Merkle root of arrays of 32-byte hashes, such as [64][32]byte according to the Simple Serialize specification of eth2.
Types ¶
type BeaconState ¶
type BeaconState struct {
// contains filtered or unexported fields
}
BeaconState defines a struct containing utilities for the eth2 chain state, defining getters and setters for its respective values and helpful functions such as HashTreeRoot().
func InitializeFromProto ¶
func InitializeFromProto(st *pbp2p.BeaconState) (*BeaconState, error)
InitializeFromProto the beacon state from a protobuf representation.
func InitializeFromProtoUnsafe ¶
func InitializeFromProtoUnsafe(st *pbp2p.BeaconState) (*BeaconState, error)
InitializeFromProtoUnsafe directly uses the beacon state protobuf pointer and sets it as the inner state of the BeaconState type.
func (*BeaconState) AppendBalance ¶
func (b *BeaconState) AppendBalance(bal uint64) error
AppendBalance for the beacon state. Appends the new value to the the end of list.
func (*BeaconState) AppendCurrentEpochAttestations ¶
func (b *BeaconState) AppendCurrentEpochAttestations(val *pbp2p.PendingAttestation) error
AppendCurrentEpochAttestations for the beacon state. Appends the new value to the 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 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 the end of list.
func (*BeaconState) AppendPreviousEpochAttestations ¶
func (b *BeaconState) AppendPreviousEpochAttestations(val *pbp2p.PendingAttestation) error
AppendPreviousEpochAttestations for the beacon state. Appends the new value to the 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 the end of list.
func (*BeaconState) ApplyToEveryValidator ¶
func (b *BeaconState) ApplyToEveryValidator(f func(idx int, val *ethpb.Validator) (bool, *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 types.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) CloneInnerState ¶
func (b *BeaconState) CloneInnerState() interface{}
CloneInnerState the beacon state into a protobuf for usage.
func (*BeaconState) Copy ¶
func (b *BeaconState) Copy() iface.BeaconState
Copy returns a deep copy of the beacon state.
func (*BeaconState) CurrentEpochAttestations ¶
func (b *BeaconState) CurrentEpochAttestations() ([]*pbp2p.PendingAttestation, error)
CurrentEpochAttestations corresponding to blocks on the beacon chain.
func (*BeaconState) CurrentJustifiedCheckpoint ¶
func (b *BeaconState) CurrentJustifiedCheckpoint() *ethpb.Checkpoint
CurrentJustifiedCheckpoint denoting an epoch and block root.
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 eth2 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) 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() types.Epoch
FinalizedCheckpointEpoch returns the epoch value of the finalized checkpoint.
func (*BeaconState) Fork ¶
func (b *BeaconState) Fork() *pbp2p.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) GenesisValidatorRoot ¶
func (b *BeaconState) GenesisValidatorRoot() []byte
GenesisValidatorRoot of the beacon state.
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 eth2 Simple Serialize specification.
func (*BeaconState) HistoricalRoots ¶
func (b *BeaconState) HistoricalRoots() [][]byte
HistoricalRoots based on epochs stored in the beacon state.
func (*BeaconState) InnerStateUnsafe ¶
func (b *BeaconState) InnerStateUnsafe() interface{}
InnerStateUnsafe returns the pointer value of the underlying beacon state proto object, bypassing immutability. Use with care.
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) MarshalSSZ ¶
func (b *BeaconState) MarshalSSZ() ([]byte, error)
MarshalSSZ marshals the underlying beacon state to bytes.
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) NumValidators ¶
func (b *BeaconState) NumValidators() int
NumValidators returns the size of the validator registry.
func (*BeaconState) PreviousEpochAttestations ¶
func (b *BeaconState) PreviousEpochAttestations() ([]*pbp2p.PendingAttestation, error)
PreviousEpochAttestations corresponding to blocks on the beacon chain.
func (*BeaconState) PreviousJustifiedCheckpoint ¶
func (b *BeaconState) PreviousJustifiedCheckpoint() *ethpb.Checkpoint
PreviousJustifiedCheckpoint denoting an epoch and block root.
func (*BeaconState) PubkeyAtIndex ¶
func (b *BeaconState) PubkeyAtIndex(idx types.ValidatorIndex) [48]byte
PubkeyAtIndex returns the pubkey at the given 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 iface.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) RotateAttestations ¶ added in v1.3.5
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) SetCurrentJustifiedCheckpoint ¶
func (b *BeaconState) SetCurrentJustifiedCheckpoint(val *ethpb.Checkpoint) error
SetCurrentJustifiedCheckpoint for the beacon state.
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 *pbp2p.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) SetGenesisValidatorRoot ¶
func (b *BeaconState) SetGenesisValidatorRoot(val []byte) error
SetGenesisValidatorRoot 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) 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) SetPreviousJustifiedCheckpoint ¶
func (b *BeaconState) SetPreviousJustifiedCheckpoint(val *ethpb.Checkpoint) error
SetPreviousJustifiedCheckpoint for the beacon state.
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 types.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() types.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 ¶ added in v1.3.6
func (b *BeaconState) ToProto() (*v1.BeaconState, error)
ToProto returns a protobuf *v1.BeaconState representation of the state.
func (*BeaconState) UpdateBalancesAtIndex ¶
func (b *BeaconState) UpdateBalancesAtIndex(idx types.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 []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 types.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 types.ValidatorIndex) (*ethpb.Validator, error)
ValidatorAtIndex is the validator at the provided index.
func (*BeaconState) ValidatorAtIndexReadOnly ¶
func (b *BeaconState) ValidatorAtIndexReadOnly(idx types.ValidatorIndex) (iface.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 [48]byte) (types.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.
type FieldTrie ¶
FieldTrie is the representation of the representative trie of the particular field.
func NewFieldTrie ¶
NewFieldTrie is the constructor for the field trie data structure. It creates the corresponding trie according to the given parameters. Depending on whether the field is a basic/composite array which is either fixed/variable length, it will appropriately determine the trie.
func (*FieldTrie) RecomputeTrie ¶
RecomputeTrie rebuilds the affected branches in the trie according to the provided changed indices and elements. This recomputes the trie according to the particular field the trie is based on.
type ReadOnlyValidator ¶
type ReadOnlyValidator struct {
// contains filtered or unexported fields
}
ReadOnlyValidator returns a wrapper that only allows fields from a validator to be read, and prevents any modification of internal validator fields.
func (ReadOnlyValidator) ActivationEligibilityEpoch ¶
func (v ReadOnlyValidator) ActivationEligibilityEpoch() types.Epoch
ActivationEligibilityEpoch returns the activation eligibility epoch of the read only validator.
func (ReadOnlyValidator) ActivationEpoch ¶
func (v ReadOnlyValidator) ActivationEpoch() types.Epoch
ActivationEpoch returns the activation epoch of the read only validator.
func (ReadOnlyValidator) EffectiveBalance ¶
func (v ReadOnlyValidator) EffectiveBalance() uint64
EffectiveBalance returns the effective balance of the read only validator.
func (ReadOnlyValidator) ExitEpoch ¶
func (v ReadOnlyValidator) ExitEpoch() types.Epoch
ExitEpoch returns the exit epoch of the read only validator.
func (ReadOnlyValidator) IsNil ¶
func (v ReadOnlyValidator) IsNil() bool
IsNil returns true if the validator is nil.
func (ReadOnlyValidator) PublicKey ¶
func (v ReadOnlyValidator) PublicKey() [48]byte
PublicKey returns the public key of the read only validator.
func (ReadOnlyValidator) Slashed ¶
func (v ReadOnlyValidator) Slashed() bool
Slashed returns the read only validator is slashed.
func (ReadOnlyValidator) WithdrawableEpoch ¶
func (v ReadOnlyValidator) WithdrawableEpoch() types.Epoch
WithdrawableEpoch returns the withdrawable epoch of the read only validator.
func (ReadOnlyValidator) WithdrawalCredentials ¶
func (v ReadOnlyValidator) WithdrawalCredentials() []byte
WithdrawalCredentials returns the withdrawal credentials of the read only validator.
Source Files ¶
- cloners.go
- doc.go
- field_roots.go
- field_trie.go
- field_trie_helpers.go
- getters_attestation.go
- getters_block.go
- getters_checkpoint.go
- getters_eth1.go
- getters_misc.go
- getters_randao.go
- getters_state.go
- getters_validator.go
- setters_attestation.go
- setters_block.go
- setters_checkpoint.go
- setters_eth1.go
- setters_misc.go
- setters_randao.go
- setters_state.go
- setters_validator.go
- state_trie.go
- types.go
- validator_getters.go