Skip to content

Commit

Permalink
simulators/ethereum/engine: Add London non-zero-number test
Browse files Browse the repository at this point in the history
  • Loading branch information
marioevz committed Sep 17, 2023
1 parent fc5f2c0 commit 220e9d8
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions simulators/ethereum/engine/config/fork.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func (f Fork) PreviousFork() Fork {
}

type ForkConfig struct {
LondonNumber *big.Int
ShanghaiTimestamp *big.Int
CancunTimestamp *big.Int
}
Expand Down
3 changes: 3 additions & 0 deletions simulators/ethereum/engine/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ func addTestsToSuite(sim *hivesim.Simulation, suite *hivesim.Suite, tests []test

// Configure Forks
newParams := globals.DefaultClientEnv.Set("HIVE_TERMINAL_TOTAL_DIFFICULTY", fmt.Sprintf("%d", ttd))
if forkConfig.LondonNumber != nil {
newParams = newParams.Set("HIVE_FORK_LONDON", fmt.Sprintf("%d", forkConfig.LondonNumber))
}
if forkConfig.ShanghaiTimestamp != nil {
newParams = newParams.Set("HIVE_SHANGHAI_TIMESTAMP", fmt.Sprintf("%d", forkConfig.ShanghaiTimestamp))
// Ensure the merge transition is activated before shanghai.
Expand Down
41 changes: 41 additions & 0 deletions simulators/ethereum/engine/suites/engine/misc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package suite_engine

import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/hive/simulators/ethereum/engine/clmock"
"github.com/ethereum/hive/simulators/ethereum/engine/config"
"github.com/ethereum/hive/simulators/ethereum/engine/test"
)

// Runs a sanity test on a post Merge fork where a previous fork's (London) number is not zero
type NonZeroPreMergeFork struct {
test.BaseSpec
}

func (s NonZeroPreMergeFork) WithMainFork(fork config.Fork) test.Spec {
specCopy := s
specCopy.MainFork = fork
return specCopy
}

func (b NonZeroPreMergeFork) GetName() string {
return "Pre-Merge Fork Number > 0"
}

func (s NonZeroPreMergeFork) GetForkConfig() *config.ForkConfig {
forkConfig := s.BaseSpec.GetForkConfig()
if forkConfig == nil {
return nil
}
forkConfig.LondonNumber = common.Big1
return forkConfig
}

func (b NonZeroPreMergeFork) Execute(t *test.Env) {
// Wait until TTD is reached by this client
t.CLMock.WaitForTTD()

// Simply produce a couple of blocks without transactions (if London is not active at genesis
// we can't send type-2 transactions) and check that the chain progresses without issues
t.CLMock.ProduceBlocks(5, clmock.BlockProcessCallbacks{})
}
9 changes: 9 additions & 0 deletions simulators/ethereum/engine/suites/engine/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,4 +406,13 @@ func init() {
}
}
}

// Misc Tests
Tests = append(Tests,
NonZeroPreMergeFork{
BaseSpec: test.BaseSpec{
ForkHeight: 1,
},
},
)
}
9 changes: 9 additions & 0 deletions simulators/ethereum/engine/suites/withdrawals/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/ethereum/hive/simulators/ethereum/engine/config"
"github.com/ethereum/hive/simulators/ethereum/engine/globals"
"github.com/ethereum/hive/simulators/ethereum/engine/helper"
suite_engine "github.com/ethereum/hive/simulators/ethereum/engine/suites/engine"
"github.com/ethereum/hive/simulators/ethereum/engine/test"
typ "github.com/ethereum/hive/simulators/ethereum/engine/types"
)
Expand Down Expand Up @@ -814,6 +815,14 @@ var Tests = []test.Spec{
},
},
},

// TODO: Remove since this will be automatically inherited when this test suite is refactored
suite_engine.NonZeroPreMergeFork{
BaseSpec: test.BaseSpec{
MainFork: config.Shanghai,
ForkHeight: 1,
},
},
}

// Helper types to convert gwei into wei more easily
Expand Down

0 comments on commit 220e9d8

Please sign in to comment.