state

package
v3.0.0-alpha5.0...-c974331 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: LGPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const PreAllocatedRewardsAndPenalties = 8192

Variables

This section is empty.

Functions

func ComputeActivationExitEpoch

func ComputeActivationExitEpoch(config *clparams.BeaconChainConfig, epoch uint64) uint64

func ComputeTimestampAtSlot

func ComputeTimestampAtSlot(b abstract.BeaconState, slot uint64) uint64

ComputeTimestampAtSlot computes the Unix timestamp at the specified slot number.

func DecreaseBalance

func DecreaseBalance(b abstract.BeaconState, index, delta uint64) error

func EligibleValidatorsIndicies

func EligibleValidatorsIndicies(b abstract.BeaconState) (eligibleValidators []uint64)

EligibleValidatorsIndicies Implementation of get_eligible_validator_indices as defined in the eth 2.0 specs.

func Epoch

Epoch returns current epoch.

func ExpectedWithdrawals

func ExpectedWithdrawals(b abstract.BeaconState, currentEpoch uint64) []*cltypes.Withdrawal

ExpectedWithdrawals calculates the expected withdrawals that can be made by validators in the current epoch

func FinalityDelay

func FinalityDelay(b abstract.BeaconState) uint64

FinalityDelay determines by how many epochs we are late on finality.

func GetBlockRoot

func GetBlockRoot(b abstract.BeaconState, epoch uint64) (libcommon.Hash, error)

GetBlockRoot returns blook root at start of a given epoch

func GetEpochAtSlot

func GetEpochAtSlot(config *clparams.BeaconChainConfig, slot uint64) uint64

GetEpochAtSlot gives the epoch for a certain slot

func GetIndexedAttestation

func GetIndexedAttestation(attestation *solid.Attestation, attestingIndicies []uint64) *cltypes.IndexedAttestation

func GetTotalBalance

func GetTotalBalance(b abstract.BeaconStateBasic, validatorSet []uint64) (uint64, error)

GetTotalBalance return the sum of all balances within the given validator set.

func GetTotalSlashingAmount

func GetTotalSlashingAmount(b abstract.BeaconState) (t uint64)

GetTotalSlashingAmount return the sum of all slashings.

func GetUnslashedParticipatingIndices

func GetUnslashedParticipatingIndices(b abstract.BeaconState, flagIndex int, epoch uint64) (validatorSet []uint64, err error)

GetUnslashedParticipatingIndices returns set of currently unslashed participating indexes.

func InactivityLeaking

func InactivityLeaking(b abstract.BeaconState) bool

InactivityLeaking returns whether epochs are in inactivity penalty. Implementation of is_in_inactivity_leak as defined in the ETH 2.0 specs.

func IncreaseBalance

func IncreaseBalance(b abstract.BeaconState, index, delta uint64) error

func IsAggregator

func IsAggregator(cfg *clparams.BeaconChainConfig, committeeLength, committeeIndex uint64, slotSignature libcommon.Bytes96) bool

func IsMergeTransitionComplete

func IsMergeTransitionComplete(b abstract.BeaconState) bool

IsMergeTransitionComplete returns whether a merge transition is complete by verifying the presence of a valid execution payload header.

func IsUnslashedParticipatingIndex

func IsUnslashedParticipatingIndex(validatorSet *solid.ValidatorSet, previousEpochParticipation *solid.ParticipationBitList, epoch, index uint64, flagIdx int) bool

IsUnslashedParticipatingIndex

func IsValidIndexedAttestation

func IsValidIndexedAttestation(b abstract.BeaconStateBasic, att *cltypes.IndexedAttestation) (bool, error)

func IsValidatorEligibleForActivation

func IsValidatorEligibleForActivation(b abstract.BeaconState, validator solid.Validator) bool

IsValidatorEligibleForActivation returns whether the validator is eligible for activation. Implementation of is_eligible_for_activation. Specs at: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#is_eligible_for_activation

func IsValidatorEligibleForActivationQueue

func IsValidatorEligibleForActivationQueue(b abstract.BeaconState, validator solid.Validator) bool

IsValidatorEligibleForActivationQueue returns whether the validator is eligible to be placed into the activation queue. Implementation of is_eligible_for_activation_queue. Specs at: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#is_eligible_for_activation_queue

func PreviousEpoch

func PreviousEpoch(b abstract.BeaconState) uint64

PreviousEpoch returns previous epoch.

func ValidatorFromDeposit

func ValidatorFromDeposit(conf *clparams.BeaconChainConfig, deposit *cltypes.Deposit) solid.Validator

Types

type CachingBeaconState

type CachingBeaconState struct {
	// embedded BeaconState
	*raw.BeaconState
	// contains filtered or unexported fields
}

CachingBeaconState is a cached wrapper around a raw CachingBeaconState provider

func NewFromRaw

func NewFromRaw(r *raw.BeaconState) *CachingBeaconState

func (*CachingBeaconState) AddValidator

func (b *CachingBeaconState) AddValidator(validator solid.Validator, balance uint64)

func (*CachingBeaconState) BaseReward

func (b *CachingBeaconState) BaseReward(index uint64) (uint64, error)

BaseReward return base rewards for processing sync committee and duties.

func (*CachingBeaconState) BaseRewardPerIncrement

func (b *CachingBeaconState) BaseRewardPerIncrement() uint64

BaseRewardPerIncrement return base rewards for processing sync committee and duties.

