beacon

package
v1.20.8 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: GPL-3.0 Imports: 14 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveExecutionBlockNumber added in v1.20.8

func ResolveExecutionBlockNumber(ctx context.Context, ec ExecutionHeaderSource, block BeaconBlock) (uint64, bool, error)

ResolveExecutionBlockNumber returns the Execution Layer block number associated with a Beacon block.

Pre-Gloas blocks embed the number in the execution payload. Gloas (EIP-7732) blocks no longer carry the payload at all - the body only has a bid committing to the payload's block hash - so the number has to be resolved through the Execution Client.

Types

type AttestationInfo added in v1.5.0

type AttestationInfo struct {
	AggregationBits bitfield.Bitlist
	SlotIndex       uint64
	// Committees represented by AggregationBits
	Committees bitfield.Bitvector64
}

func (*AttestationInfo) CommitteeIndices added in v1.15.6

func (a *AttestationInfo) CommitteeIndices() []int

func (AttestationInfo) ValidatorAttested added in v1.15.6

func (a AttestationInfo) ValidatorAttested(committeeIndex int, position int, committeeSizes map[uint64]int) bool

type BeaconBlock added in v1.5.0

type BeaconBlock struct {
	Slot                 uint64
	ProposerIndex        string
	HasExecutionPayload  bool
	Attestations         []AttestationInfo
	FeeRecipient         common.Address
	ExecutionBlockNumber uint64
	ExecutionBlockHash   common.Hash
	Withdrawals          []WithdrawalInfo
}

type BeaconBlockHeader added in v1.12.0

type BeaconBlockHeader struct {
	Slot          uint64
	ProposerIndex string
}

type BeaconBlockSSZ added in v1.18.0

type BeaconBlockSSZ struct {
	Data io.ReadCloser
	Size int64
	Fork string
}

type BeaconClientType added in v1.0.0

type BeaconClientType int

Beacon client type

const (
	// This client is a traditional "split process" design, where the beacon
	// client and validator process are separate and run in different
	// containers
	SplitProcess BeaconClientType = iota

	// This client is a "single process" where the beacon client and
	// validator run in the same process (or run as separate processes
	// within the same docker container)
	SingleProcess

	// Unknown / missing client type
	Unknown
)

type BeaconHead

type BeaconHead struct {
	Epoch                  uint64
	FinalizedEpoch         uint64
	JustifiedEpoch         uint64
	PreviousJustifiedEpoch uint64
}

type BeaconStateSSZ added in v1.18.0

type BeaconStateSSZ struct {
	Data io.ReadCloser
	Size int64
	Fork string
}

type Client

type Client interface {
	GetClientType() (BeaconClientType, error)
	GetSyncStatus() (SyncStatus, error)
	GetEth2Config() (Eth2Config, error)
	GetEth2DepositContract() (Eth2DepositContract, error)
	GetAttestations(blockId string) ([]AttestationInfo, bool, error)
	GetBeaconBlock(blockId string) (BeaconBlock, bool, error)
	GetBeaconBlockHeader(blockId string) (BeaconBlockHeader, bool, error)
	GetBeaconHead() (BeaconHead, error)
	GetValidatorStatusByIndex(index string, opts *ValidatorStatusOptions) (ValidatorStatus, error)
	GetValidatorStatus(pubkey types.ValidatorPubkey, opts *ValidatorStatusOptions) (ValidatorStatus, error)
	GetAllValidators() ([]ValidatorStatus, error)
	GetValidatorStatuses(pubkeys []types.ValidatorPubkey, opts *ValidatorStatusOptions) (map[types.ValidatorPubkey]ValidatorStatus, error)
	GetValidatorIndex(pubkey types.ValidatorPubkey) (string, error)
	GetValidatorSyncDuties(indices []string, epoch uint64) (map[string]bool, error)
	GetValidatorProposerDuties(indices []string, epoch uint64) (map[string]uint64, error)
	GetValidatorBalances(indices []string, opts *ValidatorStatusOptions) (map[string]*big.Int, error)
	GetValidatorBalancesSafe(indices []string, opts *ValidatorStatusOptions) (map[string]*big.Int, error)
	GetDomainData(domainType []byte, epoch uint64, useGenesisFork bool) ([]byte, error)
	ExitValidator(validatorIndex string, epoch uint64, signature types.ValidatorSignature) error
	Close() error
	GetEth1DataForEth2Block(blockId string) (Eth1Data, bool, error)
	GetCommitteesForEpoch(epoch *uint64) (Committees, error)
	ChangeWithdrawalCredentials(validatorIndex string, fromBlsPubkey types.ValidatorPubkey, toExecutionAddress common.Address, signature types.ValidatorSignature) error

	GetBeaconStateSSZ(slot uint64) (*BeaconStateSSZ, error)
	GetBeaconBlockSSZ(slot uint64) (*BeaconBlockSSZ, bool, error)
}

Beacon client interface

type Committees added in v1.10.0

type Committees interface {
	// Index returns the index of the committee at the provided offset
	Index(int) uint64
	// Slot returns the slot of the committee at the provided offset
	Slot(int) uint64
	// Validators returns the list of validators of the committee at
	// the provided offset
	Validators(int) []string
	// ValidatorCount returns the number of validators in the committee at
	// the provided offset
	ValidatorCount(int) int
	// Count returns the number of committees in the response
	Count() int
	// Release returns the reused validators slice buffer to the pool for
	// further reuse, and must be called when the user is done with this
	// committees instance
	Release()
}

Committees is an interface as an optimization- since committees responses are quite large, there's a decent cpu/memory improvement to removing the translation to an intermediate storage class.

Instead, the interface provides the access pattern that smartnode (or more specifically, tree-gen) wants, and the underlying format is just the format of the Beacon Node response.

type Eth1Data added in v1.0.0

type Eth1Data struct {
	DepositRoot  common.Hash
	DepositCount uint64
	BlockHash    common.Hash
}

type Eth2Config

type Eth2Config struct {
	GenesisForkVersion           []byte `json:"genesis_fork_version"`
	GenesisValidatorsRoot        []byte `json:"genesis_validators_root"`
	GenesisEpoch                 uint64 `json:"genesis_epoch"`
	GenesisTime                  uint64 `json:"genesis_time"`
	SecondsPerSlot               uint64 `json:"seconds_per_slot"`
	SlotsPerEpoch                uint64 `json:"slots_per_epoch"`
	SecondsPerEpoch              uint64 `json:"seconds_per_epoch"`
	EpochsPerSyncCommitteePeriod uint64 `json:"epochs_per_sync_committee_period"`
	ShardCommitteePeriod         uint64 `json:"shard_committee_period"`
}

func (*Eth2Config) EpochAt added in v1.20.8

func (c *Eth2Config) EpochAt(time time.Time) uint64

func (*Eth2Config) EpochToSlot added in v1.15.0

func (c *Eth2Config) EpochToSlot(epoch uint64) uint64

func (*Eth2Config) FirstSlotAtLeast added in v1.15.0

func (c *Eth2Config) FirstSlotAtLeast(t int64) uint64

FirstSlotAtLeast returns the first slot with a timestamp greater than or equal to t

func (*Eth2Config) FirstSlotOfEpoch added in v1.15.0

func (c *Eth2Config) FirstSlotOfEpoch(epoch uint64) uint64

func (*Eth2Config) GetSlotTime added in v1.15.0

func (c *Eth2Config) GetSlotTime(slot uint64) time.Time

GetSlotTime returns the time of a given slot for the network described by Eth2Config.

func (*Eth2Config) LastSlotOfEpoch added in v1.15.0

func (c *Eth2Config) LastSlotOfEpoch(epoch uint64) uint64

func (*Eth2Config) MarshalJSON added in v1.15.0

func (c *Eth2Config) MarshalJSON() ([]byte, error)

func (*Eth2Config) SlotOfEpoch added in v1.15.0

func (c *Eth2Config) SlotOfEpoch(epoch uint64, slot uint64) (uint64, error)

func (*Eth2Config) SlotToEpoch added in v1.15.0

func (c *Eth2Config) SlotToEpoch(slot uint64) uint64

func (*Eth2Config) UnmarshalJSON added in v1.15.0

func (c *Eth2Config) UnmarshalJSON(data []byte) error

type Eth2DepositContract added in v1.0.0

type Eth2DepositContract struct {
	ChainID uint64
	Address common.Address
}

type ExecutionHeaderSource added in v1.20.8

type ExecutionHeaderSource interface {
	// HeaderByHash returns the block header with the given hash.
	HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)
}

The subset of the Execution Client needed to resolve a payload hash into a block number. Kept minimal so that Execution Client managers, the raw client interface, and test stubs all satisfy it without any of them having to be imported here.

type SyncStatus

type SyncStatus struct {
	Syncing  bool
	Progress float64
}

API response types

type ValidatorState added in v1.7.1

type ValidatorState string
const (
	ValidatorState_PendingInitialized ValidatorState = "pending_initialized"
	ValidatorState_PendingQueued      ValidatorState = "pending_queued"
	ValidatorState_ActiveOngoing      ValidatorState = "active_ongoing"
	ValidatorState_ActiveExiting      ValidatorState = "active_exiting"
	ValidatorState_ActiveSlashed      ValidatorState = "active_slashed"
	ValidatorState_ExitedUnslashed    ValidatorState = "exited_unslashed"
	ValidatorState_ExitedSlashed      ValidatorState = "exited_slashed"
	ValidatorState_WithdrawalPossible ValidatorState = "withdrawal_possible"
	ValidatorState_WithdrawalDone     ValidatorState = "withdrawal_done"
)

type ValidatorStatus

type ValidatorStatus struct {
	Pubkey                     types.ValidatorPubkey `json:"pubkey"`
	Index                      string                `json:"index"`
	WithdrawalCredentials      common.Hash           `json:"withdrawal_credentials"`
	Balance                    uint64                `json:"balance"`
	Status                     ValidatorState        `json:"status"`
	EffectiveBalance           uint64                `json:"effective_balance"`
	Slashed                    bool                  `json:"slashed"`
	ActivationEligibilityEpoch uint64                `json:"activation_eligibility_epoch"`
	ActivationEpoch            uint64                `json:"activation_epoch"`
	ExitEpoch                  uint64                `json:"exit_epoch"`
	WithdrawableEpoch          uint64                `json:"withdrawable_epoch"`
	Exists                     bool                  `json:"exists"`
}

type ValidatorStatusOptions

type ValidatorStatusOptions struct {
	Epoch *uint64
	Slot  *uint64
}

API request options

type WithdrawalInfo added in v1.15.0

type WithdrawalInfo struct {
	ValidatorIndex string
	Address        common.Address
	Amount         *big.Int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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