diff --git a/Dockerfile b/Dockerfile index 85524480c..1b7998ee5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -62,7 +62,6 @@ COPY --from=tools-builder /app/build/bin/mdbx_stat /usr/local/bin/mdbx_stat COPY --from=builder /app/build/bin/devnet /usr/local/bin/devnet COPY --from=builder /app/build/bin/downloader /usr/local/bin/downloader COPY --from=builder /app/build/bin/erigon /usr/local/bin/erigon -COPY --from=builder /app/build/bin/erigon-cl /usr/local/bin/erigon-cl COPY --from=builder /app/build/bin/evm /usr/local/bin/evm COPY --from=builder /app/build/bin/hack /usr/local/bin/hack COPY --from=builder /app/build/bin/integration /usr/local/bin/integration diff --git a/Makefile b/Makefile index 1478ff500..bd4b8739b 100644 --- a/Makefile +++ b/Makefile @@ -108,7 +108,6 @@ erigon: go-version erigon.cmd COMMANDS += devnet COMMANDS += erigon-el-mock COMMANDS += downloader -COMMANDS += erigon-cl COMMANDS += hack COMMANDS += integration COMMANDS += observer diff --git a/cl/clparams/initial_state/initial_state.go b/cl/clparams/initial_state/initial_state.go index 9c9764f29..d17853754 100644 --- a/cl/clparams/initial_state/initial_state.go +++ b/cl/clparams/initial_state/initial_state.go @@ -3,9 +3,9 @@ package initial_state import ( _ "embed" "fmt" + "github.com/ledgerwatch/erigon/cl/phase1/core/state" "github.com/ledgerwatch/erigon/cl/clparams" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" ) //go:embed mainnet.state.ssz diff --git a/cl/merkle_tree/merkle_root_test.go b/cl/merkle_tree/merkle_root_test.go index 13e7d703b..b07427ff0 100644 --- a/cl/merkle_tree/merkle_root_test.go +++ b/cl/merkle_tree/merkle_root_test.go @@ -1,13 +1,13 @@ package merkle_tree_test import ( + "github.com/ledgerwatch/erigon/cl/phase1/core/state/state_encoding" "testing" libcommon "github.com/ledgerwatch/erigon-lib/common" "github.com/stretchr/testify/require" "github.com/ledgerwatch/erigon/cl/merkle_tree" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state/state_encoding" ) func TestEmptyArraysRoot(t *testing.T) { diff --git a/cmd/erigon-cl/cache/attestation_indicies_cache.go b/cl/phase1/cache/attestation_indicies_cache.go similarity index 88% rename from cmd/erigon-cl/cache/attestation_indicies_cache.go rename to cl/phase1/cache/attestation_indicies_cache.go index 36b8b6d03..174cf0290 100644 --- a/cmd/erigon-cl/cache/attestation_indicies_cache.go +++ b/cl/phase1/cache/attestation_indicies_cache.go @@ -2,7 +2,7 @@ package cache import ( "github.com/ledgerwatch/erigon/cl/cltypes" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state/lru" + "github.com/ledgerwatch/erigon/cl/phase1/core/state/lru" ) var attestationIndiciesCache *lru.Cache[*cltypes.AttestationData, []uint64] diff --git a/cmd/erigon-cl/cache/init.go b/cl/phase1/cache/init.go similarity index 81% rename from cmd/erigon-cl/cache/init.go rename to cl/phase1/cache/init.go index d0f51cd31..d342ee8ba 100644 --- a/cmd/erigon-cl/cache/init.go +++ b/cl/phase1/cache/init.go @@ -2,7 +2,7 @@ package cache import ( "github.com/ledgerwatch/erigon/cl/cltypes" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state/lru" + "github.com/ledgerwatch/erigon/cl/phase1/core/state/lru" ) func init() { diff --git a/cmd/erigon-cl/core/checkpoint.go b/cl/phase1/core/checkpoint.go similarity index 95% rename from cmd/erigon-cl/core/checkpoint.go rename to cl/phase1/core/checkpoint.go index a0e7202c4..3c5ac4d88 100644 --- a/cmd/erigon-cl/core/checkpoint.go +++ b/cl/phase1/core/checkpoint.go @@ -3,12 +3,12 @@ package core import ( "context" "fmt" + "github.com/ledgerwatch/erigon/cl/phase1/core/state" "io" "net/http" "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" "github.com/ledgerwatch/log/v3" ) diff --git a/cmd/erigon-cl/core/rawdb/accessors.go b/cl/phase1/core/rawdb/accessors.go similarity index 98% rename from cmd/erigon-cl/core/rawdb/accessors.go rename to cl/phase1/core/rawdb/accessors.go index 30841b480..c1704d7e5 100644 --- a/cmd/erigon-cl/core/rawdb/accessors.go +++ b/cl/phase1/core/rawdb/accessors.go @@ -3,6 +3,7 @@ package rawdb import ( "encoding/binary" "fmt" + "github.com/ledgerwatch/erigon/cl/phase1/core/state" libcommon "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon-lib/common/length" @@ -10,7 +11,6 @@ import ( "github.com/ledgerwatch/erigon/cl/cltypes" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" ) func EncodeNumber(n uint64) []byte { diff --git a/cmd/erigon-cl/core/rawdb/accessors_test.go b/cl/phase1/core/rawdb/accessors_test.go similarity index 94% rename from cmd/erigon-cl/core/rawdb/accessors_test.go rename to cl/phase1/core/rawdb/accessors_test.go index 2b57b3d99..e7eede063 100644 --- a/cmd/erigon-cl/core/rawdb/accessors_test.go +++ b/cl/phase1/core/rawdb/accessors_test.go @@ -1,11 +1,11 @@ package rawdb_test import ( + "github.com/ledgerwatch/erigon/cl/phase1/core/rawdb" "testing" "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/ledgerwatch/erigon/cl/cltypes" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/rawdb" "github.com/stretchr/testify/require" ) diff --git a/cmd/erigon-cl/core/rawdb/config.go b/cl/phase1/core/rawdb/config.go similarity index 100% rename from cmd/erigon-cl/core/rawdb/config.go rename to cl/phase1/core/rawdb/config.go diff --git a/cmd/erigon-cl/core/rawdb/test_utils.go b/cl/phase1/core/rawdb/test_utils.go similarity index 100% rename from cmd/erigon-cl/core/rawdb/test_utils.go rename to cl/phase1/core/rawdb/test_utils.go diff --git a/cmd/erigon-cl/core/state/accessors.go b/cl/phase1/core/state/accessors.go similarity index 99% rename from cmd/erigon-cl/core/state/accessors.go rename to cl/phase1/core/state/accessors.go index 8af6b71be..311d9fa5e 100644 --- a/cmd/erigon-cl/core/state/accessors.go +++ b/cl/phase1/core/state/accessors.go @@ -2,6 +2,7 @@ package state import ( "fmt" + "github.com/ledgerwatch/erigon/cl/phase1/core/state/raw" "github.com/Giulio2002/bls" libcommon "github.com/ledgerwatch/erigon-lib/common" @@ -10,7 +11,6 @@ import ( "github.com/ledgerwatch/erigon/cl/cltypes/solid" "github.com/ledgerwatch/erigon/cl/fork" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state/raw" "github.com/ledgerwatch/erigon/core/types" ) diff --git a/cmd/erigon-cl/core/state/accessors_test.go b/cl/phase1/core/state/accessors_test.go similarity index 85% rename from cmd/erigon-cl/core/state/accessors_test.go rename to cl/phase1/core/state/accessors_test.go index 2c3f7e88c..ecd26cd33 100644 --- a/cmd/erigon-cl/core/state/accessors_test.go +++ b/cl/phase1/core/state/accessors_test.go @@ -1,6 +1,8 @@ package state_test import ( + state2 "github.com/ledgerwatch/erigon/cl/phase1/core/state" + shuffling2 "github.com/ledgerwatch/erigon/cl/phase1/core/state/shuffling" "strconv" "testing" @@ -8,12 +10,10 @@ import ( "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/cltypes" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state/shuffling" "github.com/stretchr/testify/require" ) -func getTestState(t *testing.T) *state.BeaconState { +func getTestState(t *testing.T) *state2.BeaconState { numVals := 2048 validators := make([]*cltypes.Validator, numVals) for i := 0; i < numVals; i++ { @@ -22,7 +22,7 @@ func getTestState(t *testing.T) *state.BeaconState { v.SetActivationEpoch(0) v.SetExitEpoch(10000) } - b := state.GetEmptyBeaconState() + b := state2.GetEmptyBeaconState() b.SetValidators(validators) b.SetSlot(19) b.SetLatestBlockHeader(&cltypes.BeaconBlockHeader{Slot: 18}) @@ -36,11 +36,11 @@ func getTestState(t *testing.T) *state.BeaconState { func TestGetBlockRoot(t *testing.T) { epoch := uint64(2) - testState := state.GetEmptyBeaconState() + testState := state2.GetEmptyBeaconState() root := common.HexToHash("ff") testState.SetSlot(100) testState.SetBlockRootAt(int(epoch*32), root) - retrieved, err := state.GetBlockRoot(testState.BeaconState, epoch) + retrieved, err := state2.GetBlockRoot(testState.BeaconState, epoch) require.NoError(t, err) require.Equal(t, retrieved, root) } @@ -119,9 +119,9 @@ func TestComputeShuffledIndex(t *testing.T) { for _, tc := range testCases { t.Run(tc.description, func(t *testing.T) { for i, val := range tc.startInds { - state := state.New(&clparams.MainnetBeaconConfig) - preInputs := shuffling.ComputeShuffledIndexPreInputs(state.BeaconConfig(), tc.seed) - got, err := shuffling.ComputeShuffledIndex(state.BeaconConfig(), val, uint64(len(tc.startInds)), tc.seed, preInputs, utils.Keccak256) + state := state2.New(&clparams.MainnetBeaconConfig) + preInputs := shuffling2.ComputeShuffledIndexPreInputs(state.BeaconConfig(), tc.seed) + got, err := shuffling2.ComputeShuffledIndex(state.BeaconConfig(), val, uint64(len(tc.startInds)), tc.seed, preInputs, utils.Keccak256) // Non-failure case. if err != nil { t.Errorf("unexpected error: %v", err) @@ -134,8 +134,8 @@ func TestComputeShuffledIndex(t *testing.T) { } } -func generateBeaconStateWithValidators(n int) *state.BeaconState { - b := state.GetEmptyBeaconState() +func generateBeaconStateWithValidators(n int) *state2.BeaconState { + b := state2.GetEmptyBeaconState() for i := 0; i < n; i++ { v := &cltypes.Validator{} v.SetActivationEpoch(0) @@ -151,7 +151,7 @@ func TestComputeProposerIndex(t *testing.T) { copy(seed[:], []byte("seed")) testCases := []struct { description string - state *state.BeaconState + state *state2.BeaconState indices []uint64 seed [32]byte expected uint64 @@ -189,7 +189,7 @@ func TestComputeProposerIndex(t *testing.T) { for _, tc := range testCases { t.Run(tc.description, func(t *testing.T) { - got, err := shuffling.ComputeProposerIndex(tc.state.BeaconState, tc.indices, tc.seed) + got, err := shuffling2.ComputeProposerIndex(tc.state.BeaconState, tc.indices, tc.seed) if tc.wantErr { if err == nil { t.Errorf("unexpected success, wanted error") @@ -207,7 +207,7 @@ func TestComputeProposerIndex(t *testing.T) { } func TestSyncReward(t *testing.T) { - s := state.GetEmptyBeaconState() + s := state2.GetEmptyBeaconState() v := &cltypes.Validator{} v.SetActivationEpoch(0) @@ -234,11 +234,11 @@ func TestComputeCommittee(t *testing.T) { v.SetPublicKey(k) validators[i] = v } - bState := state.GetEmptyBeaconState() + bState := state2.GetEmptyBeaconState() bState.SetValidators(validators) bState.SetSlot(200) - epoch := state.Epoch(bState.BeaconState) + epoch := state2.Epoch(bState.BeaconState) indices := bState.GetActiveValidatorsIndices(epoch) index := uint64(5) // Test shuffled indices are correct for index 5 committee @@ -248,21 +248,21 @@ func TestComputeCommittee(t *testing.T) { } func TestAttestationParticipationFlagIndices(t *testing.T) { - beaconState := state.GetEmptyBeaconState() + beaconState := state2.GetEmptyBeaconState() //beaconState, _ := util.DeterministicGenesisStateAltair(t, params.BeaconConfig().MaxValidatorsPerCommittee) beaconState.SetSlot(1) cfg := clparams.MainnetBeaconConfig tests := []struct { name string - inputState state.BeaconState + inputState state2.BeaconState inputData *cltypes.AttestationData inputDelay uint64 participationIndices []uint8 }{ { name: "none", - inputState: func() state.BeaconState { + inputState: func() state2.BeaconState { return *beaconState }(), inputData: &cltypes.AttestationData{ @@ -276,7 +276,7 @@ func TestAttestationParticipationFlagIndices(t *testing.T) { }, { name: "participated source", - inputState: func() state.BeaconState { + inputState: func() state2.BeaconState { return *beaconState }(), inputData: &cltypes.AttestationData{ @@ -290,7 +290,7 @@ func TestAttestationParticipationFlagIndices(t *testing.T) { }, { name: "participated source and target", - inputState: func() state.BeaconState { + inputState: func() state2.BeaconState { return *beaconState }(), inputData: &cltypes.AttestationData{ @@ -302,7 +302,7 @@ func TestAttestationParticipationFlagIndices(t *testing.T) { }, { name: "participated source and target and head", - inputState: func() state.BeaconState { + inputState: func() state2.BeaconState { return *beaconState }(), inputData: &cltypes.AttestationData{ diff --git a/cmd/erigon-cl/core/state/cache.go b/cl/phase1/core/state/cache.go similarity index 94% rename from cmd/erigon-cl/core/state/cache.go rename to cl/phase1/core/state/cache.go index 8fc21bbe4..981d27054 100644 --- a/cmd/erigon-cl/core/state/cache.go +++ b/cl/phase1/core/state/cache.go @@ -3,15 +3,15 @@ package state import ( "crypto/sha256" "encoding/binary" + "github.com/ledgerwatch/erigon/cl/phase1/core/state/lru" + "github.com/ledgerwatch/erigon/cl/phase1/core/state/raw" + shuffling2 "github.com/ledgerwatch/erigon/cl/phase1/core/state/shuffling" "github.com/ledgerwatch/erigon-lib/common" libcommon "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/cltypes" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state/lru" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state/raw" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state/shuffling" ) type HashFunc func([]byte) ([32]byte, error) @@ -61,7 +61,7 @@ func (b *BeaconState) _updateProposerIndex() (err error) { hash := sha256.New() // Input for the seed hash. randao := b.RandaoMixes() - input := shuffling.GetSeed(b.BeaconConfig(), randao[:], epoch, b.BeaconConfig().DomainBeaconProposer) + input := shuffling2.GetSeed(b.BeaconConfig(), randao[:], epoch, b.BeaconConfig().DomainBeaconProposer) slotByteArray := make([]byte, 8) binary.LittleEndian.PutUint64(slotByteArray, b.Slot()) @@ -78,7 +78,7 @@ func (b *BeaconState) _updateProposerIndex() (err error) { seedArray := [32]byte{} copy(seedArray[:], seed) b.proposerIndex = new(uint64) - *b.proposerIndex, err = shuffling.ComputeProposerIndex(b.BeaconState, indices, seedArray) + *b.proposerIndex, err = shuffling2.ComputeProposerIndex(b.BeaconState, indices, seedArray) return } diff --git a/cmd/erigon-cl/core/state/cache_accessors.go b/cl/phase1/core/state/cache_accessors.go similarity index 98% rename from cmd/erigon-cl/core/state/cache_accessors.go rename to cl/phase1/core/state/cache_accessors.go index 8f8871134..3dbf1b589 100644 --- a/cmd/erigon-cl/core/state/cache_accessors.go +++ b/cl/phase1/core/state/cache_accessors.go @@ -3,14 +3,14 @@ package state import ( "encoding/binary" "fmt" + "github.com/ledgerwatch/erigon/cl/phase1/cache" + "github.com/ledgerwatch/erigon/cl/phase1/core/state/shuffling" "math" "github.com/Giulio2002/bls" "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/cltypes" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/cache" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state/shuffling" ) // these are view functions for the beacon state cache diff --git a/cmd/erigon-cl/core/state/cache_getters.go b/cl/phase1/core/state/cache_getters.go similarity index 100% rename from cmd/erigon-cl/core/state/cache_getters.go rename to cl/phase1/core/state/cache_getters.go diff --git a/cmd/erigon-cl/core/state/cache_mutators.go b/cl/phase1/core/state/cache_mutators.go similarity index 100% rename from cmd/erigon-cl/core/state/cache_mutators.go rename to cl/phase1/core/state/cache_mutators.go diff --git a/cmd/erigon-cl/core/state/cache_setters.go b/cl/phase1/core/state/cache_setters.go similarity index 100% rename from cmd/erigon-cl/core/state/cache_setters.go rename to cl/phase1/core/state/cache_setters.go diff --git a/cmd/erigon-cl/core/state/copy.go b/cl/phase1/core/state/copy.go similarity index 95% rename from cmd/erigon-cl/core/state/copy.go rename to cl/phase1/core/state/copy.go index d70ae2a0f..b1dea6453 100644 --- a/cmd/erigon-cl/core/state/copy.go +++ b/cl/phase1/core/state/copy.go @@ -2,7 +2,7 @@ package state import ( "github.com/ledgerwatch/erigon/cl/clparams" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state/raw" + "github.com/ledgerwatch/erigon/cl/phase1/core/state/raw" ) func (b *BeaconState) CopyInto(bs *BeaconState) (err error) { diff --git a/cmd/erigon-cl/core/state/lru/lru.go b/cl/phase1/core/state/lru/lru.go similarity index 100% rename from cmd/erigon-cl/core/state/lru/lru.go rename to cl/phase1/core/state/lru/lru.go diff --git a/cmd/erigon-cl/core/state/mutators.go b/cl/phase1/core/state/mutators.go similarity index 90% rename from cmd/erigon-cl/core/state/mutators.go rename to cl/phase1/core/state/mutators.go index 775385a21..2b5bff219 100644 --- a/cmd/erigon-cl/core/state/mutators.go +++ b/cl/phase1/core/state/mutators.go @@ -1,7 +1,7 @@ package state import ( - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state/raw" + "github.com/ledgerwatch/erigon/cl/phase1/core/state/raw" ) func IncreaseBalance(b *raw.BeaconState, index, delta uint64) error { diff --git a/cmd/erigon-cl/core/state/mutators_test.go b/cl/phase1/core/state/mutators_test.go similarity index 91% rename from cmd/erigon-cl/core/state/mutators_test.go rename to cl/phase1/core/state/mutators_test.go index 6b71dc822..932736923 100644 --- a/cmd/erigon-cl/core/state/mutators_test.go +++ b/cl/phase1/core/state/mutators_test.go @@ -1,11 +1,11 @@ package state_test import ( + state2 "github.com/ledgerwatch/erigon/cl/phase1/core/state" "testing" "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/cltypes" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" "github.com/stretchr/testify/require" ) @@ -13,9 +13,9 @@ const ( testExitEpoch = 53 ) -func getTestStateBalances(t *testing.T) *state.BeaconState { +func getTestStateBalances(t *testing.T) *state2.BeaconState { numVals := uint64(2048) - b := state.GetEmptyBeaconState() + b := state2.GetEmptyBeaconState() for i := uint64(0); i < numVals; i++ { v := &cltypes.Validator{} v.SetExitEpoch(clparams.MainnetBeaconConfig.FarFutureEpoch) @@ -24,7 +24,7 @@ func getTestStateBalances(t *testing.T) *state.BeaconState { return b } -func getTestStateValidators(t *testing.T, numVals int) *state.BeaconState { +func getTestStateValidators(t *testing.T, numVals int) *state2.BeaconState { validators := make([]*cltypes.Validator, numVals) for i := 0; i < numVals; i++ { v := &cltypes.Validator{} @@ -32,7 +32,7 @@ func getTestStateValidators(t *testing.T, numVals int) *state.BeaconState { v.SetExitEpoch(testExitEpoch) validators[i] = v } - b := state.GetEmptyBeaconState() + b := state2.GetEmptyBeaconState() b.SetSlot(testExitEpoch * clparams.MainnetBeaconConfig.SlotsPerEpoch) b.SetValidators(validators) return b @@ -43,7 +43,7 @@ func TestIncreaseBalance(t *testing.T) { testInd := uint64(42) amount := uint64(100) beforeBalance, _ := s.ValidatorBalance(int(testInd)) - state.IncreaseBalance(s.BeaconState, testInd, amount) + state2.IncreaseBalance(s.BeaconState, testInd, amount) afterBalance, _ := s.ValidatorBalance(int(testInd)) require.Equal(t, afterBalance, beforeBalance+amount) } @@ -78,7 +78,7 @@ func TestDecreaseBalance(t *testing.T) { for _, tc := range testCases { t.Run(tc.description, func(t *testing.T) { s := getTestStateBalances(t) - require.NoError(t, state.DecreaseBalance(s.BeaconState, testInd, tc.delta)) + require.NoError(t, state2.DecreaseBalance(s.BeaconState, testInd, tc.delta)) afterBalance, _ := s.ValidatorBalance(int(testInd)) require.Equal(t, afterBalance, tc.expectedBalance) }) @@ -156,7 +156,7 @@ func TestSlashValidator(t *testing.T) { testCases := []struct { description string - state *state.BeaconState + state *state2.BeaconState wantErr bool }{ { diff --git a/cmd/erigon-cl/core/state/raw/copy.go b/cl/phase1/core/state/raw/copy.go similarity index 100% rename from cmd/erigon-cl/core/state/raw/copy.go rename to cl/phase1/core/state/raw/copy.go diff --git a/cmd/erigon-cl/core/state/raw/errors.go b/cl/phase1/core/state/raw/errors.go similarity index 100% rename from cmd/erigon-cl/core/state/raw/errors.go rename to cl/phase1/core/state/raw/errors.go diff --git a/cmd/erigon-cl/core/state/raw/getters.go b/cl/phase1/core/state/raw/getters.go similarity index 100% rename from cmd/erigon-cl/core/state/raw/getters.go rename to cl/phase1/core/state/raw/getters.go diff --git a/cmd/erigon-cl/core/state/raw/hashing.go b/cl/phase1/core/state/raw/hashing.go similarity index 99% rename from cmd/erigon-cl/core/state/raw/hashing.go rename to cl/phase1/core/state/raw/hashing.go index 2ffe240c2..343215a47 100644 --- a/cmd/erigon-cl/core/state/raw/hashing.go +++ b/cl/phase1/core/state/raw/hashing.go @@ -5,8 +5,8 @@ import ( libcommon "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/merkle_tree" + "github.com/ledgerwatch/erigon/cl/phase1/core/state/state_encoding" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state/state_encoding" ) const maxEth1Votes = 2048 diff --git a/cmd/erigon-cl/core/state/raw/params.go b/cl/phase1/core/state/raw/params.go similarity index 100% rename from cmd/erigon-cl/core/state/raw/params.go rename to cl/phase1/core/state/raw/params.go diff --git a/cmd/erigon-cl/core/state/raw/setters.go b/cl/phase1/core/state/raw/setters.go similarity index 99% rename from cmd/erigon-cl/core/state/raw/setters.go rename to cl/phase1/core/state/raw/setters.go index 3ad800bf0..a5c1ced23 100644 --- a/cmd/erigon-cl/core/state/raw/setters.go +++ b/cl/phase1/core/state/raw/setters.go @@ -5,7 +5,7 @@ import ( "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/cltypes" "github.com/ledgerwatch/erigon/cl/cltypes/solid" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state/state_encoding" + "github.com/ledgerwatch/erigon/cl/phase1/core/state/state_encoding" ) func (b *BeaconState) SetVersion(version clparams.StateVersion) { diff --git a/cmd/erigon-cl/core/state/raw/ssz.go b/cl/phase1/core/state/raw/ssz.go similarity index 99% rename from cmd/erigon-cl/core/state/raw/ssz.go rename to cl/phase1/core/state/raw/ssz.go index 22f6984f2..ae51cb8dd 100644 --- a/cmd/erigon-cl/core/state/raw/ssz.go +++ b/cl/phase1/core/state/raw/ssz.go @@ -2,6 +2,7 @@ package raw import ( "fmt" + "github.com/ledgerwatch/erigon/cl/phase1/core/state/state_encoding" "github.com/ledgerwatch/erigon-lib/common/length" "github.com/ledgerwatch/erigon-lib/types/clonable" @@ -10,7 +11,6 @@ import ( "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/cltypes" "github.com/ledgerwatch/erigon/cl/cltypes/solid" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state/state_encoding" ) // BlockRoot computes the block root for the state. diff --git a/cmd/erigon-cl/core/state/raw/state.go b/cl/phase1/core/state/raw/state.go similarity index 100% rename from cmd/erigon-cl/core/state/raw/state.go rename to cl/phase1/core/state/raw/state.go diff --git a/cmd/erigon-cl/core/state/raw/test_util.go b/cl/phase1/core/state/raw/test_util.go similarity index 100% rename from cmd/erigon-cl/core/state/raw/test_util.go rename to cl/phase1/core/state/raw/test_util.go diff --git a/cmd/erigon-cl/core/state/root.go b/cl/phase1/core/state/root.go similarity index 100% rename from cmd/erigon-cl/core/state/root.go rename to cl/phase1/core/state/root.go diff --git a/cmd/erigon-cl/core/state/root_test.go b/cl/phase1/core/state/root_test.go similarity index 86% rename from cmd/erigon-cl/core/state/root_test.go rename to cl/phase1/core/state/root_test.go index 4d56a0c4c..e13b793d5 100644 --- a/cmd/erigon-cl/core/state/root_test.go +++ b/cl/phase1/core/state/root_test.go @@ -1,9 +1,8 @@ package state_test import ( + "github.com/ledgerwatch/erigon/cl/phase1/core/state" "testing" - - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" ) // Curr: 4358340 diff --git a/cmd/erigon-cl/core/state/shuffling/shuffling.go b/cl/phase1/core/state/shuffling/shuffling.go similarity index 95% rename from cmd/erigon-cl/core/state/shuffling/shuffling.go rename to cl/phase1/core/state/shuffling/shuffling.go index 9c39fda4c..2c1024311 100644 --- a/cmd/erigon-cl/core/state/shuffling/shuffling.go +++ b/cl/phase1/core/state/shuffling/shuffling.go @@ -3,9 +3,9 @@ package shuffling import ( "encoding/binary" "fmt" + "github.com/ledgerwatch/erigon/cl/phase1/core/state/raw" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state/raw" ) func ComputeProposerIndex(b *raw.BeaconState, indices []uint64, seed [32]byte) (uint64, error) { diff --git a/cmd/erigon-cl/core/state/shuffling/shuffling_test.go b/cl/phase1/core/state/shuffling/shuffling_test.go similarity index 89% rename from cmd/erigon-cl/core/state/shuffling/shuffling_test.go rename to cl/phase1/core/state/shuffling/shuffling_test.go index 81a5c2998..d864a7a6c 100644 --- a/cmd/erigon-cl/core/state/shuffling/shuffling_test.go +++ b/cl/phase1/core/state/shuffling/shuffling_test.go @@ -1,12 +1,12 @@ package shuffling_test import ( + "github.com/ledgerwatch/erigon/cl/phase1/core/state" + "github.com/ledgerwatch/erigon/cl/phase1/core/state/shuffling" "testing" "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state/shuffling" eth2_shuffle "github.com/protolambda/eth2-shuffle" ) diff --git a/cmd/erigon-cl/core/state/shuffling/util.go b/cl/phase1/core/state/shuffling/util.go similarity index 100% rename from cmd/erigon-cl/core/state/shuffling/util.go rename to cl/phase1/core/state/shuffling/util.go diff --git a/cmd/erigon-cl/core/state/ssz.go b/cl/phase1/core/state/ssz.go similarity index 100% rename from cmd/erigon-cl/core/state/ssz.go rename to cl/phase1/core/state/ssz.go diff --git a/cmd/erigon-cl/core/state/ssz_test.go b/cl/phase1/core/state/ssz_test.go similarity index 96% rename from cmd/erigon-cl/core/state/ssz_test.go rename to cl/phase1/core/state/ssz_test.go index 044ef4755..b6175d2bc 100644 --- a/cmd/erigon-cl/core/state/ssz_test.go +++ b/cl/phase1/core/state/ssz_test.go @@ -2,13 +2,13 @@ package state_test import ( _ "embed" + "github.com/ledgerwatch/erigon/cl/phase1/core/state" "testing" libcommon "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" "github.com/stretchr/testify/require" ) diff --git a/cmd/erigon-cl/core/state/state_encoding/encoding.go b/cl/phase1/core/state/state_encoding/encoding.go similarity index 100% rename from cmd/erigon-cl/core/state/state_encoding/encoding.go rename to cl/phase1/core/state/state_encoding/encoding.go diff --git a/cmd/erigon-cl/core/state/state_encoding/encoding_test.go b/cl/phase1/core/state/state_encoding/encoding_test.go similarity index 86% rename from cmd/erigon-cl/core/state/state_encoding/encoding_test.go rename to cl/phase1/core/state/state_encoding/encoding_test.go index cdd64cbb8..94e2ec7bd 100644 --- a/cmd/erigon-cl/core/state/state_encoding/encoding_test.go +++ b/cl/phase1/core/state/state_encoding/encoding_test.go @@ -1,12 +1,11 @@ package state_encoding_test import ( + "github.com/ledgerwatch/erigon/cl/phase1/core/state/state_encoding" "testing" libcommon "github.com/ledgerwatch/erigon-lib/common" "github.com/stretchr/testify/require" - - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state/state_encoding" ) func TestSlashingsRoot(t *testing.T) { diff --git a/cmd/erigon-cl/core/state/test_util.go b/cl/phase1/core/state/test_util.go similarity index 82% rename from cmd/erigon-cl/core/state/test_util.go rename to cl/phase1/core/state/test_util.go index 96ed11670..ae15ecadd 100644 --- a/cmd/erigon-cl/core/state/test_util.go +++ b/cl/phase1/core/state/test_util.go @@ -2,7 +2,7 @@ package state import ( "github.com/ledgerwatch/erigon/cl/clparams" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state/raw" + "github.com/ledgerwatch/erigon/cl/phase1/core/state/raw" ) func GetEmptyBeaconState() *BeaconState { diff --git a/cmd/erigon-cl/core/state/tests/capella.ssz_snappy b/cl/phase1/core/state/tests/capella.ssz_snappy similarity index 100% rename from cmd/erigon-cl/core/state/tests/capella.ssz_snappy rename to cl/phase1/core/state/tests/capella.ssz_snappy diff --git a/cmd/erigon-cl/core/state/tests/phase0.ssz_snappy b/cl/phase1/core/state/tests/phase0.ssz_snappy similarity index 100% rename from cmd/erigon-cl/core/state/tests/phase0.ssz_snappy rename to cl/phase1/core/state/tests/phase0.ssz_snappy diff --git a/cmd/erigon-cl/core/state/upgrade.go b/cl/phase1/core/state/upgrade.go similarity index 100% rename from cmd/erigon-cl/core/state/upgrade.go rename to cl/phase1/core/state/upgrade.go diff --git a/cmd/erigon-cl/core/state/util.go b/cl/phase1/core/state/util.go similarity index 97% rename from cmd/erigon-cl/core/state/util.go rename to cl/phase1/core/state/util.go index e37b45610..73852b4ec 100644 --- a/cmd/erigon-cl/core/state/util.go +++ b/cl/phase1/core/state/util.go @@ -1,12 +1,12 @@ package state import ( + "github.com/ledgerwatch/erigon/cl/phase1/core/state/lru" "sort" "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/cltypes" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state/lru" ) func copyLRU[K comparable, V any](dst *lru.Cache[K, V], src *lru.Cache[K, V]) *lru.Cache[K, V] { diff --git a/cmd/erigon-cl/core/transition/block_transition.go b/cl/phase1/core/transition/block_transition.go similarity index 87% rename from cmd/erigon-cl/core/transition/block_transition.go rename to cl/phase1/core/transition/block_transition.go index b1f9e1e62..4e0c89b09 100644 --- a/cmd/erigon-cl/core/transition/block_transition.go +++ b/cl/phase1/core/transition/block_transition.go @@ -3,16 +3,16 @@ package transition import ( "errors" "fmt" + state2 "github.com/ledgerwatch/erigon/cl/phase1/core/state" libcommon "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/cltypes" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" "github.com/ledgerwatch/erigon/metrics/methelp" ) // processBlock takes a block and transitions the state to the next slot, using the provided execution payload if enabled. -func processBlock(state *state.BeaconState, signedBlock *cltypes.SignedBeaconBlock, fullValidation bool) error { +func processBlock(state *state2.BeaconState, signedBlock *cltypes.SignedBeaconBlock, fullValidation bool) error { block := signedBlock.Block version := state.Version() // Check the state version is correct. @@ -94,7 +94,7 @@ func processBlock(state *state.BeaconState, signedBlock *cltypes.SignedBeaconBlo return nil } -func processOperations(state *state.BeaconState, blockBody *cltypes.BeaconBody, fullValidation bool) error { +func processOperations(state *state2.BeaconState, blockBody *cltypes.BeaconBody, fullValidation bool) error { if len(blockBody.Deposits) != int(maximumDeposits(state)) { return errors.New("outstanding deposits do not match maximum deposits") } @@ -156,7 +156,7 @@ func processOperations(state *state.BeaconState, blockBody *cltypes.BeaconBody, return nil } -func maximumDeposits(state *state.BeaconState) (maxDeposits uint64) { +func maximumDeposits(state *state2.BeaconState) (maxDeposits uint64) { maxDeposits = state.Eth1Data().DepositCount - state.Eth1DepositIndex() if maxDeposits > state.BeaconConfig().MaxDeposits { maxDeposits = state.BeaconConfig().MaxDeposits @@ -165,16 +165,16 @@ func maximumDeposits(state *state.BeaconState) (maxDeposits uint64) { } // ProcessExecutionPayload sets the latest payload header accordinly. -func ProcessExecutionPayload(s *state.BeaconState, payload *cltypes.Eth1Block) error { - if state.IsMergeTransitionComplete(s.BeaconState) { +func ProcessExecutionPayload(s *state2.BeaconState, payload *cltypes.Eth1Block) error { + if state2.IsMergeTransitionComplete(s.BeaconState) { if payload.ParentHash != s.LatestExecutionPayloadHeader().BlockHash { return fmt.Errorf("ProcessExecutionPayload: invalid eth1 chain. mismatching parent") } } - if payload.PrevRandao != s.GetRandaoMixes(state.Epoch(s.BeaconState)) { + if payload.PrevRandao != s.GetRandaoMixes(state2.Epoch(s.BeaconState)) { return fmt.Errorf("ProcessExecutionPayload: randao mix mismatches with mix digest") } - if payload.Time != state.ComputeTimestampAtSlot(s.BeaconState, s.Slot()) { + if payload.Time != state2.ComputeTimestampAtSlot(s.BeaconState, s.Slot()) { return fmt.Errorf("ProcessExecutionPayload: invalid Eth1 timestamp") } payloadHeader, err := payload.PayloadHeader() @@ -185,6 +185,6 @@ func ProcessExecutionPayload(s *state.BeaconState, payload *cltypes.Eth1Block) e return nil } -func executionEnabled(s *state.BeaconState, payload *cltypes.Eth1Block) bool { - return (!state.IsMergeTransitionComplete(s.BeaconState) && payload.BlockHash != libcommon.Hash{}) || state.IsMergeTransitionComplete(s.BeaconState) +func executionEnabled(s *state2.BeaconState, payload *cltypes.Eth1Block) bool { + return (!state2.IsMergeTransitionComplete(s.BeaconState) && payload.BlockHash != libcommon.Hash{}) || state2.IsMergeTransitionComplete(s.BeaconState) } diff --git a/cmd/erigon-cl/core/transition/finalization_and_justification.go b/cl/phase1/core/transition/finalization_and_justification.go similarity index 85% rename from cmd/erigon-cl/core/transition/finalization_and_justification.go rename to cl/phase1/core/transition/finalization_and_justification.go index a92f4c526..76f621572 100644 --- a/cmd/erigon-cl/core/transition/finalization_and_justification.go +++ b/cl/phase1/core/transition/finalization_and_justification.go @@ -3,14 +3,14 @@ package transition import ( "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/cltypes" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" + state2 "github.com/ledgerwatch/erigon/cl/phase1/core/state" ) // weighJustificationAndFinalization checks justification and finality of epochs and adds records to the state as needed. -func weighJustificationAndFinalization(s *state.BeaconState, previousEpochTargetBalance, currentEpochTargetBalance uint64) error { +func weighJustificationAndFinalization(s *state2.BeaconState, previousEpochTargetBalance, currentEpochTargetBalance uint64) error { totalActiveBalance := s.GetTotalActiveBalance() - currentEpoch := state.Epoch(s.BeaconState) - previousEpoch := state.PreviousEpoch(s.BeaconState) + currentEpoch := state2.Epoch(s.BeaconState) + previousEpoch := state2.PreviousEpoch(s.BeaconState) oldPreviousJustifiedCheckpoint := s.PreviousJustifiedCheckpoint() oldCurrentJustifiedCheckpoint := s.CurrentJustifiedCheckpoint() justificationBits := s.JustificationBits() @@ -22,7 +22,7 @@ func weighJustificationAndFinalization(s *state.BeaconState, previousEpochTarget justificationBits[0] = false // Update justified checkpoint if super majority is reached on previous epoch if previousEpochTargetBalance*3 >= totalActiveBalance*2 { - checkPointRoot, err := state.GetBlockRoot(s.BeaconState, previousEpoch) + checkPointRoot, err := state2.GetBlockRoot(s.BeaconState, previousEpoch) if err != nil { return err } @@ -33,7 +33,7 @@ func weighJustificationAndFinalization(s *state.BeaconState, previousEpochTarget justificationBits[1] = true } if currentEpochTargetBalance*3 >= totalActiveBalance*2 { - checkPointRoot, err := state.GetBlockRoot(s.BeaconState, currentEpoch) + checkPointRoot, err := state2.GetBlockRoot(s.BeaconState, currentEpoch) if err != nil { return err } @@ -61,9 +61,9 @@ func weighJustificationAndFinalization(s *state.BeaconState, previousEpochTarget return nil } -func ProcessJustificationBitsAndFinality(s *state.BeaconState) error { - currentEpoch := state.Epoch(s.BeaconState) - previousEpoch := state.PreviousEpoch(s.BeaconState) +func ProcessJustificationBitsAndFinality(s *state2.BeaconState) error { + currentEpoch := state2.Epoch(s.BeaconState) + previousEpoch := state2.PreviousEpoch(s.BeaconState) beaconConfig := s.BeaconConfig() // Skip for first 2 epochs if currentEpoch <= beaconConfig.GenesisEpoch+1 { diff --git a/cmd/erigon-cl/core/transition/operations.go b/cl/phase1/core/transition/operations.go similarity index 86% rename from cmd/erigon-cl/core/transition/operations.go rename to cl/phase1/core/transition/operations.go index 370e5e794..c4314f20b 100644 --- a/cmd/erigon-cl/core/transition/operations.go +++ b/cl/phase1/core/transition/operations.go @@ -3,6 +3,7 @@ package transition import ( "errors" "fmt" + state2 "github.com/ledgerwatch/erigon/cl/phase1/core/state" "github.com/Giulio2002/bls" "github.com/ledgerwatch/log/v3" @@ -11,11 +12,10 @@ import ( "github.com/ledgerwatch/erigon/cl/cltypes" "github.com/ledgerwatch/erigon/cl/fork" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" "github.com/ledgerwatch/erigon/core/types" ) -func ProcessProposerSlashing(s *state.BeaconState, propSlashing *cltypes.ProposerSlashing) error { +func ProcessProposerSlashing(s *state2.BeaconState, propSlashing *cltypes.ProposerSlashing) error { h1 := propSlashing.Header1.Header h2 := propSlashing.Header2.Header @@ -43,12 +43,12 @@ func ProcessProposerSlashing(s *state.BeaconState, propSlashing *cltypes.Propose if err != nil { return err } - if !proposer.IsSlashable(state.Epoch(s.BeaconState)) { + if !proposer.IsSlashable(state2.Epoch(s.BeaconState)) { return fmt.Errorf("proposer is not slashable: %v", proposer) } for _, signedHeader := range []*cltypes.SignedBeaconBlockHeader{propSlashing.Header1, propSlashing.Header2} { - domain, err := s.GetDomain(s.BeaconConfig().DomainBeaconProposer, state.GetEpochAtSlot(s.BeaconConfig(), signedHeader.Header.Slot)) + domain, err := s.GetDomain(s.BeaconConfig().DomainBeaconProposer, state2.GetEpochAtSlot(s.BeaconConfig(), signedHeader.Header.Slot)) if err != nil { return fmt.Errorf("unable to get domain: %v", err) } @@ -71,7 +71,7 @@ func ProcessProposerSlashing(s *state.BeaconState, propSlashing *cltypes.Propose return nil } -func ProcessAttesterSlashing(s *state.BeaconState, attSlashing *cltypes.AttesterSlashing) error { +func ProcessAttesterSlashing(s *state2.BeaconState, attSlashing *cltypes.AttesterSlashing) error { att1 := attSlashing.Attestation_1 att2 := attSlashing.Attestation_2 @@ -79,7 +79,7 @@ func ProcessAttesterSlashing(s *state.BeaconState, attSlashing *cltypes.Attester return fmt.Errorf("attestation data not slashable: %+v; %+v", att1.Data, att2.Data) } - valid, err := state.IsValidIndexedAttestation(s.BeaconState, att1) + valid, err := state2.IsValidIndexedAttestation(s.BeaconState, att1) if err != nil { return fmt.Errorf("error calculating indexed attestation 1 validity: %v", err) } @@ -87,7 +87,7 @@ func ProcessAttesterSlashing(s *state.BeaconState, attSlashing *cltypes.Attester return fmt.Errorf("invalid indexed attestation 1") } - valid, err = state.IsValidIndexedAttestation(s.BeaconState, att2) + valid, err = state2.IsValidIndexedAttestation(s.BeaconState, att2) if err != nil { return fmt.Errorf("error calculating indexed attestation 2 validity: %v", err) } @@ -96,7 +96,7 @@ func ProcessAttesterSlashing(s *state.BeaconState, attSlashing *cltypes.Attester } slashedAny := false - currentEpoch := state.GetEpochAtSlot(s.BeaconConfig(), s.Slot()) + currentEpoch := state2.GetEpochAtSlot(s.BeaconConfig(), s.Slot()) for _, ind := range utils.IntersectionOfSortedSets(att1.AttestingIndices, att2.AttestingIndices) { validator, err := s.ValidatorForValidatorIndex(int(ind)) if err != nil { @@ -117,7 +117,7 @@ func ProcessAttesterSlashing(s *state.BeaconState, attSlashing *cltypes.Attester return nil } -func ProcessDeposit(s *state.BeaconState, deposit *cltypes.Deposit, fullValidation bool) error { +func ProcessDeposit(s *state2.BeaconState, deposit *cltypes.Deposit, fullValidation bool) error { if deposit == nil { return nil } @@ -163,7 +163,7 @@ func ProcessDeposit(s *state.BeaconState, deposit *cltypes.Deposit, fullValidati return nil } // Append validator - s.AddValidator(state.ValidatorFromDeposit(s.BeaconConfig(), deposit), amount) + s.AddValidator(state2.ValidatorFromDeposit(s.BeaconConfig(), deposit), amount) // Altair forward if s.Version() >= clparams.AltairVersion { s.AddCurrentEpochParticipationFlags(cltypes.ParticipationFlags(0)) @@ -173,14 +173,14 @@ func ProcessDeposit(s *state.BeaconState, deposit *cltypes.Deposit, fullValidati return nil } // Increase the balance if exists already - return state.IncreaseBalance(s.BeaconState, validatorIndex, amount) + return state2.IncreaseBalance(s.BeaconState, validatorIndex, amount) } // ProcessVoluntaryExit takes a voluntary exit and applies state transition. -func ProcessVoluntaryExit(s *state.BeaconState, signedVoluntaryExit *cltypes.SignedVoluntaryExit, fullValidation bool) error { +func ProcessVoluntaryExit(s *state2.BeaconState, signedVoluntaryExit *cltypes.SignedVoluntaryExit, fullValidation bool) error { // Sanity checks so that we know it is good. voluntaryExit := signedVoluntaryExit.VolunaryExit - currentEpoch := state.Epoch(s.BeaconState) + currentEpoch := state2.Epoch(s.BeaconState) validator, err := s.ValidatorForValidatorIndex(int(voluntaryExit.ValidatorIndex)) if err != nil { return err @@ -223,7 +223,7 @@ func ProcessVoluntaryExit(s *state.BeaconState, signedVoluntaryExit *cltypes.Sig // ProcessWithdrawals processes withdrawals by decreasing the balance of each validator // and updating the next withdrawal index and validator index. -func ProcessWithdrawals(s *state.BeaconState, withdrawals types.Withdrawals, fullValidation bool) error { +func ProcessWithdrawals(s *state2.BeaconState, withdrawals types.Withdrawals, fullValidation bool) error { // Get the list of withdrawals, the expected withdrawals (if performing full validation), // and the beacon configuration. beaconConfig := s.BeaconConfig() @@ -231,7 +231,7 @@ func ProcessWithdrawals(s *state.BeaconState, withdrawals types.Withdrawals, ful // Check if full validation is required and verify expected withdrawals. if fullValidation { - expectedWithdrawals := state.ExpectedWithdrawals(s.BeaconState) + expectedWithdrawals := state2.ExpectedWithdrawals(s.BeaconState) if len(expectedWithdrawals) != len(withdrawals) { return fmt.Errorf("ProcessWithdrawals: expected %d withdrawals, but got %d", len(expectedWithdrawals), len(withdrawals)) } @@ -244,7 +244,7 @@ func ProcessWithdrawals(s *state.BeaconState, withdrawals types.Withdrawals, ful // Decrease the balance of each validator for the corresponding withdrawal. for _, withdrawal := range withdrawals { - if err := state.DecreaseBalance(s.BeaconState, withdrawal.Validator, withdrawal.Amount); err != nil { + if err := state2.DecreaseBalance(s.BeaconState, withdrawal.Validator, withdrawal.Amount); err != nil { return err } } diff --git a/cmd/erigon-cl/core/transition/operations_test.go b/cl/phase1/core/transition/operations_test.go similarity index 98% rename from cmd/erigon-cl/core/transition/operations_test.go rename to cl/phase1/core/transition/operations_test.go index 38111efa7..9fce6b7ce 100644 --- a/cmd/erigon-cl/core/transition/operations_test.go +++ b/cl/phase1/core/transition/operations_test.go @@ -1,6 +1,7 @@ package transition import ( + state2 "github.com/ledgerwatch/erigon/cl/phase1/core/state" "testing" libcommon "github.com/ledgerwatch/erigon-lib/common" @@ -8,7 +9,6 @@ import ( "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/cltypes" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" "github.com/ledgerwatch/erigon/common" ) @@ -122,7 +122,7 @@ func TestProcessProposerSlashing(t *testing.T) { testCases := []struct { description string - state *state.BeaconState + state *state2.BeaconState slashing *cltypes.ProposerSlashing wantErr bool }{ @@ -236,7 +236,7 @@ func TestProcessAttesterSlashing(t *testing.T) { testCases := []struct { description string - state *state.BeaconState + state *state2.BeaconState slashing *cltypes.AttesterSlashing wantErr bool }{ @@ -320,7 +320,7 @@ func TestProcessDeposit(t *testing.T) { WithdrawalCredentials: libcommon.HexToHash("00ec7ef7780c9d151597924036262dd28dc60e1228f4da6fecf9d402cb3f3594"), }, } - testState := state.GetEmptyBeaconState() + testState := state2.GetEmptyBeaconState() v := &cltypes.Validator{} v.SetPublicKey([48]byte{1}) v.SetWithdrawalCredentials([32]byte{1, 2, 3}) @@ -333,7 +333,7 @@ func TestProcessDeposit(t *testing.T) { } func TestProcessVoluntaryExits(t *testing.T) { - state := state.GetEmptyBeaconState() + state := state2.GetEmptyBeaconState() exit := &cltypes.SignedVoluntaryExit{ VolunaryExit: &cltypes.VoluntaryExit{ ValidatorIndex: 0, diff --git a/cmd/erigon-cl/core/transition/process_attestations.go b/cl/phase1/core/transition/process_attestations.go similarity index 83% rename from cmd/erigon-cl/core/transition/process_attestations.go rename to cl/phase1/core/transition/process_attestations.go index ed2d97f93..726336885 100644 --- a/cmd/erigon-cl/core/transition/process_attestations.go +++ b/cl/phase1/core/transition/process_attestations.go @@ -3,16 +3,16 @@ package transition import ( "errors" "fmt" + state2 "github.com/ledgerwatch/erigon/cl/phase1/core/state" "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/cltypes" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" "github.com/ledgerwatch/erigon/metrics/methelp" "golang.org/x/exp/slices" ) -func ProcessAttestations(s *state.BeaconState, attestations []*cltypes.Attestation, fullValidation bool) error { +func ProcessAttestations(s *state2.BeaconState, attestations []*cltypes.Attestation, fullValidation bool) error { var err error attestingIndiciesSet := make([][]uint64, len(attestations)) h := methelp.NewHistTimer("beacon_process_attestations") @@ -40,9 +40,9 @@ func ProcessAttestations(s *state.BeaconState, attestations []*cltypes.Attestati return nil } -func processAttestationPostAltair(s *state.BeaconState, attestation *cltypes.Attestation, baseRewardPerIncrement uint64) ([]uint64, error) { +func processAttestationPostAltair(s *state2.BeaconState, attestation *cltypes.Attestation, baseRewardPerIncrement uint64) ([]uint64, error) { data := attestation.Data - currentEpoch := state.Epoch(s.BeaconState) + currentEpoch := state2.Epoch(s.BeaconState) stateSlot := s.Slot() beaconConfig := s.BeaconConfig() @@ -95,11 +95,11 @@ func processAttestationPostAltair(s *state.BeaconState, attestation *cltypes.Att c.PutSince() proposerRewardDenominator := (beaconConfig.WeightDenominator - beaconConfig.ProposerWeight) * beaconConfig.WeightDenominator / beaconConfig.ProposerWeight reward := proposerRewardNumerator / proposerRewardDenominator - return attestingIndicies, state.IncreaseBalance(s.BeaconState, proposer, reward) + return attestingIndicies, state2.IncreaseBalance(s.BeaconState, proposer, reward) } // processAttestationsPhase0 implements the rules for phase0 processing. -func processAttestationPhase0(s *state.BeaconState, attestation *cltypes.Attestation) ([]uint64, error) { +func processAttestationPhase0(s *state2.BeaconState, attestation *cltypes.Attestation) ([]uint64, error) { data := attestation.Data committee, err := s.GetBeaconCommitee(data.Slot, data.Index) if err != nil { @@ -121,7 +121,7 @@ func processAttestationPhase0(s *state.BeaconState, attestation *cltypes.Attesta InclusionDelay: s.Slot() - data.Slot, ProposerIndex: proposerIndex, } - isCurrentAttestation := data.Target.Epoch == state.Epoch(s.BeaconState) + isCurrentAttestation := data.Target.Epoch == state2.Epoch(s.BeaconState) // Depending of what slot we are on we put in either the current justified or previous justified. if isCurrentAttestation { if !data.Source.Equal(s.CurrentJustifiedCheckpoint()) { @@ -139,7 +139,7 @@ func processAttestationPhase0(s *state.BeaconState, attestation *cltypes.Attesta if err != nil { return nil, err } - epochRoot, err := state.GetBlockRoot(s.BeaconState, attestation.Data.Target.Epoch) + epochRoot, err := state2.GetBlockRoot(s.BeaconState, attestation.Data.Target.Epoch) if err != nil { return nil, err } @@ -186,14 +186,14 @@ func processAttestationPhase0(s *state.BeaconState, attestation *cltypes.Attesta } // ProcessAttestation takes an attestation and process it. -func processAttestation(s *state.BeaconState, attestation *cltypes.Attestation, baseRewardPerIncrement uint64) ([]uint64, error) { +func processAttestation(s *state2.BeaconState, attestation *cltypes.Attestation, baseRewardPerIncrement uint64) ([]uint64, error) { data := attestation.Data - currentEpoch := state.Epoch(s.BeaconState) - previousEpoch := state.PreviousEpoch(s.BeaconState) + currentEpoch := state2.Epoch(s.BeaconState) + previousEpoch := state2.PreviousEpoch(s.BeaconState) stateSlot := s.Slot() beaconConfig := s.BeaconConfig() // Prelimary checks. - if (data.Target.Epoch != currentEpoch && data.Target.Epoch != previousEpoch) || data.Target.Epoch != state.GetEpochAtSlot(s.BeaconConfig(), data.Slot) { + if (data.Target.Epoch != currentEpoch && data.Target.Epoch != previousEpoch) || data.Target.Epoch != state2.GetEpochAtSlot(s.BeaconConfig(), data.Slot) { return nil, errors.New("ProcessAttestation: attestation with invalid epoch") } if data.Slot+beaconConfig.MinAttestationInclusionDelay > stateSlot || stateSlot > data.Slot+beaconConfig.SlotsPerEpoch { @@ -209,10 +209,10 @@ func processAttestation(s *state.BeaconState, attestation *cltypes.Attestation, return processAttestationPostAltair(s, attestation, baseRewardPerIncrement) } -func verifyAttestations(s *state.BeaconState, attestations []*cltypes.Attestation, attestingIndicies [][]uint64) (bool, error) { +func verifyAttestations(s *state2.BeaconState, attestations []*cltypes.Attestation, attestingIndicies [][]uint64) (bool, error) { for i, attestation := range attestations { - indexedAttestation := state.GetIndexedAttestation(attestation, attestingIndicies[i]) - success, err := state.IsValidIndexedAttestation(s.BeaconState, indexedAttestation) + indexedAttestation := state2.GetIndexedAttestation(attestation, attestingIndicies[i]) + success, err := state2.IsValidIndexedAttestation(s.BeaconState, indexedAttestation) if err != nil { return false, err } diff --git a/cmd/erigon-cl/core/transition/process_blob_kzg_commitments.go b/cl/phase1/core/transition/process_blob_kzg_commitments.go similarity index 100% rename from cmd/erigon-cl/core/transition/process_blob_kzg_commitments.go rename to cl/phase1/core/transition/process_blob_kzg_commitments.go diff --git a/cmd/erigon-cl/core/transition/process_bls_to_execution_change.go b/cl/phase1/core/transition/process_bls_to_execution_change.go similarity index 97% rename from cmd/erigon-cl/core/transition/process_bls_to_execution_change.go rename to cl/phase1/core/transition/process_bls_to_execution_change.go index 66e811e0b..8c86a38b0 100644 --- a/cmd/erigon-cl/core/transition/process_bls_to_execution_change.go +++ b/cl/phase1/core/transition/process_bls_to_execution_change.go @@ -3,12 +3,12 @@ package transition import ( "bytes" "fmt" + "github.com/ledgerwatch/erigon/cl/phase1/core/state" "github.com/Giulio2002/bls" "github.com/ledgerwatch/erigon/cl/cltypes" "github.com/ledgerwatch/erigon/cl/fork" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" ) // ProcessBlsToExecutionChange processes a BLSToExecutionChange message by updating a validator's withdrawal credentials. diff --git a/cmd/erigon-cl/core/transition/process_effective_balance_update.go b/cl/phase1/core/transition/process_effective_balance_update.go similarity index 96% rename from cmd/erigon-cl/core/transition/process_effective_balance_update.go rename to cl/phase1/core/transition/process_effective_balance_update.go index e98cc39c9..ae05c93de 100644 --- a/cmd/erigon-cl/core/transition/process_effective_balance_update.go +++ b/cl/phase1/core/transition/process_effective_balance_update.go @@ -2,8 +2,8 @@ package transition import ( "github.com/ledgerwatch/erigon/cl/cltypes" + "github.com/ledgerwatch/erigon/cl/phase1/core/state" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" ) // ProcessEffectiveBalanceUpdates updates the effective balance of validators. Specs at: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#effective-balances-updates diff --git a/cmd/erigon-cl/core/transition/process_epoch.go b/cl/phase1/core/transition/process_epoch.go similarity index 97% rename from cmd/erigon-cl/core/transition/process_epoch.go rename to cl/phase1/core/transition/process_epoch.go index 8d0e13768..c44574bbe 100644 --- a/cmd/erigon-cl/core/transition/process_epoch.go +++ b/cl/phase1/core/transition/process_epoch.go @@ -3,7 +3,7 @@ package transition import ( "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/cltypes" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" + "github.com/ledgerwatch/erigon/cl/phase1/core/state" ) // ProcessEpoch process epoch transition. diff --git a/cmd/erigon-cl/core/transition/process_epoch_test.go b/cl/phase1/core/transition/process_epoch_test.go similarity index 89% rename from cmd/erigon-cl/core/transition/process_epoch_test.go rename to cl/phase1/core/transition/process_epoch_test.go index 9856ae273..6cc8af9ef 100644 --- a/cmd/erigon-cl/core/transition/process_epoch_test.go +++ b/cl/phase1/core/transition/process_epoch_test.go @@ -2,12 +2,12 @@ package transition_test import ( _ "embed" + "github.com/ledgerwatch/erigon/cl/phase1/core/state" + transition2 "github.com/ledgerwatch/erigon/cl/phase1/core/transition" "testing" "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/transition" "github.com/stretchr/testify/require" ) @@ -90,64 +90,64 @@ var startingSlashingsResetState []byte func TestProcessRewardsAndPenalties(t *testing.T) { runEpochTransitionConsensusTest(t, startingRewardsPenaltyState, expectedRewardsPenaltyState, func(s *state.BeaconState) error { - return transition.ProcessRewardsAndPenalties(s) + return transition2.ProcessRewardsAndPenalties(s) }) } func TestProcessRegistryUpdates(t *testing.T) { runEpochTransitionConsensusTest(t, startingRegistryUpdatesState, expectedRegistryUpdatesState, func(s *state.BeaconState) error { - return transition.ProcessRegistryUpdates(s) + return transition2.ProcessRegistryUpdates(s) }) } func TestProcessEffectiveBalances(t *testing.T) { runEpochTransitionConsensusTest(t, startingEffectiveBalancesState, expectedEffectiveBalancesState, func(s *state.BeaconState) error { - return transition.ProcessEffectiveBalanceUpdates(s) + return transition2.ProcessEffectiveBalanceUpdates(s) }) } func TestProcessHistoricalRoots(t *testing.T) { runEpochTransitionConsensusTest(t, startingHistoricalRootsState, expectedHistoricalRootsState, func(s *state.BeaconState) error { - return transition.ProcessHistoricalRootsUpdate(s) + return transition2.ProcessHistoricalRootsUpdate(s) }) } func TestProcessParticipationFlagUpdates(t *testing.T) { runEpochTransitionConsensusTest(t, startingParticipationFlagState, expectedParticipationFlagState, func(s *state.BeaconState) error { - transition.ProcessParticipationFlagUpdates(s) + transition2.ProcessParticipationFlagUpdates(s) return nil }) } func TestProcessSlashings(t *testing.T) { runEpochTransitionConsensusTest(t, startingSlashingsState, expectedSlashingsState, func(s *state.BeaconState) error { - return transition.ProcessSlashings(s) + return transition2.ProcessSlashings(s) }) } func TestProcessJustificationAndFinality(t *testing.T) { runEpochTransitionConsensusTest(t, startingJustificationAndFinalityState, expectedJustificationAndFinalityState, func(s *state.BeaconState) error { - return transition.ProcessJustificationBitsAndFinality(s) + return transition2.ProcessJustificationBitsAndFinality(s) }) } func TestEth1DataReset(t *testing.T) { runEpochTransitionConsensusTest(t, startingEth1DataResetState, expectedEth1DataResetState, func(s *state.BeaconState) error { - transition.ProcessEth1DataReset(s) + transition2.ProcessEth1DataReset(s) return nil }) } func TestRandaoMixesReset(t *testing.T) { runEpochTransitionConsensusTest(t, startingRandaoMixesResetState, expectedRandaoMixesResetState, func(s *state.BeaconState) error { - transition.ProcessRandaoMixesReset(s) + transition2.ProcessRandaoMixesReset(s) return nil }) } func TestSlashingsReset(t *testing.T) { runEpochTransitionConsensusTest(t, startingSlashingsResetState, expectedSlashingsResetState, func(s *state.BeaconState) error { - transition.ProcessSlashingsReset(s) + transition2.ProcessSlashingsReset(s) return nil }) } @@ -160,6 +160,6 @@ var startingInactivityScoresState []byte func TestInactivityScores(t *testing.T) { runEpochTransitionConsensusTest(t, startingInactivityScoresState, expectedInactivityScoresState, func(s *state.BeaconState) error { - return transition.ProcessInactivityScores(s) + return transition2.ProcessInactivityScores(s) }) } diff --git a/cmd/erigon-cl/core/transition/process_inactivity_scores.go b/cl/phase1/core/transition/process_inactivity_scores.go similarity index 54% rename from cmd/erigon-cl/core/transition/process_inactivity_scores.go rename to cl/phase1/core/transition/process_inactivity_scores.go index b4faaa810..0dbb8f438 100644 --- a/cmd/erigon-cl/core/transition/process_inactivity_scores.go +++ b/cl/phase1/core/transition/process_inactivity_scores.go @@ -1,28 +1,28 @@ package transition import ( + state2 "github.com/ledgerwatch/erigon/cl/phase1/core/state" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" ) // ProcessInactivityScores will updates the inactivity registry of each validator. -func ProcessInactivityScores(s *state.BeaconState) error { - if state.Epoch(s.BeaconState) == s.BeaconConfig().GenesisEpoch { +func ProcessInactivityScores(s *state2.BeaconState) error { + if state2.Epoch(s.BeaconState) == s.BeaconConfig().GenesisEpoch { return nil } - previousEpoch := state.PreviousEpoch(s.BeaconState) - for _, validatorIndex := range state.EligibleValidatorsIndicies(s.BeaconState) { + previousEpoch := state2.PreviousEpoch(s.BeaconState) + for _, validatorIndex := range state2.EligibleValidatorsIndicies(s.BeaconState) { // retrieve validator inactivity score index. score, err := s.ValidatorInactivityScore(int(validatorIndex)) if err != nil { return err } - if state.IsUnslashedParticipatingIndex(s.BeaconState, previousEpoch, validatorIndex, int(s.BeaconConfig().TimelyTargetFlagIndex)) { + if state2.IsUnslashedParticipatingIndex(s.BeaconState, previousEpoch, validatorIndex, int(s.BeaconConfig().TimelyTargetFlagIndex)) { score -= utils.Min64(1, score) } else { score += s.BeaconConfig().InactivityScoreBias } - if !state.InactivityLeaking(s.BeaconState) { + if !state2.InactivityLeaking(s.BeaconState) { score -= utils.Min64(s.BeaconConfig().InactivityScoreRecoveryRate, score) } if err := s.SetValidatorInactivityScore(int(validatorIndex), score); err != nil { diff --git a/cmd/erigon-cl/core/transition/process_registry_updates.go b/cl/phase1/core/transition/process_registry_updates.go similarity index 88% rename from cmd/erigon-cl/core/transition/process_registry_updates.go rename to cl/phase1/core/transition/process_registry_updates.go index c8138293e..e98b66255 100644 --- a/cmd/erigon-cl/core/transition/process_registry_updates.go +++ b/cl/phase1/core/transition/process_registry_updates.go @@ -1,11 +1,11 @@ package transition import ( + state2 "github.com/ledgerwatch/erigon/cl/phase1/core/state" "sort" "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/cltypes" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" ) // computeActivationExitEpoch is Implementation of compute_activation_exit_epoch. Defined in https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#compute_activation_exit_epoch. @@ -14,15 +14,15 @@ func computeActivationExitEpoch(beaconConfig *clparams.BeaconChainConfig, epoch } // ProcessRegistyUpdates updates every epoch the activation status of validators. Specs at: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#registry-updates. -func ProcessRegistryUpdates(s *state.BeaconState) error { +func ProcessRegistryUpdates(s *state2.BeaconState) error { beaconConfig := s.BeaconConfig() - currentEpoch := state.Epoch(s.BeaconState) + currentEpoch := state2.Epoch(s.BeaconState) // start also initializing the activation queue. activationQueue := make([]uint64, 0) // Process activation eligibility and ejections. var err error s.ForEachValidator(func(validator *cltypes.Validator, validatorIndex, total int) bool { - if state.IsValidatorEligibleForActivationQueue(s.BeaconState, validator) { + if state2.IsValidatorEligibleForActivationQueue(s.BeaconState, validator) { s.SetActivationEligibilityEpochForValidatorAtIndex(validatorIndex, currentEpoch+1) } if validator.Active(currentEpoch) && validator.EffectiveBalance() <= beaconConfig.EjectionBalance { @@ -31,7 +31,7 @@ func ProcessRegistryUpdates(s *state.BeaconState) error { } } // Insert in the activation queue in case. - if state.IsValidatorEligibleForActivation(s.BeaconState, validator) { + if state2.IsValidatorEligibleForActivation(s.BeaconState, validator) { activationQueue = append(activationQueue, uint64(validatorIndex)) } return true diff --git a/cmd/erigon-cl/core/transition/process_rewards_and_penalties.go b/cl/phase1/core/transition/process_rewards_and_penalties.go similarity index 69% rename from cmd/erigon-cl/core/transition/process_rewards_and_penalties.go rename to cl/phase1/core/transition/process_rewards_and_penalties.go index 17ee66463..a809e2b55 100644 --- a/cmd/erigon-cl/core/transition/process_rewards_and_penalties.go +++ b/cl/phase1/core/transition/process_rewards_and_penalties.go @@ -3,16 +3,16 @@ package transition import ( "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/cltypes" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" + state2 "github.com/ledgerwatch/erigon/cl/phase1/core/state" ) -func processRewardsAndPenaltiesPostAltair(s *state.BeaconState) (err error) { +func processRewardsAndPenaltiesPostAltair(s *state2.BeaconState) (err error) { beaconConfig := s.BeaconConfig() weights := beaconConfig.ParticipationWeights() - eligibleValidators := state.EligibleValidatorsIndicies(s.BeaconState) + eligibleValidators := state2.EligibleValidatorsIndicies(s.BeaconState) // Initialize variables totalActiveBalance := s.GetTotalActiveBalance() - previousEpoch := state.PreviousEpoch(s.BeaconState) + previousEpoch := state2.PreviousEpoch(s.BeaconState) // Inactivity penalties denominator. inactivityPenaltyDenominator := beaconConfig.InactivityScoreBias * beaconConfig.GetPenaltyQuotient(s.Version()) // Make buffer for flag indexes total balances. @@ -20,7 +20,7 @@ func processRewardsAndPenaltiesPostAltair(s *state.BeaconState) (err error) { // Compute all total balances for each enable unslashed validator indicies with all flags on. s.ForEachValidator(func(validator *cltypes.Validator, validatorIndex, total int) bool { for i := range weights { - if state.IsUnslashedParticipatingIndex(s.BeaconState, previousEpoch, uint64(validatorIndex), i) { + if state2.IsUnslashedParticipatingIndex(s.BeaconState, previousEpoch, uint64(validatorIndex), i) { flagsTotalBalances[i] += validator.EffectiveBalance() } } @@ -40,20 +40,20 @@ func processRewardsAndPenaltiesPostAltair(s *state.BeaconState) (err error) { return } for flagIdx := range weights { - if state.IsUnslashedParticipatingIndex(s.BeaconState, previousEpoch, index, flagIdx) { - if !state.InactivityLeaking(s.BeaconState) { + if state2.IsUnslashedParticipatingIndex(s.BeaconState, previousEpoch, index, flagIdx) { + if !state2.InactivityLeaking(s.BeaconState) { rewardNumerator := baseReward * rewardMultipliers[flagIdx] - if err := state.IncreaseBalance(s.BeaconState, index, rewardNumerator/rewardDenominator); err != nil { + if err := state2.IncreaseBalance(s.BeaconState, index, rewardNumerator/rewardDenominator); err != nil { return err } } } else if flagIdx != int(beaconConfig.TimelyHeadFlagIndex) { - if err := state.DecreaseBalance(s.BeaconState, index, baseReward*weights[flagIdx]/beaconConfig.WeightDenominator); err != nil { + if err := state2.DecreaseBalance(s.BeaconState, index, baseReward*weights[flagIdx]/beaconConfig.WeightDenominator); err != nil { return err } } } - if !state.IsUnslashedParticipatingIndex(s.BeaconState, previousEpoch, index, int(beaconConfig.TimelyTargetFlagIndex)) { + if !state2.IsUnslashedParticipatingIndex(s.BeaconState, previousEpoch, index, int(beaconConfig.TimelyTargetFlagIndex)) { inactivityScore, err := s.ValidatorInactivityScore(int(index)) if err != nil { return err @@ -63,19 +63,19 @@ func processRewardsAndPenaltiesPostAltair(s *state.BeaconState) (err error) { if err != nil { return err } - state.DecreaseBalance(s.BeaconState, index, (effectiveBalance*inactivityScore)/inactivityPenaltyDenominator) + state2.DecreaseBalance(s.BeaconState, index, (effectiveBalance*inactivityScore)/inactivityPenaltyDenominator) } } return } // processRewardsAndPenaltiesPhase0 process rewards and penalties for phase0 state. -func processRewardsAndPenaltiesPhase0(s *state.BeaconState) (err error) { +func processRewardsAndPenaltiesPhase0(s *state2.BeaconState) (err error) { beaconConfig := s.BeaconConfig() - if state.Epoch(s.BeaconState) == beaconConfig.GenesisEpoch { + if state2.Epoch(s.BeaconState) == beaconConfig.GenesisEpoch { return nil } - eligibleValidators := state.EligibleValidatorsIndicies(s.BeaconState) + eligibleValidators := state2.EligibleValidatorsIndicies(s.BeaconState) // Initialize variables rewardDenominator := s.GetTotalActiveBalance() / beaconConfig.EffectiveBalanceIncrement // Make buffer for flag indexes totTargetal balances. @@ -113,47 +113,47 @@ func processRewardsAndPenaltiesPhase0(s *state.BeaconState) (err error) { // we can use a multiplier to account for all attesting attested, missed := currentValidator.DutiesAttested() // If we attested then we reward the validator. - if state.InactivityLeaking(s.BeaconState) { - if err := state.IncreaseBalance(s.BeaconState, index, baseReward*attested); err != nil { + if state2.InactivityLeaking(s.BeaconState) { + if err := state2.IncreaseBalance(s.BeaconState, index, baseReward*attested); err != nil { return err } } else { if !currentValidator.Slashed() && currentValidator.IsPreviousMatchingSourceAttester { rewardNumerator := baseReward * unslashedMatchingSourceBalanceIncrements - if err := state.IncreaseBalance(s.BeaconState, index, rewardNumerator/rewardDenominator); err != nil { + if err := state2.IncreaseBalance(s.BeaconState, index, rewardNumerator/rewardDenominator); err != nil { return err } } if !currentValidator.Slashed() && currentValidator.IsPreviousMatchingTargetAttester { rewardNumerator := baseReward * unslashedMatchingTargetBalanceIncrements - if err := state.IncreaseBalance(s.BeaconState, index, rewardNumerator/rewardDenominator); err != nil { + if err := state2.IncreaseBalance(s.BeaconState, index, rewardNumerator/rewardDenominator); err != nil { return err } } if !currentValidator.Slashed() && currentValidator.IsPreviousMatchingHeadAttester { rewardNumerator := baseReward * unslashedMatchingHeadBalanceIncrements - if err := state.IncreaseBalance(s.BeaconState, index, rewardNumerator/rewardDenominator); err != nil { + if err := state2.IncreaseBalance(s.BeaconState, index, rewardNumerator/rewardDenominator); err != nil { return err } } } // Process inactivity of the network as a whole finalities. - if state.InactivityLeaking(s.BeaconState) { + if state2.InactivityLeaking(s.BeaconState) { proposerReward := baseReward / beaconConfig.ProposerRewardQuotient // Neutralize rewards. - if state.DecreaseBalance(s.BeaconState, index, beaconConfig.BaseRewardsPerEpoch*baseReward-proposerReward); err != nil { + if state2.DecreaseBalance(s.BeaconState, index, beaconConfig.BaseRewardsPerEpoch*baseReward-proposerReward); err != nil { return err } if currentValidator.Slashed() || !currentValidator.IsPreviousMatchingTargetAttester { // Increase penalities linearly if network is leaking. - if state.DecreaseBalance(s.BeaconState, index, currentValidator.EffectiveBalance()*state.FinalityDelay(s.BeaconState)/beaconConfig.InactivityPenaltyQuotient); err != nil { + if state2.DecreaseBalance(s.BeaconState, index, currentValidator.EffectiveBalance()*state2.FinalityDelay(s.BeaconState)/beaconConfig.InactivityPenaltyQuotient); err != nil { return err } } } // For each missed duty we penalize the validator. - if state.DecreaseBalance(s.BeaconState, index, baseReward*missed); err != nil { + if state2.DecreaseBalance(s.BeaconState, index, baseReward*missed); err != nil { return err } @@ -172,11 +172,11 @@ func processRewardsAndPenaltiesPhase0(s *state.BeaconState) (err error) { } // Compute proposer reward. proposerReward := (baseReward / beaconConfig.ProposerRewardQuotient) - if err = state.IncreaseBalance(s.BeaconState, attestation.ProposerIndex, proposerReward); err != nil { + if err = state2.IncreaseBalance(s.BeaconState, attestation.ProposerIndex, proposerReward); err != nil { return false } maxAttesterReward := baseReward - proposerReward - if err = state.IncreaseBalance(s.BeaconState, uint64(index), maxAttesterReward/attestation.InclusionDelay); err != nil { + if err = state2.IncreaseBalance(s.BeaconState, uint64(index), maxAttesterReward/attestation.InclusionDelay); err != nil { return false } return true @@ -188,8 +188,8 @@ func processRewardsAndPenaltiesPhase0(s *state.BeaconState) (err error) { } // ProcessRewardsAndPenalties applies rewards/penalties accumulated during previous epoch. -func ProcessRewardsAndPenalties(s *state.BeaconState) error { - if state.Epoch(s.BeaconState) == s.BeaconConfig().GenesisEpoch { +func ProcessRewardsAndPenalties(s *state2.BeaconState) error { + if state2.Epoch(s.BeaconState) == s.BeaconConfig().GenesisEpoch { return nil } if s.Version() == clparams.Phase0Version { diff --git a/cmd/erigon-cl/core/transition/process_slashings.go b/cl/phase1/core/transition/process_slashings.go similarity index 82% rename from cmd/erigon-cl/core/transition/process_slashings.go rename to cl/phase1/core/transition/process_slashings.go index 03d88eb58..27a339c11 100644 --- a/cmd/erigon-cl/core/transition/process_slashings.go +++ b/cl/phase1/core/transition/process_slashings.go @@ -3,17 +3,17 @@ package transition import ( "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/cltypes" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" + state2 "github.com/ledgerwatch/erigon/cl/phase1/core/state" ) -func processSlashings(s *state.BeaconState, slashingMultiplier uint64) error { +func processSlashings(s *state2.BeaconState, slashingMultiplier uint64) error { // Get the current epoch - epoch := state.Epoch(s.BeaconState) + epoch := state2.Epoch(s.BeaconState) // Get the total active balance totalBalance := s.GetTotalActiveBalance() // Calculate the total slashing amount // by summing all slashings and multiplying by the provided multiplier - slashing := state.GetTotalSlashingAmount(s.BeaconState) * slashingMultiplier + slashing := state2.GetTotalSlashingAmount(s.BeaconState) * slashingMultiplier // Adjust the total slashing amount to be no greater than the total active balance if totalBalance < slashing { slashing = totalBalance @@ -32,7 +32,7 @@ func processSlashings(s *state.BeaconState, slashingMultiplier uint64) error { // Calculate the penalty by dividing the penalty numerator by the total balance and multiplying by the increment penalty := penaltyNumerator / totalBalance * increment // Decrease the validator's balance by the calculated penalty - if err = state.DecreaseBalance(s.BeaconState, uint64(i), penalty); err != nil { + if err = state2.DecreaseBalance(s.BeaconState, uint64(i), penalty); err != nil { return false } return true @@ -43,7 +43,7 @@ func processSlashings(s *state.BeaconState, slashingMultiplier uint64) error { return nil } -func ProcessSlashings(state *state.BeaconState) error { +func ProcessSlashings(state *state2.BeaconState) error { // Depending on the version of the state, use different multipliers switch state.Version() { case clparams.Phase0Version: diff --git a/cmd/erigon-cl/core/transition/process_slots.go b/cl/phase1/core/transition/process_slots.go similarity index 81% rename from cmd/erigon-cl/core/transition/process_slots.go rename to cl/phase1/core/transition/process_slots.go index e18c2d90d..3fbc422db 100644 --- a/cmd/erigon-cl/core/transition/process_slots.go +++ b/cl/phase1/core/transition/process_slots.go @@ -2,23 +2,21 @@ package transition import ( "fmt" + state2 "github.com/ledgerwatch/erigon/cl/phase1/core/state" + "github.com/ledgerwatch/erigon/cl/phase1/core/state/state_encoding" "time" "github.com/Giulio2002/bls" + libcommon "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/cltypes" "github.com/ledgerwatch/erigon/cl/fork" "github.com/ledgerwatch/erigon/cl/merkle_tree" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state/state_encoding" - - libcommon "github.com/ledgerwatch/erigon-lib/common" - "github.com/ledgerwatch/log/v3" ) -func TransitionState(s *state.BeaconState, block *cltypes.SignedBeaconBlock, fullValidation bool) error { +func TransitionState(s *state2.BeaconState, block *cltypes.SignedBeaconBlock, fullValidation bool) error { currentBlock := block.Block if err := ProcessSlots(s, currentBlock.Slot); err != nil { return err @@ -52,7 +50,7 @@ func TransitionState(s *state.BeaconState, block *cltypes.SignedBeaconBlock, ful } // transitionSlot is called each time there is a new slot to process -func transitionSlot(s *state.BeaconState) error { +func transitionSlot(s *state2.BeaconState) error { slot := s.Slot() previousStateRoot := s.PreviousStateRoot() var err error @@ -82,7 +80,7 @@ func transitionSlot(s *state.BeaconState) error { return nil } -func ProcessSlots(s *state.BeaconState, slot uint64) error { +func ProcessSlots(s *state2.BeaconState, slot uint64) error { beaconConfig := s.BeaconConfig() sSlot := s.Slot() if slot <= sSlot { @@ -100,7 +98,7 @@ func ProcessSlots(s *state.BeaconState, slot uint64) error { if err := ProcessEpoch(s); err != nil { return err } - log.Debug("Processed new epoch successfully", "epoch", state.Epoch(s.BeaconState), "process_epoch_elpsed", time.Since(start)) + log.Debug("Processed new epoch successfully", "epoch", state2.Epoch(s.BeaconState), "process_epoch_elpsed", time.Since(start)) } // TODO: add logic to process epoch updates. sSlot += 1 @@ -108,22 +106,22 @@ func ProcessSlots(s *state.BeaconState, slot uint64) error { if sSlot%beaconConfig.SlotsPerEpoch != 0 { continue } - if state.Epoch(s.BeaconState) == beaconConfig.AltairForkEpoch { + if state2.Epoch(s.BeaconState) == beaconConfig.AltairForkEpoch { if err := s.UpgradeToAltair(); err != nil { return err } } - if state.Epoch(s.BeaconState) == beaconConfig.BellatrixForkEpoch { + if state2.Epoch(s.BeaconState) == beaconConfig.BellatrixForkEpoch { if err := s.UpgradeToBellatrix(); err != nil { return err } } - if state.Epoch(s.BeaconState) == beaconConfig.CapellaForkEpoch { + if state2.Epoch(s.BeaconState) == beaconConfig.CapellaForkEpoch { if err := s.UpgradeToCapella(); err != nil { return err } } - if state.Epoch(s.BeaconState) == beaconConfig.DenebForkEpoch { + if state2.Epoch(s.BeaconState) == beaconConfig.DenebForkEpoch { if err := s.UpgradeToDeneb(); err != nil { return err } @@ -132,12 +130,12 @@ func ProcessSlots(s *state.BeaconState, slot uint64) error { return nil } -func verifyBlockSignature(s *state.BeaconState, block *cltypes.SignedBeaconBlock) (bool, error) { +func verifyBlockSignature(s *state2.BeaconState, block *cltypes.SignedBeaconBlock) (bool, error) { proposer, err := s.ValidatorForValidatorIndex(int(block.Block.ProposerIndex)) if err != nil { return false, err } - domain, err := s.GetDomain(s.BeaconConfig().DomainBeaconProposer, state.Epoch(s.BeaconState)) + domain, err := s.GetDomain(s.BeaconConfig().DomainBeaconProposer, state2.Epoch(s.BeaconState)) if err != nil { return false, err } @@ -150,8 +148,8 @@ func verifyBlockSignature(s *state.BeaconState, block *cltypes.SignedBeaconBlock } // ProcessHistoricalRootsUpdate updates the historical root data structure by computing a new historical root batch when it is time to do so. -func ProcessHistoricalRootsUpdate(s *state.BeaconState) error { - nextEpoch := state.Epoch(s.BeaconState) + 1 +func ProcessHistoricalRootsUpdate(s *state2.BeaconState) error { + nextEpoch := state2.Epoch(s.BeaconState) + 1 beaconConfig := s.BeaconConfig() blockRoots := s.BlockRoots() stateRoots := s.StateRoots() diff --git a/cmd/erigon-cl/core/transition/process_slots_test.go b/cl/phase1/core/transition/process_slots_test.go similarity index 90% rename from cmd/erigon-cl/core/transition/process_slots_test.go rename to cl/phase1/core/transition/process_slots_test.go index 97eb3a943..58321fc68 100644 --- a/cmd/erigon-cl/core/transition/process_slots_test.go +++ b/cl/phase1/core/transition/process_slots_test.go @@ -2,6 +2,7 @@ package transition import ( "encoding/hex" + state2 "github.com/ledgerwatch/erigon/cl/phase1/core/state" "testing" libcommon "github.com/ledgerwatch/erigon-lib/common" @@ -9,7 +10,6 @@ import ( "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/cltypes" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" ) var ( @@ -26,22 +26,22 @@ var ( blockHash44 = "3ff92b54cba8067044f6b6ca0a69c7a6344154de2a38742e7a89b1057877fffa" ) -func getTestBeaconState() *state.BeaconState { - return state.GetEmptyBeaconState() +func getTestBeaconState() *state2.BeaconState { + return state2.GetEmptyBeaconState() } -func getEmptyInvalidBeaconState() *state.BeaconState { - b := state.GetEmptyBeaconState() +func getEmptyInvalidBeaconState() *state2.BeaconState { + b := state2.GetEmptyBeaconState() b.SetCurrentSyncCommittee(&cltypes.SyncCommittee{}) return b // Invalid public key length } -func assertStateEq(t *testing.T, got *state.BeaconState, expected *state.BeaconState) { +func assertStateEq(t *testing.T, got *state2.BeaconState, expected *state2.BeaconState) { assert.Equal(t, got.LatestExecutionPayloadHeader(), expected.LatestExecutionPayloadHeader()) } -func prepareNextBeaconState(t *testing.T, slots []uint64, stateHashs, blockHashs []string, nextState *state.BeaconState) *state.BeaconState { +func prepareNextBeaconState(t *testing.T, slots []uint64, stateHashs, blockHashs []string, nextState *state2.BeaconState) *state2.BeaconState { // Set slot to initial index. for i, val := range slots { nextState.SetSlot(val) @@ -71,8 +71,8 @@ func TestTransitionSlot(t *testing.T) { slot42.SetSlot(42) testCases := []struct { description string - prevState *state.BeaconState - expectedState *state.BeaconState + prevState *state2.BeaconState + expectedState *state2.BeaconState wantErr bool }{ { @@ -137,8 +137,8 @@ func TestProcessSlots(t *testing.T) { slot42.SetSlot(42) testCases := []struct { description string - prevState *state.BeaconState - expectedState *state.BeaconState + prevState *state2.BeaconState + expectedState *state2.BeaconState numSlots uint64 startSlot uint64 wantErr bool diff --git a/cmd/erigon-cl/core/transition/process_sync_aggregate.go b/cl/phase1/core/transition/process_sync_aggregate.go similarity index 75% rename from cmd/erigon-cl/core/transition/process_sync_aggregate.go rename to cl/phase1/core/transition/process_sync_aggregate.go index b3687bc65..2bca5b62e 100644 --- a/cmd/erigon-cl/core/transition/process_sync_aggregate.go +++ b/cl/phase1/core/transition/process_sync_aggregate.go @@ -2,18 +2,18 @@ package transition import ( "errors" + state2 "github.com/ledgerwatch/erigon/cl/phase1/core/state" "github.com/Giulio2002/bls" "github.com/ledgerwatch/erigon/cl/cltypes" "github.com/ledgerwatch/erigon/cl/fork" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" ) // processSyncAggregate applies all the logic in the spec function `process_sync_aggregate` except // verifying the BLS signatures. It returns the modified beacons state and the list of validators' // public keys that voted, for future signature verification. -func processSyncAggregate(s *state.BeaconState, sync *cltypes.SyncAggregate) ([][]byte, error) { +func processSyncAggregate(s *state2.BeaconState, sync *cltypes.SyncAggregate) ([][]byte, error) { currentSyncCommittee := s.CurrentSyncCommittee() if currentSyncCommittee == nil { @@ -47,12 +47,12 @@ func processSyncAggregate(s *state.BeaconState, sync *cltypes.SyncAggregate) ([] } if syncAggregateBits[i]&byte(bit) > 0 { votedKeys = append(votedKeys, currentSyncCommittee.PubKeys[currPubKeyIndex][:]) - if err := state.IncreaseBalance(s.BeaconState, vIdx, participantReward); err != nil { + if err := state2.IncreaseBalance(s.BeaconState, vIdx, participantReward); err != nil { return nil, err } earnedProposerReward += proposerReward } else { - if err := state.DecreaseBalance(s.BeaconState, vIdx, participantReward); err != nil { + if err := state2.DecreaseBalance(s.BeaconState, vIdx, participantReward); err != nil { return nil, err } } @@ -60,10 +60,10 @@ func processSyncAggregate(s *state.BeaconState, sync *cltypes.SyncAggregate) ([] } } - return votedKeys, state.IncreaseBalance(s.BeaconState, proposerIndex, earnedProposerReward) + return votedKeys, state2.IncreaseBalance(s.BeaconState, proposerIndex, earnedProposerReward) } -func ProcessSyncAggregate(s *state.BeaconState, sync *cltypes.SyncAggregate, fullValidation bool) error { +func ProcessSyncAggregate(s *state2.BeaconState, sync *cltypes.SyncAggregate, fullValidation bool) error { votedKeys, err := processSyncAggregate(s, sync) if err != nil { return err @@ -71,7 +71,7 @@ func ProcessSyncAggregate(s *state.BeaconState, sync *cltypes.SyncAggregate, ful if fullValidation { previousSlot := s.PreviousSlot() - domain, err := fork.Domain(s.Fork(), state.GetEpochAtSlot(s.BeaconConfig(), previousSlot), s.BeaconConfig().DomainSyncCommittee, s.GenesisValidatorsRoot()) + domain, err := fork.Domain(s.Fork(), state2.GetEpochAtSlot(s.BeaconConfig(), previousSlot), s.BeaconConfig().DomainSyncCommittee, s.GenesisValidatorsRoot()) if err != nil { return nil } diff --git a/cmd/erigon-cl/core/transition/process_sync_committee_update.go b/cl/phase1/core/transition/process_sync_committee_update.go similarity index 66% rename from cmd/erigon-cl/core/transition/process_sync_committee_update.go rename to cl/phase1/core/transition/process_sync_committee_update.go index 43fdcd75d..ec043b5a1 100644 --- a/cmd/erigon-cl/core/transition/process_sync_committee_update.go +++ b/cl/phase1/core/transition/process_sync_committee_update.go @@ -1,12 +1,12 @@ package transition import ( - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" + state2 "github.com/ledgerwatch/erigon/cl/phase1/core/state" ) // ProcessSyncCommitteeUpdate implements processing for the sync committee update. unfortunately there is no easy way to test it. -func ProcessSyncCommitteeUpdate(s *state.BeaconState) error { - if (state.Epoch(s.BeaconState)+1)%s.BeaconConfig().EpochsPerSyncCommitteePeriod != 0 { +func ProcessSyncCommitteeUpdate(s *state2.BeaconState) error { + if (state2.Epoch(s.BeaconState)+1)%s.BeaconConfig().EpochsPerSyncCommitteePeriod != 0 { return nil } // Set new current sync committee. diff --git a/cmd/erigon-cl/core/transition/process_sync_committee_update_test.go b/cl/phase1/core/transition/process_sync_committee_update_test.go similarity index 92% rename from cmd/erigon-cl/core/transition/process_sync_committee_update_test.go rename to cl/phase1/core/transition/process_sync_committee_update_test.go index b16260a0c..90fd1c0ae 100644 --- a/cmd/erigon-cl/core/transition/process_sync_committee_update_test.go +++ b/cl/phase1/core/transition/process_sync_committee_update_test.go @@ -2,12 +2,12 @@ package transition_test import ( "encoding/binary" + "github.com/ledgerwatch/erigon/cl/phase1/core/state" + "github.com/ledgerwatch/erigon/cl/phase1/core/transition" "testing" "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/cltypes" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/transition" "github.com/ledgerwatch/erigon/common" "github.com/stretchr/testify/require" ) diff --git a/cmd/erigon-cl/core/transition/processing.go b/cl/phase1/core/transition/processing.go similarity index 89% rename from cmd/erigon-cl/core/transition/processing.go rename to cl/phase1/core/transition/processing.go index a5afa127a..b9bdd7689 100644 --- a/cmd/erigon-cl/core/transition/processing.go +++ b/cl/phase1/core/transition/processing.go @@ -3,13 +3,13 @@ package transition import ( "encoding/binary" "fmt" + state2 "github.com/ledgerwatch/erigon/cl/phase1/core/state" libcommon "github.com/ledgerwatch/erigon-lib/common" "github.com/Giulio2002/bls" "github.com/ledgerwatch/erigon/cl/cltypes" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" ) func computeSigningRootEpoch(epoch uint64, domain []byte) (libcommon.Hash, error) { @@ -18,7 +18,7 @@ func computeSigningRootEpoch(epoch uint64, domain []byte) (libcommon.Hash, error return utils.Keccak256(b, domain), nil } -func ProcessBlockHeader(state *state.BeaconState, block *cltypes.BeaconBlock, fullValidation bool) error { +func ProcessBlockHeader(state *state2.BeaconState, block *cltypes.BeaconBlock, fullValidation bool) error { if fullValidation { if block.Slot != state.Slot() { return fmt.Errorf("state slot: %d, not equal to block slot: %d", state.Slot(), block.Slot) @@ -64,8 +64,8 @@ func ProcessBlockHeader(state *state.BeaconState, block *cltypes.BeaconBlock, fu return nil } -func ProcessRandao(s *state.BeaconState, randao [96]byte, proposerIndex uint64, fullValidation bool) error { - epoch := state.Epoch(s.BeaconState) +func ProcessRandao(s *state2.BeaconState, randao [96]byte, proposerIndex uint64, fullValidation bool) error { + epoch := state2.Epoch(s.BeaconState) proposer, err := s.ValidatorForValidatorIndex(int(proposerIndex)) if err != nil { return err @@ -99,7 +99,7 @@ func ProcessRandao(s *state.BeaconState, randao [96]byte, proposerIndex uint64, return nil } -func ProcessEth1Data(state *state.BeaconState, eth1Data *cltypes.Eth1Data) error { +func ProcessEth1Data(state *state2.BeaconState, eth1Data *cltypes.Eth1Data) error { state.AddEth1DataVote(eth1Data) newVotes := state.Eth1DataVotes() diff --git a/cmd/erigon-cl/core/transition/processing_test.go b/cl/phase1/core/transition/processing_test.go similarity index 95% rename from cmd/erigon-cl/core/transition/processing_test.go rename to cl/phase1/core/transition/processing_test.go index baa8266e1..eb1c6eb45 100644 --- a/cmd/erigon-cl/core/transition/processing_test.go +++ b/cl/phase1/core/transition/processing_test.go @@ -2,13 +2,13 @@ package transition import ( "encoding/hex" + state2 "github.com/ledgerwatch/erigon/cl/phase1/core/state" "testing" libcommon "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/cltypes" "github.com/ledgerwatch/erigon/cl/merkle_tree" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" "github.com/stretchr/testify/require" ) @@ -20,7 +20,7 @@ var ( emptyBlock = &cltypes.Eth1Block{} ) -func getTestState(t *testing.T) *state.BeaconState { +func getTestState(t *testing.T) *state2.BeaconState { numVals := 2048 validators := make([]*cltypes.Validator, numVals) for i := 0; i < numVals; i++ { @@ -29,7 +29,7 @@ func getTestState(t *testing.T) *state.BeaconState { v.SetExitEpoch(10000) validators[i] = v } - b := state.GetEmptyBeaconState() + b := state2.GetEmptyBeaconState() b.SetValidators(validators) b.SetSlot(19) b.SetLatestBlockHeader(&cltypes.BeaconBlockHeader{Slot: 18}) @@ -90,7 +90,7 @@ func TestProcessBlockHeader(t *testing.T) { testCases := []struct { description string - state *state.BeaconState + state *state2.BeaconState block *cltypes.BeaconBlock wantErr bool }{ @@ -179,7 +179,7 @@ func TestProcessRandao(t *testing.T) { testCases := []struct { description string - state *state.BeaconState + state *state2.BeaconState body *cltypes.BeaconBody wantErr bool }{ @@ -232,7 +232,7 @@ func TestProcessEth1Data(t *testing.T) { if err != nil { t.Fatalf("unable to hash expected eth1data: %v", err) } - successState := state.GetEmptyBeaconState() + successState := state2.GetEmptyBeaconState() successState.SetEth1Data(Eth1DataB) // Fill all votes. @@ -243,12 +243,12 @@ func TestProcessEth1Data(t *testing.T) { Eth1Data: Eth1DataA, } - noUpdateState := state.GetEmptyBeaconState() + noUpdateState := state2.GetEmptyBeaconState() noUpdateState.SetEth1Data(Eth1DataB) testCases := []struct { description string - state *state.BeaconState + state *state2.BeaconState body *cltypes.BeaconBody expectedHash [32]byte }{ diff --git a/cl/phase1/core/transition/resets.go b/cl/phase1/core/transition/resets.go new file mode 100644 index 000000000..28f470b71 --- /dev/null +++ b/cl/phase1/core/transition/resets.go @@ -0,0 +1,27 @@ +package transition + +import ( + state2 "github.com/ledgerwatch/erigon/cl/phase1/core/state" +) + +func ProcessEth1DataReset(s *state2.BeaconState) { + nextEpoch := state2.Epoch(s.BeaconState) + 1 + if nextEpoch%s.BeaconConfig().EpochsPerEth1VotingPeriod == 0 { + s.ResetEth1DataVotes() + } +} + +func ProcessSlashingsReset(s *state2.BeaconState) { + s.SetSlashingSegmentAt(int(state2.Epoch(s.BeaconState)+1)%int(s.BeaconConfig().EpochsPerSlashingsVector), 0) + +} + +func ProcessRandaoMixesReset(s *state2.BeaconState) { + currentEpoch := state2.Epoch(s.BeaconState) + nextEpoch := state2.Epoch(s.BeaconState) + 1 + s.SetRandaoMixAt(int(nextEpoch%s.BeaconConfig().EpochsPerHistoricalVector), s.GetRandaoMixes(currentEpoch)) +} + +func ProcessParticipationFlagUpdates(state *state2.BeaconState) { + state.ResetEpochParticipation() +} diff --git a/cmd/erigon-cl/core/transition/test_data/effective_balances_expected.ssz_snappy b/cl/phase1/core/transition/test_data/effective_balances_expected.ssz_snappy similarity index 100% rename from cmd/erigon-cl/core/transition/test_data/effective_balances_expected.ssz_snappy rename to cl/phase1/core/transition/test_data/effective_balances_expected.ssz_snappy diff --git a/cmd/erigon-cl/core/transition/test_data/effective_balances_test_state.ssz_snappy b/cl/phase1/core/transition/test_data/effective_balances_test_state.ssz_snappy similarity index 100% rename from cmd/erigon-cl/core/transition/test_data/effective_balances_test_state.ssz_snappy rename to cl/phase1/core/transition/test_data/effective_balances_test_state.ssz_snappy diff --git a/cmd/erigon-cl/core/transition/test_data/eth1_data_reset_expected_test.ssz_snappy b/cl/phase1/core/transition/test_data/eth1_data_reset_expected_test.ssz_snappy similarity index 100% rename from cmd/erigon-cl/core/transition/test_data/eth1_data_reset_expected_test.ssz_snappy rename to cl/phase1/core/transition/test_data/eth1_data_reset_expected_test.ssz_snappy diff --git a/cmd/erigon-cl/core/transition/test_data/eth1_data_reset_state_test.ssz_snappy b/cl/phase1/core/transition/test_data/eth1_data_reset_state_test.ssz_snappy similarity index 100% rename from cmd/erigon-cl/core/transition/test_data/eth1_data_reset_state_test.ssz_snappy rename to cl/phase1/core/transition/test_data/eth1_data_reset_state_test.ssz_snappy diff --git a/cmd/erigon-cl/core/transition/test_data/historical_roots_expected_test.ssz_snappy b/cl/phase1/core/transition/test_data/historical_roots_expected_test.ssz_snappy similarity index 100% rename from cmd/erigon-cl/core/transition/test_data/historical_roots_expected_test.ssz_snappy rename to cl/phase1/core/transition/test_data/historical_roots_expected_test.ssz_snappy diff --git a/cmd/erigon-cl/core/transition/test_data/historical_roots_state_test.ssz_snappy b/cl/phase1/core/transition/test_data/historical_roots_state_test.ssz_snappy similarity index 100% rename from cmd/erigon-cl/core/transition/test_data/historical_roots_state_test.ssz_snappy rename to cl/phase1/core/transition/test_data/historical_roots_state_test.ssz_snappy diff --git a/cmd/erigon-cl/core/transition/test_data/inactivity_scores_expected_test.ssz_snappy b/cl/phase1/core/transition/test_data/inactivity_scores_expected_test.ssz_snappy similarity index 100% rename from cmd/erigon-cl/core/transition/test_data/inactivity_scores_expected_test.ssz_snappy rename to cl/phase1/core/transition/test_data/inactivity_scores_expected_test.ssz_snappy diff --git a/cmd/erigon-cl/core/transition/test_data/inactivity_scores_state_test.ssz_snappy b/cl/phase1/core/transition/test_data/inactivity_scores_state_test.ssz_snappy similarity index 100% rename from cmd/erigon-cl/core/transition/test_data/inactivity_scores_state_test.ssz_snappy rename to cl/phase1/core/transition/test_data/inactivity_scores_state_test.ssz_snappy diff --git a/cmd/erigon-cl/core/transition/test_data/justification_and_finality_expected_test.ssz_snappy b/cl/phase1/core/transition/test_data/justification_and_finality_expected_test.ssz_snappy similarity index 100% rename from cmd/erigon-cl/core/transition/test_data/justification_and_finality_expected_test.ssz_snappy rename to cl/phase1/core/transition/test_data/justification_and_finality_expected_test.ssz_snappy diff --git a/cmd/erigon-cl/core/transition/test_data/justification_and_finality_state_test.ssz_snappy b/cl/phase1/core/transition/test_data/justification_and_finality_state_test.ssz_snappy similarity index 100% rename from cmd/erigon-cl/core/transition/test_data/justification_and_finality_state_test.ssz_snappy rename to cl/phase1/core/transition/test_data/justification_and_finality_state_test.ssz_snappy diff --git a/cmd/erigon-cl/core/transition/test_data/participation_flag_updates_expected_test.ssz_snappy b/cl/phase1/core/transition/test_data/participation_flag_updates_expected_test.ssz_snappy similarity index 100% rename from cmd/erigon-cl/core/transition/test_data/participation_flag_updates_expected_test.ssz_snappy rename to cl/phase1/core/transition/test_data/participation_flag_updates_expected_test.ssz_snappy diff --git a/cmd/erigon-cl/core/transition/test_data/participation_flag_updates_state_test.ssz_snappy b/cl/phase1/core/transition/test_data/participation_flag_updates_state_test.ssz_snappy similarity index 100% rename from cmd/erigon-cl/core/transition/test_data/participation_flag_updates_state_test.ssz_snappy rename to cl/phase1/core/transition/test_data/participation_flag_updates_state_test.ssz_snappy diff --git a/cmd/erigon-cl/core/transition/test_data/randao_mixes_reset_expected_test.ssz_snappy b/cl/phase1/core/transition/test_data/randao_mixes_reset_expected_test.ssz_snappy similarity index 100% rename from cmd/erigon-cl/core/transition/test_data/randao_mixes_reset_expected_test.ssz_snappy rename to cl/phase1/core/transition/test_data/randao_mixes_reset_expected_test.ssz_snappy diff --git a/cmd/erigon-cl/core/transition/test_data/randao_mixes_reset_state_test.ssz_snappy b/cl/phase1/core/transition/test_data/randao_mixes_reset_state_test.ssz_snappy similarity index 100% rename from cmd/erigon-cl/core/transition/test_data/randao_mixes_reset_state_test.ssz_snappy rename to cl/phase1/core/transition/test_data/randao_mixes_reset_state_test.ssz_snappy diff --git a/cmd/erigon-cl/core/transition/test_data/registry_updates_test_expected.ssz_snappy b/cl/phase1/core/transition/test_data/registry_updates_test_expected.ssz_snappy similarity index 100% rename from cmd/erigon-cl/core/transition/test_data/registry_updates_test_expected.ssz_snappy rename to cl/phase1/core/transition/test_data/registry_updates_test_expected.ssz_snappy diff --git a/cmd/erigon-cl/core/transition/test_data/registry_updates_test_state.ssz_snappy b/cl/phase1/core/transition/test_data/registry_updates_test_state.ssz_snappy similarity index 100% rename from cmd/erigon-cl/core/transition/test_data/registry_updates_test_state.ssz_snappy rename to cl/phase1/core/transition/test_data/registry_updates_test_state.ssz_snappy diff --git a/cmd/erigon-cl/core/transition/test_data/rewards_penalty_test_expected.ssz_snappy b/cl/phase1/core/transition/test_data/rewards_penalty_test_expected.ssz_snappy similarity index 100% rename from cmd/erigon-cl/core/transition/test_data/rewards_penalty_test_expected.ssz_snappy rename to cl/phase1/core/transition/test_data/rewards_penalty_test_expected.ssz_snappy diff --git a/cmd/erigon-cl/core/transition/test_data/rewards_penalty_test_state.ssz_snappy b/cl/phase1/core/transition/test_data/rewards_penalty_test_state.ssz_snappy similarity index 100% rename from cmd/erigon-cl/core/transition/test_data/rewards_penalty_test_state.ssz_snappy rename to cl/phase1/core/transition/test_data/rewards_penalty_test_state.ssz_snappy diff --git a/cmd/erigon-cl/core/transition/test_data/slashings_expected_test.ssz_snappy b/cl/phase1/core/transition/test_data/slashings_expected_test.ssz_snappy similarity index 100% rename from cmd/erigon-cl/core/transition/test_data/slashings_expected_test.ssz_snappy rename to cl/phase1/core/transition/test_data/slashings_expected_test.ssz_snappy diff --git a/cmd/erigon-cl/core/transition/test_data/slashings_reset_expected_test.ssz_snappy b/cl/phase1/core/transition/test_data/slashings_reset_expected_test.ssz_snappy similarity index 100% rename from cmd/erigon-cl/core/transition/test_data/slashings_reset_expected_test.ssz_snappy rename to cl/phase1/core/transition/test_data/slashings_reset_expected_test.ssz_snappy diff --git a/cmd/erigon-cl/core/transition/test_data/slashings_reset_state_test.ssz_snappy b/cl/phase1/core/transition/test_data/slashings_reset_state_test.ssz_snappy similarity index 100% rename from cmd/erigon-cl/core/transition/test_data/slashings_reset_state_test.ssz_snappy rename to cl/phase1/core/transition/test_data/slashings_reset_state_test.ssz_snappy diff --git a/cmd/erigon-cl/core/transition/test_data/slashings_state_test.ssz_snappy b/cl/phase1/core/transition/test_data/slashings_state_test.ssz_snappy similarity index 100% rename from cmd/erigon-cl/core/transition/test_data/slashings_state_test.ssz_snappy rename to cl/phase1/core/transition/test_data/slashings_state_test.ssz_snappy diff --git a/cmd/erigon-cl/execution_client/execution_client.go b/cl/phase1/execution_client/execution_client.go similarity index 100% rename from cmd/erigon-cl/execution_client/execution_client.go rename to cl/phase1/execution_client/execution_client.go diff --git a/cmd/erigon-cl/execution_client/execution_engine.go b/cl/phase1/execution_client/execution_engine.go similarity index 100% rename from cmd/erigon-cl/execution_client/execution_engine.go rename to cl/phase1/execution_client/execution_engine.go diff --git a/cmd/erigon-cl/execution_client/insert_batch.go b/cl/phase1/execution_client/insert_batch.go similarity index 100% rename from cmd/erigon-cl/execution_client/insert_batch.go rename to cl/phase1/execution_client/insert_batch.go diff --git a/cmd/erigon-cl/forkchoice/checkpoint_state.go b/cl/phase1/forkchoice/checkpoint_state.go similarity index 98% rename from cmd/erigon-cl/forkchoice/checkpoint_state.go rename to cl/phase1/forkchoice/checkpoint_state.go index 8df981a2f..0f0a3fe35 100644 --- a/cmd/erigon-cl/forkchoice/checkpoint_state.go +++ b/cl/phase1/forkchoice/checkpoint_state.go @@ -2,6 +2,7 @@ package forkchoice import ( "fmt" + "github.com/ledgerwatch/erigon/cl/phase1/core/state/shuffling" "github.com/Giulio2002/bls" libcommon "github.com/ledgerwatch/erigon-lib/common" @@ -10,7 +11,6 @@ import ( "github.com/ledgerwatch/erigon/cl/cltypes" "github.com/ledgerwatch/erigon/cl/fork" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state/shuffling" ) const randaoMixesLength = 65536 diff --git a/cmd/erigon-cl/forkchoice/fork_choice_test.go b/cl/phase1/forkchoice/fork_choice_test.go similarity index 97% rename from cmd/erigon-cl/forkchoice/fork_choice_test.go rename to cl/phase1/forkchoice/fork_choice_test.go index 345367bbe..4bff951eb 100644 --- a/cmd/erigon-cl/forkchoice/fork_choice_test.go +++ b/cl/phase1/forkchoice/fork_choice_test.go @@ -2,6 +2,8 @@ package forkchoice_test import ( _ "embed" + "github.com/ledgerwatch/erigon/cl/phase1/core/state" + "github.com/ledgerwatch/erigon/cl/phase1/forkchoice" "testing" libcommon "github.com/ledgerwatch/erigon-lib/common" @@ -9,8 +11,6 @@ import ( "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/cltypes" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/forkchoice" "github.com/stretchr/testify/require" ) diff --git a/cmd/erigon-cl/forkchoice/fork_graph/fork_graph.go b/cl/phase1/forkchoice/fork_graph/fork_graph.go similarity index 98% rename from cmd/erigon-cl/forkchoice/fork_graph/fork_graph.go rename to cl/phase1/forkchoice/fork_graph/fork_graph.go index abedf4603..b10e56838 100644 --- a/cmd/erigon-cl/forkchoice/fork_graph/fork_graph.go +++ b/cl/phase1/forkchoice/fork_graph/fork_graph.go @@ -4,8 +4,8 @@ import ( libcommon "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/cltypes" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/transition" + "github.com/ledgerwatch/erigon/cl/phase1/core/state" + "github.com/ledgerwatch/erigon/cl/phase1/core/transition" "github.com/ledgerwatch/log/v3" "golang.org/x/exp/slices" ) diff --git a/cmd/erigon-cl/forkchoice/fork_graph/fork_graph_test.go b/cl/phase1/forkchoice/fork_graph/fork_graph_test.go similarity index 93% rename from cmd/erigon-cl/forkchoice/fork_graph/fork_graph_test.go rename to cl/phase1/forkchoice/fork_graph/fork_graph_test.go index 5ae4a82ed..ac8b85b8c 100644 --- a/cmd/erigon-cl/forkchoice/fork_graph/fork_graph_test.go +++ b/cl/phase1/forkchoice/fork_graph/fork_graph_test.go @@ -2,13 +2,13 @@ package fork_graph_test import ( _ "embed" + "github.com/ledgerwatch/erigon/cl/phase1/core/state" + "github.com/ledgerwatch/erigon/cl/phase1/forkchoice/fork_graph" "testing" "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/cltypes" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/forkchoice/fork_graph" "github.com/stretchr/testify/require" ) diff --git a/cmd/erigon-cl/forkchoice/fork_graph/test_data/anchor_state.ssz_snappy b/cl/phase1/forkchoice/fork_graph/test_data/anchor_state.ssz_snappy similarity index 100% rename from cmd/erigon-cl/forkchoice/fork_graph/test_data/anchor_state.ssz_snappy rename to cl/phase1/forkchoice/fork_graph/test_data/anchor_state.ssz_snappy diff --git a/cmd/erigon-cl/forkchoice/fork_graph/test_data/block_0xbf1a9ba2d349f6b5a5095bff40bd103ae39177e36018fb1f589953b9eeb0ca9d.ssz_snappy b/cl/phase1/forkchoice/fork_graph/test_data/block_0xbf1a9ba2d349f6b5a5095bff40bd103ae39177e36018fb1f589953b9eeb0ca9d.ssz_snappy similarity index 100% rename from cmd/erigon-cl/forkchoice/fork_graph/test_data/block_0xbf1a9ba2d349f6b5a5095bff40bd103ae39177e36018fb1f589953b9eeb0ca9d.ssz_snappy rename to cl/phase1/forkchoice/fork_graph/test_data/block_0xbf1a9ba2d349f6b5a5095bff40bd103ae39177e36018fb1f589953b9eeb0ca9d.ssz_snappy diff --git a/cmd/erigon-cl/forkchoice/fork_graph/test_data/block_0xe2a37a22d208ebe969c50e9d44bb3f1f63c5404787b9c214a5f2f28fb9835feb.ssz_snappy b/cl/phase1/forkchoice/fork_graph/test_data/block_0xe2a37a22d208ebe969c50e9d44bb3f1f63c5404787b9c214a5f2f28fb9835feb.ssz_snappy similarity index 100% rename from cmd/erigon-cl/forkchoice/fork_graph/test_data/block_0xe2a37a22d208ebe969c50e9d44bb3f1f63c5404787b9c214a5f2f28fb9835feb.ssz_snappy rename to cl/phase1/forkchoice/fork_graph/test_data/block_0xe2a37a22d208ebe969c50e9d44bb3f1f63c5404787b9c214a5f2f28fb9835feb.ssz_snappy diff --git a/cmd/erigon-cl/forkchoice/forkchoice.go b/cl/phase1/forkchoice/forkchoice.go similarity index 91% rename from cmd/erigon-cl/forkchoice/forkchoice.go rename to cl/phase1/forkchoice/forkchoice.go index e5aafa99d..dc000dc89 100644 --- a/cmd/erigon-cl/forkchoice/forkchoice.go +++ b/cl/phase1/forkchoice/forkchoice.go @@ -1,14 +1,14 @@ package forkchoice import ( + state2 "github.com/ledgerwatch/erigon/cl/phase1/core/state" + "github.com/ledgerwatch/erigon/cl/phase1/execution_client" + "github.com/ledgerwatch/erigon/cl/phase1/forkchoice/fork_graph" "sync" lru "github.com/hashicorp/golang-lru/v2" libcommon "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon/cl/cltypes" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/execution_client" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/forkchoice/fork_graph" ) const ( @@ -43,13 +43,13 @@ type LatestMessage struct { } // NewForkChoiceStore initialize a new store from the given anchor state, either genesis or checkpoint sync state. -func NewForkChoiceStore(anchorState *state.BeaconState, engine execution_client.ExecutionEngine, enabledPruning bool) (*ForkChoiceStore, error) { +func NewForkChoiceStore(anchorState *state2.BeaconState, engine execution_client.ExecutionEngine, enabledPruning bool) (*ForkChoiceStore, error) { anchorRoot, err := anchorState.BlockRoot() if err != nil { return nil, err } anchorCheckpoint := &cltypes.Checkpoint{ - Epoch: state.Epoch(anchorState.BeaconState), + Epoch: state2.Epoch(anchorState.BeaconState), Root: anchorRoot, } checkpointStates, err := lru.New[cltypes.Checkpoint, *checkpointState](allowedCachedStates) diff --git a/cmd/erigon-cl/forkchoice/get_head.go b/cl/phase1/forkchoice/get_head.go similarity index 100% rename from cmd/erigon-cl/forkchoice/get_head.go rename to cl/phase1/forkchoice/get_head.go diff --git a/cmd/erigon-cl/forkchoice/on_attestation.go b/cl/phase1/forkchoice/on_attestation.go similarity index 97% rename from cmd/erigon-cl/forkchoice/on_attestation.go rename to cl/phase1/forkchoice/on_attestation.go index 128b96b51..8801d4c97 100644 --- a/cmd/erigon-cl/forkchoice/on_attestation.go +++ b/cl/phase1/forkchoice/on_attestation.go @@ -2,11 +2,11 @@ package forkchoice import ( "fmt" + "github.com/ledgerwatch/erigon/cl/phase1/cache" + "github.com/ledgerwatch/erigon/cl/phase1/core/state" libcommon "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon/cl/cltypes" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/cache" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" ) // OnAttestation processes incoming attestations. TODO(Giulio2002): finish it with forward changesets. diff --git a/cmd/erigon-cl/forkchoice/on_attester_slashing.go b/cl/phase1/forkchoice/on_attester_slashing.go similarity index 96% rename from cmd/erigon-cl/forkchoice/on_attester_slashing.go rename to cl/phase1/forkchoice/on_attester_slashing.go index e07c34823..36321e134 100644 --- a/cmd/erigon-cl/forkchoice/on_attester_slashing.go +++ b/cl/phase1/forkchoice/on_attester_slashing.go @@ -2,10 +2,10 @@ package forkchoice import ( "fmt" + "github.com/ledgerwatch/erigon/cl/phase1/core/state" "github.com/ledgerwatch/erigon/cl/cltypes" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" ) func (f *ForkChoiceStore) OnAttesterSlashing(attesterSlashing *cltypes.AttesterSlashing) error { diff --git a/cmd/erigon-cl/forkchoice/on_block.go b/cl/phase1/forkchoice/on_block.go similarity index 96% rename from cmd/erigon-cl/forkchoice/on_block.go rename to cl/phase1/forkchoice/on_block.go index 1947b5c77..325ce8fd6 100644 --- a/cmd/erigon-cl/forkchoice/on_block.go +++ b/cl/phase1/forkchoice/on_block.go @@ -2,10 +2,10 @@ package forkchoice import ( "fmt" + "github.com/ledgerwatch/erigon/cl/phase1/core/transition" + "github.com/ledgerwatch/erigon/cl/phase1/forkchoice/fork_graph" "github.com/ledgerwatch/erigon/cl/cltypes" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/transition" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/forkchoice/fork_graph" "github.com/ledgerwatch/log/v3" ) diff --git a/cmd/erigon-cl/forkchoice/on_tick.go b/cl/phase1/forkchoice/on_tick.go similarity index 100% rename from cmd/erigon-cl/forkchoice/on_tick.go rename to cl/phase1/forkchoice/on_tick.go diff --git a/cmd/erigon-cl/forkchoice/test_data/anchor_state.ssz_snappy b/cl/phase1/forkchoice/test_data/anchor_state.ssz_snappy similarity index 100% rename from cmd/erigon-cl/forkchoice/test_data/anchor_state.ssz_snappy rename to cl/phase1/forkchoice/test_data/anchor_state.ssz_snappy diff --git a/cmd/erigon-cl/forkchoice/test_data/attestation_0xfb924d35b2888d9cd70e6879c1609e6cad7ea3b028a501967747d96e49068cb6.ssz_snappy b/cl/phase1/forkchoice/test_data/attestation_0xfb924d35b2888d9cd70e6879c1609e6cad7ea3b028a501967747d96e49068cb6.ssz_snappy similarity index 100% rename from cmd/erigon-cl/forkchoice/test_data/attestation_0xfb924d35b2888d9cd70e6879c1609e6cad7ea3b028a501967747d96e49068cb6.ssz_snappy rename to cl/phase1/forkchoice/test_data/attestation_0xfb924d35b2888d9cd70e6879c1609e6cad7ea3b028a501967747d96e49068cb6.ssz_snappy diff --git a/cmd/erigon-cl/forkchoice/test_data/block_0x3af8b5b42ca135c75b32abb32b3d71badb73695d3dc638bacfb6c8b7bcbee1a9.ssz_snappy b/cl/phase1/forkchoice/test_data/block_0x3af8b5b42ca135c75b32abb32b3d71badb73695d3dc638bacfb6c8b7bcbee1a9.ssz_snappy similarity index 100% rename from cmd/erigon-cl/forkchoice/test_data/block_0x3af8b5b42ca135c75b32abb32b3d71badb73695d3dc638bacfb6c8b7bcbee1a9.ssz_snappy rename to cl/phase1/forkchoice/test_data/block_0x3af8b5b42ca135c75b32abb32b3d71badb73695d3dc638bacfb6c8b7bcbee1a9.ssz_snappy diff --git a/cmd/erigon-cl/forkchoice/test_data/block_0xc2788d6005ee2b92c3df2eff0aeab0374d155fa8ca1f874df305fa376ce334cf.ssz_snappy b/cl/phase1/forkchoice/test_data/block_0xc2788d6005ee2b92c3df2eff0aeab0374d155fa8ca1f874df305fa376ce334cf.ssz_snappy similarity index 100% rename from cmd/erigon-cl/forkchoice/test_data/block_0xc2788d6005ee2b92c3df2eff0aeab0374d155fa8ca1f874df305fa376ce334cf.ssz_snappy rename to cl/phase1/forkchoice/test_data/block_0xc2788d6005ee2b92c3df2eff0aeab0374d155fa8ca1f874df305fa376ce334cf.ssz_snappy diff --git a/cmd/erigon-cl/forkchoice/test_data/block_0xd4503d46e43df56de4e19acb0f93b3b52087e422aace49a7c3816cf59bafb0ad.ssz_snappy b/cl/phase1/forkchoice/test_data/block_0xd4503d46e43df56de4e19acb0f93b3b52087e422aace49a7c3816cf59bafb0ad.ssz_snappy similarity index 100% rename from cmd/erigon-cl/forkchoice/test_data/block_0xd4503d46e43df56de4e19acb0f93b3b52087e422aace49a7c3816cf59bafb0ad.ssz_snappy rename to cl/phase1/forkchoice/test_data/block_0xd4503d46e43df56de4e19acb0f93b3b52087e422aace49a7c3816cf59bafb0ad.ssz_snappy diff --git a/cmd/erigon-cl/forkchoice/utils.go b/cl/phase1/forkchoice/utils.go similarity index 97% rename from cmd/erigon-cl/forkchoice/utils.go rename to cl/phase1/forkchoice/utils.go index 682e26808..caac53311 100644 --- a/cmd/erigon-cl/forkchoice/utils.go +++ b/cl/phase1/forkchoice/utils.go @@ -2,11 +2,11 @@ package forkchoice import ( "fmt" + "github.com/ledgerwatch/erigon/cl/phase1/core/state" + "github.com/ledgerwatch/erigon/cl/phase1/core/transition" libcommon "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon/cl/cltypes" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/transition" "github.com/ledgerwatch/log/v3" ) diff --git a/cmd/erigon-cl/main.go b/cl/phase1/main.go similarity index 83% rename from cmd/erigon-cl/main.go rename to cl/phase1/main.go index b4051bc86..7d0828a5c 100644 --- a/cmd/erigon-cl/main.go +++ b/cl/phase1/main.go @@ -4,6 +4,13 @@ import ( "context" "errors" "fmt" + "github.com/ledgerwatch/erigon/cl/phase1/core" + rawdb2 "github.com/ledgerwatch/erigon/cl/phase1/core/rawdb" + "github.com/ledgerwatch/erigon/cl/phase1/core/state" + "github.com/ledgerwatch/erigon/cl/phase1/execution_client" + "github.com/ledgerwatch/erigon/cl/phase1/forkchoice" + network2 "github.com/ledgerwatch/erigon/cl/phase1/network" + stages2 "github.com/ledgerwatch/erigon/cl/phase1/stages" "os" sentinelrpc "github.com/ledgerwatch/erigon-lib/gointerfaces/sentinel" @@ -14,13 +21,6 @@ import ( "github.com/ledgerwatch/erigon/cl/cltypes" "github.com/ledgerwatch/erigon/cl/fork" "github.com/ledgerwatch/erigon/cl/rpc" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/rawdb" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/execution_client" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/forkchoice" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/network" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/stages" lcCli "github.com/ledgerwatch/erigon/cmd/sentinel/cli" "github.com/ledgerwatch/erigon/cmd/sentinel/cli/flags" @@ -80,7 +80,7 @@ func runConsensusLayerNode(cliCtx *cli.Context) error { return err } // Execute from genesis to whatever we have. - return stages.SpawnStageBeaconState(stages.StageBeaconState(db, cfg.BeaconCfg, state, executionClient), nil, ctx) + return stages2.SpawnStageBeaconState(stages2.StageBeaconState(db, cfg.BeaconCfg, state, executionClient), nil, ctx) } // Fetch the checkpoint state. @@ -102,16 +102,16 @@ func runConsensusLayerNode(cliCtx *cli.Context) error { genesisCfg := cfg.GenesisCfg beaconConfig := cfg.BeaconCfg beaconRpc := rpc.NewBeaconRpcP2P(ctx, s, beaconConfig, genesisCfg) - downloader := network.NewForwardBeaconDownloader(ctx, beaconRpc) - bdownloader := network.NewBackwardBeaconDownloader(ctx, beaconRpc) + downloader := network2.NewForwardBeaconDownloader(ctx, beaconRpc) + bdownloader := network2.NewBackwardBeaconDownloader(ctx, beaconRpc) forkChoice, err := forkchoice.NewForkChoiceStore(cpState, nil, true) if err != nil { log.Error("Could not start forkchoice service", "err", err) return nil } - gossipManager := network.NewGossipReceiver(ctx, s, forkChoice, beaconConfig, genesisCfg) - stageloop, err := stages.NewConsensusStagedSync(ctx, db, downloader, bdownloader, genesisCfg, beaconConfig, cpState, + gossipManager := network2.NewGossipReceiver(ctx, s, forkChoice, beaconConfig, genesisCfg) + stageloop, err := stages2.NewConsensusStagedSync(ctx, db, downloader, bdownloader, genesisCfg, beaconConfig, cpState, tmpdir, executionClient, cfg.BeaconDataCfg, gossipManager, forkChoice, logger) if err != nil { return err @@ -171,7 +171,7 @@ func getCheckpointState(ctx context.Context, db kv.RwDB, beaconConfig *clparams. } defer tx.Rollback() - if err := rawdb.WriteBeaconState(tx, state); err != nil { + if err := rawdb2.WriteBeaconState(tx, state); err != nil { log.Error("[DB] Failed", "reason", err) return nil, err } @@ -179,7 +179,7 @@ func getCheckpointState(ctx context.Context, db kv.RwDB, beaconConfig *clparams. return state, tx.Commit() } -func checkAndStoreBeaconDataConfigWithDB(ctx context.Context, db kv.RwDB, provided *rawdb.BeaconDataConfig) error { +func checkAndStoreBeaconDataConfigWithDB(ctx context.Context, db kv.RwDB, provided *rawdb2.BeaconDataConfig) error { tx, err := db.BeginRw(ctx) if err != nil { log.Error("[DB] Failed", "reason", err) @@ -189,7 +189,7 @@ func checkAndStoreBeaconDataConfigWithDB(ctx context.Context, db kv.RwDB, provid if provided == nil { return errors.New("no valid beacon data config found") } - stored, err := rawdb.ReadBeaconDataConfig(tx) + stored, err := rawdb2.ReadBeaconDataConfig(tx) if err != nil { return err } @@ -198,10 +198,10 @@ func checkAndStoreBeaconDataConfigWithDB(ctx context.Context, db kv.RwDB, provid return err } } - return rawdb.WriteBeaconDataConfig(tx, provided) + return rawdb2.WriteBeaconDataConfig(tx, provided) } -func checkBeaconDataConfig(provided *rawdb.BeaconDataConfig, stored *rawdb.BeaconDataConfig) error { +func checkBeaconDataConfig(provided *rawdb2.BeaconDataConfig, stored *rawdb2.BeaconDataConfig) error { if provided.BackFillingAmount != stored.BackFillingAmount { return fmt.Errorf("mismatching backfilling amount, provided %d, stored %d", provided.BackFillingAmount, stored.BackFillingAmount) } diff --git a/cmd/erigon-cl/network/backward_beacon_downloader.go b/cl/phase1/network/backward_beacon_downloader.go similarity index 100% rename from cmd/erigon-cl/network/backward_beacon_downloader.go rename to cl/phase1/network/backward_beacon_downloader.go diff --git a/cmd/erigon-cl/network/beacon_downloader.go b/cl/phase1/network/beacon_downloader.go similarity index 100% rename from cmd/erigon-cl/network/beacon_downloader.go rename to cl/phase1/network/beacon_downloader.go diff --git a/cmd/erigon-cl/network/gossip_manager.go b/cl/phase1/network/gossip_manager.go similarity index 99% rename from cmd/erigon-cl/network/gossip_manager.go rename to cl/phase1/network/gossip_manager.go index 2c51f6794..db83c9e5f 100644 --- a/cmd/erigon-cl/network/gossip_manager.go +++ b/cl/phase1/network/gossip_manager.go @@ -2,6 +2,7 @@ package network import ( "context" + "github.com/ledgerwatch/erigon/cl/phase1/forkchoice" "runtime" libcommon "github.com/ledgerwatch/erigon-lib/common" @@ -11,7 +12,6 @@ import ( "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/cltypes" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/forkchoice" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/log/v3" ) diff --git a/cmd/erigon-cl/stages/stage_fork_choice.go b/cl/phase1/stages/stage_fork_choice.go similarity index 92% rename from cmd/erigon-cl/stages/stage_fork_choice.go rename to cl/phase1/stages/stage_fork_choice.go index 4040d298c..933358c06 100644 --- a/cmd/erigon-cl/stages/stage_fork_choice.go +++ b/cl/phase1/stages/stage_fork_choice.go @@ -2,6 +2,10 @@ package stages import ( "context" + "github.com/ledgerwatch/erigon/cl/phase1/core/state" + "github.com/ledgerwatch/erigon/cl/phase1/execution_client" + "github.com/ledgerwatch/erigon/cl/phase1/forkchoice" + network2 "github.com/ledgerwatch/erigon/cl/phase1/network" "runtime" "time" @@ -13,28 +17,24 @@ import ( "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/cltypes" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/execution_client" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/forkchoice" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/network" "github.com/ledgerwatch/erigon/eth/stagedsync" ) type StageForkChoiceCfg struct { db kv.RwDB - downloader *network.ForwardBeaconDownloader + downloader *network2.ForwardBeaconDownloader genesisCfg *clparams.GenesisConfig beaconCfg *clparams.BeaconChainConfig executionClient *execution_client.ExecutionClient state *state.BeaconState - gossipManager *network.GossipManager + gossipManager *network2.GossipManager forkChoice *forkchoice.ForkChoiceStore } const minPeersForDownload = 3 -func StageForkChoice(db kv.RwDB, downloader *network.ForwardBeaconDownloader, genesisCfg *clparams.GenesisConfig, - beaconCfg *clparams.BeaconChainConfig, state *state.BeaconState, executionClient *execution_client.ExecutionClient, gossipManager *network.GossipManager, forkChoice *forkchoice.ForkChoiceStore) StageForkChoiceCfg { +func StageForkChoice(db kv.RwDB, downloader *network2.ForwardBeaconDownloader, genesisCfg *clparams.GenesisConfig, + beaconCfg *clparams.BeaconChainConfig, state *state.BeaconState, executionClient *execution_client.ExecutionClient, gossipManager *network2.GossipManager, forkChoice *forkchoice.ForkChoiceStore) StageForkChoiceCfg { return StageForkChoiceCfg{ db: db, downloader: downloader, diff --git a/cmd/erigon-cl/stages/stage_history_reconstruction.go b/cl/phase1/stages/stage_history_reconstruction.go similarity index 89% rename from cmd/erigon-cl/stages/stage_history_reconstruction.go rename to cl/phase1/stages/stage_history_reconstruction.go index 370239c7e..803dfa5db 100644 --- a/cmd/erigon-cl/stages/stage_history_reconstruction.go +++ b/cl/phase1/stages/stage_history_reconstruction.go @@ -3,16 +3,16 @@ package stages import ( "context" "fmt" + rawdb2 "github.com/ledgerwatch/erigon/cl/phase1/core/rawdb" + "github.com/ledgerwatch/erigon/cl/phase1/core/state" + execution_client2 "github.com/ledgerwatch/erigon/cl/phase1/execution_client" + "github.com/ledgerwatch/erigon/cl/phase1/network" "time" "github.com/ledgerwatch/erigon-lib/etl" "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/cltypes" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/rawdb" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/execution_client" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/network" "github.com/ledgerwatch/erigon/eth/stagedsync" "github.com/ledgerwatch/log/v3" ) @@ -23,14 +23,14 @@ type StageHistoryReconstructionCfg struct { beaconCfg *clparams.BeaconChainConfig downloader *network.BackwardBeaconDownloader state *state.BeaconState - executionClient *execution_client.ExecutionClient - beaconDBCfg *rawdb.BeaconDataConfig + executionClient *execution_client2.ExecutionClient + beaconDBCfg *rawdb2.BeaconDataConfig tmpdir string } const logIntervalTime = 30 * time.Second -func StageHistoryReconstruction(db kv.RwDB, downloader *network.BackwardBeaconDownloader, genesisCfg *clparams.GenesisConfig, beaconCfg *clparams.BeaconChainConfig, beaconDBCfg *rawdb.BeaconDataConfig, state *state.BeaconState, tmpdir string, executionClient *execution_client.ExecutionClient) StageHistoryReconstructionCfg { +func StageHistoryReconstruction(db kv.RwDB, downloader *network.BackwardBeaconDownloader, genesisCfg *clparams.GenesisConfig, beaconCfg *clparams.BeaconChainConfig, beaconDBCfg *rawdb2.BeaconDataConfig, state *state.BeaconState, tmpdir string, executionClient *execution_client2.ExecutionClient) StageHistoryReconstructionCfg { return StageHistoryReconstructionCfg{ db: db, genesisCfg: genesisCfg, @@ -99,7 +99,7 @@ func SpawnStageHistoryReconstruction(cfg StageHistoryReconstructionCfg, s *stage if err != nil { return false, err } - key := append(rawdb.EncodeNumber(slot), blockRoot[:]...) + key := append(rawdb2.EncodeNumber(slot), blockRoot[:]...) // Collect attestations encodedAttestations := cltypes.EncodeAttestationsForStorage(blk.Block.Body.Attestations) if err := attestationsCollector.Collect(key, encodedAttestations); err != nil { @@ -110,7 +110,7 @@ func SpawnStageHistoryReconstruction(cfg StageHistoryReconstructionCfg, s *stage if err != nil { return false, err } - slotBytes := rawdb.EncodeNumber(slot) + slotBytes := rawdb2.EncodeNumber(slot) if err := beaconBlocksCollector.Collect(key, encodedBeaconBlock); err != nil { return false, err } @@ -139,7 +139,7 @@ func SpawnStageHistoryReconstruction(cfg StageHistoryReconstructionCfg, s *stage if err != nil { return false, err } - if err := executionPayloadsCollector.Collect(rawdb.EncodeNumber(slot), encodedPayload); err != nil { + if err := executionPayloadsCollector.Collect(rawdb2.EncodeNumber(slot), encodedPayload); err != nil { return false, err } } @@ -193,7 +193,7 @@ func SpawnStageHistoryReconstruction(cfg StageHistoryReconstructionCfg, s *stage if err := finalizationCollector.Load(tx, kv.FinalizedBlockRoots, etl.IdentityLoadFunc, etl.TransformArgs{Quit: ctx.Done()}); err != nil { return err } - executionPayloadInsertionBatch := execution_client.NewInsertBatch(cfg.executionClient) + executionPayloadInsertionBatch := execution_client2.NewInsertBatch(cfg.executionClient) // Send in ordered manner EL blocks to Execution Layer if err := executionPayloadsCollector.Load(tx, kv.BeaconBlocks, func(k, v []byte, table etl.CurrentTableReader, next etl.LoadNextFunc) error { payload := &cltypes.Eth1Block{} diff --git a/cmd/erigon-cl/stages/stages.go b/cl/phase1/stages/stages.go similarity index 87% rename from cmd/erigon-cl/stages/stages.go rename to cl/phase1/stages/stages.go index 6f7d29df2..98aa4c298 100644 --- a/cmd/erigon-cl/stages/stages.go +++ b/cl/phase1/stages/stages.go @@ -2,14 +2,14 @@ package stages import ( "context" + "github.com/ledgerwatch/erigon/cl/phase1/core/rawdb" + "github.com/ledgerwatch/erigon/cl/phase1/core/state" + "github.com/ledgerwatch/erigon/cl/phase1/execution_client" + "github.com/ledgerwatch/erigon/cl/phase1/forkchoice" + network2 "github.com/ledgerwatch/erigon/cl/phase1/network" "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/cl/clparams" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/rawdb" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/execution_client" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/forkchoice" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/network" "github.com/ledgerwatch/erigon/eth/stagedsync" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" "github.com/ledgerwatch/log/v3" @@ -63,15 +63,15 @@ var ConsensusPruneOrder = stagedsync.PruneOrder{ func NewConsensusStagedSync(ctx context.Context, db kv.RwDB, - forwardDownloader *network.ForwardBeaconDownloader, - backwardDownloader *network.BackwardBeaconDownloader, + forwardDownloader *network2.ForwardBeaconDownloader, + backwardDownloader *network2.BackwardBeaconDownloader, genesisCfg *clparams.GenesisConfig, beaconCfg *clparams.BeaconChainConfig, state *state.BeaconState, tmpdir string, executionClient *execution_client.ExecutionClient, beaconDBCfg *rawdb.BeaconDataConfig, - gossipManager *network.GossipManager, + gossipManager *network2.GossipManager, forkChoice *forkchoice.ForkChoiceStore, logger log.Logger, ) (*stagedsync.Sync, error) { diff --git a/cmd/erigon-cl/stages/stages_beacon_state.go b/cl/phase1/stages/stages_beacon_state.go similarity index 84% rename from cmd/erigon-cl/stages/stages_beacon_state.go rename to cl/phase1/stages/stages_beacon_state.go index 91142f8ef..4fbf93eb5 100644 --- a/cmd/erigon-cl/stages/stages_beacon_state.go +++ b/cl/phase1/stages/stages_beacon_state.go @@ -2,15 +2,15 @@ package stages import ( "context" + "github.com/ledgerwatch/erigon/cl/phase1/core/rawdb" + state2 "github.com/ledgerwatch/erigon/cl/phase1/core/state" + "github.com/ledgerwatch/erigon/cl/phase1/core/transition" + "github.com/ledgerwatch/erigon/cl/phase1/execution_client" libcommon "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/rawdb" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/transition" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/execution_client" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" "github.com/ledgerwatch/log/v3" ) @@ -18,13 +18,13 @@ import ( type StageBeaconStateCfg struct { db kv.RwDB beaconCfg *clparams.BeaconChainConfig - state *state.BeaconState + state *state2.BeaconState executionClient *execution_client.ExecutionClient enabled bool } func StageBeaconState(db kv.RwDB, - beaconCfg *clparams.BeaconChainConfig, state *state.BeaconState, executionClient *execution_client.ExecutionClient) StageBeaconStateCfg { + beaconCfg *clparams.BeaconChainConfig, state *state2.BeaconState, executionClient *execution_client.ExecutionClient) StageBeaconStateCfg { return StageBeaconStateCfg{ db: db, beaconCfg: beaconCfg, @@ -78,7 +78,7 @@ func SpawnStageBeaconState(cfg StageBeaconStateCfg, tx kv.RwTx, ctx context.Cont } } // validate fully only in current epoch. - fullValidate := utils.GetCurrentEpoch(cfg.state.GenesisTime(), cfg.beaconCfg.SecondsPerSlot, cfg.beaconCfg.SlotsPerEpoch) == state.Epoch(cfg.state.BeaconState) + fullValidate := utils.GetCurrentEpoch(cfg.state.GenesisTime(), cfg.beaconCfg.SecondsPerSlot, cfg.beaconCfg.SlotsPerEpoch) == state2.Epoch(cfg.state.BeaconState) if err := transition.TransitionState(cfg.state, block, fullValidate); err != nil { log.Info("Found epoch, so stopping now...", "count", slot-(fromSlot+1), "slot", slot) return err diff --git a/cmd/ef-tests-cl/.gitignore b/cl/spectest/.gitignore similarity index 50% rename from cmd/ef-tests-cl/.gitignore rename to cl/spectest/.gitignore index 5eeb48d94..8d79c411c 100644 --- a/cmd/ef-tests-cl/.gitignore +++ b/cl/spectest/.gitignore @@ -1,6 +1,6 @@ tests -./eftests -./consensus-spec-tests +eftests +consensus-spec-tests junit.xml test_report.html diff --git a/cmd/ef-tests-cl/Makefile b/cl/spectest/Makefile similarity index 83% rename from cmd/ef-tests-cl/Makefile rename to cl/spectest/Makefile index 3f6f9e7fe..596c57d05 100644 --- a/cmd/ef-tests-cl/Makefile +++ b/cl/spectest/Makefile @@ -12,8 +12,8 @@ clean: rm -rf junit.xml rm -rf test_report.html -example: tests +example: ../../cmd/ef-tests-cl/tests go test -tags=spectest -v -run=/mainnet/altair/sanity -run: tests +run: ../../cmd/ef-tests-cl/tests go test -v diff --git a/cmd/ef-tests-cl/README.md b/cl/spectest/README.md similarity index 100% rename from cmd/ef-tests-cl/README.md rename to cl/spectest/README.md diff --git a/cmd/ef-tests-cl/consensus_tests/appendix.go b/cl/spectest/consensus_tests/appendix.go similarity index 98% rename from cmd/ef-tests-cl/consensus_tests/appendix.go rename to cl/spectest/consensus_tests/appendix.go index 3a9f6ff06..2f54926f7 100644 --- a/cmd/ef-tests-cl/consensus_tests/appendix.go +++ b/cl/spectest/consensus_tests/appendix.go @@ -3,8 +3,8 @@ package consensus_tests import ( "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/cltypes" - "github.com/ledgerwatch/erigon/cmd/ef-tests-cl/spectest" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" + "github.com/ledgerwatch/erigon/cl/phase1/core/state" + "github.com/ledgerwatch/erigon/spectest" ) var TestFormats = spectest.Appendix{} diff --git a/cmd/ef-tests-cl/consensus_tests/bls.go b/cl/spectest/consensus_tests/bls.go similarity index 91% rename from cmd/ef-tests-cl/consensus_tests/bls.go rename to cl/spectest/consensus_tests/bls.go index 991b90e75..59a8da3fe 100644 --- a/cmd/ef-tests-cl/consensus_tests/bls.go +++ b/cl/spectest/consensus_tests/bls.go @@ -4,7 +4,7 @@ import ( "io/fs" "testing" - "github.com/ledgerwatch/erigon/cmd/ef-tests-cl/spectest" + "github.com/ledgerwatch/erigon/spectest" ) type BlsAggregateVerify struct { diff --git a/cmd/ef-tests-cl/consensus_tests/epoch_processing.go b/cl/spectest/consensus_tests/epoch_processing.go similarity index 74% rename from cmd/ef-tests-cl/consensus_tests/epoch_processing.go rename to cl/spectest/consensus_tests/epoch_processing.go index 65ab66d27..ebebadd65 100644 --- a/cmd/ef-tests-cl/consensus_tests/epoch_processing.go +++ b/cl/spectest/consensus_tests/epoch_processing.go @@ -1,13 +1,13 @@ package consensus_tests import ( + "github.com/ledgerwatch/erigon/cl/phase1/core/state" + transition2 "github.com/ledgerwatch/erigon/cl/phase1/core/transition" "io/fs" "os" "testing" - "github.com/ledgerwatch/erigon/cmd/ef-tests-cl/spectest" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/transition" + "github.com/ledgerwatch/erigon/spectest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -51,58 +51,58 @@ func (b *EpochProcessing) Run(t *testing.T, root fs.FS, c spectest.TestCase) (er } var effectiveBalancesUpdateTest = NewEpochProcessing(func(s *state.BeaconState) error { - return transition.ProcessEffectiveBalanceUpdates(s) + return transition2.ProcessEffectiveBalanceUpdates(s) }) var eth1DataResetTest = NewEpochProcessing(func(s *state.BeaconState) error { - transition.ProcessEth1DataReset(s) + transition2.ProcessEth1DataReset(s) return nil }) var historicalRootsUpdateTest = NewEpochProcessing(func(s *state.BeaconState) error { - transition.ProcessHistoricalRootsUpdate(s) + transition2.ProcessHistoricalRootsUpdate(s) return nil }) var inactivityUpdateTest = NewEpochProcessing(func(s *state.BeaconState) error { - return transition.ProcessInactivityScores(s) + return transition2.ProcessInactivityScores(s) }) var justificationFinalizationTest = NewEpochProcessing(func(s *state.BeaconState) error { - return transition.ProcessJustificationBitsAndFinality(s) + return transition2.ProcessJustificationBitsAndFinality(s) }) var participationFlagUpdatesTest = NewEpochProcessing(func(s *state.BeaconState) error { - transition.ProcessParticipationFlagUpdates(s) + transition2.ProcessParticipationFlagUpdates(s) return nil }) var participationRecordUpdatesTest = NewEpochProcessing(func(s *state.BeaconState) error { - return transition.ProcessParticipationRecordUpdates(s) + return transition2.ProcessParticipationRecordUpdates(s) }) var randaoMixesTest = NewEpochProcessing(func(s *state.BeaconState) error { - transition.ProcessRandaoMixesReset(s) + transition2.ProcessRandaoMixesReset(s) return nil }) var registryUpdatesTest = NewEpochProcessing(func(s *state.BeaconState) error { - return transition.ProcessRegistryUpdates(s) + return transition2.ProcessRegistryUpdates(s) }) var rewardsAndPenaltiesTest = NewEpochProcessing(func(s *state.BeaconState) error { - return transition.ProcessRewardsAndPenalties(s) + return transition2.ProcessRewardsAndPenalties(s) }) var slashingsTest = NewEpochProcessing(func(s *state.BeaconState) error { - return transition.ProcessSlashings(s) + return transition2.ProcessSlashings(s) }) var slashingsResetTest = NewEpochProcessing(func(s *state.BeaconState) error { - transition.ProcessSlashingsReset(s) + transition2.ProcessSlashingsReset(s) return nil }) var recordsResetTest = NewEpochProcessing(func(s *state.BeaconState) error { - transition.ProcessParticipationRecordUpdates(s) + transition2.ProcessParticipationRecordUpdates(s) return nil }) diff --git a/cmd/ef-tests-cl/consensus_tests/finality.go b/cl/spectest/consensus_tests/finality.go similarity index 89% rename from cmd/ef-tests-cl/consensus_tests/finality.go rename to cl/spectest/consensus_tests/finality.go index 72c521855..eb7ed1b1a 100644 --- a/cmd/ef-tests-cl/consensus_tests/finality.go +++ b/cl/spectest/consensus_tests/finality.go @@ -2,11 +2,11 @@ package consensus_tests import ( "fmt" + "github.com/ledgerwatch/erigon/cl/phase1/core/transition" "io/fs" "testing" - "github.com/ledgerwatch/erigon/cmd/ef-tests-cl/spectest" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/transition" + "github.com/ledgerwatch/erigon/spectest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/cmd/ef-tests-cl/consensus_tests/fork_choice.go b/cl/spectest/consensus_tests/fork_choice.go similarity index 97% rename from cmd/ef-tests-cl/consensus_tests/fork_choice.go rename to cl/spectest/consensus_tests/fork_choice.go index 25ddefc90..1692ea1f3 100644 --- a/cmd/ef-tests-cl/consensus_tests/fork_choice.go +++ b/cl/spectest/consensus_tests/fork_choice.go @@ -2,14 +2,14 @@ package consensus_tests import ( "fmt" + "github.com/ledgerwatch/erigon/cl/phase1/core/state" + "github.com/ledgerwatch/erigon/cl/phase1/forkchoice" "io/fs" "testing" "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon/cl/cltypes" - "github.com/ledgerwatch/erigon/cmd/ef-tests-cl/spectest" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/forkchoice" + "github.com/ledgerwatch/erigon/spectest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/cmd/ef-tests-cl/consensus_tests/forks.go b/cl/spectest/consensus_tests/forks.go similarity index 95% rename from cmd/ef-tests-cl/consensus_tests/forks.go rename to cl/spectest/consensus_tests/forks.go index b29b2f3dc..796673f5b 100644 --- a/cmd/ef-tests-cl/consensus_tests/forks.go +++ b/cl/spectest/consensus_tests/forks.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/ledgerwatch/erigon/cl/clparams" - "github.com/ledgerwatch/erigon/cmd/ef-tests-cl/spectest" + "github.com/ledgerwatch/erigon/spectest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/cmd/ef-tests-cl/consensus_tests/operations.go b/cl/spectest/consensus_tests/operations.go similarity index 90% rename from cmd/ef-tests-cl/consensus_tests/operations.go rename to cl/spectest/consensus_tests/operations.go index bedf7ead1..dc5f66d53 100644 --- a/cmd/ef-tests-cl/consensus_tests/operations.go +++ b/cl/spectest/consensus_tests/operations.go @@ -2,13 +2,13 @@ package consensus_tests import ( "fmt" + transition2 "github.com/ledgerwatch/erigon/cl/phase1/core/transition" "io/fs" "os" "testing" "github.com/ledgerwatch/erigon/cl/cltypes" - "github.com/ledgerwatch/erigon/cmd/ef-tests-cl/spectest" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/transition" + "github.com/ledgerwatch/erigon/spectest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -37,7 +37,7 @@ func operationAttestationHandler(t *testing.T, root fs.FS, c spectest.TestCase) if err := spectest.ReadSszOld(root, att, c.Version(), attestationFileName); err != nil { return err } - if err := transition.ProcessAttestations(preState, []*cltypes.Attestation{att}, true); err != nil { + if err := transition2.ProcessAttestations(preState, []*cltypes.Attestation{att}, true); err != nil { if expectedError { return nil } @@ -67,7 +67,7 @@ func operationAttesterSlashingHandler(t *testing.T, root fs.FS, c spectest.TestC if err := spectest.ReadSszOld(root, att, c.Version(), attesterSlashingFileName); err != nil { return err } - if err := transition.ProcessAttesterSlashing(preState, att); err != nil { + if err := transition2.ProcessAttesterSlashing(preState, att); err != nil { if expectedError { return nil } @@ -97,7 +97,7 @@ func operationProposerSlashingHandler(t *testing.T, root fs.FS, c spectest.TestC if err := spectest.ReadSszOld(root, att, c.Version(), proposerSlashingFileName); err != nil { return err } - if err := transition.ProcessProposerSlashing(preState, att); err != nil { + if err := transition2.ProcessProposerSlashing(preState, att); err != nil { if expectedError { return nil } @@ -127,7 +127,7 @@ func operationBlockHeaderHandler(t *testing.T, root fs.FS, c spectest.TestCase) if err := spectest.ReadSszOld(root, block, c.Version(), blockFileName); err != nil { return err } - if err := transition.ProcessBlockHeader(preState, block, true); err != nil { + if err := transition2.ProcessBlockHeader(preState, block, true); err != nil { if expectedError { return nil } @@ -157,7 +157,7 @@ func operationDepositHandler(t *testing.T, root fs.FS, c spectest.TestCase) erro if err := spectest.ReadSszOld(root, deposit, c.Version(), depositFileName); err != nil { return err } - if err := transition.ProcessDeposit(preState, deposit, true); err != nil { + if err := transition2.ProcessDeposit(preState, deposit, true); err != nil { if expectedError { return nil } @@ -187,7 +187,7 @@ func operationSyncAggregateHandler(t *testing.T, root fs.FS, c spectest.TestCase if err := spectest.ReadSszOld(root, agg, c.Version(), syncAggregateFileName); err != nil { return err } - if err := transition.ProcessSyncAggregate(preState, agg, true); err != nil { + if err := transition2.ProcessSyncAggregate(preState, agg, true); err != nil { if expectedError { return nil } @@ -217,7 +217,7 @@ func operationVoluntaryExitHandler(t *testing.T, root fs.FS, c spectest.TestCase if err := spectest.ReadSszOld(root, vo, c.Version(), voluntaryExitFileName); err != nil { return err } - if err := transition.ProcessVoluntaryExit(preState, vo, true); err != nil { + if err := transition2.ProcessVoluntaryExit(preState, vo, true); err != nil { if expectedError { return nil } @@ -247,7 +247,7 @@ func operationWithdrawalHandler(t *testing.T, root fs.FS, c spectest.TestCase) e if err := spectest.ReadSszOld(root, executionPayload, c.Version(), executionPayloadFileName); err != nil { return err } - if err := transition.ProcessWithdrawals(preState, executionPayload.Withdrawals, true); err != nil { + if err := transition2.ProcessWithdrawals(preState, executionPayload.Withdrawals, true); err != nil { if expectedError { return nil } @@ -277,7 +277,7 @@ func operationSignedBlsChangeHandler(t *testing.T, root fs.FS, c spectest.TestCa if err := spectest.ReadSszOld(root, change, c.Version(), addressChangeFileName); err != nil { return err } - if err := transition.ProcessBlsToExecutionChange(preState, change, true); err != nil { + if err := transition2.ProcessBlsToExecutionChange(preState, change, true); err != nil { if expectedError { return nil } diff --git a/cmd/ef-tests-cl/consensus_tests/rewards.go b/cl/spectest/consensus_tests/rewards.go similarity index 95% rename from cmd/ef-tests-cl/consensus_tests/rewards.go rename to cl/spectest/consensus_tests/rewards.go index a2ebf13be..ef49b5979 100644 --- a/cmd/ef-tests-cl/consensus_tests/rewards.go +++ b/cl/spectest/consensus_tests/rewards.go @@ -6,7 +6,7 @@ import ( "github.com/ledgerwatch/erigon/cl/cltypes" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/ef-tests-cl/spectest" + "github.com/ledgerwatch/erigon/spectest" ) type RewardsCore struct { diff --git a/cmd/ef-tests-cl/consensus_tests/sanity.go b/cl/spectest/consensus_tests/sanity.go similarity index 94% rename from cmd/ef-tests-cl/consensus_tests/sanity.go rename to cl/spectest/consensus_tests/sanity.go index 067a49248..8e55035a7 100644 --- a/cmd/ef-tests-cl/consensus_tests/sanity.go +++ b/cl/spectest/consensus_tests/sanity.go @@ -1,13 +1,13 @@ package consensus_tests import ( + "github.com/ledgerwatch/erigon/cl/phase1/core/transition" "io/fs" "os" "testing" "github.com/ledgerwatch/erigon/cl/cltypes" - "github.com/ledgerwatch/erigon/cmd/ef-tests-cl/spectest" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/transition" + "github.com/ledgerwatch/erigon/spectest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/cmd/ef-tests-cl/consensus_tests/shuffling.go b/cl/spectest/consensus_tests/shuffling.go similarity index 84% rename from cmd/ef-tests-cl/consensus_tests/shuffling.go rename to cl/spectest/consensus_tests/shuffling.go index 8b929c3c8..25f0420f4 100644 --- a/cmd/ef-tests-cl/consensus_tests/shuffling.go +++ b/cl/spectest/consensus_tests/shuffling.go @@ -1,14 +1,14 @@ package consensus_tests import ( + "github.com/ledgerwatch/erigon/cl/phase1/core/state" + "github.com/ledgerwatch/erigon/cl/phase1/core/state/shuffling" "io/fs" "testing" "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/ef-tests-cl/spectest" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state/shuffling" + "github.com/ledgerwatch/erigon/spectest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/cmd/ef-tests-cl/consensus_tests/ssz_static.go b/cl/spectest/consensus_tests/ssz_static.go similarity index 93% rename from cmd/ef-tests-cl/consensus_tests/ssz_static.go rename to cl/spectest/consensus_tests/ssz_static.go index 50e7e000c..2f06e24cc 100644 --- a/cmd/ef-tests-cl/consensus_tests/ssz_static.go +++ b/cl/spectest/consensus_tests/ssz_static.go @@ -1,6 +1,7 @@ package consensus_tests import ( + "github.com/ledgerwatch/erigon/cl/phase1/core/state" "io/fs" "testing" @@ -9,8 +10,7 @@ import ( "github.com/ledgerwatch/erigon-lib/types/ssz" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/ef-tests-cl/spectest" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" + "github.com/ledgerwatch/erigon/spectest" "github.com/stretchr/testify/require" "gopkg.in/yaml.v2" ) diff --git a/cmd/ef-tests-cl/consensus_tests/transition.go b/cl/spectest/consensus_tests/transition.go similarity index 94% rename from cmd/ef-tests-cl/consensus_tests/transition.go rename to cl/spectest/consensus_tests/transition.go index 892504ece..e9c0d036a 100644 --- a/cmd/ef-tests-cl/consensus_tests/transition.go +++ b/cl/spectest/consensus_tests/transition.go @@ -2,13 +2,13 @@ package consensus_tests import ( "fmt" + "github.com/ledgerwatch/erigon/cl/phase1/core/transition" "io/fs" "testing" "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/cltypes" - "github.com/ledgerwatch/erigon/cmd/ef-tests-cl/spectest" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/transition" + "github.com/ledgerwatch/erigon/spectest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/cmd/ef-tests-cl/scripts/gen_ssz_static.sh b/cl/spectest/scripts/gen_ssz_static.sh similarity index 100% rename from cmd/ef-tests-cl/scripts/gen_ssz_static.sh rename to cl/spectest/scripts/gen_ssz_static.sh diff --git a/cmd/ef-tests-cl/tests_test.go b/cl/spectest/tests_test.go similarity index 63% rename from cmd/ef-tests-cl/tests_test.go rename to cl/spectest/tests_test.go index 3abe30415..8147068a3 100644 --- a/cmd/ef-tests-cl/tests_test.go +++ b/cl/spectest/tests_test.go @@ -2,14 +2,14 @@ // once all tests are implemented, we can allow this test in the ci build path -package main +package spectest import ( + "github.com/ledgerwatch/erigon/cl/spectest/consensus_tests" "os" "testing" - "github.com/ledgerwatch/erigon/cmd/ef-tests-cl/consensus_tests" - "github.com/ledgerwatch/erigon/cmd/ef-tests-cl/spectest" + "github.com/ledgerwatch/erigon/spectest" ) func Test(t *testing.T) { diff --git a/cmd/caplin-phase1/caplin1/run.go b/cmd/caplin-phase1/caplin1/run.go index f85cf38e8..86f83aee8 100644 --- a/cmd/caplin-phase1/caplin1/run.go +++ b/cmd/caplin-phase1/caplin1/run.go @@ -2,17 +2,17 @@ package caplin1 import ( "context" + "github.com/ledgerwatch/erigon/cl/phase1/core/state" + "github.com/ledgerwatch/erigon/cl/phase1/execution_client" + "github.com/ledgerwatch/erigon/cl/phase1/forkchoice" + network2 "github.com/ledgerwatch/erigon/cl/phase1/network" + "github.com/ledgerwatch/erigon/cl/phase1/stages" "github.com/Giulio2002/bls" "github.com/ledgerwatch/erigon-lib/gointerfaces/sentinel" "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/cltypes" "github.com/ledgerwatch/erigon/cl/rpc" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/execution_client" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/forkchoice" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/network" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/stages" "github.com/ledgerwatch/log/v3" "github.com/ledgerwatch/erigon/eth/stagedsync" @@ -20,7 +20,7 @@ import ( func RunCaplinPhase1(ctx context.Context, sentinel sentinel.SentinelClient, beaconConfig *clparams.BeaconChainConfig, genesisConfig *clparams.GenesisConfig, engine execution_client.ExecutionEngine, state *state.BeaconState) error { beaconRpc := rpc.NewBeaconRpcP2P(ctx, sentinel, beaconConfig, genesisConfig) - downloader := network.NewForwardBeaconDownloader(ctx, beaconRpc) + downloader := network2.NewForwardBeaconDownloader(ctx, beaconRpc) forkChoice, err := forkchoice.NewForkChoiceStore(state, engine, true) if err != nil { @@ -35,6 +35,6 @@ func RunCaplinPhase1(ctx context.Context, sentinel sentinel.SentinelClient, beac } return true }) - gossipManager := network.NewGossipReceiver(ctx, sentinel, forkChoice, beaconConfig, genesisConfig) + gossipManager := network2.NewGossipReceiver(ctx, sentinel, forkChoice, beaconConfig, genesisConfig) return stages.SpawnStageForkChoice(stages.StageForkChoice(nil, downloader, genesisConfig, beaconConfig, state, nil, gossipManager, forkChoice), &stagedsync.StageState{ID: "Caplin"}, nil, ctx) } diff --git a/cmd/caplin-phase1/main.go b/cmd/caplin-phase1/main.go index bff11cbfd..3298f8920 100644 --- a/cmd/caplin-phase1/main.go +++ b/cmd/caplin-phase1/main.go @@ -16,6 +16,8 @@ package main import ( "context" "fmt" + "github.com/ledgerwatch/erigon/cl/phase1/core" + "github.com/ledgerwatch/erigon/cl/phase1/execution_client" "os" "github.com/ledgerwatch/erigon-lib/gointerfaces/remote" @@ -26,8 +28,6 @@ import ( "github.com/ledgerwatch/erigon/cl/cltypes" "github.com/ledgerwatch/erigon/cl/fork" "github.com/ledgerwatch/erigon/cmd/caplin-phase1/caplin1" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/execution_client" lcCli "github.com/ledgerwatch/erigon/cmd/sentinel/cli" "github.com/ledgerwatch/erigon/cmd/sentinel/cli/flags" "github.com/ledgerwatch/erigon/cmd/sentinel/sentinel" diff --git a/cmd/erigon-cl/core/transition/resets.go b/cmd/erigon-cl/core/transition/resets.go deleted file mode 100644 index 5a248e38c..000000000 --- a/cmd/erigon-cl/core/transition/resets.go +++ /dev/null @@ -1,27 +0,0 @@ -package transition - -import ( - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" -) - -func ProcessEth1DataReset(s *state.BeaconState) { - nextEpoch := state.Epoch(s.BeaconState) + 1 - if nextEpoch%s.BeaconConfig().EpochsPerEth1VotingPeriod == 0 { - s.ResetEth1DataVotes() - } -} - -func ProcessSlashingsReset(s *state.BeaconState) { - s.SetSlashingSegmentAt(int(state.Epoch(s.BeaconState)+1)%int(s.BeaconConfig().EpochsPerSlashingsVector), 0) - -} - -func ProcessRandaoMixesReset(s *state.BeaconState) { - currentEpoch := state.Epoch(s.BeaconState) - nextEpoch := state.Epoch(s.BeaconState) + 1 - s.SetRandaoMixAt(int(nextEpoch%s.BeaconConfig().EpochsPerHistoricalVector), s.GetRandaoMixes(currentEpoch)) -} - -func ProcessParticipationFlagUpdates(state *state.BeaconState) { - state.ResetEpochParticipation() -} diff --git a/cmd/release/main.go b/cmd/release/main.go index 854260728..6f1296311 100644 --- a/cmd/release/main.go +++ b/cmd/release/main.go @@ -10,8 +10,6 @@ import ( "sort" "strings" "time" - - "github.com/hashicorp/go-version" ) type Binary struct { diff --git a/cmd/sentinel/cli/cliSettings.go b/cmd/sentinel/cli/cliSettings.go index c462ce0cf..5d8207166 100644 --- a/cmd/sentinel/cli/cliSettings.go +++ b/cmd/sentinel/cli/cliSettings.go @@ -2,12 +2,12 @@ package cli import ( "fmt" + "github.com/ledgerwatch/erigon/cl/phase1/core/rawdb" "github.com/ledgerwatch/erigon/cmd/utils" "github.com/urfave/cli/v2" "github.com/ledgerwatch/erigon/cl/clparams" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/rawdb" "github.com/ledgerwatch/erigon/cmd/sentinel/cli/flags" "github.com/ledgerwatch/erigon/turbo/logging" diff --git a/eth/backend.go b/eth/backend.go index b23a85e0e..7f54006ff 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -21,6 +21,8 @@ import ( "context" "errors" "fmt" + clcore "github.com/ledgerwatch/erigon/cl/phase1/core" + "github.com/ledgerwatch/erigon/cl/phase1/execution_client" "io/fs" "math/big" "net" @@ -65,8 +67,6 @@ import ( "github.com/ledgerwatch/erigon/cl/cltypes" "github.com/ledgerwatch/erigon/cl/fork" "github.com/ledgerwatch/erigon/cmd/caplin-phase1/caplin1" - clcore "github.com/ledgerwatch/erigon/cmd/erigon-cl/core" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/execution_client" "github.com/ledgerwatch/erigon/cmd/rpcdaemon/cli" "github.com/ledgerwatch/erigon/cmd/rpcdaemon/commands" "github.com/ledgerwatch/erigon/cmd/sentinel/sentinel" diff --git a/cmd/ef-tests-cl/spectest/appendix.go b/spectest/appendix.go similarity index 100% rename from cmd/ef-tests-cl/spectest/appendix.go rename to spectest/appendix.go diff --git a/cmd/ef-tests-cl/spectest/case.go b/spectest/case.go similarity index 100% rename from cmd/ef-tests-cl/spectest/case.go rename to spectest/case.go diff --git a/cmd/ef-tests-cl/spectest/consts.go b/spectest/consts.go similarity index 100% rename from cmd/ef-tests-cl/spectest/consts.go rename to spectest/consts.go diff --git a/spectest/data_faketest/tests/.gitkeep b/spectest/data_faketest/tests/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/spectest/data_faketest/tests/general/altair/bls/eth_aggregate_pubkeys/small/eth_aggregate_pubkeys_empty_list/data.yaml b/spectest/data_faketest/tests/general/altair/bls/eth_aggregate_pubkeys/small/eth_aggregate_pubkeys_empty_list/data.yaml new file mode 100644 index 000000000..b72065296 --- /dev/null +++ b/spectest/data_faketest/tests/general/altair/bls/eth_aggregate_pubkeys/small/eth_aggregate_pubkeys_empty_list/data.yaml @@ -0,0 +1,2 @@ +input: [] +output: null diff --git a/spectest/data_faketest/tests/general/altair/bls/eth_aggregate_pubkeys/small/eth_aggregate_pubkeys_infinity_pubkey/data.yaml b/spectest/data_faketest/tests/general/altair/bls/eth_aggregate_pubkeys/small/eth_aggregate_pubkeys_infinity_pubkey/data.yaml new file mode 100644 index 000000000..1706ad88a --- /dev/null +++ b/spectest/data_faketest/tests/general/altair/bls/eth_aggregate_pubkeys/small/eth_aggregate_pubkeys_infinity_pubkey/data.yaml @@ -0,0 +1,2 @@ +input: ['0xc00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'] +output: null diff --git a/spectest/data_faketest/tests/general/altair/bls/eth_aggregate_pubkeys/small/eth_aggregate_pubkeys_valid_e235e92e3a313f43/data.yaml b/spectest/data_faketest/tests/general/altair/bls/eth_aggregate_pubkeys/small/eth_aggregate_pubkeys_valid_e235e92e3a313f43/data.yaml new file mode 100644 index 000000000..85649d3a3 --- /dev/null +++ b/spectest/data_faketest/tests/general/altair/bls/eth_aggregate_pubkeys/small/eth_aggregate_pubkeys_valid_e235e92e3a313f43/data.yaml @@ -0,0 +1,2 @@ +input: ['0xb53d21a4cfd562c469cc81514d4ce5a6b577d8403d32a394dc265dd190b47fa9f829fdd7963afdf972e5e77854051f6f'] +output: '0xb53d21a4cfd562c469cc81514d4ce5a6b577d8403d32a394dc265dd190b47fa9f829fdd7963afdf972e5e77854051f6f' diff --git a/spectest/data_faketest/tests/general/altair/bls/eth_aggregate_pubkeys/small/eth_aggregate_pubkeys_valid_ea0e3cc74e1de899/data.yaml b/spectest/data_faketest/tests/general/altair/bls/eth_aggregate_pubkeys/small/eth_aggregate_pubkeys_valid_ea0e3cc74e1de899/data.yaml new file mode 100644 index 000000000..536d58f19 --- /dev/null +++ b/spectest/data_faketest/tests/general/altair/bls/eth_aggregate_pubkeys/small/eth_aggregate_pubkeys_valid_ea0e3cc74e1de899/data.yaml @@ -0,0 +1,2 @@ +input: ['0xa491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a'] +output: '0xa491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a' diff --git a/spectest/data_faketest/tests/general/altair/bls/eth_aggregate_pubkeys/small/eth_aggregate_pubkeys_valid_f15974ec693571cf/data.yaml b/spectest/data_faketest/tests/general/altair/bls/eth_aggregate_pubkeys/small/eth_aggregate_pubkeys_valid_f15974ec693571cf/data.yaml new file mode 100644 index 000000000..02ef8e371 --- /dev/null +++ b/spectest/data_faketest/tests/general/altair/bls/eth_aggregate_pubkeys/small/eth_aggregate_pubkeys_valid_f15974ec693571cf/data.yaml @@ -0,0 +1,2 @@ +input: ['0xb301803f8b5ac4a1133581fc676dfedc60d891dd5fa99028805e5ea5b08d3491af75d0707adab3b70c6a6a580217bf81'] +output: '0xb301803f8b5ac4a1133581fc676dfedc60d891dd5fa99028805e5ea5b08d3491af75d0707adab3b70c6a6a580217bf81' diff --git a/spectest/data_faketest/tests/general/altair/bls/eth_aggregate_pubkeys/small/eth_aggregate_pubkeys_valid_pubkeys/data.yaml b/spectest/data_faketest/tests/general/altair/bls/eth_aggregate_pubkeys/small/eth_aggregate_pubkeys_valid_pubkeys/data.yaml new file mode 100644 index 000000000..9d92be57a --- /dev/null +++ b/spectest/data_faketest/tests/general/altair/bls/eth_aggregate_pubkeys/small/eth_aggregate_pubkeys_valid_pubkeys/data.yaml @@ -0,0 +1,4 @@ +input: ['0xa491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a', + '0xb301803f8b5ac4a1133581fc676dfedc60d891dd5fa99028805e5ea5b08d3491af75d0707adab3b70c6a6a580217bf81', + '0xb53d21a4cfd562c469cc81514d4ce5a6b577d8403d32a394dc265dd190b47fa9f829fdd7963afdf972e5e77854051f6f'] +output: '0xa095608b35495ca05002b7b5966729dd1ed096568cf2ff24f3318468e0f3495361414a78ebc09574489bc79e48fca969' diff --git a/spectest/data_faketest/tests/general/altair/bls/eth_aggregate_pubkeys/small/eth_aggregate_pubkeys_x40_pubkey/data.yaml b/spectest/data_faketest/tests/general/altair/bls/eth_aggregate_pubkeys/small/eth_aggregate_pubkeys_x40_pubkey/data.yaml new file mode 100644 index 000000000..f9ad4dae6 --- /dev/null +++ b/spectest/data_faketest/tests/general/altair/bls/eth_aggregate_pubkeys/small/eth_aggregate_pubkeys_x40_pubkey/data.yaml @@ -0,0 +1,2 @@ +input: ['0x400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'] +output: null diff --git a/spectest/data_faketest/tests/general/altair/bls/eth_aggregate_pubkeys/small/eth_aggregate_pubkeys_zero_pubkey/data.yaml b/spectest/data_faketest/tests/general/altair/bls/eth_aggregate_pubkeys/small/eth_aggregate_pubkeys_zero_pubkey/data.yaml new file mode 100644 index 000000000..c3e06c632 --- /dev/null +++ b/spectest/data_faketest/tests/general/altair/bls/eth_aggregate_pubkeys/small/eth_aggregate_pubkeys_zero_pubkey/data.yaml @@ -0,0 +1,2 @@ +input: ['0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'] +output: null diff --git a/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_extra_pubkey_4f079f946446fabf/data.yaml b/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_extra_pubkey_4f079f946446fabf/data.yaml new file mode 100644 index 000000000..90951ffa0 --- /dev/null +++ b/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_extra_pubkey_4f079f946446fabf/data.yaml @@ -0,0 +1,7 @@ +input: + pubkeys: ['0xa491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a', + '0xb301803f8b5ac4a1133581fc676dfedc60d891dd5fa99028805e5ea5b08d3491af75d0707adab3b70c6a6a580217bf81', + '0xb53d21a4cfd562c469cc81514d4ce5a6b577d8403d32a394dc265dd190b47fa9f829fdd7963afdf972e5e77854051f6f'] + message: '0x5656565656565656565656565656565656565656565656565656565656565656' + signature: '0x912c3615f69575407db9392eb21fee18fff797eeb2fbe1816366ca2a08ae574d8824dbfafb4c9eaa1cf61b63c6f9b69911f269b664c42947dd1b53ef1081926c1e82bb2a465f927124b08391a5249036146d6f3f1e17ff5f162f779746d830d1' +output: false diff --git a/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_extra_pubkey_5a38e6b4017fe4dd/data.yaml b/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_extra_pubkey_5a38e6b4017fe4dd/data.yaml new file mode 100644 index 000000000..f6751c530 --- /dev/null +++ b/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_extra_pubkey_5a38e6b4017fe4dd/data.yaml @@ -0,0 +1,8 @@ +input: + pubkeys: ['0xa491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a', + '0xb301803f8b5ac4a1133581fc676dfedc60d891dd5fa99028805e5ea5b08d3491af75d0707adab3b70c6a6a580217bf81', + '0xb53d21a4cfd562c469cc81514d4ce5a6b577d8403d32a394dc265dd190b47fa9f829fdd7963afdf972e5e77854051f6f', + '0xb53d21a4cfd562c469cc81514d4ce5a6b577d8403d32a394dc265dd190b47fa9f829fdd7963afdf972e5e77854051f6f'] + message: '0xabababababababababababababababababababababababababababababababab' + signature: '0x9712c3edd73a209c742b8250759db12549b3eaf43b5ca61376d9f30e2747dbcf842d8b2ac0901d2a093713e20284a7670fcf6954e9ab93de991bb9b313e664785a075fc285806fa5224c82bde146561b446ccfc706a64b8579513cfc4ff1d930' +output: false diff --git a/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_extra_pubkey_a698ea45b109f303/data.yaml b/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_extra_pubkey_a698ea45b109f303/data.yaml new file mode 100644 index 000000000..b77819729 --- /dev/null +++ b/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_extra_pubkey_a698ea45b109f303/data.yaml @@ -0,0 +1,6 @@ +input: + pubkeys: ['0xa491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a', + '0xb53d21a4cfd562c469cc81514d4ce5a6b577d8403d32a394dc265dd190b47fa9f829fdd7963afdf972e5e77854051f6f'] + message: '0x0000000000000000000000000000000000000000000000000000000000000000' + signature: '0xb6ed936746e01f8ecf281f020953fbf1f01debd5657c4a383940b020b26507f6076334f91e2366c96e9ab279fb5158090352ea1c5b0c9274504f4f0e7053af24802e51e4568d164fe986834f41e55c8e850ce1f98458c0cfc9ab380b55285a55' +output: false diff --git a/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_infinity_pubkey/data.yaml b/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_infinity_pubkey/data.yaml new file mode 100644 index 000000000..cb9f48646 --- /dev/null +++ b/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_infinity_pubkey/data.yaml @@ -0,0 +1,8 @@ +input: + pubkeys: ['0xa491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a', + '0xb301803f8b5ac4a1133581fc676dfedc60d891dd5fa99028805e5ea5b08d3491af75d0707adab3b70c6a6a580217bf81', + '0xb53d21a4cfd562c469cc81514d4ce5a6b577d8403d32a394dc265dd190b47fa9f829fdd7963afdf972e5e77854051f6f', + '0xc00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'] + message: '0x1212121212121212121212121212121212121212121212121212121212121212' + signature: '0xafcb4d980f079265caa61aee3e26bf48bebc5dc3e7f2d7346834d76cbc812f636c937b6b44a9323d8bc4b1cdf71d6811035ddc2634017faab2845308f568f2b9a0356140727356eae9eded8b87fd8cb8024b440c57aee06076128bb32921f584' +output: false diff --git a/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_na_pubkeys_and_infinity_signature/data.yaml b/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_na_pubkeys_and_infinity_signature/data.yaml new file mode 100644 index 000000000..ebeb26167 --- /dev/null +++ b/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_na_pubkeys_and_infinity_signature/data.yaml @@ -0,0 +1,5 @@ +input: + pubkeys: [] + message: '0xabababababababababababababababababababababababababababababababab' + signature: '0xc00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' +output: true diff --git a/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_na_pubkeys_and_zero_signature/data.yaml b/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_na_pubkeys_and_zero_signature/data.yaml new file mode 100644 index 000000000..4ef80244f --- /dev/null +++ b/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_na_pubkeys_and_zero_signature/data.yaml @@ -0,0 +1,5 @@ +input: + pubkeys: [] + message: '0xabababababababababababababababababababababababababababababababab' + signature: '0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' +output: false diff --git a/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_tampered_signature_3d7576f3c0e3570a/data.yaml b/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_tampered_signature_3d7576f3c0e3570a/data.yaml new file mode 100644 index 000000000..0dc16c2d1 --- /dev/null +++ b/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_tampered_signature_3d7576f3c0e3570a/data.yaml @@ -0,0 +1,7 @@ +input: + pubkeys: ['0xa491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a', + '0xb301803f8b5ac4a1133581fc676dfedc60d891dd5fa99028805e5ea5b08d3491af75d0707adab3b70c6a6a580217bf81', + '0xb53d21a4cfd562c469cc81514d4ce5a6b577d8403d32a394dc265dd190b47fa9f829fdd7963afdf972e5e77854051f6f'] + message: '0xabababababababababababababababababababababababababababababababab' + signature: '0x9712c3edd73a209c742b8250759db12549b3eaf43b5ca61376d9f30e2747dbcf842d8b2ac0901d2a093713e20284a7670fcf6954e9ab93de991bb9b313e664785a075fc285806fa5224c82bde146561b446ccfc706a64b8579513cfcffffffff' +output: false diff --git a/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_tampered_signature_5e745ad0c6199a6c/data.yaml b/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_tampered_signature_5e745ad0c6199a6c/data.yaml new file mode 100644 index 000000000..7f176a2b0 --- /dev/null +++ b/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_tampered_signature_5e745ad0c6199a6c/data.yaml @@ -0,0 +1,5 @@ +input: + pubkeys: ['0xa491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a'] + message: '0x0000000000000000000000000000000000000000000000000000000000000000' + signature: '0xb6ed936746e01f8ecf281f020953fbf1f01debd5657c4a383940b020b26507f6076334f91e2366c96e9ab279fb5158090352ea1c5b0c9274504f4f0e7053af24802e51e4568d164fe986834f41e55c8e850ce1f98458c0cfc9ab380bffffffff' +output: false diff --git a/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_tampered_signature_652ce62f09290811/data.yaml b/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_tampered_signature_652ce62f09290811/data.yaml new file mode 100644 index 000000000..b426471d7 --- /dev/null +++ b/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_tampered_signature_652ce62f09290811/data.yaml @@ -0,0 +1,6 @@ +input: + pubkeys: ['0xa491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a', + '0xb301803f8b5ac4a1133581fc676dfedc60d891dd5fa99028805e5ea5b08d3491af75d0707adab3b70c6a6a580217bf81'] + message: '0x5656565656565656565656565656565656565656565656565656565656565656' + signature: '0x912c3615f69575407db9392eb21fee18fff797eeb2fbe1816366ca2a08ae574d8824dbfafb4c9eaa1cf61b63c6f9b69911f269b664c42947dd1b53ef1081926c1e82bb2a465f927124b08391a5249036146d6f3f1e17ff5f162f7797ffffffff' +output: false diff --git a/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_valid_3d7576f3c0e3570a/data.yaml b/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_valid_3d7576f3c0e3570a/data.yaml new file mode 100644 index 000000000..a76d1bbd8 --- /dev/null +++ b/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_valid_3d7576f3c0e3570a/data.yaml @@ -0,0 +1,7 @@ +input: + pubkeys: ['0xa491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a', + '0xb301803f8b5ac4a1133581fc676dfedc60d891dd5fa99028805e5ea5b08d3491af75d0707adab3b70c6a6a580217bf81', + '0xb53d21a4cfd562c469cc81514d4ce5a6b577d8403d32a394dc265dd190b47fa9f829fdd7963afdf972e5e77854051f6f'] + message: '0xabababababababababababababababababababababababababababababababab' + signature: '0x9712c3edd73a209c742b8250759db12549b3eaf43b5ca61376d9f30e2747dbcf842d8b2ac0901d2a093713e20284a7670fcf6954e9ab93de991bb9b313e664785a075fc285806fa5224c82bde146561b446ccfc706a64b8579513cfc4ff1d930' +output: true diff --git a/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_valid_5e745ad0c6199a6c/data.yaml b/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_valid_5e745ad0c6199a6c/data.yaml new file mode 100644 index 000000000..1eba7e825 --- /dev/null +++ b/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_valid_5e745ad0c6199a6c/data.yaml @@ -0,0 +1,5 @@ +input: + pubkeys: ['0xa491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a'] + message: '0x0000000000000000000000000000000000000000000000000000000000000000' + signature: '0xb6ed936746e01f8ecf281f020953fbf1f01debd5657c4a383940b020b26507f6076334f91e2366c96e9ab279fb5158090352ea1c5b0c9274504f4f0e7053af24802e51e4568d164fe986834f41e55c8e850ce1f98458c0cfc9ab380b55285a55' +output: true diff --git a/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_valid_652ce62f09290811/data.yaml b/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_valid_652ce62f09290811/data.yaml new file mode 100644 index 000000000..a0562cc45 --- /dev/null +++ b/spectest/data_faketest/tests/general/altair/bls/eth_fast_aggregate_verify/small/eth_fast_aggregate_verify_valid_652ce62f09290811/data.yaml @@ -0,0 +1,6 @@ +input: + pubkeys: ['0xa491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a', + '0xb301803f8b5ac4a1133581fc676dfedc60d891dd5fa99028805e5ea5b08d3491af75d0707adab3b70c6a6a580217bf81'] + message: '0x5656565656565656565656565656565656565656565656565656565656565656' + signature: '0x912c3615f69575407db9392eb21fee18fff797eeb2fbe1816366ca2a08ae574d8824dbfafb4c9eaa1cf61b63c6f9b69911f269b664c42947dd1b53ef1081926c1e82bb2a465f927124b08391a5249036146d6f3f1e17ff5f162f779746d830d1' +output: true diff --git a/cmd/ef-tests-cl/spectest/errors.go b/spectest/errors.go similarity index 100% rename from cmd/ef-tests-cl/spectest/errors.go rename to spectest/errors.go diff --git a/cmd/ef-tests-cl/spectest/extra.go b/spectest/extra.go similarity index 100% rename from cmd/ef-tests-cl/spectest/extra.go rename to spectest/extra.go diff --git a/cmd/ef-tests-cl/spectest/format.go b/spectest/format.go similarity index 100% rename from cmd/ef-tests-cl/spectest/format.go rename to spectest/format.go diff --git a/cmd/ef-tests-cl/spectest/handler.go b/spectest/handler.go similarity index 100% rename from cmd/ef-tests-cl/spectest/handler.go rename to spectest/handler.go diff --git a/cmd/ef-tests-cl/spectest/suite.go b/spectest/suite.go similarity index 100% rename from cmd/ef-tests-cl/spectest/suite.go rename to spectest/suite.go diff --git a/cmd/ef-tests-cl/spectest/util.go b/spectest/util.go similarity index 98% rename from cmd/ef-tests-cl/spectest/util.go rename to spectest/util.go index 36349d184..10e2207b3 100644 --- a/cmd/ef-tests-cl/spectest/util.go +++ b/spectest/util.go @@ -2,6 +2,7 @@ package spectest import ( "fmt" + "github.com/ledgerwatch/erigon/cl/phase1/core/state" "io/fs" "os" @@ -10,7 +11,6 @@ import ( "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/cltypes" "github.com/ledgerwatch/erigon/cl/utils" - "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" "gopkg.in/yaml.v3" )