func (*CachingBeaconState) Clone

func (*CachingBeaconState) CommitteeCount

func (b *CachingBeaconState) CommitteeCount(epoch uint64) uint64

CommitteeCount returns current number of committee for epoch.

func (*CachingBeaconState) ComputeCommittee

func (b *CachingBeaconState) ComputeCommittee(
	indicies []uint64,
	slot uint64,
	index, count uint64,
) ([]uint64, error)

ComputeCommittee uses cache to compute compittee

func (*CachingBeaconState) ComputeNextSyncCommittee

func (b *CachingBeaconState) ComputeNextSyncCommittee() (*solid.SyncCommittee, error)

func (*CachingBeaconState) Copy

func (b *CachingBeaconState) Copy() (bs *CachingBeaconState, err error)

func (*CachingBeaconState) CopyInto

func (b *CachingBeaconState) CopyInto(bs *CachingBeaconState) (err error)

func (*CachingBeaconState) DecodeCaches

func (b *CachingBeaconState) DecodeCaches(r io.Reader) error

func (*CachingBeaconState) DecodeSSZ

func (b *CachingBeaconState) DecodeSSZ(buf []byte, version int) error

func (*CachingBeaconState) EncodeCaches

func (b *CachingBeaconState) EncodeCaches(w io.Writer) error

EncodeCaches, encodes the beacon state caches into a byte slice

func (*CachingBeaconState) EncodeSSZ

func (b *CachingBeaconState) EncodeSSZ(buf []byte) ([]byte, error)

func (*CachingBeaconState) EncodingSizeSSZ

func (b *CachingBeaconState) EncodingSizeSSZ() (size int)

SSZ size of the Beacon State

func (*CachingBeaconState) GetActiveValidatorsIndices

func (b *CachingBeaconState) GetActiveValidatorsIndices(epoch uint64) []uint64

GetActiveValidatorsIndices returns the list of validator indices active for the given epoch.

func (*CachingBeaconState) GetAttestationParticipationFlagIndicies

func (b *CachingBeaconState) GetAttestationParticipationFlagIndicies(
	data *solid.AttestationData,
	inclusionDelay uint64,
	skipAssert bool,
) ([]uint8, error)

func (*CachingBeaconState) GetAttestingIndicies

func (b *CachingBeaconState) GetAttestingIndicies(
	attestation *solid.Attestation,
	checkBitsLength bool,
) ([]uint64, error)

GetAttestingIndicies retrieves attesting indicies for a specific attestation. however some tests will not expect the aggregation bits check. thus, it is a flag now.

func (*CachingBeaconState) GetBeaconCommitee

func (b *CachingBeaconState) GetBeaconCommitee(slot, committeeIndex uint64) ([]uint64, error)

GetBeaconCommitee grabs beacon committee using cache first

func (*CachingBeaconState) GetBeaconProposerIndex

func (b *CachingBeaconState) GetBeaconProposerIndex() (uint64, error)

GetBeaconProposerIndex updates cache and gets the beacon proposer index

func (*CachingBeaconState) GetBeaconProposerIndexForSlot

func (b *CachingBeaconState) GetBeaconProposerIndexForSlot(slot uint64) (uint64, error)

GetBeaconProposerIndexForSlot compute the proposer index for a specific slot

func (*CachingBeaconState) GetTotalActiveBalance

func (b *CachingBeaconState) GetTotalActiveBalance() uint64

GetTotalActiveBalance return the sum of all balances within active validators.

func (*CachingBeaconState) InitBeaconState

func (b *CachingBeaconState) InitBeaconState() error

func (*CachingBeaconState) InitiateValidatorExit

func (b *CachingBeaconState) InitiateValidatorExit(index uint64) error

func (*CachingBeaconState) PreviousStateRoot

func (b *CachingBeaconState) PreviousStateRoot() libcommon.Hash

PreviousStateRoot gets the previously saved state root and then deletes it.

func (*CachingBeaconState) SetPreviousStateRoot

func (b *CachingBeaconState) SetPreviousStateRoot(root libcommon.Hash)

func (*CachingBeaconState) SetSlot

func (b *CachingBeaconState) SetSlot(slot uint64)

func (*CachingBeaconState) SlashValidator

func (b *CachingBeaconState) SlashValidator(slashedInd uint64, whistleblowerInd *uint64) (uint64, error)

func (*CachingBeaconState) SyncRewards

func (b *CachingBeaconState) SyncRewards() (proposerReward, participantReward uint64, err error)

SyncRewards returns the proposer reward and the sync participant reward given the total active balance in state. It grabs values from cache as needed

func (*CachingBeaconState) UpgradeToAltair

func (b *CachingBeaconState) UpgradeToAltair() error

func (*CachingBeaconState) UpgradeToBellatrix

func (b *CachingBeaconState) UpgradeToBellatrix() error

func (*CachingBeaconState) UpgradeToCapella

func (b *CachingBeaconState) UpgradeToCapella() error

func (*CachingBeaconState) UpgradeToDeneb

func (b *CachingBeaconState) UpgradeToDeneb() error

func (*CachingBeaconState) UpgradeToElectra

func (b *CachingBeaconState) UpgradeToElectra() error

func (*CachingBeaconState) ValidatorIndexByPubkey

func (b *CachingBeaconState) ValidatorIndexByPubkey(key [48]byte) (uint64, bool)

type HashFunc

type HashFunc func([]byte) ([32]byte, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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