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 ¶
- Variables
- func Initialize(ctx context.Context, dir string, providers ...Provider) error
- func State() (state.BeaconState, error)
- func Store(d GenesisData) error
- func StoreDuringTest(t *testing.T, gd GenesisData)
- func StoreEmbeddedDuringTest(t *testing.T, name string)
- func StoreStateDuringTest(t *testing.T, st state.BeaconState)
- func Time() time.Time
- func ValidatorsRoot() [32]byte
- type APIProvider
- type FileProvider
- type GenesisData
- type Provider
Constants ¶
This section is empty.
Variables ¶
var ErrFilePathUnset = errors.New("path to genesis data directory is not set")
var ErrGenesisFileNotFound = errors.New("genesis state file not found")
var ErrGenesisStateNotInitialized = errors.New("genesis state has not been initialized")
var ErrNotGenesisStateFile = errors.New("file is not a genesis state file")
Functions ¶
func Initialize ¶
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 ¶
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 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.