2023-03-17 12:37:51 +00:00
|
|
|
package initial_state
|
|
|
|
|
|
|
|
import (
|
|
|
|
_ "embed"
|
|
|
|
"fmt"
|
2023-05-13 21:44:07 +00:00
|
|
|
"github.com/ledgerwatch/erigon/cl/phase1/core/state"
|
2023-03-17 12:37:51 +00:00
|
|
|
|
|
|
|
"github.com/ledgerwatch/erigon/cl/clparams"
|
|
|
|
)
|
|
|
|
|
|
|
|
//go:embed mainnet.state.ssz
|
|
|
|
var mainnetStateSSZ []byte
|
|
|
|
|
|
|
|
//go:embed sepolia.state.ssz
|
|
|
|
var sepoliaStateSSZ []byte
|
|
|
|
|
|
|
|
//go:embed goerli.state.ssz
|
|
|
|
var goerliStateSSZ []byte
|
|
|
|
|
|
|
|
// Return genesis state
|
|
|
|
func GetGenesisState(network clparams.NetworkType) (*state.BeaconState, error) {
|
|
|
|
_, _, config := clparams.GetConfigsByNetwork(network)
|
|
|
|
returnState := state.New(config)
|
|
|
|
|
|
|
|
switch network {
|
|
|
|
case clparams.MainnetNetwork:
|
2023-05-05 09:19:24 +00:00
|
|
|
if err := returnState.DecodeSSZ(mainnetStateSSZ, int(clparams.Phase0Version)); err != nil {
|
2023-03-17 12:37:51 +00:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
case clparams.GoerliNetwork:
|
2023-05-05 09:19:24 +00:00
|
|
|
if err := returnState.DecodeSSZ(goerliStateSSZ, int(clparams.Phase0Version)); err != nil {
|
2023-03-17 12:37:51 +00:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
case clparams.SepoliaNetwork:
|
2023-05-05 09:19:24 +00:00
|
|
|
if err := returnState.DecodeSSZ(sepoliaStateSSZ, int(clparams.Phase0Version)); err != nil {
|
2023-03-17 12:37:51 +00:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return nil, fmt.Errorf("unsupported network for genesis fetching")
|
|
|
|
}
|
|
|
|
return returnState, nil
|
|
|
|
}
|