Skip to content

Commit 0618310

Browse files
marioevzEikix
authored andcommitted
simulators/ethereum/engine: Add London non-zero-number test (ethereum#867)
1 parent 5f398bf commit 0618310

File tree

5 files changed

+63
-0
lines changed

5 files changed

+63
-0
lines changed

simulators/ethereum/engine/config/fork.go

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func (f Fork) PreviousFork() Fork {
2727
}
2828

2929
type ForkConfig struct {
30+
LondonNumber *big.Int
3031
ShanghaiTimestamp *big.Int
3132
CancunTimestamp *big.Int
3233
}

simulators/ethereum/engine/main.go

+3
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ func makeRunner(tests []test.Spec, nodeType string) func(t *hivesim.T) {
141141

142142
// Configure Forks
143143
newParams := globals.DefaultClientEnv.Set("HIVE_TERMINAL_TOTAL_DIFFICULTY", fmt.Sprintf("%d", ttd))
144+
if forkConfig.LondonNumber != nil {
145+
newParams = newParams.Set("HIVE_FORK_LONDON", fmt.Sprintf("%d", forkConfig.LondonNumber))
146+
}
144147
if forkConfig.ShanghaiTimestamp != nil {
145148
newParams = newParams.Set("HIVE_SHANGHAI_TIMESTAMP", fmt.Sprintf("%d", forkConfig.ShanghaiTimestamp))
146149
// Ensure the merge transition is activated before shanghai.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package suite_engine
2+
3+
import (
4+
"github.com/ethereum/go-ethereum/common"
5+
"github.com/ethereum/hive/simulators/ethereum/engine/clmock"
6+
"github.com/ethereum/hive/simulators/ethereum/engine/config"
7+
"github.com/ethereum/hive/simulators/ethereum/engine/test"
8+
)
9+
10+
// Runs a sanity test on a post Merge fork where a previous fork's (London) number is not zero
11+
type NonZeroPreMergeFork struct {
12+
test.BaseSpec
13+
}
14+
15+
func (s NonZeroPreMergeFork) WithMainFork(fork config.Fork) test.Spec {
16+
specCopy := s
17+
specCopy.MainFork = fork
18+
return specCopy
19+
}
20+
21+
func (b NonZeroPreMergeFork) GetName() string {
22+
return "Pre-Merge Fork Number > 0"
23+
}
24+
25+
func (s NonZeroPreMergeFork) GetForkConfig() *config.ForkConfig {
26+
forkConfig := s.BaseSpec.GetForkConfig()
27+
if forkConfig == nil {
28+
return nil
29+
}
30+
forkConfig.LondonNumber = common.Big1
31+
return forkConfig
32+
}
33+
34+
func (b NonZeroPreMergeFork) Execute(t *test.Env) {
35+
// Wait until TTD is reached by this client
36+
t.CLMock.WaitForTTD()
37+
38+
// Simply produce a couple of blocks without transactions (if London is not active at genesis
39+
// we can't send type-2 transactions) and check that the chain progresses without issues
40+
t.CLMock.ProduceBlocks(5, clmock.BlockProcessCallbacks{})
41+
}

simulators/ethereum/engine/suites/engine/tests.go

+9
Original file line numberDiff line numberDiff line change
@@ -406,4 +406,13 @@ func init() {
406406
}
407407
}
408408
}
409+
410+
// Misc Tests
411+
Tests = append(Tests,
412+
NonZeroPreMergeFork{
413+
BaseSpec: test.BaseSpec{
414+
ForkHeight: 1,
415+
},
416+
},
417+
)
409418
}

simulators/ethereum/engine/suites/withdrawals/tests.go

+9
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/ethereum/hive/simulators/ethereum/engine/config"
2020
"github.com/ethereum/hive/simulators/ethereum/engine/globals"
2121
"github.com/ethereum/hive/simulators/ethereum/engine/helper"
22+
suite_engine "github.com/ethereum/hive/simulators/ethereum/engine/suites/engine"
2223
"github.com/ethereum/hive/simulators/ethereum/engine/test"
2324
typ "github.com/ethereum/hive/simulators/ethereum/engine/types"
2425
)
@@ -814,6 +815,14 @@ var Tests = []test.Spec{
814815
},
815816
},
816817
},
818+
819+
// TODO: Remove since this will be automatically inherited when this test suite is refactored
820+
suite_engine.NonZeroPreMergeFork{
821+
BaseSpec: test.BaseSpec{
822+
MainFork: config.Shanghai,
823+
ForkHeight: 1,
824+
},
825+
},
817826
}
818827

819828
// Helper types to convert gwei into wei more easily

0 commit comments

Comments
 (0)