state_accessors

package
v0.0.0-...-1f8a15b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2023 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownEvent = errors.New("unknown event")

Functions

func GetStateProcessingProgress

func GetStateProcessingProgress(tx kv.Tx) (uint64, error)

func IncrementHistoricalRootsTable

func IncrementHistoricalRootsTable(tx kv.RwTx, state *state.CachingBeaconState, preverifiedIndicies uint64) error

func IncrementHistoricalSummariesTable

func IncrementHistoricalSummariesTable(tx kv.RwTx, state *state.CachingBeaconState, preverifiedIndicies uint64) error

func IncrementPublicKeyTable

func IncrementPublicKeyTable(tx kv.RwTx, state *state.CachingBeaconState, preverifiedIndicies uint64) error

IncrementValidatorTable increments the validator table in the database, by ignoring all the preverified indices.

func InitializeStaticTables

func InitializeStaticTables(tx kv.RwTx, state *state.CachingBeaconState) error

InitializeValidatorTable initializes the validator table in the database.

func ReadCheckpoints

func ReadCheckpoints(tx kv.Tx, slot uint64) (current solid.Checkpoint, previous solid.Checkpoint, finalized solid.Checkpoint, err error)

ReadCheckpoints reads the checkpoints from the database, Current, Previous and Finalized

func ReadCurrentEpochAttestations

func ReadCurrentEpochAttestations(tx kv.Tx, slot uint64, limit int) (*solid.ListSSZ[*solid.PendingAttestation], error)

func ReadCurrentSyncCommittee

func ReadCurrentSyncCommittee(tx kv.Tx, slot uint64) (committee *solid.SyncCommittee, err error)

ReadCheckpoints reads the checkpoints from the database, Current, Previous and Finalized

func ReadHistoricalRoots

func ReadHistoricalRoots(tx kv.Tx, l uint64, fn func(idx int, root libcommon.Hash) error) error

func ReadHistoricalSummaries

func ReadHistoricalSummaries(tx kv.Tx, l uint64, fn func(idx int, historicalSummary *cltypes.HistoricalSummary) error) error

func ReadNextSyncCommittee

func ReadNextSyncCommittee(tx kv.Tx, slot uint64) (committee *solid.SyncCommittee, err error)

ReadCheckpoints reads the checkpoints from the database, Current, Previous and Finalized

func ReadPreviousEpochAttestations

func ReadPreviousEpochAttestations(tx kv.Tx, slot uint64, limit int) (*solid.ListSSZ[*solid.PendingAttestation], error)

func ReadPublicKeyByIndex

func ReadPublicKeyByIndex(tx kv.Tx, index uint64) (libcommon.Bytes48, error)

func ReadValidatorsTable

func ReadValidatorsTable(tx kv.Tx, out *StaticValidatorTable) error

func ReplayEvents

func ReplayEvents(onAddValidator func(validatorIndex uint64, validator solid.Validator) error,
	onChangeExitEpoch func(validatorIndex uint64, exitEpoch uint64) error,
	onChangeWithdrawableEpoch func(validatorIndex uint64, withdrawableEpoch uint64) error,
	onChangeWithdrawalCredentials func(validatorIndex uint64, withdrawalCredentials libcommon.Hash) error,
	onChangeActivationEpoch func(validatorIndex uint64, activationEpoch uint64) error,
	onChangeActivationEligibilityEpoch func(validatorIndex uint64, activationEligibilityEpoch uint64) error,
	onChangeSlashed func(validatorIndex uint64, slashed bool) error,
	e *StateEvents) error

ReplayEvents replays the events in the buffer and will return the err on handler failure

func SetStateProcessingProgress

func SetStateProcessingProgress(tx kv.RwTx, progress uint64) error

Types

type MinimalBeaconState

type MinimalBeaconState struct {
	// Block Header and Execution Headers can be retrieved from block snapshots
	Version clparams.StateVersion
	// Lengths
	ValidatorLength                 uint64
	Eth1DataLength                  uint64
	PreviousEpochAttestationsLength uint64
	CurrentEpochAttestationsLength  uint64
	HistoricalSummariesLength       uint64
	HistoricalRootsLength           uint64
	// Phase0
	Eth1Data          *cltypes.Eth1Data
	Eth1DepositIndex  uint64
	JustificationBits *cltypes.JustificationBits
	Fork              *cltypes.Fork
	// Capella
	NextWithdrawalIndex          uint64
	NextWithdrawalValidatorIndex uint64
}

