From c405487fca5f5502c46cc30df356ee0fc9f1e934 Mon Sep 17 00:00:00 2001 From: Lindsey Gray Date: Fri, 29 Dec 2023 15:20:44 -0600 Subject: [PATCH] revert cleanup: ressurect most tests --- .../internal/ethtest/testdata/genesis.json | 2 +- consensus/ethash/sealer_test.go | 6 +++--- core/block_validator_test.go | 1 + core/blockchain_test.go | 2 +- miner/stress/1559/main.go | 11 ++++++----- miner/stress/beacon/main.go | 17 ++++++++--------- miner/stress/ethash/main.go | 11 ++++++----- params/config.go | 2 +- 8 files changed, 27 insertions(+), 25 deletions(-) diff --git a/cmd/devp2p/internal/ethtest/testdata/genesis.json b/cmd/devp2p/internal/ethtest/testdata/genesis.json index 52c4a05257..e8bb66bb3c 100644 --- a/cmd/devp2p/internal/ethtest/testdata/genesis.json +++ b/cmd/devp2p/internal/ethtest/testdata/genesis.json @@ -109,4 +109,4 @@ "baseFeePerGas": null, "excessBlobGas": null, "blobGasUsed": null -} +} \ No newline at end of file diff --git a/consensus/ethash/sealer_test.go b/consensus/ethash/sealer_test.go index e338f75290..73711c0549 100644 --- a/consensus/ethash/sealer_test.go +++ b/consensus/ethash/sealer_test.go @@ -96,7 +96,7 @@ func TestRemoteNotifyFull(t *testing.T) { config := Config{ PowMode: ModeTest, NotifyFull: true, - Log: testlog.Logger(t, log.LvlWarn), + Log: testlog.Logger(t, log.LevelWarn), } ethash := New(config, []string{server.URL}, false) defer ethash.Close() @@ -139,7 +139,7 @@ func TestRemoteMultiNotify(t *testing.T) { // Create the custom ethash engine. ethash := NewTester([]string{server.URL}, false) - ethash.config.Log = testlog.Logger(t, log.LvlWarn) + ethash.config.Log = testlog.Logger(t, log.LevelWarn) defer ethash.Close() // Provide a results reader. @@ -186,7 +186,7 @@ func TestRemoteMultiNotifyFull(t *testing.T) { config := Config{ PowMode: ModeTest, NotifyFull: true, - Log: testlog.Logger(t, log.LvlWarn), + Log: testlog.Logger(t, log.LevelWarn), } ethash := New(config, []string{server.URL}, false) defer ethash.Close() diff --git a/core/block_validator_test.go b/core/block_validator_test.go index 2f391759f6..0ca6d102e8 100644 --- a/core/block_validator_test.go +++ b/core/block_validator_test.go @@ -18,6 +18,7 @@ package core import ( "math/big" + "runtime" "testing" "time" diff --git a/core/blockchain_test.go b/core/blockchain_test.go index e2a64398f9..8137e3504b 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -1065,7 +1065,7 @@ func testLightVsFastVsFullChainHeads(t *testing.T, scheme string) { defer lightDb.Close() light, _ := NewBlockChain(lightDb, DefaultCacheConfigWithScheme(scheme), gspec, nil, ethash.NewFaker(), vm.Config{}, nil, nil) - if n, err := light.InsertHeaderChain(headers); err != nil { + if n, err := light.InsertHeaderChain(headers, 1); err != nil { t.Fatalf("failed to insert header %d: %v", n, err) } defer light.Stop() diff --git a/miner/stress/1559/main.go b/miner/stress/1559/main.go index 2e8b78d85e..23874cb138 100644 --- a/miner/stress/1559/main.go +++ b/miner/stress/1559/main.go @@ -30,7 +30,7 @@ import ( "github.com/ethereum/go-ethereum/common/fdlimit" "github.com/ethereum/go-ethereum/consensus/ethash" "github.com/ethereum/go-ethereum/core" - "github.com/ethereum/go-ethereum/core/txpool" + "github.com/ethereum/go-ethereum/core/txpool/legacypool" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/eth" @@ -49,7 +49,7 @@ var ( ) func main() { - log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true)))) + log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.LevelInfo, true))) fdlimit.Raise(2048) // Generate a batch of accounts to seal and fund with @@ -130,8 +130,9 @@ func main() { // Create a self transaction and inject into the pool. The legacy // and 1559 transactions can all be created by random even if the // fork is not happened. - tx := makeTransaction(nonces[index], faucets[index], signer, baseFee) - if err := backend.TxPool().AddLocal(tx); err != nil { + ttx := makeTransaction(nonces[index], faucets[index], signer, baseFee) + tx := []*types.Transaction{ttx} + if err := backend.TxPool().Add(tx, true, true); err != nil { continue } nonces[index]++ @@ -246,7 +247,7 @@ func makeMiner(genesis *core.Genesis) (*node.Node, *eth.Ethereum, error) { SyncMode: downloader.FullSync, DatabaseCache: 256, DatabaseHandles: 256, - TxPool: txpool.DefaultConfig, + TxPool: legacypool.DefaultConfig, GPO: ethconfig.Defaults.GPO, Ethash: ethconfig.Defaults.Ethash, Miner: miner.Config{ diff --git a/miner/stress/beacon/main.go b/miner/stress/beacon/main.go index 57cfacbccb..fbfa37a5ce 100644 --- a/miner/stress/beacon/main.go +++ b/miner/stress/beacon/main.go @@ -32,7 +32,7 @@ import ( "github.com/ethereum/go-ethereum/common/fdlimit" "github.com/ethereum/go-ethereum/consensus/ethash" "github.com/ethereum/go-ethereum/core" - "github.com/ethereum/go-ethereum/core/txpool" + "github.com/ethereum/go-ethereum/core/txpool/legacypool" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/eth" @@ -134,8 +134,6 @@ func newNode(typ nodetype, genesis *core.Genesis, enodes []*enode.Node) *ethNode typ: typ, api: api, ethBackend: ethBackend, - lapi: lapi, - lesBackend: lesBackend, stack: stack, enode: enode, } @@ -192,7 +190,7 @@ func (n *ethNode) insertBlockAndSetHead(parent *types.Header, ed engine.Executab if err := n.insertBlock(ed); err != nil { return err } - block, err := engine.ExecutableDataToBlock(ed) + block, err := engine.ExecutableDataToBlock(ed, nil, nil) if err != nil { return err } @@ -347,7 +345,7 @@ func (mgr *nodeManager) run() { log.Error("Failed to assemble the block", "err", err) continue } - block, _ := engine.ExecutableDataToBlock(*ed) + block, _ := engine.ExecutableDataToBlock(*ed, nil, nil) nodes := mgr.getNodes(eth2MiningNode) nodes = append(nodes, mgr.getNodes(eth2NormalNode)...) @@ -365,7 +363,7 @@ func (mgr *nodeManager) run() { } func main() { - log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true)))) + log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.LevelInfo, true))) fdlimit.Raise(2048) // Generate a batch of accounts to seal and fund with @@ -404,11 +402,12 @@ func main() { node := nodes[index%len(nodes)] // Create a self transaction and inject into the pool - tx, err := types.SignTx(types.NewTransaction(nonces[index], crypto.PubkeyToAddress(faucets[index].PublicKey), new(big.Int), 21000, big.NewInt(10_000_000_000+rand.Int63n(6_553_600_000)), nil), types.HomesteadSigner{}, faucets[index]) + ttx, err := types.SignTx(types.NewTransaction(nonces[index], crypto.PubkeyToAddress(faucets[index].PublicKey), new(big.Int), 21000, big.NewInt(10_000_000_000+rand.Int63n(6_553_600_000)), nil), types.HomesteadSigner{}, faucets[index]) if err != nil { panic(err) } - if err := node.ethBackend.TxPool().AddLocal(tx); err != nil { + tx := []*types.Transaction{ttx} + if err := node.ethBackend.TxPool().Add(tx, true, true); err != nil { panic(err) } nonces[index]++ @@ -466,7 +465,7 @@ func makeFullNode(genesis *core.Genesis) (*node.Node, *eth.Ethereum, *ethcatalys SyncMode: downloader.FullSync, DatabaseCache: 256, DatabaseHandles: 256, - TxPool: txpool.DefaultConfig, + TxPool: legacypool.DefaultConfig, GPO: ethconfig.Defaults.GPO, Ethash: ethconfig.Defaults.Ethash, Miner: miner.Config{ diff --git a/miner/stress/ethash/main.go b/miner/stress/ethash/main.go index 6905bf01f1..8dff4cdbc9 100644 --- a/miner/stress/ethash/main.go +++ b/miner/stress/ethash/main.go @@ -29,7 +29,7 @@ import ( "github.com/ethereum/go-ethereum/common/fdlimit" "github.com/ethereum/go-ethereum/consensus/ethash" "github.com/ethereum/go-ethereum/core" - "github.com/ethereum/go-ethereum/core/txpool" + "github.com/ethereum/go-ethereum/core/txpool/legacypool" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/eth" @@ -44,7 +44,7 @@ import ( ) func main() { - log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true)))) + log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.LevelInfo, true))) fdlimit.Raise(2048) // Generate a batch of accounts to seal and fund with @@ -115,11 +115,12 @@ func main() { backend := nodes[index%len(nodes)] // Create a self transaction and inject into the pool - tx, err := types.SignTx(types.NewTransaction(nonces[index], crypto.PubkeyToAddress(faucets[index].PublicKey), new(big.Int), 21000, big.NewInt(100000000000+rand.Int63n(65536)), nil), types.HomesteadSigner{}, faucets[index]) + ttx, err := types.SignTx(types.NewTransaction(nonces[index], crypto.PubkeyToAddress(faucets[index].PublicKey), new(big.Int), 21000, big.NewInt(100000000000+rand.Int63n(65536)), nil), types.HomesteadSigner{}, faucets[index]) if err != nil { panic(err) } - if err := backend.TxPool().AddLocal(tx); err != nil { + tx := []*types.Transaction{ttx} + if err := backend.TxPool().Add(tx, true, true); err != nil { panic(err) } nonces[index]++ @@ -175,7 +176,7 @@ func makeMiner(genesis *core.Genesis) (*node.Node, *eth.Ethereum, error) { SyncMode: downloader.FullSync, DatabaseCache: 256, DatabaseHandles: 256, - TxPool: txpool.DefaultConfig, + TxPool: legacypool.DefaultConfig, GPO: ethconfig.Defaults.GPO, Ethash: ethconfig.Defaults.Ethash, Miner: miner.Config{ diff --git a/params/config.go b/params/config.go index 731c4f3407..463041bd01 100644 --- a/params/config.go +++ b/params/config.go @@ -157,7 +157,7 @@ var ( PragueTime: nil, VerkleTime: nil, TerminalTotalDifficulty: nil, - TerminalTotalDifficultyPassed: false, + TerminalTotalDifficultyPassed: true, Ethash: new(EthashConfig), Clique: nil, }