state_accessors

package
v1.9.7-0...-24da1cd Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: LGPL-3.0 Imports: 15 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 ReadActiveIndicies

func ReadActiveIndicies(getFn GetValFn, slot uint64) ([]uint64, error)

func ReadCheckpoints

func ReadCheckpoints(getFn GetValFn, slot uint64) (current solid.Checkpoint, previous solid.Checkpoint, finalized solid.Checkpoint, ok bool, err error)

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

func ReadCurrentSyncCommittee

func ReadCurrentSyncCommittee(getFn GetValFn, slot uint64) (committee *solid.SyncCommittee, err error)

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

func ReadNextSyncCommittee

func ReadNextSyncCommittee(getFn GetValFn, slot uint64) (committee *solid.SyncCommittee, err error)

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

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 EpochData

type EpochData struct {
	TotalActiveBalance          uint64
	JustificationBits           *cltypes.JustificationBits
	CurrentJustifiedCheckpoint  solid.Checkpoint
	PreviousJustifiedCheckpoint solid.Checkpoint
	FinalizedCheckpoint         solid.Checkpoint
	HistoricalSummariesLength   uint64
	HistoricalRootsLength       uint64
}

EpochData stores the data for the epoch (valid throughout the epoch)

func EpochDataFromBeaconState

func EpochDataFromBeaconState(s *state.CachingBeaconState) *EpochData

func ReadEpochData

func ReadEpochData(getFn GetValFn, slot uint64) (*EpochData, error)

func (*EpochData) ReadFrom

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

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

func (*EpochData) WriteTo

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

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

type GetValFn

type GetValFn func(table string, key []byte) ([]byte, error)

func GetValFnTxAndSnapshot

func GetValFnTxAndSnapshot(tx kv.Tx, snapshotRoTx *snapshotsync.CaplinStateView) GetValFn

type SlotData

type SlotData struct {
	// Block Header and Execution Headers can be retrieved from block snapshots
	Version clparams.StateVersion
	// Lengths
	ValidatorLength uint64
	Eth1DataLength  uint64
	// Phase0
	Eth1Data         *cltypes.Eth1Data
	Eth1DepositIndex uint64
	Fork             *cltypes.Fork
	// Capella
	NextWithdrawalIndex          uint64
	NextWithdrawalValidatorIndex uint64
	// Electra
	DepositRequestsStartIndex     uint64
	DepositBalanceToConsume       uint64
	ExitBalanceToConsume          uint64
	EarliestExitEpoch             uint64
	ConsolidationBalanceToConsume uint64
	EarliestConsolidationEpoch    uint64
	PendingDeposits               *solid.ListSSZ[*solid.PendingDeposit]
	PendingPartialWithdrawals     *solid.ListSSZ[*solid.PendingPartialWithdrawal]
	PendingConsolidations         *solid.ListSSZ[*solid.PendingConsolidation]

	// BlockRewards for proposer
	AttestationsRewards  uint64
	SyncAggregateRewards uint64
	ProposerSlashings    uint64
	AttesterSlashings    uint64
}

func ReadSlotData

func ReadSlotData(getFn GetValFn, slot uint64, cfg *clparams.BeaconChainConfig) (*SlotData, error)

func SlotDataFromBeaconState

func SlotDataFromBeaconState(s *state.CachingBeaconState) *SlotData

func (*SlotData) ReadFrom

func (m *SlotData) ReadFrom(r io.Reader, cfg *clparams.BeaconChainConfig) error

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

func (*SlotData) WriteTo

func (m *SlotData) 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 NewStateEventsFromBytes

func NewStateEventsFromBytes(buf []byte) *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) Reset

func (s *StaticValidator) Reset(slot uint64)

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