func MinimalBeaconStateFromBeaconState

func MinimalBeaconStateFromBeaconState(s *raw.BeaconState) *MinimalBeaconState

func ReadMinimalBeaconState

func ReadMinimalBeaconState(tx kv.Tx, slot uint64) (*MinimalBeaconState, error)

func (*MinimalBeaconState) ReadFrom

func (m *MinimalBeaconState) ReadFrom(r io.Reader) error

Deserialize deserializes the state from a byte slice with zstd compression.

func (*MinimalBeaconState) WriteTo

func (m *MinimalBeaconState) WriteTo(w io.Writer) error

Serialize serializes the state into a byte slice with zstd compression.

type StateEvents

type StateEvents struct {
	// contains filtered or unexported fields
}

func NewStateEvents

func NewStateEvents() *StateEvents

func (*StateEvents) AddValidator

func (se *StateEvents) AddValidator(validatorIndex uint64, validator solid.Validator)

func (*StateEvents) ChangeActivationEligibilityEpoch

func (se *StateEvents) ChangeActivationEligibilityEpoch(validatorIndex uint64, activationEligibilityEpoch uint64)

func (*StateEvents) ChangeActivationEpoch

func (se *StateEvents) ChangeActivationEpoch(validatorIndex uint64, activationEpoch uint64)

func (*StateEvents) ChangeExitEpoch

func (se *StateEvents) ChangeExitEpoch(validatorIndex uint64, exitEpoch uint64)

func (*StateEvents) ChangeSlashed

func (se *StateEvents) ChangeSlashed(validatorIndex uint64, slashed bool)

func (*StateEvents) ChangeWithdrawableEpoch

func (se *StateEvents) ChangeWithdrawableEpoch(validatorIndex uint64, withdrawableEpoch uint64)

func (*StateEvents) ChangeWithdrawalCredentials

func (se *StateEvents) ChangeWithdrawalCredentials(validatorIndex uint64, withdrawalCredentials libcommon.Hash)

func (*StateEvents) CopyBytes

func (se *StateEvents) CopyBytes() []byte

func (*StateEvents) Reset

func (se *StateEvents) Reset()

type StaticValidator

type StaticValidator struct {
	// contains filtered or unexported fields
}

class Validator(Container):

pubkey: BLSPubkey
withdrawal_credentials: Bytes32  # Commitment to pubkey for withdrawals
effective_balance: Gwei  # Balance at stake
slashed: boolean
# Status epochs
activation_eligibility_epoch: Epoch  # When criteria for activation were met
activation_epoch: Epoch
exit_epoch: Epoch
withdrawable_epoch: Epoch  # When validator can withdraw funds

StaticValidator is designed to track changes in a validator's attributes over time. It keeps track of attributes such as withdrawal credentials, slashed status, and various epochs that typically change at most twice during the validator's lifespan.

func NewStaticValidatorFromValidator

func NewStaticValidatorFromValidator(v solid.Validator, slot uint64) *StaticValidator

NewStaticValidatorFromValidator creates a new StaticValidator from a given Validator and Slot, initializing the fields with the current state of the Validator at the given Slot.

func (*StaticValidator) ActivationEligibilityEpoch

func (s *StaticValidator) ActivationEligibilityEpoch(slot uint64) uint64

func (*StaticValidator) ActivationEpoch

func (s *StaticValidator) ActivationEpoch(slot uint64) uint64

func (*StaticValidator) AddActivationEligibility

func (s *StaticValidator) AddActivationEligibility(slot uint64, activationEligibility uint64)

func (*StaticValidator) AddActivationEpoch

func (s *StaticValidator) AddActivationEpoch(slot uint64, activationEpoch uint64)

func (*StaticValidator) AddExitEpoch

func (s *StaticValidator) AddExitEpoch(slot uint64, exitEpoch uint64)

func (*StaticValidator) AddSlashed

func (s *StaticValidator) AddSlashed(slot uint64, slashed bool)

func (*StaticValidator) AddWithdrawableEpoch

func (s *StaticValidator) AddWithdrawableEpoch(slot uint64, withdrawableEpoch uint64)

func (*StaticValidator) AddWithdrawalCredentials

func (s *StaticValidator) AddWithdrawalCredentials(slot uint64, withdrawalCredentials libcommon.Hash)

AddWithdrawalCredentials adds a new withdrawal credential entry to the validator. This method is used to track changes in withdrawal credentials over time.

func (*StaticValidator) ExitEpoch

