forkchoice

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: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEIP4844DataNotAvailable = errors.New("EIP-4844 blob data is not available")
View Source
var (
	ErrIgnore = errors.New("ignore")
)

Functions

This section is empty.

Types

type ForkChoiceStorage

type ForkChoiceStorage interface {
	ForkChoiceStorageWriter
	ForkChoiceStorageReader
}

type ForkChoiceStorageReader

type ForkChoiceStorageReader interface {
	Ancestor(root common.Hash, slot uint64) common.Hash
	AnchorSlot() uint64
	Engine() execution_client.ExecutionEngine
	FinalizedCheckpoint() solid.Checkpoint
	FinalizedSlot() uint64
	LowestAvailableSlot() uint64
	GetEth1Hash(eth2Root common.Hash) common.Hash
	GetHead(auxilliaryState *state.CachingBeaconState) (common.Hash, uint64, error)
	HighestSeen() uint64
	JustifiedCheckpoint() solid.Checkpoint
	JustifiedSlot() uint64
	ProposerBoostRoot() common.Hash
	GetStateAtBlockRoot(
		blockRoot libcommon.Hash,
		alwaysCopy bool,
	) (*state.CachingBeaconState, error)
	GetFinalityCheckpoints(
		blockRoot libcommon.Hash,
	) (solid.Checkpoint, solid.Checkpoint, solid.Checkpoint, bool)
	GetSyncCommittees(period uint64) (*solid.SyncCommittee, *solid.SyncCommittee, bool)
	GetBeaconCommitee(slot, committeeIndex uint64) ([]uint64, error)
	Slot() uint64
	Time() uint64
	Participation(epoch uint64) (*solid.ParticipationBitList, bool)
	RandaoMixes(blockRoot libcommon.Hash, out solid.HashListSSZ) bool
	BlockRewards(root libcommon.Hash) (*eth2.BlockRewardsCollector, bool)
	TotalActiveBalance(root libcommon.Hash) (uint64, bool)

	ForkNodes() []ForkNode
	Synced() bool
	GetLightClientBootstrap(blockRoot libcommon.Hash) (*cltypes.LightClientBootstrap, bool)
	NewestLightClientUpdate() *cltypes.LightClientUpdate
	GetLightClientUpdate(period uint64) (*cltypes.LightClientUpdate, bool)
	GetHeader(blockRoot libcommon.Hash) (*cltypes.BeaconBlockHeader, bool)

	GetBalances(blockRoot libcommon.Hash) (solid.Uint64ListSSZ, error)
	GetInactivitiesScores(blockRoot libcommon.Hash) (solid.Uint64ListSSZ, error)
	GetPreviousParticipationIndicies(blockRoot libcommon.Hash) (*solid.ParticipationBitList, error)
	GetValidatorSet(blockRoot libcommon.Hash) (*solid.ValidatorSet, error)
	GetCurrentParticipationIndicies(blockRoot libcommon.Hash) (*solid.ParticipationBitList, error)

	ValidateOnAttestation(attestation *solid.Attestation) error
	IsRootOptimistic(root common.Hash) bool
	IsHeadOptimistic() bool
}

type ForkChoiceStorageWriter

type ForkChoiceStorageWriter interface {
	OnAttestation(attestation *solid.Attestation, fromBlock, insert bool) error
	OnAttesterSlashing(attesterSlashing *cltypes.AttesterSlashing, test bool) error
	OnBlock(
		ctx context.Context,
		block *cltypes.SignedBeaconBlock,
		newPayload bool,
		fullValidation bool,
		checkDataAvaibility bool,
	) error
	AddPreverifiedBlobSidecar(blobSidecar *cltypes.BlobSidecar) error
	OnTick(time uint64)
	SetSynced(synced bool)
	ProcessAttestingIndicies(attestation *solid.Attestation, attestionIndicies []uint64)
}

type ForkChoiceStore

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

func NewForkChoiceStore

func NewForkChoiceStore(
	ethClock eth_clock.EthereumClock,
	anchorState *state2.CachingBeaconState,
	engine execution_client.ExecutionEngine,
	operationsPool pool.OperationsPool,
	forkGraph fork_graph.ForkGraph,
	emitters *beaconevents.EventEmitter,
	syncedDataManager *synced_data.SyncedDataManager,
	blobStorage blob_storage.BlobStorage,
	validatorMonitor monitor.ValidatorMonitor,
	probabilisticHeadGetter bool,
) (*ForkChoiceStore, error)

NewForkChoiceStore initialize a new store from the given anchor state, either genesis or checkpoint sync state.

func (*ForkChoiceStore) AddPreverifiedBlobSidecar

