-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tool for processing for all mainnet beacon blocks (#7095)
- Loading branch information
1 parent
e4b2072
commit 36828fb
Showing
14 changed files
with
134 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package initial_state | ||
|
||
import ( | ||
_ "embed" | ||
"fmt" | ||
|
||
"github.com/ledgerwatch/erigon/cl/clparams" | ||
"github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" | ||
) | ||
|
||
//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: | ||
if err := returnState.DecodeSSZWithVersion(mainnetStateSSZ, int(clparams.Phase0Version)); err != nil { | ||
return nil, err | ||
} | ||
case clparams.GoerliNetwork: | ||
if err := returnState.DecodeSSZWithVersion(goerliStateSSZ, int(clparams.Phase0Version)); err != nil { | ||
return nil, err | ||
} | ||
case clparams.SepoliaNetwork: | ||
if err := returnState.DecodeSSZWithVersion(sepoliaStateSSZ, int(clparams.Phase0Version)); err != nil { | ||
return nil, err | ||
} | ||
default: | ||
return nil, fmt.Errorf("unsupported network for genesis fetching") | ||
} | ||
return returnState, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package initial_state_test | ||
|
||
import ( | ||
"testing" | ||
|
||
libcommon "github.com/ledgerwatch/erigon-lib/common" | ||
"github.com/ledgerwatch/erigon/cl/clparams" | ||
"github.com/ledgerwatch/erigon/cl/clparams/initial_state" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestMainnet(t *testing.T) { | ||
state, err := initial_state.GetGenesisState(clparams.MainnetNetwork) | ||
assert.NoError(t, err) | ||
root, err := state.HashSSZ() | ||
assert.NoError(t, err) | ||
assert.Equal(t, libcommon.Hash(root), libcommon.HexToHash("7e76880eb67bbdc86250aa578958e9d0675e64e714337855204fb5abaaf82c2b")) | ||
} | ||
|
||
func TestGoerli(t *testing.T) { | ||
state, err := initial_state.GetGenesisState(clparams.GoerliNetwork) | ||
assert.NoError(t, err) | ||
root, err := state.HashSSZ() | ||
assert.NoError(t, err) | ||
assert.Equal(t, libcommon.Hash(root), libcommon.HexToHash("895390e92edc03df7096e9f51e51896e8dbe6e7e838180dadbfd869fdd77a659")) | ||
} | ||
|
||
func TestSepolia(t *testing.T) { | ||
state, err := initial_state.GetGenesisState(clparams.SepoliaNetwork) | ||
assert.NoError(t, err) | ||
root, err := state.HashSSZ() | ||
assert.NoError(t, err) | ||
assert.Equal(t, libcommon.Hash(root), libcommon.HexToHash("fb9afe32150fa39f4b346be2519a67e2a4f5efcd50a1dc192c3f6b3d013d2798")) | ||
} |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters