package light

import "github.com/ethereum/go-ethereum/beacon/light"

Index

Variables

var (
	ErrNeedCommittee      = errors.New("sync committee required")
	ErrInvalidUpdate      = errors.New("invalid committee update")
	ErrInvalidPeriod      = errors.New("invalid update period")
	ErrWrongCommitteeRoot = errors.New("wrong committee root")
	ErrCannotReorg        = errors.New("can not reorg committee chain")
)

Functions

func GenerateTestCheckpoint

func GenerateTestCheckpoint(period uint64, committee *types.SerializedSyncCommittee) *types.BootstrapData

func GenerateTestCommittee

func GenerateTestCommittee() *types.SerializedSyncCommittee

func GenerateTestSignedHeader

func GenerateTestSignedHeader(header types.Header, config *params.ChainConfig, committee *types.SerializedSyncCommittee, signatureSlot uint64, signerCount int) types.SignedHeader

func GenerateTestUpdate

func GenerateTestUpdate(config *params.ChainConfig, period uint64, committee, nextCommittee *types.SerializedSyncCommittee, signerCount int, finalizedHeader bool) *types.LightClientUpdate

Types

type CommitteeChain

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

CommitteeChain is a passive data structure that can validate, hold and update a chain of beacon light sync committees and updates. It requires at least one externally set fixed committee root at the beginning of the chain which can be set either based on a BootstrapData or a trusted source (a local beacon full node). This makes the structure useful for both light client and light server setups.

It always maintains the following consistency constraints:

Once synced to the current sync period, CommitteeChain can also validate signed beacon headers.

func NewCommitteeChain

func NewCommitteeChain(db ethdb.KeyValueStore, config *params.ChainConfig, signerThreshold int, enforceTime bool) *CommitteeChain

NewCommitteeChain creates a new CommitteeChain.

func NewTestCommitteeChain

func NewTestCommitteeChain(db ethdb.KeyValueStore, config *params.ChainConfig, signerThreshold int, enforceTime bool, clock *mclock.Simulated) *CommitteeChain

NewTestCommitteeChain creates a new CommitteeChain for testing.

func (*CommitteeChain) ChangeCounter

func (s *CommitteeChain) ChangeCounter() uint64

func (*CommitteeChain) CheckpointInit

func (s *CommitteeChain) CheckpointInit(bootstrap types.BootstrapData) error

CheckpointInit initializes a CommitteeChain based on a checkpoint. Note: if the chain is already initialized and the committees proven by the checkpoint do match the existing chain then the chain is retained and the new checkpoint becomes fixed.

func (*CommitteeChain) InsertUpdate

func (s *CommitteeChain) InsertUpdate(update *types.LightClientUpdate, nextCommittee *types.SerializedSyncCommittee) error

InsertUpdate adds a new update if possible.

func (*CommitteeChain) NextSyncPeriod

func (s *CommitteeChain) NextSyncPeriod() (uint64, bool)

NextSyncPeriod returns the next period where an update can be added and also whether the chain is initialized at all.

func (*CommitteeChain) Reset

func (s *CommitteeChain) Reset()

Reset resets the committee chain.

func (*CommitteeChain) VerifySignedHeader

func (s *CommitteeChain) VerifySignedHeader(head types.SignedHeader) (bool, time.Duration, error)

VerifySignedHeader returns true if the given signed header has a valid signature according to the local committee chain. The caller should ensure that the committees advertised by the same source where the signed header came from are synced before verifying the signature. The age of the header is also returned (the time elapsed since the beginning of the given slot, according to the local system clock). If enforceTime is true then negative age (future) headers are rejected.

type HeadTracker

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

HeadTracker keeps track of the latest validated head and the "prefetch" head which is the (not necessarily validated) head announced by the majority of servers.

func NewHeadTracker

func NewHeadTracker(committeeChain *CommitteeChain, minSignerCount int, saveCheckpoint func(common.Hash)) *HeadTracker

NewHeadTracker creates a new HeadTracker.

func (*HeadTracker) ChangeCounter

func (h *HeadTracker) ChangeCounter() uint64

ChangeCounter implements request.targetData

func (*HeadTracker) PrefetchHead

func (h *HeadTracker) PrefetchHead() types.HeadInfo

PrefetchHead returns the latest known prefetch head's head info. This head can be used to start fetching related data hoping that it will be validated soon. Note that the prefetch head cannot be validated cryptographically so it should only be used as a performance optimization hint.

func (*HeadTracker) SetPrefetchHead

func (h *HeadTracker) SetPrefetchHead(head types.HeadInfo)

SetPrefetchHead sets the prefetch head info. Note that HeadTracker does not verify the prefetch head, just acts as a thread safe bulletin board.

func (*HeadTracker) ValidateFinality

func (h *HeadTracker) ValidateFinality(update types.FinalityUpdate) (bool, error)

ValidateFinality validates the given finality update. If the update is successfully validated and it is better than the old validated update (higher slot or same slot and more signers) then ValidatedFinality is updated. The boolean return flag signals if ValidatedFinality has been changed.

func (*HeadTracker) ValidateOptimistic

func (h *HeadTracker) ValidateOptimistic(update types.OptimisticUpdate) (bool, error)

ValidateOptimistic validates the given optimistic update. If the update is successfully validated and it is better than the old validated update (higher slot or same slot and more signers) then ValidatedOptimistic is updated. The boolean return flag signals if ValidatedOptimistic has been changed.

func (*HeadTracker) ValidatedFinality

func (h *HeadTracker) ValidatedFinality() (types.FinalityUpdate, bool)

ValidatedFinality returns the latest validated finality update.

func (*HeadTracker) ValidatedOptimistic

func (h *HeadTracker) ValidatedOptimistic() (types.OptimisticUpdate, bool)

ValidatedOptimistic returns the latest validated optimistic update.

Source Files

canonical.go committee_chain.go head_tracker.go range.go test_helpers.go

Directories

PathSynopsis
beacon/light/api
beacon/light/request
beacon/light/sync
Version
v1.16.1 (latest)
Published
Jul 2, 2025
Platform
linux/amd64
Imports
19 packages
Last checked
42 minutes ago

Tools for package owners.