mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-23 04:03:49 +00:00
3ab373787e
we need to extract this interface from the struct. i need to also break down the interface more, to better show what parts the caching is used, move some functions from the cache state to the underlying. don't merge
44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
package initial_state
|
|
|
|
import (
|
|
_ "embed"
|
|
"fmt"
|
|
|
|
"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
|
|
|
|
//go:embed goerli.state.ssz
|
|
var goerliStateSSZ []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.GoerliNetwork:
|
|
if err := returnState.DecodeSSZ(goerliStateSSZ, int(clparams.Phase0Version)); err != nil {
|
|
return nil, err
|
|
}
|
|
case clparams.SepoliaNetwork:
|
|
if err := returnState.DecodeSSZ(sepoliaStateSSZ, int(clparams.Phase0Version)); err != nil {
|
|
return nil, err
|
|
}
|
|
default:
|
|
return nil, fmt.Errorf("unsupported network for genesis fetching")
|
|
}
|
|
return returnState, nil
|
|
}
|