protoarray

package
v0.3.10 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2020 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

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 following light house implementation: https://github.com/sigp/lighthouse/pull/804

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ForkChoice

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

ForkChoice defines the overall fork choice store which includes all block nodes, validator's latest votes and balances.

func New

func New(justifiedEpoch uint64, finalizedEpoch uint64, finalizedRoot [32]byte) *ForkChoice

New initializes a new fork choice store.

func (*ForkChoice) HasNode

func (f *ForkChoice) HasNode(root [32]byte) bool

HasNode returns true if the node exists in fork choice store, false else wise.

func (*ForkChoice) Head

func (f *ForkChoice) Head(ctx context.Context, justifiedEpoch uint64, justifiedRoot [32]byte, justifiedStateBalances []uint64, finalizedEpoch uint64) ([32]byte, error)

Head returns the head root from fork choice store. It firsts computes validator's balance changes then recalculates block tree from leaves to root.

func (*ForkChoice) Node

func (f *ForkChoice) Node(root [32]byte) *Node

Node returns the copied node in the fork choice store.

func (*ForkChoice) Nodes

func (f *ForkChoice) Nodes() []*Node

Nodes returns the copied list of block nodes in the fork choice store.

func (*ForkChoice) ProcessAttestation

func (f *ForkChoice) ProcessAttestation(ctx context.Context, validatorIndices []uint64, blockRoot [32]byte, targetEpoch uint64)

ProcessAttestation processes attestation for vote accounting, it iterates around validator indices and update their votes accordingly.

func (*ForkChoice) ProcessBlock

func (f *ForkChoice) ProcessBlock(ctx context.Context, slot uint64, blockRoot [32]byte, parentRoot [32]byte, justifiedEpoch uint64, finalizedEpoch uint64) error

ProcessBlock processes a new block by inserting it to the fork choice store.

func (*ForkChoice) Prune

func (f *ForkChoice) Prune(ctx context.Context, finalizedRoot [32]byte) error

Prune prunes the fork choice store with the new finalized root. The store is only pruned if the input root is different than the current store finalized root, and the number of the store has met prune threshold.

type Node

type Node struct {
	Slot uint64 // slot of the block converted to the node.

	Parent uint64 // the parent index of this node.

	Weight uint64 // weight of this node.

	BestDescendent uint64 // head index of this node.
	// contains filtered or unexported fields
}

Node defines the individual block which includes its block parent, ancestor and how much weight accounted for it. This is used as an array based stateful DAG for efficient fork choice look up.

type Store

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

Store defines the fork choice store which includes block nodes and the last view of checkpoint information.

type Vote

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

Vote defines an individual validator's vote.

Jump to

Keyboard shortcuts

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