2023-03-17 12:37:51 +00:00
|
|
|
package initial_state
|
|
|
|
|
|
|
|
import (
|
|
|
|
_ "embed"
|
2023-06-02 03:35:26 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
|
// Return genesis state
|
2023-07-19 22:20:33 +00:00
|
|
|
func GetGenesisState(network clparams.NetworkType) (*state.CachingBeaconState, error) {
|
2023-03-17 12:37:51 +00:00
|
|
|
_, _, 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.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
|
|
|
|
}
|
2023-12-06 09:48:36 +00:00
|
|
|
case clparams.GoerliNetwork:
|
|
|
|
return nil, nil
|
2023-03-17 12:37:51 +00:00
|
|
|
}
|
|
|
|
return returnState, nil
|
|
|
|
}
|
2023-12-06 09:48:36 +00:00
|
|
|
|
|
|
|
func IsGenesisStateSupported(network clparams.NetworkType) bool {
|
|
|
|
switch network {
|
|
|
|
case clparams.MainnetNetwork:
|
|
|
|
return true
|
|
|
|
case clparams.SepoliaNetwork:
|
|
|
|
return true
|
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|