forks

package
v1.4.2-0...-e33850b Latest Latest
Warning

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

Go to latest
Published: May 11, 2022 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package forks contains useful helpers for Ethereum consensus fork-related functionality.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoPreviousVersion = errors.New("no previous version")

ErrNoPreviousVersion indicates that a version prior to the given version could not be found, because the given version is the first one in the list

View Source
var ErrVersionNotFound = errors.New("could not find an entry in the fork schedule")

ErrVersionNotFound indicates the config package couldn't determine the version for an epoch using the fork schedule.

Functions

func CreateForkDigest

func CreateForkDigest(
	genesisTime time.Time,
	genesisValidatorsRoot []byte,
) ([4]byte, error)

CreateForkDigest creates a fork digest from a genesis time and genesis validators root, utilizing the current slot to determine the active fork version in the node.

func Fork

func Fork(
	targetEpoch types.Epoch,
) (*ethpb.Fork, error)

Fork given a target epoch, returns the active fork version during this epoch.

func ForkDigestFromEpoch

func ForkDigestFromEpoch(currentEpoch types.Epoch, genesisValidatorsRoot []byte) ([4]byte, error)

ForkDigestFromEpoch retrieves the fork digest from the current schedule determined by the provided epoch.

func IsForkNextEpoch

func IsForkNextEpoch(genesisTime time.Time, genesisValidatorsRoot []byte) (bool, error)

IsForkNextEpoch checks if an alloted fork is in the following epoch.

func NextForkData

func NextForkData(currEpoch types.Epoch) ([4]byte, types.Epoch, error)

NextForkData retrieves the next fork data according to the provided current epoch.

func RetrieveForkDataFromDigest

func RetrieveForkDataFromDigest(digest [4]byte, genesisValidatorsRoot []byte) ([4]byte, types.Epoch, error)

RetrieveForkDataFromDigest performs the inverse, where it tries to determine the fork version and epoch from a provided digest by looping through our current fork schedule.

func SortedForkVersions

func SortedForkVersions(forkSchedule map[[4]byte]types.Epoch) [][4]byte

SortedForkVersions sorts the provided fork schedule in ascending order by epoch.

Types

type ForkScheduleEntry

type ForkScheduleEntry struct {
	Version [fieldparams.VersionLength]byte
	Epoch   types.Epoch
}

ForkScheduleEntry is a Version+Epoch tuple for sorted storage in an OrderedSchedule

type OrderedSchedule

type OrderedSchedule []ForkScheduleEntry

OrderedSchedule provides a type that can be used to sort the fork schedule and find the Version the chain should be at for a given epoch (via VersionForEpoch).

func NewOrderedSchedule

func NewOrderedSchedule(b *params.BeaconChainConfig) OrderedSchedule

Converts the ForkVersionSchedule map into a list of Version+Epoch values, ordered by Epoch from lowest to highest. See docs for OrderedSchedule for more detail on what you can do with this type.

func (OrderedSchedule) Len

func (o OrderedSchedule) Len() int

Len implements the Len method of sort.Interface

func (OrderedSchedule) Less

func (o OrderedSchedule) Less(i, j int) bool

Less implements the Less method of sort.Interface

func (OrderedSchedule) Previous

func (OrderedSchedule) Swap

func (o OrderedSchedule) Swap(i, j int)

Swap implements the Swap method of sort.Interface

func (OrderedSchedule) VersionForEpoch

func (o OrderedSchedule) VersionForEpoch(epoch types.Epoch) ([fieldparams.VersionLength]byte, error)

VersionForEpoch finds the Version with the highest epoch <= the given epoch

Jump to

Keyboard shortcuts

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