genesis

package
v7.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Code generated by hack/gen-logs.sh; DO NOT EDIT. This file is created and regenerated automatically. Anything added here might get removed.

Index

Constants

This section is empty.

Variables

View Source
var ErrFilePathUnset = errors.New("path to genesis data directory is not set")
View Source
var ErrGenesisFileNotFound = errors.New("genesis state file not found")
View Source
var ErrGenesisStateNotInitialized = errors.New("genesis state has not been initialized")
View Source
var ErrNotGenesisStateFile = errors.New("file is not a genesis state file")

Functions

func Initialize

func Initialize(ctx context.Context, dir string, providers ...Provider) error

Initialize is mainly exported for the node initialization process to specify providers of the genesis data and the path to the local storage location via cli flags.

func State

func State() (state.BeaconState, error)

State returns the full genesis BeaconState. It can return an error because this value is lazy loaded. The returned value will always be a copy of the underlying value.

func Store

func Store(d GenesisData) error

Store is an exported method that allows another package to set the genesis data value and persist it to disk. It is exported to be used by implementations of the Provider interface.

func StoreDuringTest

func StoreDuringTest(t *testing.T, gd GenesisData)

StoreDuringTest temporarily replaces the package level GenesisData with the provided GenesisData

func StoreEmbeddedDuringTest

func StoreEmbeddedDuringTest(t *testing.T, name string)

StoreEmbeddedDuringTest sets the named embedded genesis file as the genesis data for the lifecycle of the current test.

func StoreStateDuringTest

func StoreStateDuringTest(t *testing.T, st state.BeaconState)

StoreStateDuringTest creates and stores genesis data from a beacon state for the duration of a test. This is essential for testing components that depend on genesis information being globally available, The function automatically cleans up after the test completes, restoring the previous genesis state to prevent test interference. Without this setup, many blockchain components would fail during testing due to uninitialized genesis data.

func Time

func Time() time.Time

Time returns the genesis time.

func ValidatorsRoot

func ValidatorsRoot() [32]byte

ValidatorsRoot returns the genesis validators root.

Types

type APIProvider

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

APIProvider provides a genesis state using the given beacon node API url.

func NewAPIProvider

func NewAPIProvider(beaconNodeHost string) (*APIProvider, error)

NewAPIProvider creates an APIProvider, handling the set up of a beacon node api client.

func (*APIProvider) Genesis

func (dl *APIProvider) Genesis(ctx context.Context) (state.BeaconState, error)

Genesis satisfies the Provider interface by retrieving the genesis state from the beacon node API and unmarshaling it into a phase0 beacon state.

type FileProvider

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

FileProvider provides the genesis state by reading the given ssz-encoded beacon state file path.

func NewFileProvider

func NewFileProvider(statePath string) (*FileProvider, error)

NewFileProvider validates the given path information and creates a Provider which sources the genesis state from an ssz-encoded file on the local filesystem.

func (*FileProvider) Genesis

func (fi *FileProvider) Genesis(_ context.Context) (state.BeaconState, error)

Genesis satisfies the Provider interface by reading the genesis state from a file and unmarshaling it.

type GenesisData

type GenesisData struct {
	ValidatorsRoot [32]byte
	Time           time.Time
	FileDir        string
	State          state.BeaconState
	// contains filtered or unexported fields
}

GenesisData bundles all the package level data. It is exported to allow implementations of the Provider interface to set genesis data.

func FindStateFile

func FindStateFile(dir string) (GenesisData, error)

FindStateFile searches for a valid genesis state file in the specified directory.

func (GenesisData) FilePath

func (d GenesisData) FilePath() string

FilePath returns the full path to the genesis state file.

type Provider

type Provider interface {
	Genesis(context.Context) (state.BeaconState, error)
}

Provider is a type that can provide the genesis state for the initialization of the genesis package. Examples are getting the state from a beacon node API, reading it from a file, or from the legacy database.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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