Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simulators/ethereum/engine: Add London non-zero-number test #867

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -141,6 +141,9 @@ func makeRunner(tests []test.Spec, nodeType string) func(t *hivesim.T) {

// 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