func (s *StaticValidator) ExitEpoch(slot uint64) uint64

func (*StaticValidator) PublicKey

func (s *StaticValidator) PublicKey(slot uint64) libcommon.Bytes48

func (*StaticValidator) ReadFrom

func (s *StaticValidator) ReadFrom(r io.Reader) error

Deserialize decodes CBOR data from the given reader and updates the StaticValidator fields.

func (*StaticValidator) Slashed

func (s *StaticValidator) Slashed(slot uint64) bool

func (*StaticValidator) ToValidator

func (s *StaticValidator) ToValidator(v solid.Validator, slot uint64)

func (*StaticValidator) WithdrawableEpoch

func (s *StaticValidator) WithdrawableEpoch(slot uint64) uint64

func (*StaticValidator) WithdrawalCredentials

func (s *StaticValidator) WithdrawalCredentials(slot uint64) libcommon.Hash

func (*StaticValidator) WriteTo

func (s *StaticValidator) WriteTo(w io.Writer) error

Serialize encodes the StaticValidator data into CBOR format and writes it to the given writer.

type StaticValidatorTable

type StaticValidatorTable struct {
	// contains filtered or unexported fields
}

StaticValidatorTable is a structure to manage a collection of StaticValidators. It is used for tracking multiple validators and their state changes.

func NewStaticValidatorTable

func NewStaticValidatorTable() *StaticValidatorTable

NewStaticValidatorTable creates a new instance of StaticValidatorTable.

func (*StaticValidatorTable) ActivationEligibilityEpoch

func (s *StaticValidatorTable) ActivationEligibilityEpoch(validatorIndex uint64, slot uint64) uint64

func (*StaticValidatorTable) ActivationEpoch

func (s *StaticValidatorTable) ActivationEpoch(validatorIndex uint64, slot uint64) uint64

func (*StaticValidatorTable) AddActivationEligibility

func (s *StaticValidatorTable) AddActivationEligibility(validatorIndex, slot uint64, activationEligibility uint64) error

func (*StaticValidatorTable) AddActivationEpoch

func (s *StaticValidatorTable) AddActivationEpoch(validatorIndex, slot uint64, activationEpoch uint64) error

func (*StaticValidatorTable) AddExitEpoch

func (s *StaticValidatorTable) AddExitEpoch(validatorIndex, slot uint64, exitEpoch uint64) error

func (*StaticValidatorTable) AddSlashed

func (s *StaticValidatorTable) AddSlashed(validatorIndex, slot uint64, slashed bool) error

func (*StaticValidatorTable) AddValidator

func (s *StaticValidatorTable) AddValidator(v solid.Validator, validatorIndex, slot uint64) error

func (*StaticValidatorTable) AddWithdrawableEpoch

func (s *StaticValidatorTable) AddWithdrawableEpoch(validatorIndex, slot uint64, withdrawableEpoch uint64) error

func (*StaticValidatorTable) AddWithdrawalCredentials

func (s *StaticValidatorTable) AddWithdrawalCredentials(validatorIndex, slot uint64, withdrawalCredentials libcommon.Hash) error

func (*StaticValidatorTable) ExitEpoch

func (s *StaticValidatorTable) ExitEpoch(validatorIndex uint64, slot uint64) uint64

func (*StaticValidatorTable) ForEach

func (s *StaticValidatorTable) ForEach(fn func(validatorIndex uint64, validator *StaticValidator) bool)

func (*StaticValidatorTable) GetInPlace

func (s *StaticValidatorTable) GetInPlace(validatorIndex uint64, slot uint64, v solid.Validator)

func (*StaticValidatorTable) GetStaticValidator

func (s *StaticValidatorTable) GetStaticValidator(validatorIndex uint64) *StaticValidator

func (*StaticValidatorTable) SetSlot

func (s *StaticValidatorTable) SetSlot(slot uint64)

This is for versioning

func (*StaticValidatorTable) Slashed

func (s *StaticValidatorTable) Slashed(validatorIndex uint64, slot uint64) bool

func (*StaticValidatorTable) Slot

func (s *StaticValidatorTable) Slot() uint64

func (*StaticValidatorTable) WithdrawableEpoch

func (s *StaticValidatorTable) WithdrawableEpoch(validatorIndex uint64, slot uint64) uint64

func (*StaticValidatorTable) WithdrawalCredentials

func (s *StaticValidatorTable) WithdrawalCredentials(validatorIndex uint64, slot uint64) libcommon.Hash

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL