forkchoice

package
v3.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2022 License: GPL-3.0 Imports: 7 Imported by: 6

Documentation

Overview

Package forkchoice implements the service to support fork choice for the Ethereum beacon chain. This contains the necessary components to track latest validators votes, and balances. Then a store object to be used to calculate head. High level fork choice summary: https://notes.ethereum.org/@vbuterin/rkhCgQteN?type=view#LMD-GHOST-fork-choice-rule

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownCommonAncestor = errors.New("unknown common ancestor")

Functions

This section is empty.

Types

type AttestationProcessor

type AttestationProcessor interface {
	ProcessAttestation(context.Context, []uint64, [32]byte, types.Epoch)
	InsertSlashedIndex(context.Context, types.ValidatorIndex)
}

AttestationProcessor processes the attestation that's used for accounting fork choice.

type BlockProcessor

type BlockProcessor interface {
	InsertNode(context.Context, state.BeaconState, [32]byte) error
	InsertOptimisticChain(context.Context, []*forkchoicetypes.BlockAndCheckpoints) error
}

BlockProcessor processes the block that's used for accounting fork choice.

type ForkChoicer

type ForkChoicer interface {
	HeadRetriever        // to compute head.
	BlockProcessor       // to track new block for fork choice.
	AttestationProcessor // to track new attestation for fork choice.
	Getter               // to retrieve fork choice information.
	Setter               // to set fork choice information.
	ProposerBooster      // ability to boost timely-proposed block roots.
}

ForkChoicer represents the full fork choice interface composed of all the sub-interfaces.

type Getter

type Getter interface {
	HasNode([32]byte) bool
	ProposerBoost() [fieldparams.RootLength]byte
	HasParent(root [32]byte) bool
	AncestorRoot(ctx context.Context, root [32]byte, slot types.Slot) ([32]byte, error)
	CommonAncestor(ctx context.Context, root1 [32]byte, root2 [32]byte) ([32]byte, types.Slot, error)
	IsCanonical(root [32]byte) bool
	FinalizedCheckpoint() *forkchoicetypes.Checkpoint
	FinalizedPayloadBlockHash() [32]byte
	JustifiedCheckpoint() *forkchoicetypes.Checkpoint
	PreviousJustifiedCheckpoint() *forkchoicetypes.Checkpoint
	JustifiedPayloadBlockHash() [32]byte
	BestJustifiedCheckpoint() *forkchoicetypes.Checkpoint
	NodeCount() int
	HighestReceivedBlockSlot() types.Slot
	ReceivedBlocksLastEpoch() (uint64, error)
	ForkChoiceDump(context.Context) (*v1.ForkChoiceResponse, error)
}

Getter returns fork choice related information.

type HeadRetriever

type HeadRetriever interface {
	Head(context.Context, []uint64) ([32]byte, error)
	CachedHeadRoot() [32]byte
	Tips() ([][32]byte, []types.Slot)
	IsOptimistic(root [32]byte) (bool, error)
	AllTipsAreInvalid() bool
}

HeadRetriever retrieves head root and optimistic info of the current chain.

type ProposerBooster

type ProposerBooster interface {
	ResetBoostedProposerRoot(ctx context.Context) error
}

ProposerBooster is able to boost the proposer's root score during fork choice.

type Setter

type Setter interface {
	SetOptimisticToValid(context.Context, [fieldparams.RootLength]byte) error
	SetOptimisticToInvalid(context.Context, [fieldparams.RootLength]byte, [fieldparams.RootLength]byte, [fieldparams.RootLength]byte) ([][32]byte, error)
	UpdateJustifiedCheckpoint(*forkchoicetypes.Checkpoint) error
	UpdateFinalizedCheckpoint(*forkchoicetypes.Checkpoint) error
	SetGenesisTime(uint64)
	SetOriginRoot([32]byte)
	NewSlot(context.Context, types.Slot) error
}

Setter allows to set forkchoice information

Directories

Path Synopsis
Package doublylinkedtree implements eth2 LMD GHOST fork choice using the doubly linked proto array node structure.
Package doublylinkedtree implements eth2 LMD GHOST fork choice using the doubly linked proto array node structure.
Package protoarray implements proto array fork choice as outlined: https://github.com/protolambda/lmd-ghost#array-based-stateful-dag-proto_array This was motivated by the original implementation by Sigma Prime here: https://github.com/sigp/lighthouse/pull/804
Package protoarray implements proto array fork choice as outlined: https://github.com/protolambda/lmd-ghost#array-based-stateful-dag-proto_array This was motivated by the original implementation by Sigma Prime here: https://github.com/sigp/lighthouse/pull/804

Jump to

Keyboard shortcuts

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