func (f *ForkChoiceStore) AddPreverifiedBlobSidecar(blobSidecar *cltypes.BlobSidecar) error

func (*ForkChoiceStore) Ancestor

func (f *ForkChoiceStore) Ancestor(root libcommon.Hash, slot uint64) libcommon.Hash

Ancestor returns the ancestor to the given root.

func (*ForkChoiceStore) AnchorSlot

func (f *ForkChoiceStore) AnchorSlot() uint64

FinalizedCheckpoint returns justified checkpoint

func (*ForkChoiceStore) BlockRewards

func (f *ForkChoiceStore) BlockRewards(root libcommon.Hash) (*eth2.BlockRewardsCollector, bool)

func (*ForkChoiceStore) DumpBeaconStateOnDisk

func (f *ForkChoiceStore) DumpBeaconStateOnDisk(bs *state.CachingBeaconState) error

func (*ForkChoiceStore) Engine

FinalizedCheckpoint returns justified checkpoint

func (*ForkChoiceStore) FinalizedCheckpoint

func (f *ForkChoiceStore) FinalizedCheckpoint() solid.Checkpoint

FinalizedCheckpoint returns justified checkpoint

func (*ForkChoiceStore) FinalizedSlot

func (f *ForkChoiceStore) FinalizedSlot() uint64

FinalizedCheckpoint returns justified checkpoint

func (*ForkChoiceStore) ForkNodes

func (f *ForkChoiceStore) ForkNodes() []ForkNode

func (*ForkChoiceStore) GetBalances

func (f *ForkChoiceStore) GetBalances(blockRoot libcommon.Hash) (solid.Uint64ListSSZ, error)

func (*ForkChoiceStore) GetBeaconCommitee

func (f *ForkChoiceStore) GetBeaconCommitee(slot, committeeIndex uint64) ([]uint64, error)

func (*ForkChoiceStore) GetCurrentParticipationIndicies

func (f *ForkChoiceStore) GetCurrentParticipationIndicies(blockRoot libcommon.Hash) (*solid.ParticipationBitList, error)

func (*ForkChoiceStore) GetEth1Hash

func (f *ForkChoiceStore) GetEth1Hash(eth2Root libcommon.Hash) libcommon.Hash

FinalizedCheckpoint returns justified checkpoint

func (*ForkChoiceStore) GetFinalityCheckpoints

func (f *ForkChoiceStore) GetFinalityCheckpoints(blockRoot libcommon.Hash) (solid.Checkpoint, solid.Checkpoint, solid.Checkpoint, bool)

func (*ForkChoiceStore) GetHead

func (f *ForkChoiceStore) GetHead(auxilliaryState *state.CachingBeaconState) (libcommon.Hash, uint64, error)

GetHead returns the head of the fork choice store. it can take an optional auxilliary state to determine the current weights instead of computing the justified state.

func (*ForkChoiceStore) GetHeader

func (f *ForkChoiceStore) GetHeader(blockRoot libcommon.Hash) (*cltypes.BeaconBlockHeader, bool)

func (*ForkChoiceStore) GetInactivitiesScores

func (f *ForkChoiceStore) GetInactivitiesScores(blockRoot libcommon.Hash) (solid.Uint64ListSSZ, error)

func (*ForkChoiceStore) GetLightClientBootstrap

func (f *ForkChoiceStore) GetLightClientBootstrap(blockRoot libcommon.Hash) (*cltypes.LightClientBootstrap, bool)

func (*ForkChoiceStore) GetLightClientUpdate

func (f *ForkChoiceStore) GetLightClientUpdate(period uint64) (*cltypes.LightClientUpdate, bool)

func (*ForkChoiceStore) GetPreviousParticipationIndicies

func (f *ForkChoiceStore) GetPreviousParticipationIndicies(blockRoot libcommon.Hash) (*solid.ParticipationBitList, error)

func (*ForkChoiceStore) GetStateAtBlockRoot

func (f *ForkChoiceStore) GetStateAtBlockRoot(blockRoot libcommon.Hash, alwaysCopy bool) (*state2.CachingBeaconState, error)

func (*ForkChoiceStore) GetSyncCommittees

func (f *ForkChoiceStore) GetSyncCommittees(period uint64) (*solid.SyncCommittee, *solid.SyncCommittee, bool)

func (*ForkChoiceStore) GetValidatorSet

func (f *ForkChoiceStore) GetValidatorSet(blockRoot libcommon.Hash) (*solid.ValidatorSet, error)

func (*ForkChoiceStore) HighestSeen

func (f *ForkChoiceStore) HighestSeen() uint64

