forkchoice

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2021 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checkpoint

type Checkpoint = common.Checkpoint

type Epoch

type Epoch = common.Epoch

type ExtendedNodeRef added in v0.14.0

type ExtendedNodeRef = common.ExtendedNodeRef

type Forkchoice added in v0.14.0

type Forkchoice interface {
	ForkchoiceView
	ForkchoiceNodeInput
	VoteInput
	UpdateJustified(ctx context.Context, trigger Root, justified Checkpoint, finalized Checkpoint,
		justifiedStateBalances func() ([]Gwei, error)) error
	Pin() *NodeRef
	SetPin(root Root, slot Slot) error
	Justified() Checkpoint
	Finalized() Checkpoint
	Head() (NodeRef, error)
}

func NewForkChoice

func NewForkChoice(spec *common.Spec, finalized Checkpoint, justified Checkpoint,
	anchorRoot Root, anchorSlot Slot, graph ForkchoiceGraph, votes VoteStore,
	initialBalances []Gwei) (Forkchoice, error)

type ForkchoiceGraph added in v0.14.0

type ForkchoiceGraph interface {
	ForkchoiceView
	ForkchoiceNodeInput
	Indices() map[NodeRef]NodeIndex
	ApplyScoreChanges(deltas []SignedGwei, justifiedEpoch Epoch, finalizedEpoch Epoch) error
	OnPrune(ctx context.Context, anchorRoot Root, anchorSlot Slot) error
}

type ForkchoiceNodeInput added in v0.14.0

type ForkchoiceNodeInput interface {
	ProcessSlot(parent Root, slot Slot, justifiedEpoch Epoch, finalizedEpoch Epoch)
	ProcessBlock(parent Root, blockRoot Root, blockSlot Slot, justifiedEpoch Epoch, finalizedEpoch Epoch) (ok bool)
}

type ForkchoiceView added in v0.14.0

type ForkchoiceView interface {
	CanonicalChain(anchorRoot Root, anchorSlot Slot) ([]ExtendedNodeRef, error)
	ClosestToSlot(anchor Root, slot Slot) (closest NodeRef, err error)
	CanonAtSlot(anchor Root, slot Slot, withBlock bool) (at NodeRef, err error)
	GetSlot(blockRoot Root) (slot Slot, ok bool)
	FindHead(anchorRoot Root, anchorSlot Slot) (NodeRef, error)
	InSubtree(anchor Root, root Root) (unknown bool, inSubtree bool)
	Search(anchor NodeRef, parentRoot *Root, slot *Slot) (nonCanon []NodeRef, canon []NodeRef, err error)
}

type Gwei

type Gwei = common.Gwei

type NodeIndex added in v0.14.0

type NodeIndex uint64

type NodeRef added in v0.14.0

type NodeRef = common.NodeRef

type ProtoForkChoice added in v0.14.0

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

func (*ProtoForkChoice) CanonAtSlot added in v0.14.0

func (fc *ProtoForkChoice) CanonAtSlot(anchor Root, slot Slot, withBlock bool) (closest NodeRef, err error)

func (*ProtoForkChoice) CanonicalChain added in v0.14.0

func (fc *ProtoForkChoice) CanonicalChain(anchorRoot Root, anchorSlot Slot) ([]ExtendedNodeRef, error)

func (*ProtoForkChoice) ClosestToSlot added in v0.14.0

func (fc *ProtoForkChoice) ClosestToSlot(anchor Root, slot Slot) (ref NodeRef, err error)

func (*ProtoForkChoice) Finalized added in v0.14.0

func (fc *ProtoForkChoice) Finalized() Checkpoint

func (*ProtoForkChoice) FindHead added in v0.14.0

func (fc *ProtoForkChoice) FindHead(anchorRoot Root, anchorSlot Slot) (NodeRef, error)

func (*ProtoForkChoice) GetSlot added in v0.14.0

func (fc *ProtoForkChoice) GetSlot(root Root) (slot Slot, ok bool)

func (*ProtoForkChoice) Head added in v0.14.0

func (fc *ProtoForkChoice) Head() (NodeRef, error)

func (*ProtoForkChoice) InSubtree added in v0.14.0

func (fc *ProtoForkChoice) InSubtree(anchor Root, root Root) (unknown bool, inSubtree bool)

func (*ProtoForkChoice) Justified added in v0.14.0

func (fc *ProtoForkChoice) Justified() Checkpoint

func (*ProtoForkChoice) Pin added in v0.14.0

func (fc *ProtoForkChoice) Pin() *NodeRef

func (*ProtoForkChoice) ProcessAttestation added in v0.14.0

func (fc *ProtoForkChoice) ProcessAttestation(index ValidatorIndex, blockRoot Root, headSlot Slot) (ok bool)

func (*ProtoForkChoice) ProcessBlock added in v0.14.0

func (fc *ProtoForkChoice) ProcessBlock(parentRoot Root, blockRoot Root, blockSlot Slot, justifiedEpoch Epoch, finalizedEpoch Epoch) (ok bool)

func (*ProtoForkChoice) ProcessSlot added in v0.14.0

func (fc *ProtoForkChoice) ProcessSlot(parentRoot Root, slot Slot, justifiedEpoch Epoch, finalizedEpoch Epoch)

func (*ProtoForkChoice) Search added in v0.14.0

func (fc *ProtoForkChoice) Search(anchor NodeRef, parentRoot *Root, slot *Slot) (nonCanon []NodeRef, canon []NodeRef, err error)

func (*ProtoForkChoice) SetPin added in v0.14.0

func (fc *ProtoForkChoice) SetPin(root Root, slot Slot) error

func (*ProtoForkChoice) UpdateJustified added in v0.14.0

func (fc *ProtoForkChoice) UpdateJustified(ctx context.Context, trigger Root, justified Checkpoint, finalized Checkpoint,
	justifiedStateBalances func() ([]Gwei, error)) error

UpdateJustified updates what is recognized as justified and finalized checkpoint, and adjusts justified balances for vote weights. If the finalized checkpoint changes, it triggers pruning. Note that pruning can prune the pre-block node of the start slot of the finalized epoch, if it is not a gap slot. And the finalizing node with the block will remain. The justification/finalization trigger must be within the pinned subtree (if any).

type Root

type Root = common.Root

type SignedGwei

type SignedGwei int64

type Slot

type Slot = common.Slot

type ValidatorIndex

type ValidatorIndex = common.ValidatorIndex

type VoteInput added in v0.14.0

type VoteInput interface {
	// ProcessAttestation overrides any previous vote, and applies voting weight to the new root/slot.
	// If the root/slot combination does not exist, no changes are made, and ok=false is returned.
	// It is up to the caller if nodes should be added, to then process the attestation.
	ProcessAttestation(index ValidatorIndex, blockRoot Root, headSlot Slot) (ok bool)
}

type VoteStore added in v0.14.0

type VoteStore interface {
	VoteInput
	HasChanges() bool
	ComputeDeltas(indices map[NodeRef]NodeIndex, oldBalances []Gwei, newBalances []Gwei) []SignedGwei
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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