From c30dd4246d025ff52dc5542f19db1ab0b8439333 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 3 Jan 2025 21:00:02 +0100 Subject: [PATCH] simulators/ethereum/engine: remove terminal total difficulty (#1186) * simulators/ethereum/engine: WIP removing terminal total difficulty * simulators/ethereum/engine: upgrade to go-ethereum v1.14.12 * simulators/ethereum/engine: WIP removing ttd * simulators/ethereum/engine: call InitChain at start of test * simulators/ethereum/engine: remove ttd in main * simulators/ethereum/engine: remove configurability of london and merge fork * simulators/ethereum/engine: fixup * simulators/ethereum/engine: fixup genesis * simulators/ethereum/engine: add comment * simulators/ethereum/engine: change difficulty check * simulators/ethereum/engine/config/cancun: fix deprecation warning * simulators/ethereum/engine/config: remove even more config support --- simulators/ethereum/engine/client/engine.go | 4 - .../engine/client/hive_rpc/hive_rpc.go | 65 ++----------- .../ethereum/engine/client/node/node.go | 95 ++++--------------- simulators/ethereum/engine/clmock/clmock.go | 61 ++---------- .../ethereum/engine/config/cancun/genesis.go | 3 +- simulators/ethereum/engine/config/fork.go | 2 - simulators/ethereum/engine/config/genesis.go | 19 +--- simulators/ethereum/engine/go.mod | 27 +++--- simulators/ethereum/engine/go.sum | 46 ++++----- simulators/ethereum/engine/helper/helper.go | 89 ----------------- simulators/ethereum/engine/init/genesis.json | 3 +- simulators/ethereum/engine/main.go | 26 ++--- .../ethereum/engine/suites/auth/tests.go | 2 +- .../ethereum/engine/suites/cancun/config.go | 3 - .../ethereum/engine/suites/engine/bad_hash.go | 6 -- .../ethereum/engine/suites/engine/fork_id.go | 9 -- .../engine/suites/engine/forkchoice.go | 6 -- .../engine/suites/engine/invalid_ancestor.go | 7 -- .../engine/suites/engine/invalid_payload.go | 9 -- .../ethereum/engine/suites/engine/misc.go | 50 ---------- .../suites/engine/payload_attributes.go | 3 - .../engine/suites/engine/payload_execution.go | 15 --- .../engine/suites/engine/payload_id.go | 3 - .../engine/suites/engine/prev_randao.go | 2 - .../ethereum/engine/suites/engine/reorg.go | 18 ---- .../ethereum/engine/suites/engine/rpc.go | 3 - .../suites/engine/suggested_fee_recipient.go | 3 - .../ethereum/engine/suites/engine/tests.go | 10 -- .../engine/suites/engine/versioning.go | 3 - .../ethereum/engine/suites/sync/tests.go | 16 +--- .../engine/suites/withdrawals/tests.go | 14 --- simulators/ethereum/engine/test/env.go | 14 ++- simulators/ethereum/engine/test/spec.go | 11 --- simulators/ethereum/engine/types/types.go | 2 +- 34 files changed, 92 insertions(+), 557 deletions(-) delete mode 100644 simulators/ethereum/engine/suites/engine/misc.go diff --git a/simulators/ethereum/engine/client/engine.go b/simulators/ethereum/engine/client/engine.go index a330511c6c..370995a971 100644 --- a/simulators/ethereum/engine/client/engine.go +++ b/simulators/ethereum/engine/client/engine.go @@ -72,10 +72,6 @@ type EngineClient interface { GetNextAccountNonce(testCtx context.Context, account common.Address, head *types.Header) (uint64, error) UpdateNonce(testCtx context.Context, account common.Address, newNonce uint64) error - // TTD Methods - TerminalTotalDifficulty() *big.Int - GetTotalDifficulty(context.Context) (*big.Int, error) - // Test Methods PostRunVerifications() error diff --git a/simulators/ethereum/engine/client/hive_rpc/hive_rpc.go b/simulators/ethereum/engine/client/hive_rpc/hive_rpc.go index 7d1c79a630..fe037ff8fc 100644 --- a/simulators/ethereum/engine/client/hive_rpc/hive_rpc.go +++ b/simulators/ethereum/engine/client/hive_rpc/hive_rpc.go @@ -2,7 +2,6 @@ package hive_rpc import ( "context" - "encoding/json" "fmt" "math/big" "net" @@ -30,12 +29,11 @@ import ( type HiveRPCEngineStarter struct { // Client parameters used to launch the default client - ClientType string - ChainFile string - TerminalTotalDifficulty *big.Int - EnginePort int - EthPort int - JWTSecret []byte + ClientType string + ChainFile string + EnginePort int + EthPort int + JWTSecret []byte } var _ client.EngineStarter = (*HiveRPCEngineStarter)(nil) @@ -46,7 +44,6 @@ func (s HiveRPCEngineStarter) StartClient(T *hivesim.T, testContext context.Cont enginePort = s.EnginePort ethPort = s.EthPort jwtSecret = s.JWTSecret - ttd = s.TerminalTotalDifficulty ) if clientType == "" { cs, err := T.Sim.ClientTypes() @@ -70,20 +67,6 @@ func (s HiveRPCEngineStarter) StartClient(T *hivesim.T, testContext context.Cont if s.ChainFile != "" { ClientFiles = ClientFiles.Set("/chain.rlp", "./chains/"+s.ChainFile) } - if ttd == nil { - if ttdStr, ok := ClientParams["HIVE_TERMINAL_TOTAL_DIFFICULTY"]; ok { - // Retrieve TTD from parameters - ttd, ok = new(big.Int).SetString(ttdStr, 10) - if !ok { - return nil, fmt.Errorf("unable to parse TTD from parameters") - } - } - } else { - // Real TTD must be calculated adding the genesis difficulty - ttdInt := helper.CalculateRealTTD(genesis, ttd.Int64()) - ClientParams = ClientParams.Set("HIVE_TERMINAL_TOTAL_DIFFICULTY", fmt.Sprintf("%d", ttdInt)) - ttd = big.NewInt(ttdInt) - } if len(bootClients) > 0 { var ( enodes = make([]string, len(bootClients)) @@ -108,7 +91,7 @@ func (s HiveRPCEngineStarter) StartClient(T *hivesim.T, testContext context.Cont if err := CheckEthEngineLive(c); err != nil { return nil, fmt.Errorf("Engine/Eth ports were never open for client: %v", err) } - ec := NewHiveRPCEngineClient(c, enginePort, ethPort, jwtSecret, ttd, &helper.LoggingRoundTrip{ + ec := NewHiveRPCEngineClient(c, enginePort, ethPort, jwtSecret, &helper.LoggingRoundTrip{ Logger: T, ID: c.Container, Inner: http.DefaultTransport, @@ -154,7 +137,6 @@ type HiveRPCEngineClient struct { h *hivesim.Client c *rpc.Client cEth *rpc.Client - ttd *big.Int JWTSecretBytes []byte // Engine updates info @@ -173,7 +155,7 @@ type HiveRPCEngineClient struct { var _ client.EngineClient = (*HiveRPCEngineClient)(nil) // NewClient creates a engine client that uses the given RPC client. -func NewHiveRPCEngineClient(h *hivesim.Client, enginePort int, ethPort int, jwtSecretBytes []byte, ttd *big.Int, transport http.RoundTripper) *HiveRPCEngineClient { +func NewHiveRPCEngineClient(h *hivesim.Client, enginePort int, ethPort int, jwtSecretBytes []byte, transport http.RoundTripper) *HiveRPCEngineClient { // Prepare HTTP Client httpClient := rpc.WithHTTPClient(&http.Client{Transport: transport}) @@ -193,7 +175,6 @@ func NewHiveRPCEngineClient(h *hivesim.Client, enginePort int, ethPort int, jwtS c: engineRpcClient, Client: eth, cEth: ethRpcClient, - ttd: ttd, JWTSecretBytes: jwtSecretBytes, accTxInfoMap: make(map[common.Address]*AccountTransactionInfo), } @@ -207,10 +188,6 @@ func (ec *HiveRPCEngineClient) EnodeURL() (string, error) { return ec.h.EnodeURL() } -func (ec *HiveRPCEngineClient) TerminalTotalDifficulty() *big.Int { - return ec.ttd -} - var ( Head *big.Int // Nil Pending = big.NewInt(-2) @@ -275,34 +252,6 @@ func (ec *HiveRPCEngineClient) HeaderByNumber(ctx context.Context, number *big.I return header, err } -// Helper structs to fetch the TotalDifficulty -type TD struct { - TotalDifficulty *hexutil.Big `json:"totalDifficulty"` -} -type TotalDifficultyHeader struct { - types.Header - TD -} - -func (tdh *TotalDifficultyHeader) UnmarshalJSON(data []byte) error { - if err := json.Unmarshal(data, &tdh.Header); err != nil { - return err - } - if err := json.Unmarshal(data, &tdh.TD); err != nil { - return err - } - return nil -} - -func (ec *HiveRPCEngineClient) GetTotalDifficulty(ctx context.Context) (*big.Int, error) { - var td *TotalDifficultyHeader - if err := ec.cEth.CallContext(ctx, &td, "eth_getBlockByNumber", "latest", false); err == nil { - return td.TotalDifficulty.ToInt(), nil - } else { - return nil, err - } -} - func (ec *HiveRPCEngineClient) Close() error { ec.c.Close() ec.Client.Close() diff --git a/simulators/ethereum/engine/client/node/node.go b/simulators/ethereum/engine/client/node/node.go index 75f88952af..3acdd10cd3 100644 --- a/simulators/ethereum/engine/client/node/node.go +++ b/simulators/ethereum/engine/client/node/node.go @@ -27,12 +27,10 @@ import ( "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/p2p/enode" - "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/hive/hivesim" "github.com/ethereum/hive/simulators/ethereum/engine/client" - "github.com/ethereum/hive/simulators/ethereum/engine/helper" typ "github.com/ethereum/hive/simulators/ethereum/engine/types" "github.com/pkg/errors" ) @@ -53,8 +51,7 @@ type GethNodeTestConfiguration struct { } type GethNodeEngineStarter struct { // Client parameters used to launch the default client - ChainFile string - TerminalTotalDifficulty *big.Int + ChainFile string // Test specific configuration Config GethNodeTestConfiguration @@ -69,29 +66,7 @@ func (s GethNodeEngineStarter) StartClient(T *hivesim.T, testContext context.Con } func (s GethNodeEngineStarter) StartGethNode(T *hivesim.T, testContext context.Context, genesis *core.Genesis, ClientParams hivesim.Params, ClientFiles hivesim.Params, bootClients ...client.EngineClient) (*GethNode, error) { - var ( - ttd = s.TerminalTotalDifficulty - err error - ) - - if ttd == nil { - if ttdStr, ok := ClientParams["HIVE_TERMINAL_TOTAL_DIFFICULTY"]; ok { - // Retrieve TTD from parameters - ttd, ok = new(big.Int).SetString(ttdStr, 10) - if !ok { - return nil, fmt.Errorf("Unable to parse TTD from parameters") - } - } - } else { - ttd = big.NewInt(helper.CalculateRealTTD(genesis, ttd.Int64())) - ClientParams = ClientParams.Set("HIVE_TERMINAL_TOTAL_DIFFICULTY", fmt.Sprintf("%d", ttd)) - } - - // Not sure if this hack works - genesisCopy := *genesis - configCopy := *genesisCopy.Config - configCopy.TerminalTotalDifficulty = ttd - genesisCopy.Config = &configCopy + var err error var enodes []string if bootClients != nil && len(bootClients) > 0 { @@ -116,7 +91,7 @@ func (s GethNodeEngineStarter) StartGethNode(T *hivesim.T, testContext context.C } } - g, err := newNode(s.Config, enodes, &genesisCopy) + g, err := newNode(s.Config, enodes, genesis) if err != nil { return nil, err } @@ -138,6 +113,7 @@ type AccountTransactionInfo struct { PreviousBlock common.Hash PreviousNonce uint64 } + type GethNode struct { node *node.Node eth *eth.Ethereum @@ -146,7 +122,6 @@ type GethNode struct { datadir string genesis *core.Genesis - ttd *big.Int api *ethcatalyst.ConsensusAPI running context.Context closing context.CancelFunc @@ -183,7 +158,6 @@ func restart(startConfig GethNodeTestConfiguration, bootnodes []string, datadir } config := &node.Config{ Name: startConfig.Name, - Version: params.Version, DataDir: datadir, P2P: p2p.Config{ ListenAddr: "0.0.0.0:0", @@ -200,22 +174,16 @@ func restart(startConfig GethNodeTestConfiguration, bootnodes []string, datadir if genesis == nil || genesis.Config == nil { return nil, fmt.Errorf("genesis configuration is nil") } - if genesis.Config.TerminalTotalDifficultyPassed == false { - return nil, fmt.Errorf("genesis configuration is has not passed terminal total difficulty") - } econfig := ðconfig.Config{ - Genesis: genesis, - NetworkId: genesis.Config.ChainID.Uint64(), - SyncMode: downloader.FullSync, - DatabaseCache: 256, - DatabaseHandles: 256, - StateScheme: rawdb.PathScheme, - TxPool: ethconfig.Defaults.TxPool, - GPO: ethconfig.Defaults.GPO, - Miner: ethconfig.Defaults.Miner, - LightServ: 100, - LightPeers: int(startConfig.MaxPeers.Int64()) - 1, - LightNoSyncServe: true, + Genesis: genesis, + NetworkId: genesis.Config.ChainID.Uint64(), + SyncMode: downloader.FullSync, + DatabaseCache: 256, + DatabaseHandles: 256, + StateScheme: rawdb.PathScheme, + TxPool: ethconfig.Defaults.TxPool, + GPO: ethconfig.Defaults.GPO, + Miner: ethconfig.Defaults.Miner, } ethBackend, err := eth.New(stack, econfig) if err != nil { @@ -248,7 +216,6 @@ func restart(startConfig GethNodeTestConfiguration, bootnodes []string, datadir eth: ethBackend, datadir: datadir, genesis: genesis, - ttd: genesis.Config.TerminalTotalDifficulty, api: ethcatalyst.NewConsensusAPI(ethBackend), accTxInfoMap: make(map[common.Address]*AccountTransactionInfo), // Test related configuration @@ -352,7 +319,7 @@ type validator struct{} func (v *validator) ValidateBody(block *types.Block) error { return nil } -func (v *validator) ValidateState(block *types.Block, state *state.StateDB, receipts types.Receipts, usedGas uint64, stateless bool) error { +func (v *validator) ValidateState(block *types.Block, state *state.StateDB, result *core.ProcessResult, stateless bool) error { return nil } func (v *validator) ValidateWitness(witness *stateless.Witness, receiptRoot common.Hash, stateRoot common.Hash) error { @@ -361,8 +328,8 @@ func (v *validator) ValidateWitness(witness *stateless.Witness, receiptRoot comm type processor struct{} -func (p *processor) Process(block *types.Block, statedb *state.StateDB, cfg vm.Config) (types.Receipts, []*types.Log, uint64, error) { - return types.Receipts{}, []*types.Log{}, 21000, nil +func (p *processor) Process(block *types.Block, statedb *state.StateDB, cfg vm.Config) (*core.ProcessResult, error) { + return &core.ProcessResult{GasUsed: 21000}, nil } var headerPrefix = []byte("h") // headerPrefix + num (uint64 big endian) + hash -> header @@ -396,17 +363,17 @@ func (n *GethNode) SetBlock(block *types.Block, parentNumber uint64, parentRoot bc := n.eth.BlockChain() bc.SetBlockValidatorAndProcessorForTesting(new(validator), n.eth.BlockChain().Processor()) - statedb, err := state.New(parentRoot, bc.StateCache(), bc.Snapshots()) + statedb, err := state.New(parentRoot, bc.StateCache()) if err != nil { return errors.Wrap(err, "failed to create state db") } statedb.StartPrefetcher("chain", nil) var failedProcessing bool - receipts, _, _, err := n.eth.BlockChain().Processor().Process(block, statedb, *n.eth.BlockChain().GetVMConfig()) + result, err := n.eth.BlockChain().Processor().Process(block, statedb, *n.eth.BlockChain().GetVMConfig()) if err != nil { failedProcessing = true } - rawdb.WriteReceipts(db, block.Hash(), block.NumberU64(), receipts) + rawdb.WriteReceipts(db, block.Hash(), block.NumberU64(), result.Receipts) root, err := statedb.Commit(block.NumberU64(), false) if err != nil { return errors.Wrap(err, "failed to commit state") @@ -681,7 +648,7 @@ func (n *GethNode) getStateDB(ctx context.Context, blockNumber *big.Int) (*state if err != nil { return nil, err } - return state.New(b.Root(), n.eth.BlockChain().StateCache(), n.eth.BlockChain().Snapshots()) + return state.New(b.Root(), n.eth.BlockChain().StateCache()) } func (n *GethNode) BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error) { @@ -724,28 +691,6 @@ func (n *GethNode) PendingTransactionCount(ctx context.Context) (uint, error) { panic("NOT IMPLEMENTED") } -func (n *GethNode) GetBlockTotalDifficulty(ctx context.Context, hash common.Hash) (*big.Int, error) { - block := n.eth.BlockChain().GetBlockByHash(hash) - if block == nil { - return big.NewInt(0), nil - } - return n.eth.BlockChain().GetTd(hash, block.NumberU64()), nil -} - -func (n *GethNode) GetTotalDifficulty(ctx context.Context) (*big.Int, error) { - if n.mustHeadBlock != nil { - return n.GetBlockTotalDifficulty(ctx, n.mustHeadBlock.Hash()) - } - return n.GetBlockTotalDifficulty(ctx, n.eth.BlockChain().CurrentHeader().Hash()) -} - -func (n *GethNode) TerminalTotalDifficulty() *big.Int { - if n.ttd != nil { - return n.ttd - } - return n.genesis.Config.TerminalTotalDifficulty -} - func (n *GethNode) EnodeURL() (string, error) { return n.node.Server().NodeInfo().Enode, nil } diff --git a/simulators/ethereum/engine/clmock/clmock.go b/simulators/ethereum/engine/clmock/clmock.go index b58c5aa18a..f66f1673b7 100644 --- a/simulators/ethereum/engine/clmock/clmock.go +++ b/simulators/ethereum/engine/clmock/clmock.go @@ -4,7 +4,6 @@ import ( "context" "crypto/sha256" "encoding/binary" - "encoding/json" "fmt" "math/big" "math/rand" @@ -18,7 +17,6 @@ import ( "github.com/ethereum/hive/simulators/ethereum/engine/config" "github.com/ethereum/hive/simulators/ethereum/engine/config/cancun" "github.com/ethereum/hive/simulators/ethereum/engine/globals" - "github.com/ethereum/hive/simulators/ethereum/engine/helper" typ "github.com/ethereum/hive/simulators/ethereum/engine/types" "github.com/ethereum/go-ethereum/common" @@ -67,6 +65,7 @@ func (h ExecutableDataHistory) LatestWithdrawalsIndex() uint64 { // Consensus Layer Client Mock used to sync the Execution Clients once the TTD has been reached type CLMocker struct { *hivesim.T + // List of Engine Clients being served by the CL Mocker EngineClients []client.EngineClient // Lock required so no client is offboarded during block production. @@ -111,7 +110,6 @@ type CLMocker struct { // Merge related FirstPoSBlockNumber *big.Int - TTDReached bool TransitionPayloadTimestamp *big.Int SafeSlotsToImportOptimistically *big.Int ChainTotalDifficulty *big.Int @@ -148,18 +146,16 @@ func NewCLMocker(t *hivesim.T, genesis *core.Genesis, forkConfig *config.ForkCon LatestHeader: nil, FirstPoSBlockNumber: nil, LatestHeadNumber: nil, - TTDReached: false, NextFeeRecipient: common.Address{}, LatestForkchoice: api.ForkchoiceStateV1{ HeadBlockHash: common.Hash{}, SafeBlockHash: common.Hash{}, FinalizedBlockHash: common.Hash{}, }, - ChainTotalDifficulty: genesis.Difficulty, - ForkConfig: forkConfig, - Genesis: genesis, - TestContext: context.Background(), - Rand: randSource, + ForkConfig: forkConfig, + Genesis: genesis, + TestContext: context.Background(), + Rand: randSource, } // Create header history @@ -180,6 +176,7 @@ func (cl *CLMocker) GenesisBlock() *types.Block { func (cl *CLMocker) AddEngineClient(ec client.EngineClient) { cl.EngineClientsLock.Lock() defer cl.EngineClientsLock.Unlock() + cl.Logf("CLMocker: Adding engine client %v", ec.ID()) cl.EngineClients = append(cl.EngineClients, ec) } @@ -261,8 +258,8 @@ func (cl *CLMocker) GetHeaders(amount uint64, originHash common.Hash, originNumb return headers, nil } -// Sets the specified client's chain head as Terminal PoW block by sending the initial forkchoiceUpdated. -func (cl *CLMocker) SetTTDBlockClient(ec client.EngineClient) { +// InitChain sets the test chain head block and initial forkchoiceUpdated. +func (cl *CLMocker) InitChain(ec client.EngineClient) { var err error ctx, cancel := context.WithTimeout(cl.TestContext, globals.RPCTimeout) defer cancel() @@ -273,22 +270,10 @@ func (cl *CLMocker) SetTTDBlockClient(ec client.EngineClient) { } cl.HeaderHistory[cl.LatestHeader.Number.Uint64()] = cl.LatestHeader - ctx, cancel = context.WithTimeout(cl.TestContext, globals.RPCTimeout) - defer cancel() - - if td, err := ec.GetTotalDifficulty(ctx); err != nil { - cl.Fatalf("CLMocker: Error getting total difficulty from engine client: %v", err) - } else if td.Cmp(ec.TerminalTotalDifficulty()) < 0 { - cl.Fatalf("CLMocker: Attempted to set TTD Block when TTD had not been reached: %d > %d", ec.TerminalTotalDifficulty(), td) - } else { - cl.Logf("CLMocker: TTD has been reached at block %d (%d>=%d)\n", cl.LatestHeader.Number, td, ec.TerminalTotalDifficulty()) - jsH, _ := json.MarshalIndent(cl.LatestHeader, "", " ") - cl.Logf("CLMocker: Client: %s, Block %d: %s\n", ec.ID(), cl.LatestHeader.Number, jsH) - cl.ChainTotalDifficulty = td + if cl.LatestHeader.Difficulty.Cmp(cl.Genesis.Difficulty) != 0 { + cl.Fatalf("CLMocker: invalid difficulty %d on latest header, expected", cl.LatestHeader.Difficulty, cl.Genesis.Difficulty) } - cl.TTDReached = true - // Reset transition values cl.LatestHeadNumber = cl.LatestHeader.Number cl.HeadHashHistory = []common.Hash{} @@ -297,26 +282,6 @@ func (cl *CLMocker) SetTTDBlockClient(ec client.EngineClient) { // Prepare initial forkchoice, to be sent to the transition payload producer cl.LatestForkchoice = api.ForkchoiceStateV1{} cl.LatestForkchoice.HeadBlockHash = cl.LatestHeader.Hash() - -} - -// This method waits for TTD in at least one of the clients, then sends the -// initial forkchoiceUpdated with the info obtained from the client. -func (cl *CLMocker) WaitForTTD() { - ec, err := helper.WaitAnyClientForTTD(cl.EngineClients, cl.TestContext) - if ec == nil || err != nil { - cl.Fatalf("CLMocker: Error while waiting for TTD: %v", err) - } - // One of the clients has reached TTD, send the initial fcU with this client as head - cl.SetTTDBlockClient(ec) -} - -// Check whether a block number is a PoS block -func (cl *CLMocker) IsBlockPoS(bn *big.Int) bool { - if cl.FirstPoSBlockNumber == nil || cl.FirstPoSBlockNumber.Cmp(bn) > 0 { - return false - } - return true } // Return the per-block timestamp value increment @@ -521,7 +486,6 @@ func (cl *CLMocker) GetNextPayload() { } func (cl *CLMocker) broadcastNextNewPayload() { - // Broadcast the executePayload to all clients version := cl.ForkConfig.NewPayloadVersion(cl.LatestPayloadBuilt.Timestamp) validations := 0 @@ -599,11 +563,6 @@ type BlockProcessCallbacks struct { } func (cl *CLMocker) ProduceSingleBlock(callbacks BlockProcessCallbacks) { - - if !cl.TTDReached { - cl.Fatalf("CLMocker: Attempted to create a block when the TTD had not yet been reached") - } - // Lock needed to ensure EngineClients is not modified mid block production cl.EngineClientsLock.Lock() defer cl.EngineClientsLock.Unlock() diff --git a/simulators/ethereum/engine/config/cancun/genesis.go b/simulators/ethereum/engine/config/cancun/genesis.go index d7f0dd607d..d3171a165a 100644 --- a/simulators/ethereum/engine/config/cancun/genesis.go +++ b/simulators/ethereum/engine/config/cancun/genesis.go @@ -6,6 +6,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/types" ) // ConfigGenesis configures the genesis block for the Cancun fork. @@ -67,7 +68,7 @@ func ConfigTestAccounts(genesis *core.Genesis) error { if _, ok := genesis.Alloc[address]; ok { panic(fmt.Errorf("reused address %s during genesis configuration for cancun", address.Hex())) } - genesis.Alloc[address] = core.GenesisAccount{ + genesis.Alloc[address] = types.Account{ Code: datahashCode, Balance: common.Big0, } diff --git a/simulators/ethereum/engine/config/fork.go b/simulators/ethereum/engine/config/fork.go index a02147f3db..04fe580245 100644 --- a/simulators/ethereum/engine/config/fork.go +++ b/simulators/ethereum/engine/config/fork.go @@ -30,8 +30,6 @@ func (f Fork) PreviousFork() Fork { } type ForkConfig struct { - LondonNumber *big.Int - ParisNumber *big.Int ShanghaiTimestamp *big.Int CancunTimestamp *big.Int } diff --git a/simulators/ethereum/engine/config/genesis.go b/simulators/ethereum/engine/config/genesis.go index 3436e2e44d..51444940c7 100644 --- a/simulators/ethereum/engine/config/genesis.go +++ b/simulators/ethereum/engine/config/genesis.go @@ -2,25 +2,17 @@ package config import ( "fmt" + "math/big" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/hive/simulators/ethereum/engine/config/cancun" ) func (f *ForkConfig) ConfigGenesis(genesis *core.Genesis) error { - if f.ParisNumber != nil { - genesis.Config.MergeNetsplitBlock = f.ParisNumber - if genesis.Number >= f.ParisNumber.Uint64() { - removePoW(genesis) - } - } + genesis.Config.MergeNetsplitBlock = big.NewInt(0) if f.ShanghaiTimestamp != nil { shanghaiTime := f.ShanghaiTimestamp.Uint64() genesis.Config.ShanghaiTime = &shanghaiTime - if genesis.Timestamp >= shanghaiTime { - removePoW(genesis) - } } if f.CancunTimestamp != nil { if err := cancun.ConfigGenesis(genesis, f.CancunTimestamp.Uint64()); err != nil { @@ -29,10 +21,3 @@ func (f *ForkConfig) ConfigGenesis(genesis *core.Genesis) error { } return nil } - -func removePoW(genesis *core.Genesis) { - genesis.Difficulty = common.Big0 - genesis.Config.TerminalTotalDifficulty = common.Big0 - genesis.Config.Clique = nil - genesis.ExtraData = []byte{} -} diff --git a/simulators/ethereum/engine/go.mod b/simulators/ethereum/engine/go.mod index 424e90d3e0..bc1ad87e13 100644 --- a/simulators/ethereum/engine/go.mod +++ b/simulators/ethereum/engine/go.mod @@ -1,16 +1,16 @@ module github.com/ethereum/hive/simulators/ethereum/engine -go 1.21 +go 1.22 -toolchain go1.22.1 +toolchain go1.23.4 require ( github.com/crate-crypto/go-kzg-4844 v1.0.0 github.com/davecgh/go-spew v1.1.1 - github.com/ethereum/go-ethereum v1.14.7 + github.com/ethereum/go-ethereum v1.14.12 github.com/ethereum/hive v0.0.0-20240715150147-c87a99dccfce - github.com/golang-jwt/jwt/v4 v4.5.0 - github.com/holiman/uint256 v1.3.0 + github.com/golang-jwt/jwt/v4 v4.5.1 + github.com/holiman/uint256 v1.3.1 github.com/pkg/errors v0.9.1 golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa ) @@ -21,14 +21,13 @@ require ( github.com/VictoriaMetrics/fastcache v1.12.2 // indirect github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect github.com/beorn7/perks v1.0.1 // indirect - github.com/bits-and-blooms/bitset v1.10.0 // indirect - github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect + github.com/bits-and-blooms/bitset v1.13.0 // indirect github.com/cespare/cp v1.1.1 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cockroachdb/errors v1.11.3 // indirect github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect - github.com/cockroachdb/pebble v1.1.1 // indirect + github.com/cockroachdb/pebble v1.1.2 // indirect github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect github.com/consensys/bavard v0.1.13 // indirect @@ -39,9 +38,8 @@ require ( github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect github.com/deepmap/oapi-codegen v1.12.4 // indirect github.com/ethereum/c-kzg-4844 v1.0.0 // indirect - github.com/ethereum/go-verkle v0.1.1-0.20240306133620-7d920df305f0 // indirect + github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 // indirect github.com/ferranbt/fastssz v0.1.2 // indirect - github.com/fjl/memsize v0.0.2 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect github.com/getsentry/sentry-go v0.27.0 // indirect @@ -87,24 +85,23 @@ require ( github.com/rs/cors v1.8.2 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/shirou/gopsutil v3.21.11+incompatible // indirect - github.com/status-im/keycard-go v0.2.0 // indirect - github.com/supranational/blst v0.3.11 // indirect + github.com/supranational/blst v0.3.13 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect - github.com/tyler-smith/go-bip39 v1.1.0 // indirect github.com/urfave/cli/v2 v2.25.7 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect github.com/yusufpapurcu/wmi v1.2.2 // indirect golang.org/x/crypto v0.22.0 // indirect golang.org/x/net v0.24.0 // indirect golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.20.0 // indirect + golang.org/x/sys v0.22.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.5.0 // indirect - google.golang.org/protobuf v1.33.0 // indirect + google.golang.org/protobuf v1.34.2 // indirect gopkg.in/inconshreveable/log15.v2 v2.0.0-20200109203555-b30bc20e4fd1 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect rsc.io/tmplfunc v0.0.3 // indirect ) diff --git a/simulators/ethereum/engine/go.sum b/simulators/ethereum/engine/go.sum index 26c9231dbc..afc335249d 100644 --- a/simulators/ethereum/engine/go.sum +++ b/simulators/ethereum/engine/go.sum @@ -12,13 +12,9 @@ github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7D github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bits-and-blooms/bitset v1.10.0 h1:ePXTeiPEazB5+opbv5fr8umg2R/1NlzgDsyepwsSr88= -github.com/bits-and-blooms/bitset v1.10.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= +github.com/bits-and-blooms/bitset v1.13.0 h1:bAQ9OPNFYbGHV6Nez0tmNI0RiEu7/hxlYJRUA0wFAVE= +github.com/bits-and-blooms/bitset v1.13.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w= -github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= -github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/cespare/cp v1.1.1 h1:nCb6ZLdB7NRaqsm91JtQTAme2SKJzXVsdPIPkyJr1MU= github.com/cespare/cp v1.1.1/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= @@ -35,8 +31,8 @@ github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce h1:giXvy4KSc/6g/e github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce/go.mod h1:9/y3cnZ5GKakj/H4y9r9GTjCvAFta7KLgSHPJJYc52M= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= -github.com/cockroachdb/pebble v1.1.1 h1:XnKU22oiCLy2Xn8vp1re67cXg4SAasg/WDt1NtcRFaw= -github.com/cockroachdb/pebble v1.1.1/go.mod h1:4exszw1r40423ZsmkG/09AFEG83I0uDgfujJdbL6kYU= +github.com/cockroachdb/pebble v1.1.2 h1:CUh2IPtR4swHlEj48Rhfzw6l/d0qA31fItcIszQVIsA= +github.com/cockroachdb/pebble v1.1.2/go.mod h1:4exszw1r40423ZsmkG/09AFEG83I0uDgfujJdbL6kYU= github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= @@ -65,16 +61,14 @@ github.com/deepmap/oapi-codegen v1.12.4 h1:pPmn6qI9MuOtCz82WY2Xaw46EQjgvxednXXrP github.com/deepmap/oapi-codegen v1.12.4/go.mod h1:3lgHGMu6myQ2vqbbTXH2H1o4eXFTGnFiDaOaKKl5yas= github.com/ethereum/c-kzg-4844 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHEwTNA= github.com/ethereum/c-kzg-4844 v1.0.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= -github.com/ethereum/go-ethereum v1.14.7 h1:EHpv3dE8evQmpVEQ/Ne2ahB06n2mQptdwqaMNhAT29g= -github.com/ethereum/go-ethereum v1.14.7/go.mod h1:Mq0biU2jbdmKSZoqOj29017ygFrMnB5/Rifwp980W4o= -github.com/ethereum/go-verkle v0.1.1-0.20240306133620-7d920df305f0 h1:KrE8I4reeVvf7C1tm8elRjj4BdscTYzz/WAbYyf/JI4= -github.com/ethereum/go-verkle v0.1.1-0.20240306133620-7d920df305f0/go.mod h1:D9AJLVXSyZQXJQVk8oh1EwjISE+sJTn2duYIZC0dy3w= +github.com/ethereum/go-ethereum v1.14.12 h1:8hl57x77HSUo+cXExrURjU/w1VhL+ShCTJrTwcCQSe4= +github.com/ethereum/go-ethereum v1.14.12/go.mod h1:RAC2gVMWJ6FkxSPESfbshrcKpIokgQKsVKmAuqdekDY= +github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 h1:8NfxH2iXvJ60YRB8ChToFTUzl8awsc3cJ8CbLjGIl/A= +github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9/go.mod h1:M3b90YRnzqKyyzBEWJGqj8Qff4IDeXnzFw0P9bFw3uk= github.com/ethereum/hive v0.0.0-20240715150147-c87a99dccfce h1:wgH9mh3TFSd+LFSsXO6RdTEO3niapJRywO1Xl3/IoIE= github.com/ethereum/hive v0.0.0-20240715150147-c87a99dccfce/go.mod h1:ghNXZW+/WQClcyiwZpbTzUCyxwql7YeMacYd44v+BJE= github.com/ferranbt/fastssz v0.1.2 h1:Dky6dXlngF6Qjc+EfDipAkE83N5I5DE68bY6O0VLNPk= github.com/ferranbt/fastssz v0.1.2/go.mod h1:X5UPrE2u1UJjxHA8X54u04SBwdAQjG2sFtWs39YxyWs= -github.com/fjl/memsize v0.0.2 h1:27txuSD9or+NZlnOWdKUxeBzTAUkWCVh+4Gf2dWFOzA= -github.com/fjl/memsize v0.0.2/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= @@ -99,8 +93,8 @@ github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo= +github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= @@ -141,8 +135,8 @@ github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 h1:X4egAf/gcS1zATw6w github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc= github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= -github.com/holiman/uint256 v1.3.0 h1:4wdcm/tnd0xXdu7iS3ruNvxkWwrb4aeBQv19ayYn8F4= -github.com/holiman/uint256 v1.3.0/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= +github.com/holiman/uint256 v1.3.1 h1:JfTzmih28bittyHM8z360dCjIA9dbPIBlcTI6lmctQs= +github.com/holiman/uint256 v1.3.1/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc= github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= @@ -242,8 +236,6 @@ github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0= -github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA= -github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= @@ -252,16 +244,14 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4= -github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= +github.com/supranational/blst v0.3.13 h1:AYeSxdOMacwu7FBmpfloBz5pbFXDmJL33RuwnKtmTjk= +github.com/supranational/blst v0.3.13/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a h1:1ur3QoCqvE5fl+nylMaIr9PVV1w343YRDtsy+Rwu7XI= github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48= github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= -github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= -github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= @@ -325,8 +315,8 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= -golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -355,8 +345,8 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/simulators/ethereum/engine/helper/helper.go b/simulators/ethereum/engine/helper/helper.go index 349a732b4c..9f01716c83 100644 --- a/simulators/ethereum/engine/helper/helper.go +++ b/simulators/ethereum/engine/helper/helper.go @@ -2,8 +2,6 @@ package helper import ( "context" - "sync" - "time" "bytes" "encoding/json" @@ -15,9 +13,6 @@ import ( "github.com/pkg/errors" - "github.com/ethereum/hive/simulators/ethereum/engine/client" - "github.com/ethereum/hive/simulators/ethereum/engine/globals" - gokzg4844 "github.com/crate-crypto/go-kzg-4844" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" @@ -265,87 +260,3 @@ func CalculateTotalDifficulty(genesis core.Genesis, chain types.Blocks, lastBloc func CalculateRealTTD(g *core.Genesis, ttdValue int64) int64 { return g.Difficulty.Int64() + ttdValue } - -var ( - // Time between checks of a client reaching Terminal Total Difficulty - TTDCheckPeriod = time.Second * 1 -) - -// TTD Check Methods -func CheckTTD(ec client.EngineClient, ctx context.Context) (bool, error) { - ctx, cancel := context.WithTimeout(ctx, globals.RPCTimeout) - defer cancel() - td, err := ec.GetTotalDifficulty(ctx) - if err == nil { - return td.Cmp(ec.TerminalTotalDifficulty()) >= 0, nil - } - return false, err -} - -type WaitTTDResponse struct { - ec client.EngineClient - err error -} - -// Wait until the TTD is reached by a single client. -func WaitForTTD(ec client.EngineClient, wg *sync.WaitGroup, done chan<- WaitTTDResponse, ctx context.Context) { - defer wg.Done() - for { - select { - case <-time.After(TTDCheckPeriod): - ttdReached, err := CheckTTD(ec, ctx) - if err == nil && ttdReached { - select { - case done <- WaitTTDResponse{ - ec: ec, - err: err, - }: - case <-ctx.Done(): - } - return - } - case <-ctx.Done(): - return - } - } -} - -// Wait until the TTD is reached by a single client with a timeout. -// Returns true if the TTD has been reached, false when timeout occurred. -func WaitForTTDWithTimeout(ec client.EngineClient, ctx context.Context) error { - for { - select { - case <-time.After(TTDCheckPeriod): - ttdReached, err := CheckTTD(ec, ctx) - if err != nil { - return err - } - if ttdReached { - return nil - } - case <-ctx.Done(): - return fmt.Errorf("timeout reached") - } - } -} - -// Wait until the TTD is reached by any of the engine clients -func WaitAnyClientForTTD(ecs []client.EngineClient, testCtx context.Context) (client.EngineClient, error) { - var wg sync.WaitGroup - defer wg.Wait() - done := make(chan WaitTTDResponse) - cancel := make(chan interface{}) - defer close(cancel) - for _, ec := range ecs { - wg.Add(1) - ctx, cancel := context.WithCancel(testCtx) - defer cancel() - go WaitForTTD(ec, &wg, done, ctx) - } - select { - case r := <-done: - return r.ec, r.err - case <-testCtx.Done(): - return nil, testCtx.Err() - } -} diff --git a/simulators/ethereum/engine/init/genesis.json b/simulators/ethereum/engine/init/genesis.json index 9c0fd6b75a..a4d85e1dbe 100644 --- a/simulators/ethereum/engine/init/genesis.json +++ b/simulators/ethereum/engine/init/genesis.json @@ -14,7 +14,8 @@ "berlinBlock": 0, "yolov2Block": 0, "yolov3Block": 0, - "londonBlock": 0 + "londonBlock": 0, + "parisBlock": 0 }, "coinbase": "0x0000000000000000000000000000000000000000", "difficulty": "0x30000", diff --git a/simulators/ethereum/engine/main.go b/simulators/ethereum/engine/main.go index 115a3bc51d..45ee598ab6 100644 --- a/simulators/ethereum/engine/main.go +++ b/simulators/ethereum/engine/main.go @@ -2,7 +2,6 @@ package main import ( "fmt" - "math/big" "math/rand" "os" "strconv" @@ -147,34 +146,25 @@ func makeRunner(tests []test.Spec, nodeType string) func(t *hivesim.T) { panic("unable to inject genmsis") } - // Calculate and set the TTD for this test - ttd := genesis.Config.TerminalTotalDifficulty - - // 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.ParisNumber != nil { - newParams = newParams.Set("HIVE_MERGE_BLOCK_ID", fmt.Sprintf("%d", forkConfig.ParisNumber)) - } + // Configure Forks. + // Note merge is hard-coded at genesis. + newParams := globals.DefaultClientEnv.Set("HIVE_TERMINAL_TOTAL_DIFFICULTY_PASSED", "1") + newParams = newParams.Set("HIVE_TERMINAL_TOTAL_DIFFICULTY", fmt.Sprintf("%d", genesis.Difficulty)) + newParams = newParams.Set("HIVE_MERGE_BLOCK_ID", "0") if forkConfig.ShanghaiTimestamp != nil { newParams = newParams.Set("HIVE_SHANGHAI_TIMESTAMP", fmt.Sprintf("%d", forkConfig.ShanghaiTimestamp)) - // Ensure merge transition is activated before shanghai if not already - if forkConfig.ParisNumber == nil { - newParams = newParams.Set("HIVE_MERGE_BLOCK_ID", "0") - } if forkConfig.CancunTimestamp != nil { newParams = newParams.Set("HIVE_CANCUN_TIMESTAMP", fmt.Sprintf("%d", forkConfig.CancunTimestamp)) } } + // Configure node type. if nodeType != "" { newParams = newParams.Set("HIVE_NODETYPE", nodeType) } testFiles := hivesim.Params{} - if genesis.Difficulty.Cmp(ttd) < 0 { + if genesis.Difficulty.Sign() > 0 { if currentTest.GetChainFile() != "" { // We are using a Proof of Work chain file, remove all clique-related settings // TODO: Nethermind still requires HIVE_MINER for the Engine API @@ -192,7 +182,6 @@ func makeRunner(tests []test.Spec, nodeType string) func(t *hivesim.T) { delete(newParams, "HIVE_CLIQUE_PRIVATEKEY") delete(newParams, "HIVE_CLIQUE_PERIOD") delete(newParams, "HIVE_MINER") - newParams = newParams.Set("HIVE_POST_MERGE_GENESIS", "true") } if clientTypes, err := t.Sim.ClientTypes(); err == nil { @@ -220,7 +209,6 @@ func makeRunner(tests []test.Spec, nodeType string) func(t *hivesim.T) { // Run the test case test.Run( currentTest, - new(big.Int).Set(ttd), timeout, t, c, diff --git a/simulators/ethereum/engine/suites/auth/tests.go b/simulators/ethereum/engine/suites/auth/tests.go index ac9ae537a2..884ccd716c 100644 --- a/simulators/ethereum/engine/suites/auth/tests.go +++ b/simulators/ethereum/engine/suites/auth/tests.go @@ -90,7 +90,7 @@ func (authTestSpec AuthTestSpec) Execute(t *test.Env) { var ( // All test cases send a simple TransitionConfigurationV1 to check the Authentication mechanism (JWT) tConf = api.TransitionConfigurationV1{ - TerminalTotalDifficulty: (*hexutil.Big)(t.MainTTD()), + TerminalTotalDifficulty: new(hexutil.Big), // zero TerminalBlockHash: common.Hash{}, TerminalBlockNumber: 0, } diff --git a/simulators/ethereum/engine/suites/cancun/config.go b/simulators/ethereum/engine/suites/cancun/config.go index c29fcdf67f..321acd189a 100644 --- a/simulators/ethereum/engine/suites/cancun/config.go +++ b/simulators/ethereum/engine/suites/cancun/config.go @@ -16,9 +16,6 @@ type CancunBaseSpec struct { // Base test case execution procedure for blobs tests. func (cs *CancunBaseSpec) Execute(t *test.Env) { - - t.CLMock.WaitForTTD() - blobTestCtx := NewTestContext(t) defer blobTestCtx.Close() diff --git a/simulators/ethereum/engine/suites/engine/bad_hash.go b/simulators/ethereum/engine/suites/engine/bad_hash.go index 478f68097f..234a9f15a5 100644 --- a/simulators/ethereum/engine/suites/engine/bad_hash.go +++ b/simulators/ethereum/engine/suites/engine/bad_hash.go @@ -55,9 +55,6 @@ func (b BadHashOnNewPayload) GetName() string { } func (b BadHashOnNewPayload) Execute(t *test.Env) { - // Wait until TTD is reached by this client - t.CLMock.WaitForTTD() - // Produce blocks before starting the test t.CLMock.ProduceBlocks(5, clmock.BlockProcessCallbacks{}) @@ -163,9 +160,6 @@ func (p ParentHashOnNewPayload) GetName() string { // Copy the parentHash into the blockHash, client should reject the payload // (from Kintsugi Incident Report: https://notes.ethereum.org/@ExXcnR0-SJGthjz1dwkA1A/BkkdHWXTY) func (b ParentHashOnNewPayload) Execute(t *test.Env) { - // Wait until TTD is reached by this client - t.CLMock.WaitForTTD() - // Produce blocks before starting the test t.CLMock.ProduceBlocks(5, clmock.BlockProcessCallbacks{}) diff --git a/simulators/ethereum/engine/suites/engine/fork_id.go b/simulators/ethereum/engine/suites/engine/fork_id.go index 1cb92acde4..b20967d501 100644 --- a/simulators/ethereum/engine/suites/engine/fork_id.go +++ b/simulators/ethereum/engine/suites/engine/fork_id.go @@ -5,7 +5,6 @@ import ( "strings" "time" - "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/devp2p" @@ -40,18 +39,10 @@ func (s ForkIDSpec) GetForkConfig() *config.ForkConfig { if forkConfig == nil { return nil } - // Merge fork happen at block 0 - mainFork := s.GetMainFork() - if mainFork == config.Paris { - forkConfig.ParisNumber = common.Big0 - } return forkConfig } func (ft ForkIDSpec) Execute(t *test.Env) { - // Wait until TTD is reached by this client - t.CLMock.WaitForTTD() - // Produce blocks before starting the test if required t.CLMock.ProduceBlocks(ft.ProduceBlocksBeforePeering, clmock.BlockProcessCallbacks{}) diff --git a/simulators/ethereum/engine/suites/engine/forkchoice.go b/simulators/ethereum/engine/suites/engine/forkchoice.go index bc90020733..d77b319b99 100644 --- a/simulators/ethereum/engine/suites/engine/forkchoice.go +++ b/simulators/ethereum/engine/suites/engine/forkchoice.go @@ -38,9 +38,6 @@ func (tc InconsistentForkchoiceTest) GetName() string { // Send an inconsistent ForkchoiceState with a known payload that belongs to a side chain as head, safe or finalized. func (tc InconsistentForkchoiceTest) Execute(t *test.Env) { - // Wait until TTD is reached by this client - t.CLMock.WaitForTTD() - canonicalPayloads := make([]*typ.ExecutableData, 0) alternativePayloads := make([]*typ.ExecutableData, 0) // Produce blocks before starting the test @@ -104,9 +101,6 @@ func (tc ForkchoiceUpdatedUnknownBlockHashTest) GetName() string { // Send an inconsistent ForkchoiceState with a known payload that belongs to a side chain as head, safe or finalized. func (tc ForkchoiceUpdatedUnknownBlockHashTest) Execute(t *test.Env) { - // Wait until TTD is reached by this client - t.CLMock.WaitForTTD() - // Produce blocks before starting the test t.CLMock.ProduceBlocks(5, clmock.BlockProcessCallbacks{}) diff --git a/simulators/ethereum/engine/suites/engine/invalid_ancestor.go b/simulators/ethereum/engine/suites/engine/invalid_ancestor.go index be0c378e30..701ab9f950 100644 --- a/simulators/ethereum/engine/suites/engine/invalid_ancestor.go +++ b/simulators/ethereum/engine/suites/engine/invalid_ancestor.go @@ -52,10 +52,6 @@ func (tc InvalidMissingAncestorReOrgTest) GetName() string { } func (tc InvalidMissingAncestorReOrgTest) Execute(t *test.Env) { - - // Wait until TTD is reached by this client - t.CLMock.WaitForTTD() - // Produce blocks before starting the test t.CLMock.ProduceBlocks(5, clmock.BlockProcessCallbacks{}) @@ -250,9 +246,6 @@ func (tc InvalidMissingAncestorReOrgSyncTest) Execute(t *test.Env) { t.CLMock.RemoveEngineClient(t.Engine) } - // Wait until TTD is reached by this client - t.CLMock.WaitForTTD() - // Produce blocks before starting the test // Default is to produce 5 PoS blocks before the common ancestor cAHeight := 5 diff --git a/simulators/ethereum/engine/suites/engine/invalid_payload.go b/simulators/ethereum/engine/suites/engine/invalid_payload.go index 7ea39e8ea5..7f96a60209 100644 --- a/simulators/ethereum/engine/suites/engine/invalid_payload.go +++ b/simulators/ethereum/engine/suites/engine/invalid_payload.go @@ -73,9 +73,6 @@ func (tc InvalidPayloadTestCase) Execute(t *test.Env) { t.CLMock.AddEngineClient(secondaryClient) } - // Wait until TTD is reached by all clients - t.CLMock.WaitForTTD() - txFunc := func() { if !tc.EmptyTransactions { // Function to send at least one transaction each block produced @@ -339,9 +336,6 @@ func (tc PayloadBuildAfterInvalidPayloadTest) Execute(t *test.Env) { secondaryEngineTest := test.NewTestEngineClient(t, secondaryEngine) t.CLMock.AddEngineClient(secondaryEngine) - // Wait until TTD is reached by this client - t.CLMock.WaitForTTD() - // Produce blocks before starting the test t.CLMock.ProduceBlocks(5, clmock.BlockProcessCallbacks{}) @@ -420,9 +414,6 @@ func (s InvalidTxChainIDTest) GetName() string { // Attempt to produce a payload after a transaction with an invalid Chain ID was sent to the client // using `eth_sendRawTransaction`. func (spec InvalidTxChainIDTest) Execute(t *test.Env) { - // Wait until TTD is reached by this client - t.CLMock.WaitForTTD() - // Produce blocks before starting the test t.CLMock.ProduceBlocks(5, clmock.BlockProcessCallbacks{}) diff --git a/simulators/ethereum/engine/suites/engine/misc.go b/simulators/ethereum/engine/suites/engine/misc.go deleted file mode 100644 index cfb569dfb0..0000000000 --- a/simulators/ethereum/engine/suites/engine/misc.go +++ /dev/null @@ -1,50 +0,0 @@ -package suite_engine - -import ( - "math/big" - - "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 - } - // Merge fork & pre-merge happen at block 1 - forkConfig.LondonNumber = common.Big1 - forkConfig.ParisNumber = common.Big1 - // Post-merge fork happens at block 2 - mainFork := s.GetMainFork() - if mainFork == config.Cancun { - forkConfig.ShanghaiTimestamp = new(big.Int).Set(forkConfig.CancunTimestamp) - } - 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{}) -} diff --git a/simulators/ethereum/engine/suites/engine/payload_attributes.go b/simulators/ethereum/engine/suites/engine/payload_attributes.go index 540159b2a1..1ceeed3b40 100644 --- a/simulators/ethereum/engine/suites/engine/payload_attributes.go +++ b/simulators/ethereum/engine/suites/engine/payload_attributes.go @@ -34,9 +34,6 @@ func (tc InvalidPayloadAttributesTest) GetName() string { } func (tc InvalidPayloadAttributesTest) Execute(t *test.Env) { - // Wait until TTD is reached by this client - t.CLMock.WaitForTTD() - // Produce blocks before starting the test t.CLMock.ProduceBlocks(5, clmock.BlockProcessCallbacks{}) diff --git a/simulators/ethereum/engine/suites/engine/payload_execution.go b/simulators/ethereum/engine/suites/engine/payload_execution.go index a86c4e253b..b7d1be6b46 100644 --- a/simulators/ethereum/engine/suites/engine/payload_execution.go +++ b/simulators/ethereum/engine/suites/engine/payload_execution.go @@ -32,9 +32,6 @@ func (s ReExecutePayloadTest) GetName() string { // Consecutive Payload Execution: Secondary client should be able to set the forkchoiceUpdated to payloads received consecutively func (spec ReExecutePayloadTest) Execute(t *test.Env) { - // Wait until this client catches up with latest PoS - t.CLMock.WaitForTTD() - // How many Payloads we are going to re-execute var payloadReExecCount = 10 @@ -105,9 +102,6 @@ func (s InOrderPayloadExecutionTest) GetName() string { // Consecutive Payload Execution: Secondary client should be able to set the forkchoiceUpdated to payloads received consecutively func (spec InOrderPayloadExecutionTest) Execute(t *test.Env) { - // Wait until this client catches up with latest PoS - t.CLMock.WaitForTTD() - // Send a single block to allow sending newer transaction types on the payloads t.CLMock.ProduceSingleBlock(clmock.BlockProcessCallbacks{}) @@ -232,9 +226,6 @@ func (s MultiplePayloadsExtendingCanonicalChainTest) GetName() string { // Consecutive Payload Execution: Secondary client should be able to set the forkchoiceUpdated to payloads received consecutively func (spec MultiplePayloadsExtendingCanonicalChainTest) Execute(t *test.Env) { - // Wait until this client catches up with latest PoS - t.CLMock.WaitForTTD() - // Produce blocks before starting the test t.CLMock.ProduceBlocks(5, clmock.BlockProcessCallbacks{}) @@ -338,9 +329,6 @@ func (spec NewPayloadOnSyncingClientTest) Execute(t *test.Env) { t.CLMock.AddEngineClient(secondaryClient) } - // Wait until TTD is reached by all clients - t.CLMock.WaitForTTD() - // Produce blocks before starting the test t.CLMock.ProduceBlocks(5, clmock.BlockProcessCallbacks{}) @@ -473,9 +461,6 @@ func (s NewPayloadWithMissingFcUTest) GetName() string { // Send a valid `newPayload` in correct order but skip `forkchoiceUpdated` until the last payload func (spec NewPayloadWithMissingFcUTest) Execute(t *test.Env) { - // Wait until TTD is reached by this client - t.CLMock.WaitForTTD() - // Get last genesis block hash genesisHash := t.TestEngine.TestHeaderByNumber(Head).Header.Hash() diff --git a/simulators/ethereum/engine/suites/engine/payload_id.go b/simulators/ethereum/engine/suites/engine/payload_id.go index e2afe766bc..e5c4f993be 100644 --- a/simulators/ethereum/engine/suites/engine/payload_id.go +++ b/simulators/ethereum/engine/suites/engine/payload_id.go @@ -42,9 +42,6 @@ func (tc UniquePayloadIDTest) GetName() string { // Check that the payload id returned on a forkchoiceUpdated call is different // when the attributes change func (tc UniquePayloadIDTest) Execute(t *test.Env) { - // Wait until TTD is reached by this client - t.CLMock.WaitForTTD() - t.CLMock.ProduceSingleBlock(clmock.BlockProcessCallbacks{ OnPayloadAttributesGenerated: func() { payloadAttributes := t.CLMock.LatestPayloadAttributes diff --git a/simulators/ethereum/engine/suites/engine/prev_randao.go b/simulators/ethereum/engine/suites/engine/prev_randao.go index 6b6906f01d..79a0a7f523 100644 --- a/simulators/ethereum/engine/suites/engine/prev_randao.go +++ b/simulators/ethereum/engine/suites/engine/prev_randao.go @@ -29,8 +29,6 @@ func (t PrevRandaoTransactionTest) GetName() string { } func (tc PrevRandaoTransactionTest) Execute(t *test.Env) { - t.CLMock.WaitForTTD() - // Create a single block to not having to build on top of genesis t.CLMock.ProduceSingleBlock(clmock.BlockProcessCallbacks{}) diff --git a/simulators/ethereum/engine/suites/engine/reorg.go b/simulators/ethereum/engine/suites/engine/reorg.go index 05a96ee58c..1461d1c4f1 100644 --- a/simulators/ethereum/engine/suites/engine/reorg.go +++ b/simulators/ethereum/engine/suites/engine/reorg.go @@ -34,9 +34,6 @@ func (s SidechainReOrgTest) GetName() string { // Reorg to a Sidechain using ForkchoiceUpdated func (spec SidechainReOrgTest) Execute(t *test.Env) { - // Wait until this client catches up with latest PoS - t.CLMock.WaitForTTD() - // Produce blocks before starting the test t.CLMock.ProduceBlocks(5, clmock.BlockProcessCallbacks{}) @@ -146,9 +143,6 @@ func (s TransactionReOrgTest) GetName() string { // Test transaction status after a forkchoiceUpdated re-orgs to an alternative hash where a transaction is not present func (spec TransactionReOrgTest) Execute(t *test.Env) { - // Wait until this client catches up with latest PoS - t.CLMock.WaitForTTD() - // Produce blocks before starting the test (So we don't try to reorg back to the genesis block) t.CLMock.ProduceBlocks(5, clmock.BlockProcessCallbacks{}) @@ -442,9 +436,6 @@ func (s ReOrgBackToCanonicalTest) GetDepth() uint64 { // Test that performing a re-org back into a previous block of the canonical chain does not produce errors and the chain // is still capable of progressing. func (spec ReOrgBackToCanonicalTest) Execute(t *test.Env) { - // Wait until this client catches up with latest PoS - t.CLMock.WaitForTTD() - // Check the CLMock configured safe and finalized if t.CLMock.SlotsToSafe.Cmp(new(big.Int).SetUint64(spec.ReOrgDepth)) <= 0 { t.Fatalf("FAIL (%s): [TEST ISSUE] CLMock configured slots to safe less than re-org depth: %v <= %v", t.TestName, t.CLMock.SlotsToSafe, spec.ReOrgDepth) @@ -566,9 +557,6 @@ func (s ReOrgBackFromSyncingTest) GetName() string { // Test that performs a re-org back to the canonical chain after re-org to syncing/unavailable chain. func (spec ReOrgBackFromSyncingTest) Execute(t *test.Env) { - // Wait until this client catches up with latest PoS - t.CLMock.WaitForTTD() - // Produce an alternative chain sidechainPayloads := make([]*typ.ExecutableData, 0) t.CLMock.ProduceBlocks(10, clmock.BlockProcessCallbacks{ @@ -655,9 +643,6 @@ func (s ReOrgPrevValidatedPayloadOnSideChainTest) GetName() string { // Test that performs a re-org to a previously validated payload on a side chain. func (spec ReOrgPrevValidatedPayloadOnSideChainTest) Execute(t *test.Env) { - // Wait until this client catches up with latest PoS - t.CLMock.WaitForTTD() - // Produce blocks before starting the test t.CLMock.ProduceBlocks(5, clmock.BlockProcessCallbacks{}) @@ -772,9 +757,6 @@ func (s SafeReOrgToSideChainTest) GetName() string { // Test that performs a re-org of the safe block to a side chain. func (s SafeReOrgToSideChainTest) Execute(t *test.Env) { - // Wait until this client catches up with latest PoS - t.CLMock.WaitForTTD() - // Produce an alternative chain sidechainPayloads := make([]*typ.ExecutableData, 0) diff --git a/simulators/ethereum/engine/suites/engine/rpc.go b/simulators/ethereum/engine/suites/engine/rpc.go index 9d9ab22f35..5bcffb5229 100644 --- a/simulators/ethereum/engine/suites/engine/rpc.go +++ b/simulators/ethereum/engine/suites/engine/rpc.go @@ -38,9 +38,6 @@ func (b BlockStatus) GetName() string { // Test to verify Block information available at the Eth RPC after NewPayload/ForkchoiceUpdated func (b BlockStatus) Execute(t *test.Env) { - // Wait until this client catches up with latest PoS Block - t.CLMock.WaitForTTD() - switch b.CheckType { case SafeOnSafeBlockHash, FinalizedOnFinalizedBlockHash: var number *big.Int diff --git a/simulators/ethereum/engine/suites/engine/suggested_fee_recipient.go b/simulators/ethereum/engine/suites/engine/suggested_fee_recipient.go index 0c604fd87a..d00fdd2d14 100644 --- a/simulators/ethereum/engine/suites/engine/suggested_fee_recipient.go +++ b/simulators/ethereum/engine/suites/engine/suggested_fee_recipient.go @@ -29,9 +29,6 @@ func (t SuggestedFeeRecipientTest) GetName() string { } func (tc SuggestedFeeRecipientTest) Execute(t *test.Env) { - // Wait until this client catches up with latest PoS - t.CLMock.WaitForTTD() - // Create a single block to not having to build on top of genesis t.CLMock.ProduceSingleBlock(clmock.BlockProcessCallbacks{}) diff --git a/simulators/ethereum/engine/suites/engine/tests.go b/simulators/ethereum/engine/suites/engine/tests.go index e90c12158f..8ad1a1be2a 100644 --- a/simulators/ethereum/engine/suites/engine/tests.go +++ b/simulators/ethereum/engine/suites/engine/tests.go @@ -415,14 +415,4 @@ func init() { } } } - - // Misc Tests - Tests = append(Tests, - // Pre-merge & merge fork occur at block 1, post-merge forks occur at block 2 - NonZeroPreMergeFork{ - BaseSpec: test.BaseSpec{ - ForkHeight: 2, - }, - }, - ) } diff --git a/simulators/ethereum/engine/suites/engine/versioning.go b/simulators/ethereum/engine/suites/engine/versioning.go index a28517a72b..4b0080db92 100644 --- a/simulators/ethereum/engine/suites/engine/versioning.go +++ b/simulators/ethereum/engine/suites/engine/versioning.go @@ -37,9 +37,6 @@ func (tc ForkchoiceUpdatedOnPayloadRequestTest) GetName() string { } func (tc ForkchoiceUpdatedOnPayloadRequestTest) Execute(t *test.Env) { - // Wait until TTD is reached by this client - t.CLMock.WaitForTTD() - t.CLMock.ProduceSingleBlock(clmock.BlockProcessCallbacks{ OnPayloadAttributesGenerated: func() { var ( diff --git a/simulators/ethereum/engine/suites/sync/tests.go b/simulators/ethereum/engine/suites/sync/tests.go index 73c34d3294..0416c6d16d 100644 --- a/simulators/ethereum/engine/suites/sync/tests.go +++ b/simulators/ethereum/engine/suites/sync/tests.go @@ -22,17 +22,17 @@ var Tests = []test.BaseSpec{ Run: postMergeSync, TimeoutSeconds: 180, ChainFile: "blocks_1024_td_135112316.rlp", - TTD: 135112316, }, { Name: "Incremental Post Merge Sync", Run: incrementalPostMergeSync, TimeoutSeconds: 180, ChainFile: "blocks_1024_td_135112316.rlp", - TTD: 135112316, }, } +const syncTestsTD = 135112316 + // Routine that adds all sync tests to a test suite func AddSyncTestsToSuite(sim *hivesim.Simulation, suite *hivesim.Suite, tests []test.BaseSpec) { clientDefs, err := sim.ClientTypes() @@ -54,7 +54,7 @@ func AddSyncTestsToSuite(sim *hivesim.Simulation, suite *hivesim.Suite, tests [] testFiles := hivesim.Params{"/genesis.json": genesisPath} // Calculate and set the TTD for this test genesis := helper.LoadGenesis(genesisPath) - ttd := helper.CalculateRealTTD(&genesis, currentTest.TTD) + ttd := helper.CalculateRealTTD(&genesis, syncTestsTD) newParams := globals.DefaultClientEnv.Set("HIVE_TERMINAL_TOTAL_DIFFICULTY", fmt.Sprintf("%d", ttd)) if currentTest.ChainFile != "" { // We are using a Proof of Work chain file, remove all clique-related settings @@ -100,7 +100,7 @@ func AddSyncTestsToSuite(sim *hivesim.Simulation, suite *hivesim.Suite, tests [] } // Run the test case - test.Run(¤tTest, big.NewInt(ttd), timeout, t, c, &genesis, rand.New(rand.NewSource(0)), syncClientParams, testFiles.Copy()) + test.Run(¤tTest, timeout, t, c, &genesis, rand.New(rand.NewSource(0)), syncClientParams, testFiles.Copy()) }, }) } @@ -111,10 +111,6 @@ func AddSyncTestsToSuite(sim *hivesim.Simulation, suite *hivesim.Suite, tests [] // Client Sync tests func postMergeSync(t *test.Env) { - // Launch another client after the PoS transition has happened in the main client. - // Sync should eventually happen without issues. - t.CLMock.WaitForTTD() - // Speed up block production t.CLMock.PayloadProductionClientDelay = 0 @@ -162,10 +158,6 @@ func postMergeSync(t *test.Env) { // Performs a test where sync is done incrementally by sending incremental newPayload/fcU calls func incrementalPostMergeSync(t *test.Env) { - // Launch another client after the PoS transition has happened in the main client. - // Sync should eventually happen without issues. - t.CLMock.WaitForTTD() - var ( N uint64 = 500 // Total number of PoS blocks S uint64 = 5 // Number of incremental steps to sync diff --git a/simulators/ethereum/engine/suites/withdrawals/tests.go b/simulators/ethereum/engine/suites/withdrawals/tests.go index db9cd35197..253e19f441 100644 --- a/simulators/ethereum/engine/suites/withdrawals/tests.go +++ b/simulators/ethereum/engine/suites/withdrawals/tests.go @@ -19,7 +19,6 @@ 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" ) @@ -815,14 +814,6 @@ 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 @@ -1125,8 +1116,6 @@ func (ws *WithdrawalsBaseSpec) Execute(t *test.Env) { // Create the withdrawals history object ws.WithdrawalsHistory = make(WithdrawalsHistory) - t.CLMock.WaitForTTD() - // Check if we have pre-Shanghai blocks if ws.GetWithdrawalsForkTime() > uint64(globals.GenesisTimestamp) { // Check `latest` during all pre-shanghai blocks, none should @@ -1554,8 +1543,6 @@ func (ws *WithdrawalsReorgSpec) Execute(t *test.Env) { // Create the withdrawals history object ws.WithdrawalsHistory = make(WithdrawalsHistory) - t.CLMock.WaitForTTD() - // Spawn a secondary client which will produce the sidechain secondaryEngine, err := hive_rpc.HiveRPCEngineStarter{}.StartClient(t.T, t.TestContext, t.Genesis, t.ClientParams, t.ClientFiles, t.Engine) if err != nil { @@ -1821,7 +1808,6 @@ type MaxInitcodeSizeSpec struct { } func (s *MaxInitcodeSizeSpec) Execute(t *test.Env) { - t.CLMock.WaitForTTD() invalidTxSender := globals.TestAccounts[0] invalidTxCreator := &helper.BigInitcodeTransactionCreator{ InitcodeLength: MAX_INITCODE_SIZE + 1, diff --git a/simulators/ethereum/engine/test/env.go b/simulators/ethereum/engine/test/env.go index 4fb48e5e59..d52e75a2c8 100644 --- a/simulators/ethereum/engine/test/env.go +++ b/simulators/ethereum/engine/test/env.go @@ -2,7 +2,6 @@ package test import ( "context" - "math/big" "math/rand" "net/http" "time" @@ -55,7 +54,7 @@ type Env struct { TestTransactionType helper.TestTransactionType } -func Run(testSpec Spec, ttd *big.Int, timeout time.Duration, t *hivesim.T, c *hivesim.Client, genesis *core.Genesis, randSource *rand.Rand, cParams hivesim.Params, cFiles hivesim.Params) { +func Run(testSpec Spec, timeout time.Duration, t *hivesim.T, c *hivesim.Client, genesis *core.Genesis, randSource *rand.Rand, cParams hivesim.Params, cFiles hivesim.Params) { // Setup the CL Mocker for this test forkConfig := testSpec.GetForkConfig() clMocker := clmock.NewCLMocker( @@ -74,7 +73,7 @@ func Run(testSpec Spec, ttd *big.Int, timeout time.Duration, t *hivesim.T, c *hi }() // Create Engine client from main hivesim.Client to be used by tests - ec := hive_rpc.NewHiveRPCEngineClient(c, globals.EnginePortHTTP, globals.EthPortHTTP, globals.DefaultJwtTokenSecretBytes, ttd, &helper.LoggingRoundTrip{ + ec := hive_rpc.NewHiveRPCEngineClient(c, globals.EnginePortHTTP, globals.EthPortHTTP, globals.DefaultJwtTokenSecretBytes, &helper.LoggingRoundTrip{ Logger: t, ID: c.Container, Inner: http.DefaultTransport, @@ -109,6 +108,9 @@ func Run(testSpec Spec, ttd *big.Int, timeout time.Duration, t *hivesim.T, c *hi t.Fatalf("FAIL (%s): Ports were never open for client: %v", env.TestName, err) } + // Setup clMocker with client head. + clMocker.InitChain(ec) + // Full test context has a few more seconds to finish up after timeout happens ctx, cancel := context.WithTimeout(context.Background(), timeout+(time.Second*10)) defer cancel() @@ -127,7 +129,7 @@ func Run(testSpec Spec, ttd *big.Int, timeout time.Duration, t *hivesim.T, c *hi // Defer producing one last block to verify Execution client did not break after the test defer func() { // Only run if the TTD was reached during test, and test had not failed at this point. - if clMocker.TTDReached && !t.Failed() { + if !t.Failed() { clMocker.ProduceSingleBlock(clmock.BlockProcessCallbacks{}) } }() @@ -136,10 +138,6 @@ func Run(testSpec Spec, ttd *big.Int, timeout time.Duration, t *hivesim.T, c *hi testSpec.Execute(env) } -func (t *Env) MainTTD() *big.Int { - return t.Engine.TerminalTotalDifficulty() -} - func (t *Env) HandleClientPostRunVerification(ec client.EngineClient) { if err := ec.PostRunVerifications(); err != nil { t.Fatalf("FAIL (%s): Client failed post-run verification: %v", t.TestName, err) diff --git a/simulators/ethereum/engine/test/spec.go b/simulators/ethereum/engine/test/spec.go index 52d6df775d..368cc48fd4 100644 --- a/simulators/ethereum/engine/test/spec.go +++ b/simulators/ethereum/engine/test/spec.go @@ -53,11 +53,6 @@ type BaseSpec struct { // Test procedure to execute the test Run func(*Env) - // TerminalTotalDifficulty delta value. - // Actual TTD is genesis.Difficulty + this value - // Default: 0 - TTD int64 - // CL Mocker configuration for time increments BlockTimestampIncrement uint64 @@ -202,12 +197,6 @@ func (s BaseSpec) GetGenesis() *core.Genesis { } genesis := helper.LoadGenesis(genesisPath) - // Set the terminal total difficulty - genesis.Config.TerminalTotalDifficulty = big.NewInt(genesis.Difficulty.Int64() + s.TTD) - if genesis.Difficulty.Cmp(genesis.Config.TerminalTotalDifficulty) <= 0 { - genesis.Config.TerminalTotalDifficultyPassed = true - } - // Set the genesis timestamp if provided if s.GenesisTimestamp != nil { genesis.Timestamp = *s.GenesisTimestamp diff --git a/simulators/ethereum/engine/types/types.go b/simulators/ethereum/engine/types/types.go index dc61e76d44..c8e14ab2eb 100644 --- a/simulators/ethereum/engine/types/types.go +++ b/simulators/ethereum/engine/types/types.go @@ -223,5 +223,5 @@ func ExecutableDataToBlock(ed ExecutableData) (*types.Block, error) { if ed.VersionedHashes != nil { versionedHashes = *ed.VersionedHashes } - return geth_beacon.ExecutableDataToBlock(gethEd, versionedHashes, ed.ParentBeaconBlockRoot) + return geth_beacon.ExecutableDataToBlock(gethEd, versionedHashes, ed.ParentBeaconBlockRoot, nil) }