Documentation ¶
Overview ¶
Package forks contains useful helpers for Ethereum consensus fork-related functionality.
Index ¶
- Variables
- func CreateForkDigest(genesisTime time.Time, genesisValidatorsRoot []byte) ([4]byte, error)
- func Fork(targetEpoch primitives.Epoch) (*ethpb.Fork, error)
- func ForkDigestFromEpoch(currentEpoch primitives.Epoch, genesisValidatorsRoot []byte) ([4]byte, error)
- func IsForkNextEpoch(genesisTime time.Time, genesisValidatorsRoot []byte) (bool, error)
- func LastForkEpoch() primitives.Epoch
- func NextForkData(currEpoch primitives.Epoch) ([4]byte, primitives.Epoch, error)
- func RetrieveForkDataFromDigest(digest [4]byte, genesisValidatorsRoot []byte) ([4]byte, primitives.Epoch, error)
- func SortedForkVersions(forkSchedule map[[4]byte]primitives.Epoch) [][4]byte
- type ForkScheduleEntry
- type OrderedSchedule
- func (o OrderedSchedule) ForkFromVersion(version [fieldparams.VersionLength]byte) (*ethpb.Fork, error)
- func (o OrderedSchedule) Len() int
- func (o OrderedSchedule) Less(i, j int) bool
- func (o OrderedSchedule) Previous(version [fieldparams.VersionLength]byte) ([fieldparams.VersionLength]byte, error)
- func (o OrderedSchedule) Swap(i, j int)
- func (o OrderedSchedule) VersionForEpoch(epoch primitives.Epoch) ([fieldparams.VersionLength]byte, error)
- func (o OrderedSchedule) VersionForName(name string) ([fieldparams.VersionLength]byte, error)
Constants ¶
This section is empty.
Variables ¶
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
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 ¶
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 primitives.Epoch, ) (*ethpb.Fork, error)
Fork given a target epoch, returns the active fork version during this epoch.
func ForkDigestFromEpoch ¶
func ForkDigestFromEpoch(currentEpoch primitives.Epoch, genesisValidatorsRoot []byte) ([4]byte, error)
ForkDigestFromEpoch retrieves the fork digest from the current schedule determined by the provided epoch.
func IsForkNextEpoch ¶
IsForkNextEpoch checks if an allotted fork is in the following epoch.
func LastForkEpoch ¶
func LastForkEpoch() primitives.Epoch
LastForkEpoch returns the last valid fork epoch that exists in our fork schedule.
func NextForkData ¶
func NextForkData(currEpoch primitives.Epoch) ([4]byte, primitives.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, primitives.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]primitives.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 primitives.Epoch Name string }
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) or name (via VersionForName).
func NewOrderedSchedule ¶
func NewOrderedSchedule(b *params.BeaconChainConfig) OrderedSchedule
NewOrderedSchedule Converts fork version maps into a list of Version+Epoch+Name 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) ForkFromVersion ¶
func (o OrderedSchedule) ForkFromVersion(version [fieldparams.VersionLength]byte) (*ethpb.Fork, error)
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 (o OrderedSchedule) Previous(version [fieldparams.VersionLength]byte) ([fieldparams.VersionLength]byte, error)
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 primitives.Epoch) ([fieldparams.VersionLength]byte, error)
VersionForEpoch finds the Version with the highest epoch <= the given epoch
func (OrderedSchedule) VersionForName ¶
func (o OrderedSchedule) VersionForName(name string) ([fieldparams.VersionLength]byte, error)
VersionForName finds the Version corresponding to the lowercase version of the provided name.