forkid

package
v3.0.0-alpha5.0...-c974331 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: LGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package forkid implements EIP-2124 (https://eips.ethereum.org/EIPS/eip-2124).

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRemoteStale is returned by the validator if a remote fork checksum is a
	// subset of our already applied forks, but the announced next fork block is
	// not on our already passed chain.
	ErrRemoteStale = errors.New("remote needs update")

	// ErrLocalIncompatibleOrStale is returned by the validator if a remote fork
	// checksum does not match any local checksum variation, signalling that the
	// two chains have diverged in the past at some point (possibly at genesis).
	ErrLocalIncompatibleOrStale = errors.New("local incompatible or needs update")
)

Functions

func GatherForks

func GatherForks(config *chain.Config, genesisTime uint64) (heightForks []uint64, timeForks []uint64)

GatherForks gathers all the known forks and creates a sorted list out of them.

func NextForkHashFromForks

func NextForkHashFromForks(heightForks, timeForks []uint64, genesis libcommon.Hash, headHeight, headTime uint64) [4]byte

Types

type Filter

type Filter func(id ID) error

Filter is a fork id filter to validate a remotely advertised ID.

func NewFilterFromForks

func NewFilterFromForks(heightForks, timeForks []uint64, genesis libcommon.Hash, headHeight, headTime uint64) Filter

NewFilterFromForks creates a filter that returns if a fork ID should be rejected or not based on the provided current head.

func NewStaticFilter

func NewStaticFilter(config *chain.Config, genesisHash libcommon.Hash, genesisTime uint64) Filter

NewStaticFilter creates a filter at block zero.

type ID

type ID struct {
	Hash [4]byte // CRC32 checksum of the genesis block and passed fork block numbers
	Next uint64  // Block number of the next upcoming fork, or 0 if no forks are known
}

ID is a fork identifier as defined by EIP-2124.

func NewIDFromForks

func NewIDFromForks(heightForks, timeForks []uint64, genesis libcommon.Hash, headHeight, headTime uint64) ID

Jump to

Keyboard shortcuts

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