From cf2595549cca7955b2ae779d8b51c1a9d2994d43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= <93934272+Stefan-Ethernal@users.noreply.github.com> Date: Thu, 15 Feb 2024 11:45:18 +0100 Subject: [PATCH 1/2] Linter fixes (#114) * Fixes * More fixes * Remove on-demand trigger for nightly builds * More fixes --- .github/workflows/nightly.yml | 1 - archive/backup_test.go | 5 +++++ blockchain/blockchain_test.go | 9 +++------ blockchain/storage/leveldb/leveldb_test.go | 1 + command/genesis/params_test.go | 1 + command/peers/list/result.go | 1 + consensus/polybft/checkpoint_manager_test.go | 7 +++++++ consensus/polybft/consensus_runtime_test.go | 1 + consensus/polybft/extra_test.go | 6 +++++- consensus/polybft/governance_manager_test.go | 2 ++ consensus/polybft/mocks_test.go | 1 + consensus/polybft/runtime_helpers_test.go | 1 + consensus/polybft/sc_integration_test.go | 2 ++ consensus/polybft/stake_manager_test.go | 18 +++++++++++++---- consensus/polybft/state.go | 4 ++++ consensus/polybft/state_store_epoch_test.go | 1 + consensus/polybft/state_store_exit_test.go | 1 + consensus/polybft/state_store_state_sync.go | 2 ++ .../polybft/state_store_state_sync_test.go | 1 + .../validator/validator_metadata_test.go | 5 +++++ .../validator/validator_set_delta_test.go | 20 +++++++++++++++++-- consensus/polybft/validators_snapshot_test.go | 1 + e2e-polybft/e2e/bridge_test.go | 5 +++++ e2e-polybft/framework/test-cluster.go | 1 + e2e/discovery_test.go | 7 +++++++ e2e/framework/helper.go | 3 +++ e2e/framework/testserver.go | 2 ++ e2e/transaction_test.go | 3 +++ e2e/txpool_test.go | 1 + helper/common/common_test.go | 2 ++ network/dial/dial_queue_test.go | 2 ++ network/identity_e2e_test.go | 1 + network/server_test.go | 2 ++ server/server.go | 2 ++ state/executor.go | 1 + state/immutable-trie/copy_trie.go | 2 ++ state/immutable-trie/storage.go | 3 +++ state/runtime/evm/instructions_test.go | 1 + state/runtime/precompiled/blake2f_test.go | 8 ++++---- types/rlp_marshal.go | 3 +++ 40 files changed, 122 insertions(+), 18 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index ce0f1cf61a..eac54f51d8 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -1,7 +1,6 @@ --- name: Nightly Build on: # yamllint disable-line rule:truthy - workflow_dispatch: {} schedule: # * is a special character in YAML so you have to quote this string - cron: '0 0 * * *' diff --git a/archive/backup_test.go b/archive/backup_test.go index 1d5d589816..02923f61b6 100644 --- a/archive/backup_test.go +++ b/archive/backup_test.go @@ -162,6 +162,7 @@ func Test_determineTo(t *testing.T) { resTo, resToHash, err := determineTo(context.Background(), tt.systemClientMock, tt.targetTo) assert.Equal(t, tt.err, err) + if tt.err == nil { assert.Equal(t, tt.resTo, resTo) assert.Equal(t, tt.resToHash, resToHash) @@ -255,6 +256,7 @@ func Test_processExportStream(t *testing.T) { from, to, err := processExportStream(tt.mockSystemExportClient, hclog.NewNullLogger(), &buffer, 0, 0) assert.Equal(t, tt.err, err) + if err != nil { return } @@ -264,12 +266,15 @@ func Test_processExportStream(t *testing.T) { // create expected data expectedData := make([]byte, 0) + for _, rv := range tt.mockSystemExportClient.recvs { if rv.err != nil { break } + expectedData = append(expectedData, rv.event.Data...) } + assert.Equal(t, expectedData, buffer.Bytes()) }) } diff --git a/blockchain/blockchain_test.go b/blockchain/blockchain_test.go index 7e2643f9c4..9ab759513c 100644 --- a/blockchain/blockchain_test.go +++ b/blockchain/blockchain_test.go @@ -459,13 +459,10 @@ func TestInsertHeaders(t *testing.T) { } checkEvents := func(a []*header, b []*types.Header) { - if len(a) != len(b) { - t.Fatal("bad size") - } + require.Equal(t, len(a), len(b), "unexpected size") + for indx := range a { - if chain.headers[a[indx].hash].Hash != b[indx].Hash { - t.Fatal("bad") - } + require.Equal(t, chain.headers[a[indx].hash].Hash, b[indx].Hash) } } diff --git a/blockchain/storage/leveldb/leveldb_test.go b/blockchain/storage/leveldb/leveldb_test.go index 95f24c48ae..744edc2701 100644 --- a/blockchain/storage/leveldb/leveldb_test.go +++ b/blockchain/storage/leveldb/leveldb_test.go @@ -191,6 +191,7 @@ func dirSize(t *testing.T, path string) int64 { if err != nil { t.Fail() } + if !info.IsDir() { size += info.Size() } diff --git a/command/genesis/params_test.go b/command/genesis/params_test.go index fd95ec266a..1427211c1b 100644 --- a/command/genesis/params_test.go +++ b/command/genesis/params_test.go @@ -152,6 +152,7 @@ func Test_validatePremineInfo(t *testing.T) { p := &genesisParams{premine: c.premineRaw, nativeTokenConfig: &polybft.TokenConfig{IsMintable: c.isTokenMintable}} err := p.parsePremineInfo() + if c.expectedParseErrMsg != "" { require.ErrorContains(t, err, c.expectedParseErrMsg) diff --git a/command/peers/list/result.go b/command/peers/list/result.go index 0c2b1103aa..bb4c51144b 100644 --- a/command/peers/list/result.go +++ b/command/peers/list/result.go @@ -37,6 +37,7 @@ func (r *PeersListResult) GetOutput() string { for i, p := range r.Peers { rows[i] = fmt.Sprintf("[%d]|%s", i, p) } + buffer.WriteString(helper.FormatKV(rows)) } diff --git a/consensus/polybft/checkpoint_manager_test.go b/consensus/polybft/checkpoint_manager_test.go index c896be84f1..0f9241f981 100644 --- a/consensus/polybft/checkpoint_manager_test.go +++ b/consensus/polybft/checkpoint_manager_test.go @@ -67,6 +67,7 @@ func TestCheckpointManager_SubmitCheckpoint(t *testing.T) { validators.IterAcct(aliases, func(t *validator.TestValidator) { bitmap.Set(idx) + signatures = append(signatures, t.MustSign(dummyMsg, signer.DomainCheckpointManager)) idx++ }) @@ -172,7 +173,9 @@ func TestCheckpointManager_abiEncodeCheckpointBlock(t *testing.T) { currentValidators.IterAcct(nil, func(v *validator.TestValidator) { signatures = append(signatures, v.MustSign(proposalHash, signer.DomainCheckpointManager)) + bmp.Set(i) + i++ }) @@ -245,6 +248,7 @@ func TestCheckpointManager_getCurrentCheckpointID(t *testing.T) { txRelayerMock.On("Call", mock.Anything, mock.Anything, mock.Anything). Return(c.checkpointID, c.returnError). Once() + acc, err := wallet.GenerateAccount() require.NoError(t, err) @@ -253,6 +257,7 @@ func TestCheckpointManager_getCurrentCheckpointID(t *testing.T) { key: acc.Ecdsa, logger: hclog.NewNullLogger(), } + actualCheckpointID, err := getCurrentCheckpointBlock(checkpointMgr.rootChainRelayer, checkpointMgr.checkpointManagerAddr) if c.errSubstring == "" { @@ -417,7 +422,9 @@ func TestCheckpointManager_GenerateExitProof(t *testing.T) { // copy and make proof invalid invalidProof := make([]types.Hash, len(proof.Data)) + copy(invalidProof, proof.Data) + invalidProof[0][0]++ // verify generated proof on desired tree diff --git a/consensus/polybft/consensus_runtime_test.go b/consensus/polybft/consensus_runtime_test.go index ea22aa9615..5456a52099 100644 --- a/consensus/polybft/consensus_runtime_test.go +++ b/consensus/polybft/consensus_runtime_test.go @@ -1060,6 +1060,7 @@ func createTestBitmaps(t *testing.T, validators validator.AccountSet, numberOfBl if !bitmap.IsSet(index) { bitmap.Set(index) + j++ } } diff --git a/consensus/polybft/extra_test.go b/consensus/polybft/extra_test.go index 84629d77e9..59b2855bd6 100644 --- a/consensus/polybft/extra_test.go +++ b/consensus/polybft/extra_test.go @@ -377,6 +377,7 @@ func TestSignature_Verify(t *testing.T) { validatorSet := vals.ToValidatorSet() var signatures bls.Signatures + bitmap := bitmap.Bitmap{} signers := make(map[types.Address]struct{}, len(validatorsMetadata)) @@ -502,13 +503,15 @@ func TestExtra_InitGenesisValidatorsDelta(t *testing.T) { Removed: bitmap.Bitmap{}, } - var i int + i := 0 + for _, val := range vals.Validators { delta.Added[i] = &validator.ValidatorMetadata{ Address: types.Address(val.Account.Ecdsa.Address()), BlsKey: val.Account.Bls.PublicKey(), VotingPower: new(big.Int).SetUint64(val.VotingPower), } + i++ } @@ -732,6 +735,7 @@ func TestCheckpointData_Validate(t *testing.T) { c := c t.Run(c.name, func(t *testing.T) { t.Parallel() + checkpoint := &CheckpointData{ EpochNumber: c.epochNumber, CurrentValidatorsHash: c.currentValidatorsHash, diff --git a/consensus/polybft/governance_manager_test.go b/consensus/polybft/governance_manager_test.go index 9f7a8258a2..128b8caff6 100644 --- a/consensus/polybft/governance_manager_test.go +++ b/consensus/polybft/governance_manager_test.go @@ -125,8 +125,10 @@ func TestGovernanceManager_PostBlock(t *testing.T) { governanceManager, err := newGovernanceManager(chainParams, genesisPolybftConfig, hclog.NewNullLogger(), state, blockchainMock, nil) require.NoError(t, err) + // this cheats that we have this fork in code governanceManager.allForksHashes[newForkHash] = newForkName + require.NoError(t, state.GovernanceStore.insertGovernanceEvent(1, newForkBlock.Uint64(), &contractsapi.NewFeatureEvent{ Feature: newForkHash, Block: newForkBlock, diff --git a/consensus/polybft/mocks_test.go b/consensus/polybft/mocks_test.go index efedec269d..c0a1407724 100644 --- a/consensus/polybft/mocks_test.go +++ b/consensus/polybft/mocks_test.go @@ -247,6 +247,7 @@ func (m *systemStateMock) GetEpoch() (uint64, error) { return epochNumber, nil } else if len(args) == 2 { epochNumber, _ := args.Get(0).(uint64) + err, ok := args.Get(1).(error) if ok { return epochNumber, err diff --git a/consensus/polybft/runtime_helpers_test.go b/consensus/polybft/runtime_helpers_test.go index 078129d9cc..6eae3dfd02 100644 --- a/consensus/polybft/runtime_helpers_test.go +++ b/consensus/polybft/runtime_helpers_test.go @@ -15,6 +15,7 @@ func TestHelpers_isEpochEndingBlock_DeltaNotEmpty(t *testing.T) { t.Parallel() validators := validator.NewTestValidators(t, 3).GetPublicIdentities() + bitmap := bitmap.Bitmap{} bitmap.Set(0) diff --git a/consensus/polybft/sc_integration_test.go b/consensus/polybft/sc_integration_test.go index daebb6db7d..7d9df17c20 100644 --- a/consensus/polybft/sc_integration_test.go +++ b/consensus/polybft/sc_integration_test.go @@ -209,7 +209,9 @@ func TestIntegration_PerformExit(t *testing.T) { currentValidators.IterAcct(nil, func(v *validator.TestValidator) { signatures = append(signatures, v.MustSign(checkpointHash[:], signer.DomainCheckpointManager)) + bmp.Set(i) + i++ }) diff --git a/consensus/polybft/stake_manager_test.go b/consensus/polybft/stake_manager_test.go index 2a50c59568..87aa1bc1db 100644 --- a/consensus/polybft/stake_manager_test.go +++ b/consensus/polybft/stake_manager_test.go @@ -78,13 +78,15 @@ func TestStakeManager_PostBlock(t *testing.T) { fullValidatorSet, err := state.StakeStore.getFullValidatorSet(nil) require.NoError(t, err) + var firstValidatorMeta *validator.ValidatorMetadata - firstValidatorMeta = nil + for _, validator := range fullValidatorSet.Validators { if validator.Address.String() == validators.GetValidator(initialSetAliases[firstValidator]).Address().String() { firstValidatorMeta = validator } } + require.NotNil(t, firstValidatorMeta) require.Equal(t, bigZero, firstValidatorMeta.VotingPower) require.False(t, firstValidatorMeta.IsActive) @@ -133,13 +135,15 @@ func TestStakeManager_PostBlock(t *testing.T) { fullValidatorSet, err := state.StakeStore.getFullValidatorSet(nil) require.NoError(t, err) + var firstValidator *validator.ValidatorMetadata - firstValidator = nil + for _, validator := range fullValidatorSet.Validators { if validator.Address.String() == validators.GetValidator(initialSetAliases[secondValidator]).Address().String() { firstValidator = validator } } + require.NotNil(t, firstValidator) require.Equal(t, big.NewInt(251), firstValidator.VotingPower) // 250 + initial 1 require.True(t, firstValidator.IsActive) @@ -149,13 +153,11 @@ func TestStakeManager_PostBlock(t *testing.T) { t.Parallel() state := newTestState(t) - validators := validator.NewTestValidatorsWithAliases(t, allAliases, []uint64{1, 2, 3, 4, 5, 6}) txRelayerMock := newDummyStakeTxRelayer(t, func() *validator.ValidatorMetadata { return validators.GetValidator("F").ValidatorMetadata() }) - // just mock the call however, the dummy relayer should do its magic txRelayerMock.On("Call", mock.Anything, mock.Anything, mock.Anything). Return(nil, error(nil)) @@ -251,6 +253,7 @@ func TestStakeManager_UpdateValidatorSet(t *testing.T) { updateDelta, err := stakeManager.UpdateValidatorSet(epoch, maxValidatorSetSize, validators.GetPublicIdentities()) require.NoError(t, err) + require.Len(t, updateDelta.Added, 0) require.Len(t, updateDelta.Updated, 1) require.Len(t, updateDelta.Removed, 0) @@ -267,6 +270,7 @@ func TestStakeManager_UpdateValidatorSet(t *testing.T) { updateDelta, err := stakeManager.UpdateValidatorSet(epoch+1, maxValidatorSetSize, validators.GetPublicIdentities()) + require.NoError(t, err) require.Len(t, updateDelta.Added, 0) require.Len(t, updateDelta.Updated, 0) @@ -282,6 +286,7 @@ func TestStakeManager_UpdateValidatorSet(t *testing.T) { updateDelta, err := stakeManager.UpdateValidatorSet(epoch+2, maxValidatorSetSize, validators.GetPublicIdentities(aliases[1:]...)) + require.NoError(t, err) require.Len(t, updateDelta.Added, 1) require.Len(t, updateDelta.Updated, 0) @@ -293,12 +298,14 @@ func TestStakeManager_UpdateValidatorSet(t *testing.T) { fullValidatorSet := validators.GetPublicIdentities().Copy() validatorToUpdate := fullValidatorSet[2] validatorToUpdate.VotingPower = big.NewInt(5) + require.NoError(t, state.StakeStore.insertFullValidatorSet(validatorSetState{ Validators: newValidatorStakeMap(fullValidatorSet), }, nil)) updateDelta, err := stakeManager.UpdateValidatorSet(epoch+3, maxValidatorSetSize, validators.GetPublicIdentities()) + require.NoError(t, err) require.Len(t, updateDelta.Added, 0) require.Len(t, updateDelta.Updated, 1) @@ -310,12 +317,14 @@ func TestStakeManager_UpdateValidatorSet(t *testing.T) { fullValidatorSet := validators.GetPublicIdentities().Copy() validatorToUpdate := fullValidatorSet[3] validatorToUpdate.VotingPower = bigZero + require.NoError(t, state.StakeStore.insertFullValidatorSet(validatorSetState{ Validators: newValidatorStakeMap(fullValidatorSet), }, nil)) updateDelta, err := stakeManager.UpdateValidatorSet(epoch+4, maxValidatorSetSize, validators.GetPublicIdentities()) + require.NoError(t, err) require.Len(t, updateDelta.Added, 0) require.Len(t, updateDelta.Updated, 0) @@ -325,6 +334,7 @@ func TestStakeManager_UpdateValidatorSet(t *testing.T) { fullValidatorSet := validators.GetPublicIdentities().Copy() validatorsToUpdate := fullValidatorSet[4] validatorsToUpdate.VotingPower = bigZero + require.NoError(t, state.StakeStore.insertFullValidatorSet(validatorSetState{ Validators: newValidatorStakeMap(fullValidatorSet), }, nil)) diff --git a/consensus/polybft/state.go b/consensus/polybft/state.go index d2ea0c02bb..2028bbeb1e 100644 --- a/consensus/polybft/state.go +++ b/consensus/polybft/state.go @@ -78,15 +78,19 @@ func (s *State) initStorages() error { if err := s.StateSyncStore.initialize(tx); err != nil { return err } + if err := s.ExitStore.initialize(tx); err != nil { return err } + if err := s.EpochStore.initialize(tx); err != nil { return err } + if err := s.ProposerSnapshotStore.initialize(tx); err != nil { return err } + if err := s.StakeStore.initialize(tx); err != nil { return err } diff --git a/consensus/polybft/state_store_epoch_test.go b/consensus/polybft/state_store_epoch_test.go index f9d8d8821a..a48403a974 100644 --- a/consensus/polybft/state_store_epoch_test.go +++ b/consensus/polybft/state_store_epoch_test.go @@ -93,6 +93,7 @@ func TestState_cleanValidatorSnapshotsFromDb(t *testing.T) { snapshotFromDB, err = state.EpochStore.getValidatorSnapshot(epoch) assert.NoError(t, err) assert.NotNil(t, snapshotFromDB) + epoch-- } } diff --git a/consensus/polybft/state_store_exit_test.go b/consensus/polybft/state_store_exit_test.go index 92a6f935ae..4594b4af1f 100644 --- a/consensus/polybft/state_store_exit_test.go +++ b/consensus/polybft/state_store_exit_test.go @@ -194,6 +194,7 @@ func insertTestExitEvents(t *testing.T, state *State, } index++ } + block++ } } diff --git a/consensus/polybft/state_store_state_sync.go b/consensus/polybft/state_store_state_sync.go index 9f72aa7f90..644dd29d50 100644 --- a/consensus/polybft/state_store_state_sync.go +++ b/consensus/polybft/state_store_state_sync.go @@ -117,6 +117,7 @@ func (s *StateSyncStore) list() ([]*contractsapi.StateSyncedEvent, error) { if err := json.Unmarshal(v, &event); err != nil { return err } + events = append(events, event) return nil @@ -297,6 +298,7 @@ func (s *StateSyncStore) getMessageVotes(epoch uint64, hash []byte) ([]*MessageS if err != nil { return err } + signatures = res return nil diff --git a/consensus/polybft/state_store_state_sync_test.go b/consensus/polybft/state_store_state_sync_test.go index 1c63eeb385..afe6b0a39b 100644 --- a/consensus/polybft/state_store_state_sync_test.go +++ b/consensus/polybft/state_store_state_sync_test.go @@ -225,6 +225,7 @@ func TestState_GetNestedBucketInEpoch(t *testing.T) { s := newTestState(t) require.NoError(t, s.EpochStore.insertEpoch(c.epochNumber, nil)) + err = s.db.View(func(tx *bbolt.Tx) error { nestedBucket, err = getNestedBucketInEpoch(tx, c.epochNumber, c.bucketName) diff --git a/consensus/polybft/validator/validator_metadata_test.go b/consensus/polybft/validator/validator_metadata_test.go index fcdcb71495..8eaf045f88 100644 --- a/consensus/polybft/validator/validator_metadata_test.go +++ b/consensus/polybft/validator/validator_metadata_test.go @@ -214,10 +214,12 @@ func TestAccountSet_ApplyDelta(t *testing.T) { if step.added != nil { addedValidators = vals.GetPublicIdentities(step.added...) } + delta := &ValidatorSetDelta{ Added: addedValidators, Removed: bitmap.Bitmap{}, } + for _, i := range step.removed { delta.Removed.Set(i) } @@ -228,16 +230,19 @@ func TestAccountSet_ApplyDelta(t *testing.T) { // apply delta var err error snapshot, err = snapshot.ApplyDelta(delta) + if step.errMsg != "" { require.ErrorContains(t, err, step.errMsg) require.Nil(t, snapshot) return } + require.NoError(t, err) // validate validator set require.Equal(t, len(step.expected), snapshot.Len()) + for validatorAlias, votingPower := range step.expected { v := vals.GetValidator(validatorAlias).ValidatorMetadata() require.True(t, snapshot.ContainsAddress(v.Address), "validator '%s' not found in snapshot", validatorAlias) diff --git a/consensus/polybft/validator/validator_set_delta_test.go b/consensus/polybft/validator/validator_set_delta_test.go index 3e0af84775..44891483b4 100644 --- a/consensus/polybft/validator/validator_set_delta_test.go +++ b/consensus/polybft/validator/validator_set_delta_test.go @@ -71,6 +71,7 @@ func TestValidatorSetDelta_UnmarshalRLPWith_NegativeCases(t *testing.T) { t.Parallel() ar := &fastrlp.Arena{} + delta := &ValidatorSetDelta{} require.NoError(t, delta.UnmarshalRLPWith(ar.NewArray())) }) @@ -84,6 +85,7 @@ func TestValidatorSetDelta_UnmarshalRLPWith_NegativeCases(t *testing.T) { deltaMarshalled.Set(ar.NewBytes([]byte{0x33})) deltaMarshalled.Set(ar.NewBytes([]byte{0x26})) deltaMarshalled.Set(ar.NewBytes([]byte{0x74})) + delta := &ValidatorSetDelta{} require.ErrorContains(t, delta.UnmarshalRLPWith(deltaMarshalled), "incorrect elements count to decode validator set delta, expected 3 but found 4") }) @@ -93,9 +95,11 @@ func TestValidatorSetDelta_UnmarshalRLPWith_NegativeCases(t *testing.T) { ar := &fastrlp.Arena{} deltaMarshalled := ar.NewArray() + deltaMarshalled.Set(ar.NewBytes([]byte{0x59})) deltaMarshalled.Set(ar.NewBytes([]byte{0x33})) deltaMarshalled.Set(ar.NewBytes([]byte{0x27})) + delta := &ValidatorSetDelta{} require.ErrorContains(t, delta.UnmarshalRLPWith(deltaMarshalled), "array expected for added validators") }) @@ -110,6 +114,7 @@ func TestValidatorSetDelta_UnmarshalRLPWith_NegativeCases(t *testing.T) { deltaMarshalled.Set(addedArray) deltaMarshalled.Set(ar.NewNullArray()) deltaMarshalled.Set(ar.NewNull()) + delta := &ValidatorSetDelta{} require.ErrorContains(t, delta.UnmarshalRLPWith(deltaMarshalled), "value is not of type array") }) @@ -122,19 +127,21 @@ func TestValidatorSetDelta_UnmarshalRLPWith_NegativeCases(t *testing.T) { addedValidators := NewTestValidators(t, 3).GetPublicIdentities() addedArray := ar.NewArray() updatedArray := ar.NewArray() + for _, validator := range addedValidators { addedArray.Set(validator.MarshalRLPWith(ar)) - } - for _, validator := range addedValidators { + votingPower, err := rand.Int(rand.Reader, big.NewInt(100)) require.NoError(t, err) validator.VotingPower = new(big.Int).Set(votingPower) updatedArray.Set(validator.MarshalRLPWith(ar)) } + deltaMarshalled.Set(addedArray) deltaMarshalled.Set(updatedArray) deltaMarshalled.Set(ar.NewNull()) + delta := &ValidatorSetDelta{} require.ErrorContains(t, delta.UnmarshalRLPWith(deltaMarshalled), "value is not of type bytes") }) @@ -147,6 +154,7 @@ func TestValidatorSetDelta_UnmarshalRLPWith_NegativeCases(t *testing.T) { deltaMarshalled.Set(ar.NewArray()) deltaMarshalled.Set(ar.NewBytes([]byte{0x33})) deltaMarshalled.Set(ar.NewNull()) + delta := &ValidatorSetDelta{} require.ErrorContains(t, delta.UnmarshalRLPWith(deltaMarshalled), "array expected for updated validators") }) @@ -156,11 +164,14 @@ func TestValidatorSetDelta_UnmarshalRLPWith_NegativeCases(t *testing.T) { ar := &fastrlp.Arena{} deltaMarshalled := ar.NewArray() + updatedArray := ar.NewArray() + updatedArray.Set(ar.NewNull()) deltaMarshalled.Set(ar.NewArray()) deltaMarshalled.Set(updatedArray) deltaMarshalled.Set(ar.NewNull()) + delta := &ValidatorSetDelta{} require.ErrorContains(t, delta.UnmarshalRLPWith(deltaMarshalled), "value is not of type array") }) @@ -197,6 +208,7 @@ func TestExtra_CreateValidatorSetDelta_Cases(t *testing.T) { for _, name := range c.oldSet { vals.Create(t, name, 1) } + for _, name := range c.newSet { vals.Create(t, name, 1) } @@ -204,6 +216,7 @@ func TestExtra_CreateValidatorSetDelta_Cases(t *testing.T) { oldValidatorSet := vals.GetPublicIdentities(c.oldSet...) // update voting power to random value maxVotingPower := big.NewInt(100) + for _, name := range c.updated { v := vals.GetValidator(name) vp, err := rand.Int(rand.Reader, maxVotingPower) @@ -211,6 +224,7 @@ func TestExtra_CreateValidatorSetDelta_Cases(t *testing.T) { // make sure generated voting power is different than the original one v.VotingPower += vp.Uint64() + 1 } + newValidatorSet := vals.GetPublicIdentities(c.newSet...) delta, err := CreateValidatorSetDelta(oldValidatorSet, newValidatorSet) @@ -218,6 +232,7 @@ func TestExtra_CreateValidatorSetDelta_Cases(t *testing.T) { // added validators require.Len(t, delta.Added, len(c.added)) + for i, name := range c.added { require.Equal(t, delta.Added[i].Address, vals.GetValidator(name).Address()) } @@ -229,6 +244,7 @@ func TestExtra_CreateValidatorSetDelta_Cases(t *testing.T) { // updated validators require.Len(t, delta.Updated, len(c.updated)) + for i, name := range c.updated { require.Equal(t, delta.Updated[i].Address, vals.GetValidator(name).Address()) } diff --git a/consensus/polybft/validators_snapshot_test.go b/consensus/polybft/validators_snapshot_test.go index e053014ebd..aa2e4ced1b 100644 --- a/consensus/polybft/validators_snapshot_test.go +++ b/consensus/polybft/validators_snapshot_test.go @@ -149,6 +149,7 @@ func TestValidatorsSnapshotCache_Cleanup(t *testing.T) { for i := uint64(0); i < validatorSnapshotLimit; i++ { require.NoError(cache.storeSnapshot(&validatorSnapshot{i, i * 10, snapshot}, nil)) + maxEpoch++ } diff --git a/e2e-polybft/e2e/bridge_test.go b/e2e-polybft/e2e/bridge_test.go index 92e46460ae..b370fc3581 100644 --- a/e2e-polybft/e2e/bridge_test.go +++ b/e2e-polybft/e2e/bridge_test.go @@ -77,6 +77,7 @@ func TestE2E_Bridge_RootchainTokensTransfers(t *testing.T) { tcc.StakeAmounts = append(tcc.StakeAmounts, ethgo.Ether(10)) // premine receivers, so that they are able to do withdrawals } + tcc.Premine = append(tcc.Premine, receivers...) })) defer cluster.Stop() @@ -830,6 +831,7 @@ func TestE2E_Bridge_ChildchainTokensTransfer(t *testing.T) { for i, receiver := range depositors { balance := erc20BalanceOf(t, receiver, contracts.NativeERC20TokenContract, childchainTxRelayer) t.Log("Attempt", it+1, "Balance before", balancesBefore[i], "Balance after", balance) + if balance.Cmp(balancesBefore[i].Add(balancesBefore[i], big.NewInt(amount))) != 0 { allSuccessful = false @@ -910,6 +912,7 @@ func TestE2E_Bridge_ChildchainTokensTransfer(t *testing.T) { // first exit event is mapping child token on a rootchain // remaining ones are the deposits initialExitEventID++ + require.NoError(t, cluster.WaitUntil(time.Minute*3, time.Second*2, func() bool { for i := initialExitEventID; i <= initialExitEventID+transfersCount; i++ { if !isExitEventProcessed(t, polybftCfg.Bridge.ExitHelperAddr, rootchainTxRelayer, i) { @@ -966,6 +969,7 @@ func TestE2E_Bridge_ChildchainTokensTransfer(t *testing.T) { for i, receiver := range depositors { owner := erc721OwnerOf(t, big.NewInt(int64(i)), types.Address(rootERC721Token), childchainTxRelayer) t.Log("Attempt:", it+1, " Owner:", owner, " Receiver:", receiver) + if receiver != owner { allSuccessful = false @@ -1211,6 +1215,7 @@ func TestE2E_Bridge_Transfers_AccessLists(t *testing.T) { rootchainTxRelayer, polybftCfg.Bridge.CheckpointManagerAddr)) oldBalances := map[types.Address]*big.Int{} + for _, receiver := range receivers { balance := erc20BalanceOf(t, types.StringToAddress(receiver), rootERC20Token, rootchainTxRelayer) oldBalances[types.StringToAddress(receiver)] = balance diff --git a/e2e-polybft/framework/test-cluster.go b/e2e-polybft/framework/test-cluster.go index 9e41a1d613..a6332dd70d 100644 --- a/e2e-polybft/framework/test-cluster.go +++ b/e2e-polybft/framework/test-cluster.go @@ -704,6 +704,7 @@ func NewTestCluster(t *testing.T, validatorsCount int, opts ...ClusterOption) *T if proxyAdminAddr == "" { proxyAdminAddr = ProxyContractAdminAddr } + args = append(args, "--proxy-contracts-admin", proxyAdminAddr) if config.PredeployContract != "" { diff --git a/e2e/discovery_test.go b/e2e/discovery_test.go index b25463d82f..618fa423f6 100644 --- a/e2e/discovery_test.go +++ b/e2e/discovery_test.go @@ -40,18 +40,22 @@ func TestDiscovery(t *testing.T) { srvs := framework.NewTestServers(t, tt.numNodes, conf) p2pAddrs := make([]string, tt.numNodes) + for i, s := range srvs { status, err := s.Operator().GetStatus(context.Background(), &empty.Empty{}) if err != nil { t.Fatal(err) } + p2pAddrs[i] = strings.Split(status.P2PAddr, ",")[0] } for i := 0; i < tt.numInitConnectNodes-1; i++ { srv, dest := srvs[i], p2pAddrs[i+1] + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() + _, err := srv.Operator().PeersAdd(ctx, &proto.PeersAddRequest{ Id: dest, }) @@ -63,6 +67,7 @@ func TestDiscovery(t *testing.T) { for i, srv := range srvs { shouldKnowPeers := true subTestName := fmt.Sprintf("node %d should know other peers", i) + if i >= tt.numInitConnectNodes { shouldKnowPeers = false subTestName = fmt.Sprintf("node %d shouldn't know other peers", i) @@ -71,6 +76,7 @@ func TestDiscovery(t *testing.T) { t.Run(subTestName, func(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() + res, err := framework.WaitUntilPeerConnects(ctx, srv, tt.numInitConnectNodes-1) if err != nil { @@ -83,6 +89,7 @@ func TestDiscovery(t *testing.T) { } isAddrKnown := make(map[string]bool, len(res.Peers)) + for _, p := range res.Peers { addr, id := p.Addrs[0], p.Id key := fmt.Sprintf("%s/p2p/%s", addr, id) diff --git a/e2e/framework/helper.go b/e2e/framework/helper.go index e3c409ea52..d55a33a79c 100644 --- a/e2e/framework/helper.go +++ b/e2e/framework/helper.go @@ -155,6 +155,7 @@ func WaitUntilPeerConnects(ctx context.Context, srv *TestServer, requiredNum int res, err := tests.RetryUntilTimeout(ctx, func() (interface{}, bool) { subCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() + res, _ := clt.PeersList(subCtx, &empty.Empty{}) if res != nil && len(res.Peers) >= requiredNum { return res, false @@ -186,6 +187,7 @@ func WaitUntilTxPoolFilled( res, err := tests.RetryUntilTimeout(ctx, func() (interface{}, bool) { subCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() + res, _ := clt.Status(subCtx, &empty.Empty{}) if res != nil && res.Length >= requiredNum { return res, false @@ -321,6 +323,7 @@ func NewTestServers(t *testing.T, num int, conf func(*TestServerConfig)) []*Test t.Cleanup(func() { for _, srv := range srvs { srv.Stop() + if err := os.RemoveAll(srv.Config.RootDir); err != nil { t.Log(err) } diff --git a/e2e/framework/testserver.go b/e2e/framework/testserver.go index adcf7c16fc..5e536e4eb2 100644 --- a/e2e/framework/testserver.go +++ b/e2e/framework/testserver.go @@ -551,9 +551,11 @@ func (t *TestServer) WaitForReceipt(ctx context.Context, hash ethgo.Hash) (*ethg res, err := tests.RetryUntilTimeout(ctx, func() (interface{}, bool) { receipt, err := client.Eth().GetTransactionReceipt(hash) + if err != nil && err.Error() != "not found" { return result{receipt, err}, false } + if receipt != nil { return result{receipt, nil}, false } diff --git a/e2e/transaction_test.go b/e2e/transaction_test.go index e38a2637ff..aec654d677 100644 --- a/e2e/transaction_test.go +++ b/e2e/transaction_test.go @@ -48,6 +48,7 @@ func TestPreminedBalance(t *testing.T) { srvs := framework.NewTestServers(t, 1, func(config *framework.TestServerConfig) { config.SetConsensus(framework.ConsensusDev) config.SetBurnContract(types.ZeroAddress) + for _, acc := range preminedAccounts { config.Premine(acc.address, acc.balance) } @@ -123,6 +124,7 @@ func TestEthTransfer(t *testing.T) { srvs := framework.NewTestServers(t, 1, func(config *framework.TestServerConfig) { config.SetConsensus(framework.ConsensusDev) + for _, acc := range validAccounts { config.Premine(acc.address, acc.balance) config.SetBurnContract(types.StringToAddress("0xBurnContract")) @@ -188,6 +190,7 @@ func TestEthTransfer(t *testing.T) { expectedSenderBalance := previousSenderBalance expectedReceiverBalance := previousReceiverBalance + if testCase.shouldSucceed { fee := new(big.Int).Mul( big.NewInt(int64(receipt.GasUsed)), diff --git a/e2e/txpool_test.go b/e2e/txpool_test.go index 58d742f171..cf566e84be 100644 --- a/e2e/txpool_test.go +++ b/e2e/txpool_test.go @@ -186,6 +186,7 @@ func TestTxPool_ErrorCodes(t *testing.T) { convertedHash := types.StringToHash(addResponse.TxHash) _, receiptErr := tests.WaitForReceipt(receiptCtx, srv.JSONRPC().Eth(), ethgo.Hash(convertedHash)) + if receiptErr != nil { t.Fatalf("Unable to get receipt, %v", receiptErr) } diff --git a/helper/common/common_test.go b/helper/common/common_test.go index 91a654a424..f820bcc7aa 100644 --- a/helper/common/common_test.go +++ b/helper/common/common_test.go @@ -38,6 +38,7 @@ func Test_ExtendByteSlice(t *testing.T) { newSlice := ExtendByteSlice(originalSlice, c.newLength) require.Len(t, newSlice, c.newLength) + if c.length > c.newLength { require.Equal(t, originalSlice[:c.newLength], newSlice) } else { @@ -98,6 +99,7 @@ func Test_Duration_Marshal_UnmarshalJSON(t *testing.T) { require.NoError(t, err) var otherTimer *timer + require.NoError(t, json.Unmarshal(timerRaw, &otherTimer)) require.Equal(t, origTimer, otherTimer) }) diff --git a/network/dial/dial_queue_test.go b/network/dial/dial_queue_test.go index 35bc34b698..dcd40ae747 100644 --- a/network/dial/dial_queue_test.go +++ b/network/dial/dial_queue_test.go @@ -161,6 +161,7 @@ func TestDel(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { q := NewDialQueue() + for _, task := range tt.tasks { id := peer.ID(task.id) @@ -178,6 +179,7 @@ func TestDel(t *testing.T) { t.Errorf("unsupported action: %s", task.action) } } + assert.Equal(t, tt.expectedLen, q.heap.Len()) }) } diff --git a/network/identity_e2e_test.go b/network/identity_e2e_test.go index c81f7191de..6d6f7c3ed2 100644 --- a/network/identity_e2e_test.go +++ b/network/identity_e2e_test.go @@ -63,6 +63,7 @@ func TestIdentityHandshake(t *testing.T) { // Server 0 -> Server 1 joinTimeout := DefaultJoinTimeout connectTimeout := DefaultBufferTimeout + if !shouldSucceed { connectTimeout = time.Second * 5 joinTimeout = time.Second * 5 diff --git a/network/server_test.go b/network/server_test.go index 7186768150..43f06582a6 100644 --- a/network/server_test.go +++ b/network/server_test.go @@ -187,6 +187,7 @@ func TestPeerEvent_EmitAndSubscribe(t *testing.T) { id, event := getIDAndEventType(i) server.emitEvent(id, event) } + for i := 0; i < count; i++ { received := <-receiver id, event := getIDAndEventType(i) @@ -1099,6 +1100,7 @@ func TestPeerAdditionDeletion(t *testing.T) { prunedPeers := 0 for i := 0; i < len(randomPeers); i += 2 { prunedPeers++ + server.removePeer(randomPeers[i].peerID) assert.False(t, server.hasPeer(randomPeers[i].peerID)) diff --git a/server/server.go b/server/server.go index c47a82c62c..47462eec45 100644 --- a/server/server.go +++ b/server/server.go @@ -188,6 +188,7 @@ func NewServer(config *Config) (*Server, error) { if err != nil { return nil, err } + m.network = network } @@ -364,6 +365,7 @@ func NewServer(config *Config) (*Server, error) { if err := m.setupConsensus(); err != nil { return nil, err } + m.blockchain.SetConsensus(m.consensus) } diff --git a/state/executor.go b/state/executor.go index 214c377abd..5acc7de3f6 100644 --- a/state/executor.go +++ b/state/executor.go @@ -628,6 +628,7 @@ func (t *Transition) apply(msg *types.Transaction) (*runtime.ExecutionResult, er // Refund the sender remaining := new(big.Int).Mul(new(big.Int).SetUint64(result.GasLeft), gasPrice) + t.state.AddBalance(msg.From, remaining) // Spec: https://eips.ethereum.org/EIPS/eip-1559#specification diff --git a/state/immutable-trie/copy_trie.go b/state/immutable-trie/copy_trie.go index afa912187b..9bbc975ce2 100644 --- a/state/immutable-trie/copy_trie.go +++ b/state/immutable-trie/copy_trie.go @@ -195,6 +195,7 @@ func hashChecker(node Node, h *hasher, a *fastrlp.Arena, d int, storage Storage) if err != nil { return nil, err } + val.Set(v) } } @@ -207,6 +208,7 @@ func hashChecker(node Node, h *hasher, a *fastrlp.Arena, d int, storage Storage) if err != nil { return nil, err } + val.Set(v) } diff --git a/state/immutable-trie/storage.go b/state/immutable-trie/storage.go index cb1f775cad..7c4fa44e5e 100644 --- a/state/immutable-trie/storage.go +++ b/state/immutable-trie/storage.go @@ -249,11 +249,13 @@ func decodeNode(v *fastrlp.Value, s Storage) (Node, error) { } else if ll == 17 { // full node nc := &FullNode{} + for i := 0; i < 16; i++ { if v.Get(i).Type() == fastrlp.TypeBytes && len(v.Get(i).Raw()) == 0 { // empty continue } + nc.children[i], err = decodeNode(v.Get(i), s) if err != nil { return nil, err @@ -263,6 +265,7 @@ func decodeNode(v *fastrlp.Value, s Storage) (Node, error) { if v.Get(16).Type() != fastrlp.TypeBytes { return nil, fmt.Errorf("full node value expected to be bytes") } + if len(v.Get(16).Raw()) != 0 { vv := &ValueNode{} vv.buf = append(vv.buf[:0], v.Get(16).Raw()...) diff --git a/state/runtime/evm/instructions_test.go b/state/runtime/evm/instructions_test.go index 1e75aa4407..4e69221000 100644 --- a/state/runtime/evm/instructions_test.go +++ b/state/runtime/evm/instructions_test.go @@ -361,6 +361,7 @@ func TestPush0(t *testing.T) { t.Run("single push0 (EIP-3855 disabled)", func(t *testing.T) { allExceptEIP3855Fork := chain.AllForksEnabled.Copy().RemoveFork(chain.EIP3855).At(0) + s, closeFn := getState(&allExceptEIP3855Fork) defer closeFn() diff --git a/state/runtime/precompiled/blake2f_test.go b/state/runtime/precompiled/blake2f_test.go index c825260229..dbd006d20d 100644 --- a/state/runtime/precompiled/blake2f_test.go +++ b/state/runtime/precompiled/blake2f_test.go @@ -1,9 +1,10 @@ package precompiled import ( - "bytes" "testing" + "github.com/stretchr/testify/require" + "github.com/0xPolygon/polygon-edge/types" ) @@ -17,8 +18,7 @@ func TestBlake2f(t *testing.T) { if err != nil { t.Fatal(err) } - if !bytes.Equal(c.Expected, out) { - t.Fatal("bad") - } + + require.Equal(t, c.Expected, out) }) } diff --git a/types/rlp_marshal.go b/types/rlp_marshal.go index 0bb59c2a7e..6bc9893f74 100644 --- a/types/rlp_marshal.go +++ b/types/rlp_marshal.go @@ -38,6 +38,7 @@ func (b *Block) MarshalRLPWith(ar *fastrlp.Arena) *fastrlp.Value { vv.Set(ar.NewNullArray()) } else { v0 := ar.NewArray() + for _, tx := range b.Transactions { if tx.Type != LegacyTx { v0.Set(ar.NewCopyBytes([]byte{byte(tx.Type)})) @@ -45,6 +46,7 @@ func (b *Block) MarshalRLPWith(ar *fastrlp.Arena) *fastrlp.Value { v0.Set(tx.MarshalRLPWith(ar)) } + vv.Set(v0) } @@ -55,6 +57,7 @@ func (b *Block) MarshalRLPWith(ar *fastrlp.Arena) *fastrlp.Value { for _, uncle := range b.Uncles { v1.Set(uncle.MarshalRLPWith(ar)) } + vv.Set(v1) } From 599a104583cb233cd2f3fe4955e2b136eccc4077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= <93934272+Stefan-Ethernal@users.noreply.github.com> Date: Thu, 15 Feb 2024 12:05:57 +0100 Subject: [PATCH 2/2] Implement EIP-3607 (#120) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Adding hash check for empty hash when configured (#108) * Fixing transactionCollidingWithNonEmptyAccount_init and transactionCollidingWithNonEmptyAccount_calls tests by checking validity. * Update state/executor.go Co-authored-by: Goran Rojovic <100121253+goran-ethernal@users.noreply.github.com> --------- Co-authored-by: Goran Rojovic <100121253+goran-ethernal@users.noreply.github.com> Co-authored-by: Stefan Negovanović <93934272+Stefan-Ethernal@users.noreply.github.com> * Configurable EIP3607 check --------- Co-authored-by: cokicm Co-authored-by: Goran Rojovic <100121253+goran-ethernal@users.noreply.github.com> --- chain/params.go | 6 +++++- state/executor.go | 18 ++++++++++++++++++ tests/state_test_util.go | 20 ++++++++++++++++---- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/chain/params.go b/chain/params.go index 5744aa60a4..646c18a56c 100644 --- a/chain/params.go +++ b/chain/params.go @@ -93,6 +93,7 @@ const ( EIP155 = "EIP155" Governance = "governance" EIP3855 = "EIP3855" + EIP3607 = "EIP3607" ) // Forks is map which contains all forks and their starting blocks from genesis @@ -130,6 +131,7 @@ func (f *Forks) At(block uint64) ForksInTime { EIP155: f.IsActive(EIP155, block), Governance: f.IsActive(Governance, block), EIP3855: f.IsActive(EIP3855, block), + EIP3607: f.IsActive(EIP3607, block), } } @@ -181,7 +183,8 @@ type ForksInTime struct { EIP158, EIP155, Governance, - EIP3855 bool + EIP3855, + EIP3607 bool } // AllForksEnabled should contain all supported forks by current edge version @@ -197,4 +200,5 @@ var AllForksEnabled = &Forks{ London: NewFork(0), Governance: NewFork(0), EIP3855: NewFork(0), + EIP3607: NewFork(0), } diff --git a/state/executor.go b/state/executor.go index 5acc7de3f6..aaa31cabdc 100644 --- a/state/executor.go +++ b/state/executor.go @@ -425,8 +425,25 @@ func (t *Transition) Txn() *Txn { return t.state } +// checkSenderAccount rejects transactions from senders with deployed code. +// This check is performed only in case EIP 3607 is enabled. +func (t Transition) checkSenderAccount(msg *types.Transaction) bool { + if !t.config.EIP3607 { + return true + } + + codeHash := t.state.GetCodeHash(msg.From) + + return codeHash == types.ZeroHash || codeHash == types.EmptyCodeHash +} + // Apply applies a new transaction func (t *Transition) Apply(msg *types.Transaction) (*runtime.ExecutionResult, error) { + if !t.checkSenderAccount(msg) { + return nil, fmt.Errorf("%w: address %v, codehash: %v", ErrSenderNoEOA, msg.From.String(), + t.state.GetCodeHash(msg.From).String()) + } + s := t.state.Snapshot() result, err := t.apply(msg) @@ -516,6 +533,7 @@ func (t *Transition) checkDynamicFees(msg *types.Transaction) error { var ( ErrNonceIncorrect = errors.New("incorrect nonce") + ErrSenderNoEOA = errors.New("sender not an eoa") ErrNotEnoughFundsForGas = errors.New("not enough funds to cover gas costs") ErrBlockLimitReached = errors.New("gas limit reached in the pool") ErrIntrinsicGasOverflow = errors.New("overflow in intrinsic gas calculation") diff --git a/tests/state_test_util.go b/tests/state_test_util.go index 0f09383aba..b0bf7d3f72 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -421,21 +421,27 @@ func (t *stTransaction) UnmarshalJSON(input []byte) error { // forks var Forks = map[string]*chain.Forks{ - "Frontier": {}, + "Frontier": { + chain.EIP3607: chain.NewFork(0), + }, "Homestead": { + chain.EIP3607: chain.NewFork(0), chain.Homestead: chain.NewFork(0), }, "EIP150": { + chain.EIP3607: chain.NewFork(0), chain.Homestead: chain.NewFork(0), chain.EIP150: chain.NewFork(0), }, "EIP158": { + chain.EIP3607: chain.NewFork(0), chain.Homestead: chain.NewFork(0), chain.EIP150: chain.NewFork(0), chain.EIP155: chain.NewFork(0), chain.EIP158: chain.NewFork(0), }, "Byzantium": { + chain.EIP3607: chain.NewFork(0), chain.Homestead: chain.NewFork(0), chain.EIP150: chain.NewFork(0), chain.EIP155: chain.NewFork(0), @@ -443,6 +449,7 @@ var Forks = map[string]*chain.Forks{ chain.Byzantium: chain.NewFork(0), }, "Constantinople": { + chain.EIP3607: chain.NewFork(0), chain.Homestead: chain.NewFork(0), chain.EIP150: chain.NewFork(0), chain.EIP155: chain.NewFork(0), @@ -458,6 +465,7 @@ var Forks = map[string]*chain.Forks{ chain.Byzantium: chain.NewFork(0), chain.Constantinople: chain.NewFork(0), chain.Petersburg: chain.NewFork(0), + chain.EIP3607: chain.NewFork(0), }, "Istanbul": { chain.Homestead: chain.NewFork(0), @@ -468,18 +476,19 @@ var Forks = map[string]*chain.Forks{ chain.Constantinople: chain.NewFork(0), chain.Petersburg: chain.NewFork(0), chain.Istanbul: chain.NewFork(0), + chain.EIP3607: chain.NewFork(0), }, "FrontierToHomesteadAt5": { + chain.EIP3607: chain.NewFork(0), chain.Homestead: chain.NewFork(5), }, "HomesteadToEIP150At5": { + chain.EIP3607: chain.NewFork(0), chain.Homestead: chain.NewFork(0), chain.EIP150: chain.NewFork(5), }, - "HomesteadToDaoAt5": { - chain.Homestead: chain.NewFork(0), - }, "EIP158ToByzantiumAt5": { + chain.EIP3607: chain.NewFork(0), chain.Homestead: chain.NewFork(0), chain.EIP150: chain.NewFork(0), chain.EIP155: chain.NewFork(0), @@ -487,6 +496,7 @@ var Forks = map[string]*chain.Forks{ chain.Byzantium: chain.NewFork(5), }, "ByzantiumToConstantinopleAt5": { + chain.EIP3607: chain.NewFork(0), chain.Homestead: chain.NewFork(0), chain.EIP150: chain.NewFork(0), chain.EIP155: chain.NewFork(0), @@ -495,6 +505,7 @@ var Forks = map[string]*chain.Forks{ chain.Constantinople: chain.NewFork(5), }, "ByzantiumToConstantinopleFixAt5": { + chain.EIP3607: chain.NewFork(0), chain.Homestead: chain.NewFork(0), chain.EIP150: chain.NewFork(0), chain.EIP155: chain.NewFork(0), @@ -504,6 +515,7 @@ var Forks = map[string]*chain.Forks{ chain.Petersburg: chain.NewFork(5), }, "ConstantinopleFixToIstanbulAt5": { + chain.EIP3607: chain.NewFork(0), chain.Homestead: chain.NewFork(0), chain.EIP150: chain.NewFork(0), chain.EIP155: chain.NewFork(0),