Highest seen returns highest seen slot

func (*ForkChoiceStore) IsHeadOptimistic

func (f *ForkChoiceStore) IsHeadOptimistic() bool

func (*ForkChoiceStore) IsRootOptimistic

func (f *ForkChoiceStore) IsRootOptimistic(root libcommon.Hash) bool

func (*ForkChoiceStore) JustifiedCheckpoint

func (f *ForkChoiceStore) JustifiedCheckpoint() solid.Checkpoint

JustifiedCheckpoint returns justified checkpoint

func (*ForkChoiceStore) JustifiedSlot

func (f *ForkChoiceStore) JustifiedSlot() uint64

FinalizedCheckpoint returns justified checkpoint

func (*ForkChoiceStore) LowestAvailableSlot

func (f *ForkChoiceStore) LowestAvailableSlot() uint64

func (*ForkChoiceStore) NewestLightClientUpdate

func (f *ForkChoiceStore) NewestLightClientUpdate() *cltypes.LightClientUpdate

func (*ForkChoiceStore) OnAttestation

func (f *ForkChoiceStore) OnAttestation(
	attestation *solid.Attestation,
	fromBlock bool,
	insert bool,
) error

OnAttestation processes incoming attestations.

func (*ForkChoiceStore) OnAttesterSlashing

func (f *ForkChoiceStore) OnAttesterSlashing(attesterSlashing *cltypes.AttesterSlashing, test bool) error

func (*ForkChoiceStore) OnBlock

func (f *ForkChoiceStore) OnBlock(ctx context.Context, block *cltypes.SignedBeaconBlock, newPayload, fullValidation, checkDataAvaiability bool) error

func (*ForkChoiceStore) OnTick

func (f *ForkChoiceStore) OnTick(time uint64)

OnTick executes on_tick operation for forkchoice.

func (*ForkChoiceStore) Participation

func (f *ForkChoiceStore) Participation(epoch uint64) (*solid.ParticipationBitList, bool)

func (*ForkChoiceStore) PreverifiedHistoricalRoots

func (f *ForkChoiceStore) PreverifiedHistoricalRoots(blockRoot libcommon.Hash) uint64

func (*ForkChoiceStore) PreverifiedHistoricalSummaries

func (f *ForkChoiceStore) PreverifiedHistoricalSummaries(blockRoot libcommon.Hash) uint64

func (*ForkChoiceStore) PreverifiedValidator

func (f *ForkChoiceStore) PreverifiedValidator(blockRoot libcommon.Hash) uint64

func (*ForkChoiceStore) ProcessAttestingIndicies

func (f *ForkChoiceStore) ProcessAttestingIndicies(
	attestation *solid.Attestation,
	attestionIndicies []uint64,
)

func (*ForkChoiceStore) ProposerBoostRoot

func (f *ForkChoiceStore) ProposerBoostRoot() libcommon.Hash

ProposerBoostRoot returns proposer boost root

func (*ForkChoiceStore) RandaoMixes

func (f *ForkChoiceStore) RandaoMixes(blockRoot libcommon.Hash, out solid.HashListSSZ) bool

func (*ForkChoiceStore) SetSynced

func (f *ForkChoiceStore) SetSynced(s bool)

func (*ForkChoiceStore) Slot

func (f *ForkChoiceStore) Slot() uint64

Slot calculates the current slot number using the time and genesis slot.

func (*ForkChoiceStore) Synced

func (f *ForkChoiceStore) Synced() bool

func (*ForkChoiceStore) Time

func (f *ForkChoiceStore) Time() uint64

Time returns current time

func (*ForkChoiceStore) TotalActiveBalance

func (f *ForkChoiceStore) TotalActiveBalance(root libcommon.Hash) (uint64, bool)

func (*ForkChoiceStore) ValidateOnAttestation

func (f *ForkChoiceStore) ValidateOnAttestation(attestation *solid.Attestation) error

type ForkNode

type ForkNode struct {
	Slot           uint64         `json:"slot,string"`
	BlockRoot      libcommon.Hash `json:"block_root"`
	ParentRoot     libcommon.Hash `json:"parent_root"`
	JustifiedEpoch uint64         `json:"justified_epoch,string"`
	FinalizedEpoch uint64         `json:"finalized_epoch,string"`
	Weight         uint64         `json:"weight,string"`
	Validity       string         `json:"validity"`
	ExecutionBlock libcommon.Hash `json:"execution_block_hash"`
}

ForkNode is a struct that represents a node in the fork choice tree.

type LatestMessage

type LatestMessage struct {
	Epoch uint64
	Root  libcommon.Hash
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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