erigon-pulse/cl/clparams/initial_state/initial_state.go
Giulio rebuffo c477281362
Caplin: Parallel historical states reconstruction (#8817)
What does this PR do:
* Optional Backfilling and Caplin Archive Node
* Create antiquary for historical states
* Fixed gaps of chain gap related to the Head of the chain and anchor of
the chain.
* Added basic reader object to Read the Historical state
2023-12-06 10:48:36 +01:00

47 lines
1.0 KiB
Go

package initial_state
import (
_ "embed"
"github.com/ledgerwatch/erigon/cl/phase1/core/state"
"github.com/ledgerwatch/erigon/cl/clparams"
)
//go:embed mainnet.state.ssz
var mainnetStateSSZ []byte
//go:embed sepolia.state.ssz
var sepoliaStateSSZ []byte
// Return genesis state
func GetGenesisState(network clparams.NetworkType) (*state.CachingBeaconState, error) {
_, _, config := clparams.GetConfigsByNetwork(network)
returnState := state.New(config)
switch network {
case clparams.MainnetNetwork:
if err := returnState.DecodeSSZ(mainnetStateSSZ, int(clparams.Phase0Version)); err != nil {
return nil, err
}
case clparams.SepoliaNetwork:
if err := returnState.DecodeSSZ(sepoliaStateSSZ, int(clparams.Phase0Version)); err != nil {
return nil, err
}
case clparams.GoerliNetwork:
return nil, nil
}
return returnState, nil
}
func IsGenesisStateSupported(network clparams.NetworkType) bool {
switch network {
case clparams.MainnetNetwork:
return true
case clparams.SepoliaNetwork:
return true
default:
return false
}
}