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 types.Epoch) (*ethpb.Fork, error)
- func ForkDigestFromEpoch(currentEpoch types.Epoch, genesisValidatorsRoot []byte) ([4]byte, error)
- func IsForkNextEpoch(genesisTime time.Time, genesisValidatorsRoot []byte) (bool, error)
- func NextForkData(currEpoch types.Epoch) ([4]byte, types.Epoch, error)
- func RetrieveForkDataFromDigest(digest [4]byte, genesisValidatorsRoot []byte) ([4]byte, types.Epoch, error)
- func SortedForkVersions(forkSchedule map[[4]byte]types.Epoch) [][4]byte
- type ForkScheduleEntry
- type OrderedSchedule
- 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 types.Epoch) ([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 ForkDigestFromEpoch ¶
ForkDigestFromEpoch retrieves the fork digest from the current schedule determined by the provided epoch.
func IsForkNextEpoch ¶
IsForkNextEpoch checks if an alloted fork is in the following epoch.
func NextForkData ¶
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.
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 (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 types.Epoch) ([fieldparams.VersionLength]byte, error)
VersionForEpoch finds the Version with the highest epoch <= the given epoch