From cd9ae930b679356f320f9d049308486405fd207b Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Wed, 18 Jun 2025 15:31:32 +0200 Subject: [PATCH] core: make options last parameter --- cmd/utils/flags.go | 2 +- cmd/utils/history_test.go | 4 +- consensus/clique/clique_test.go | 6 +- consensus/clique/snapshot_test.go | 2 +- core/bench_test.go | 4 +- core/block_validator_test.go | 4 +- core/blockchain.go | 2 +- core/blockchain_repair_test.go | 11 +-- core/blockchain_sethead_test.go | 2 +- core/blockchain_snapshot_test.go | 20 ++--- core/blockchain_test.go | 86 +++++++++---------- core/chain_makers_test.go | 4 +- core/dao_test.go | 12 +-- core/genesis_test.go | 2 +- core/state_processor_test.go | 6 +- core/txpool/locals/tx_tracker_test.go | 2 +- core/verkle_witness_test.go | 2 +- eth/api_backend_test.go | 2 +- eth/api_debug_test.go | 2 +- eth/backend.go | 2 +- eth/downloader/downloader_test.go | 2 +- eth/downloader/testchain_test.go | 2 +- eth/filters/filter_test.go | 4 +- eth/handler_eth_test.go | 4 +- eth/handler_test.go | 2 +- eth/protocols/eth/handler_test.go | 2 +- eth/protocols/snap/handler_fuzzing_test.go | 2 +- eth/tracers/api_test.go | 4 +- eth/tracers/internal/tracetest/supply_test.go | 2 +- internal/ethapi/api_test.go | 2 +- miner/miner_test.go | 2 +- miner/payload_building_test.go | 2 +- 32 files changed, 104 insertions(+), 103 deletions(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index e6873c7acf..660b40aecd 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -2211,7 +2211,7 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh options.VmConfig = vmcfg // Disable transaction indexing/unindexing by default. - chain, err := core.NewBlockChain(options, chainDb, gspec, engine) + chain, err := core.NewBlockChain(chainDb, gspec, engine, options) if err != nil { Fatalf("Can't create BlockChain: %v", err) } diff --git a/cmd/utils/history_test.go b/cmd/utils/history_test.go index ee563a510a..1227b26f96 100644 --- a/cmd/utils/history_test.go +++ b/cmd/utils/history_test.go @@ -77,7 +77,7 @@ func TestHistoryImportAndExport(t *testing.T) { }) // Initialize BlockChain. - chain, err := core.NewBlockChain(nil, db, genesis, ethash.NewFaker()) + chain, err := core.NewBlockChain(db, genesis, ethash.NewFaker(), nil) if err != nil { t.Fatalf("unable to initialize chain: %v", err) } @@ -166,7 +166,7 @@ func TestHistoryImportAndExport(t *testing.T) { }) genesis.MustCommit(db2, triedb.NewDatabase(db2, triedb.HashDefaults)) - imported, err := core.NewBlockChain(nil, db2, genesis, ethash.NewFaker()) + imported, err := core.NewBlockChain(db2, genesis, ethash.NewFaker(), nil) if err != nil { t.Fatalf("unable to initialize chain: %v", err) } diff --git a/consensus/clique/clique_test.go b/consensus/clique/clique_test.go index 8c5879c890..afcab1d1f7 100644 --- a/consensus/clique/clique_test.go +++ b/consensus/clique/clique_test.go @@ -54,7 +54,7 @@ func TestReimportMirroredState(t *testing.T) { copy(genspec.ExtraData[extraVanity:], addr[:]) // Generate a batch of blocks, each properly signed - chain, _ := core.NewBlockChain(nil, rawdb.NewMemoryDatabase(), genspec, engine) + chain, _ := core.NewBlockChain(rawdb.NewMemoryDatabase(), genspec, engine, nil) defer chain.Stop() _, blocks, _ := core.GenerateChainWithGenesis(genspec, engine, 3, func(i int, block *core.BlockGen) { @@ -86,7 +86,7 @@ func TestReimportMirroredState(t *testing.T) { } // Insert the first two blocks and make sure the chain is valid db = rawdb.NewMemoryDatabase() - chain, _ = core.NewBlockChain(nil, db, genspec, engine) + chain, _ = core.NewBlockChain(db, genspec, engine, nil) defer chain.Stop() if _, err := chain.InsertChain(blocks[:2]); err != nil { @@ -99,7 +99,7 @@ func TestReimportMirroredState(t *testing.T) { // Simulate a crash by creating a new chain on top of the database, without // flushing the dirty states out. Insert the last block, triggering a sidechain // reimport. - chain, _ = core.NewBlockChain(nil, db, genspec, engine) + chain, _ = core.NewBlockChain(db, genspec, engine, nil) defer chain.Stop() if _, err := chain.InsertChain(blocks[2:]); err != nil { diff --git a/consensus/clique/snapshot_test.go b/consensus/clique/snapshot_test.go index 1873f3fea9..ac2355c730 100644 --- a/consensus/clique/snapshot_test.go +++ b/consensus/clique/snapshot_test.go @@ -457,7 +457,7 @@ func (tt *cliqueTest) run(t *testing.T) { batches[len(batches)-1] = append(batches[len(batches)-1], block) } // Pass all the headers through clique and ensure tallying succeeds - chain, err := core.NewBlockChain(nil, rawdb.NewMemoryDatabase(), genesis, engine) + chain, err := core.NewBlockChain(rawdb.NewMemoryDatabase(), genesis, engine, nil) if err != nil { t.Fatalf("failed to create test chain: %v", err) } diff --git a/core/bench_test.go b/core/bench_test.go index 9af8c3e7d6..f1ea698a8c 100644 --- a/core/bench_test.go +++ b/core/bench_test.go @@ -199,7 +199,7 @@ func benchInsertChain(b *testing.B, disk bool, gen func(int, *BlockGen)) { // Time the insertion of the new chain. // State and blocks are stored in the same DB. - chainman, _ := NewBlockChain(nil, db, gspec, ethash.NewFaker()) + chainman, _ := NewBlockChain(db, gspec, ethash.NewFaker(), nil) defer chainman.Stop() b.ReportAllocs() b.ResetTimer() @@ -337,7 +337,7 @@ func benchReadChain(b *testing.B, full bool, count uint64) { } db = rawdb.NewDatabase(pdb) - chain, err := NewBlockChain(&options, db, genesis, ethash.NewFaker()) + chain, err := NewBlockChain(db, genesis, ethash.NewFaker(), &options) if err != nil { b.Fatalf("error creating chain: %v", err) } diff --git a/core/block_validator_test.go b/core/block_validator_test.go index 6cd280beef..7956468086 100644 --- a/core/block_validator_test.go +++ b/core/block_validator_test.go @@ -50,7 +50,7 @@ func testHeaderVerification(t *testing.T, scheme string) { } // Run the header checker for blocks one-by-one, checking for both valid and invalid nonces options := BlockchainOptionsWithScheme(scheme) - chain, err := NewBlockChain(options, rawdb.NewMemoryDatabase(), gspec, ethash.NewFaker()) + chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), gspec, ethash.NewFaker(), options) defer chain.Stop() if err != nil { t.Fatal(err) @@ -166,7 +166,7 @@ func testHeaderVerificationForMerging(t *testing.T, isClique bool) { postHeaders[i] = block.Header() } // Run the header checker for blocks one-by-one, checking for both valid and invalid nonces - chain, err := NewBlockChain(nil, rawdb.NewMemoryDatabase(), gspec, engine) + chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), gspec, engine, nil) defer chain.Stop() if err != nil { t.Fatal(err) diff --git a/core/blockchain.go b/core/blockchain.go index e84c33d989..08bd8207a0 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -311,7 +311,7 @@ type BlockChain struct { // NewBlockChain returns a fully initialised block chain using information // available in the database. It initialises the default Ethereum Validator // and Processor. -func NewBlockChain(options *BlockchainOptions, db ethdb.Database, genesis *Genesis, engine consensus.Engine) (*BlockChain, error) { +func NewBlockChain(db ethdb.Database, genesis *Genesis, engine consensus.Engine, options *BlockchainOptions) (*BlockChain, error) { if options == nil { options = defaultOptions } diff --git a/core/blockchain_repair_test.go b/core/blockchain_repair_test.go index df7ddb2f37..b8ab1a222d 100644 --- a/core/blockchain_repair_test.go +++ b/core/blockchain_repair_test.go @@ -1794,7 +1794,7 @@ func testRepairWithScheme(t *testing.T, tt *rewindTest, snapshots bool, scheme s option.SnapshotLimit = 256 option.SnapshotWait = true } - chain, err := NewBlockChain(option, db, gspec, engine) + chain, err := NewBlockChain(db, gspec, engine, option) if err != nil { t.Fatalf("Failed to create chain: %v", err) } @@ -1859,7 +1859,7 @@ func testRepairWithScheme(t *testing.T, tt *rewindTest, snapshots bool, scheme s } defer db.Close() - newChain, err := NewBlockChain(option, db, gspec, engine) + newChain, err := NewBlockChain(db, gspec, engine, option) if err != nil { t.Fatalf("Failed to recreate chain: %v", err) } @@ -1930,9 +1930,10 @@ func testIssue23496(t *testing.T, scheme string) { Config: params.TestChainConfig, BaseFee: big.NewInt(params.InitialBaseFee), } - engine = ethash.NewFullFaker() + engine = ethash.NewFullFaker() + options = BlockchainOptionsWithScheme(scheme) ) - chain, err := NewBlockChain(BlockchainOptionsWithScheme(scheme), db, gspec, engine) + chain, err := NewBlockChain(db, gspec, engine, options) if err != nil { t.Fatalf("Failed to create chain: %v", err) } @@ -1984,7 +1985,7 @@ func testIssue23496(t *testing.T, scheme string) { } defer db.Close() - chain, err = NewBlockChain(BlockchainOptionsWithScheme(scheme), db, gspec, engine) + chain, err = NewBlockChain(db, gspec, engine, BlockchainOptionsWithScheme(scheme)) if err != nil { t.Fatalf("Failed to recreate chain: %v", err) } diff --git a/core/blockchain_sethead_test.go b/core/blockchain_sethead_test.go index 90a308c547..5f415f770f 100644 --- a/core/blockchain_sethead_test.go +++ b/core/blockchain_sethead_test.go @@ -1997,7 +1997,7 @@ func testSetHeadWithScheme(t *testing.T, tt *rewindTest, snapshots bool, scheme options.SnapshotLimit = 256 options.SnapshotWait = true } - chain, err := NewBlockChain(options, db, gspec, engine) + chain, err := NewBlockChain(db, gspec, engine, options) if err != nil { t.Fatalf("Failed to create chain: %v", err) } diff --git a/core/blockchain_snapshot_test.go b/core/blockchain_snapshot_test.go index 0f8b94a434..2c64709b27 100644 --- a/core/blockchain_snapshot_test.go +++ b/core/blockchain_snapshot_test.go @@ -81,7 +81,7 @@ func (basic *snapshotTestBasic) prepare(t *testing.T) (*BlockChain, []*types.Blo } engine = ethash.NewFullFaker() ) - chain, err := NewBlockChain(BlockchainOptionsWithScheme(basic.scheme), db, gspec, engine) + chain, err := NewBlockChain(db, gspec, engine, BlockchainOptionsWithScheme(basic.scheme)) if err != nil { t.Fatalf("Failed to create chain: %v", err) } @@ -232,7 +232,7 @@ func (snaptest *snapshotTest) test(t *testing.T) { // Restart the chain normally chain.Stop() - newchain, err := NewBlockChain(BlockchainOptionsWithScheme(snaptest.scheme), snaptest.db, snaptest.gspec, snaptest.engine) + newchain, err := NewBlockChain(snaptest.db, snaptest.gspec, snaptest.engine, BlockchainOptionsWithScheme(snaptest.scheme)) if err != nil { t.Fatalf("Failed to recreate chain: %v", err) } @@ -274,13 +274,13 @@ func (snaptest *crashSnapshotTest) test(t *testing.T) { // the crash, we do restart twice here: one after the crash and one // after the normal stop. It's used to ensure the broken snapshot // can be detected all the time. - newchain, err := NewBlockChain(BlockchainOptionsWithScheme(snaptest.scheme), newdb, snaptest.gspec, snaptest.engine) + newchain, err := NewBlockChain(newdb, snaptest.gspec, snaptest.engine, BlockchainOptionsWithScheme(snaptest.scheme)) if err != nil { t.Fatalf("Failed to recreate chain: %v", err) } newchain.Stop() - newchain, err = NewBlockChain(BlockchainOptionsWithScheme(snaptest.scheme), newdb, snaptest.gspec, snaptest.engine) + newchain, err = NewBlockChain(newdb, snaptest.gspec, snaptest.engine, BlockchainOptionsWithScheme(snaptest.scheme)) if err != nil { t.Fatalf("Failed to recreate chain: %v", err) } @@ -317,7 +317,7 @@ func (snaptest *gappedSnapshotTest) test(t *testing.T) { SnapshotLimit: 0, StateScheme: snaptest.scheme, } - newchain, err := NewBlockChain(options, snaptest.db, snaptest.gspec, snaptest.engine) + newchain, err := NewBlockChain(snaptest.db, snaptest.gspec, snaptest.engine, options) if err != nil { t.Fatalf("Failed to recreate chain: %v", err) } @@ -326,7 +326,7 @@ func (snaptest *gappedSnapshotTest) test(t *testing.T) { // Restart the chain with enabling the snapshot options = BlockchainOptionsWithScheme(snaptest.scheme) - newchain, err = NewBlockChain(options, snaptest.db, snaptest.gspec, snaptest.engine) + newchain, err = NewBlockChain(snaptest.db, snaptest.gspec, snaptest.engine, options) if err != nil { t.Fatalf("Failed to recreate chain: %v", err) } @@ -354,7 +354,7 @@ func (snaptest *setHeadSnapshotTest) test(t *testing.T) { chain.SetHead(snaptest.setHead) chain.Stop() - newchain, err := NewBlockChain(BlockchainOptionsWithScheme(snaptest.scheme), snaptest.db, snaptest.gspec, snaptest.engine) + newchain, err := NewBlockChain(snaptest.db, snaptest.gspec, snaptest.engine, BlockchainOptionsWithScheme(snaptest.scheme)) if err != nil { t.Fatalf("Failed to recreate chain: %v", err) } @@ -390,7 +390,7 @@ func (snaptest *wipeCrashSnapshotTest) test(t *testing.T) { SnapshotLimit: 0, StateScheme: snaptest.scheme, } - newchain, err := NewBlockChain(config, snaptest.db, snaptest.gspec, snaptest.engine) + newchain, err := NewBlockChain(snaptest.db, snaptest.gspec, snaptest.engine, config) if err != nil { t.Fatalf("Failed to recreate chain: %v", err) } @@ -407,7 +407,7 @@ func (snaptest *wipeCrashSnapshotTest) test(t *testing.T) { SnapshotWait: false, // Don't wait rebuild StateScheme: snaptest.scheme, } - tmp, err := NewBlockChain(config, snaptest.db, snaptest.gspec, snaptest.engine) + tmp, err := NewBlockChain(snaptest.db, snaptest.gspec, snaptest.engine, config) if err != nil { t.Fatalf("Failed to recreate chain: %v", err) } @@ -416,7 +416,7 @@ func (snaptest *wipeCrashSnapshotTest) test(t *testing.T) { tmp.triedb.Close() tmp.stopWithoutSaving() - newchain, err = NewBlockChain(BlockchainOptionsWithScheme(snaptest.scheme), snaptest.db, snaptest.gspec, snaptest.engine) + newchain, err = NewBlockChain(snaptest.db, snaptest.gspec, snaptest.engine, BlockchainOptionsWithScheme(snaptest.scheme)) if err != nil { t.Fatalf("Failed to recreate chain: %v", err) } diff --git a/core/blockchain_test.go b/core/blockchain_test.go index a3a3084632..11d081e7f5 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -67,7 +67,7 @@ func newCanonical(engine consensus.Engine, n int, full bool, scheme string) (eth ) // Initialize a fresh chain with only a genesis block options := BlockchainOptionsWithScheme(scheme) - blockchain, _ := NewBlockChain(options, rawdb.NewMemoryDatabase(), genesis, engine) + blockchain, _ := NewBlockChain(rawdb.NewMemoryDatabase(), genesis, engine, options) // Create and inject the requested chain if n == 0 { @@ -724,7 +724,7 @@ func testFastVsFullChains(t *testing.T, scheme string) { }) // Import the chain as an archive node for the comparison baseline archiveDb := rawdb.NewMemoryDatabase() - archive, _ := NewBlockChain(BlockchainOptionsWithScheme(scheme), archiveDb, gspec, ethash.NewFaker()) + archive, _ := NewBlockChain(archiveDb, gspec, ethash.NewFaker(), BlockchainOptionsWithScheme(scheme)) defer archive.Stop() if n, err := archive.InsertChain(blocks); err != nil { @@ -732,7 +732,7 @@ func testFastVsFullChains(t *testing.T, scheme string) { } // Fast import the chain as a non-archive node to test fastDb := rawdb.NewMemoryDatabase() - fast, _ := NewBlockChain(BlockchainOptionsWithScheme(scheme), fastDb, gspec, ethash.NewFaker()) + fast, _ := NewBlockChain(fastDb, gspec, ethash.NewFaker(), BlockchainOptionsWithScheme(scheme)) defer fast.Stop() if n, err := fast.InsertReceiptChain(blocks, types.EncodeBlockReceiptLists(receipts), 0); err != nil { @@ -745,7 +745,7 @@ func testFastVsFullChains(t *testing.T, scheme string) { } defer ancientDb.Close() - ancient, _ := NewBlockChain(BlockchainOptionsWithScheme(scheme), ancientDb, gspec, ethash.NewFaker()) + ancient, _ := NewBlockChain(ancientDb, gspec, ethash.NewFaker(), BlockchainOptionsWithScheme(scheme)) defer ancient.Stop() if n, err := ancient.InsertReceiptChain(blocks, types.EncodeBlockReceiptLists(receipts), uint64(len(blocks)/2)); err != nil { @@ -856,7 +856,7 @@ func testLightVsFastVsFullChainHeads(t *testing.T, scheme string) { options.ArchiveMode = true options.StateScheme = scheme - archive, _ := NewBlockChain(&options, archiveDb, gspec, ethash.NewFaker()) + archive, _ := NewBlockChain(archiveDb, gspec, ethash.NewFaker(), &options) if n, err := archive.InsertChain(blocks); err != nil { t.Fatalf("failed to process block %d: %v", n, err) } @@ -869,7 +869,7 @@ func testLightVsFastVsFullChainHeads(t *testing.T, scheme string) { // Import the chain as a non-archive node and ensure all pointers are updated fastDb := makeDb() defer fastDb.Close() - fast, _ := NewBlockChain(BlockchainOptionsWithScheme(scheme), fastDb, gspec, ethash.NewFaker()) + fast, _ := NewBlockChain(fastDb, gspec, ethash.NewFaker(), BlockchainOptionsWithScheme(scheme)) defer fast.Stop() if n, err := fast.InsertReceiptChain(blocks, types.EncodeBlockReceiptLists(receipts), 0); err != nil { @@ -882,7 +882,7 @@ func testLightVsFastVsFullChainHeads(t *testing.T, scheme string) { // Import the chain as a ancient-first node and ensure all pointers are updated ancientDb := makeDb() defer ancientDb.Close() - ancient, _ := NewBlockChain(BlockchainOptionsWithScheme(scheme), ancientDb, gspec, ethash.NewFaker()) + ancient, _ := NewBlockChain(ancientDb, gspec, ethash.NewFaker(), BlockchainOptionsWithScheme(scheme)) defer ancient.Stop() if n, err := ancient.InsertReceiptChain(blocks, types.EncodeBlockReceiptLists(receipts), uint64(3*len(blocks)/4)); err != nil { @@ -903,7 +903,7 @@ func testLightVsFastVsFullChainHeads(t *testing.T, scheme string) { for i, block := range blocks { headers[i] = block.Header() } - light, _ := NewBlockChain(BlockchainOptionsWithScheme(scheme), lightDb, gspec, ethash.NewFaker()) + light, _ := NewBlockChain(lightDb, gspec, ethash.NewFaker(), BlockchainOptionsWithScheme(scheme)) if n, err := light.InsertHeaderChain(headers); err != nil { t.Fatalf("failed to insert header %d: %v", n, err) } @@ -976,7 +976,7 @@ func testChainTxReorgs(t *testing.T, scheme string) { }) // Import the chain. This runs all block validation rules. db := rawdb.NewMemoryDatabase() - blockchain, _ := NewBlockChain(BlockchainOptionsWithScheme(scheme), db, gspec, ethash.NewFaker()) + blockchain, _ := NewBlockChain(db, gspec, ethash.NewFaker(), BlockchainOptionsWithScheme(scheme)) if i, err := blockchain.InsertChain(chain); err != nil { t.Fatalf("failed to insert original chain[%d]: %v", i, err) } @@ -1050,7 +1050,7 @@ func testLogReorgs(t *testing.T, scheme string) { signer = types.LatestSigner(gspec.Config) ) - blockchain, _ := NewBlockChain(BlockchainOptionsWithScheme(scheme), rawdb.NewMemoryDatabase(), gspec, ethash.NewFaker()) + blockchain, _ := NewBlockChain(rawdb.NewMemoryDatabase(), gspec, ethash.NewFaker(), BlockchainOptionsWithScheme(scheme)) defer blockchain.Stop() rmLogsCh := make(chan RemovedLogsEvent) @@ -1106,7 +1106,7 @@ func testLogRebirth(t *testing.T, scheme string) { gspec = &Genesis{Config: params.TestChainConfig, Alloc: types.GenesisAlloc{addr1: {Balance: big.NewInt(10000000000000000)}}} signer = types.LatestSigner(gspec.Config) engine = ethash.NewFaker() - blockchain, _ = NewBlockChain(BlockchainOptionsWithScheme(scheme), rawdb.NewMemoryDatabase(), gspec, engine) + blockchain, _ = NewBlockChain(rawdb.NewMemoryDatabase(), gspec, engine, BlockchainOptionsWithScheme(scheme)) ) defer blockchain.Stop() @@ -1187,7 +1187,7 @@ func testSideLogRebirth(t *testing.T, scheme string) { addr1 = crypto.PubkeyToAddress(key1.PublicKey) gspec = &Genesis{Config: params.TestChainConfig, Alloc: types.GenesisAlloc{addr1: {Balance: big.NewInt(10000000000000000)}}} signer = types.LatestSigner(gspec.Config) - blockchain, _ = NewBlockChain(BlockchainOptionsWithScheme(scheme), rawdb.NewMemoryDatabase(), gspec, ethash.NewFaker()) + blockchain, _ = NewBlockChain(rawdb.NewMemoryDatabase(), gspec, ethash.NewFaker(), BlockchainOptionsWithScheme(scheme)) ) defer blockchain.Stop() @@ -1386,7 +1386,7 @@ func testEIP155Transition(t *testing.T, scheme string) { } }) - blockchain, _ := NewBlockChain(BlockchainOptionsWithScheme(scheme), rawdb.NewMemoryDatabase(), gspec, ethash.NewFaker()) + blockchain, _ := NewBlockChain(rawdb.NewMemoryDatabase(), gspec, ethash.NewFaker(), BlockchainOptionsWithScheme(scheme)) defer blockchain.Stop() if _, err := blockchain.InsertChain(blocks); err != nil { @@ -1479,7 +1479,7 @@ func testEIP161AccountRemoval(t *testing.T, scheme string) { block.AddTx(tx) }) // account must exist pre eip 161 - blockchain, _ := NewBlockChain(BlockchainOptionsWithScheme(scheme), rawdb.NewMemoryDatabase(), gspec, ethash.NewFaker()) + blockchain, _ := NewBlockChain(rawdb.NewMemoryDatabase(), gspec, ethash.NewFaker(), BlockchainOptionsWithScheme(scheme)) defer blockchain.Stop() if _, err := blockchain.InsertChain(types.Blocks{blocks[0]}); err != nil { @@ -1537,7 +1537,7 @@ func testBlockchainHeaderchainReorgConsistency(t *testing.T, scheme string) { } // Import the canonical and fork chain side by side, verifying the current block // and current header consistency - chain, err := NewBlockChain(BlockchainOptionsWithScheme(scheme), rawdb.NewMemoryDatabase(), genesis, engine) + chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), genesis, engine, BlockchainOptionsWithScheme(scheme)) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -1581,7 +1581,7 @@ func TestTrieForkGC(t *testing.T) { forks[i] = fork[0] } // Import the canonical and fork chain side by side, forcing the trie cache to cache both - chain, err := NewBlockChain(nil, rawdb.NewMemoryDatabase(), genesis, engine) + chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), genesis, engine, nil) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -1627,7 +1627,7 @@ func testLargeReorgTrieGC(t *testing.T, scheme string) { db, _ := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), "", "", false) defer db.Close() - chain, err := NewBlockChain(BlockchainOptionsWithScheme(scheme), db, genesis, engine) + chain, err := NewBlockChain(db, genesis, engine, BlockchainOptionsWithScheme(scheme)) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -1695,7 +1695,7 @@ func testBlockchainRecovery(t *testing.T, scheme string) { t.Fatalf("failed to create temp freezer db: %v", err) } defer ancientDb.Close() - ancient, _ := NewBlockChain(BlockchainOptionsWithScheme(scheme), ancientDb, gspec, ethash.NewFaker()) + ancient, _ := NewBlockChain(ancientDb, gspec, ethash.NewFaker(), BlockchainOptionsWithScheme(scheme)) if n, err := ancient.InsertReceiptChain(blocks, types.EncodeBlockReceiptLists(receipts), uint64(3*len(blocks)/4)); err != nil { t.Fatalf("failed to insert receipt %d: %v", n, err) @@ -1708,7 +1708,7 @@ func testBlockchainRecovery(t *testing.T, scheme string) { rawdb.WriteHeadFastBlockHash(ancientDb, midBlock.Hash()) // Reopen broken blockchain again - ancient, _ = NewBlockChain(BlockchainOptionsWithScheme(scheme), ancientDb, gspec, ethash.NewFaker()) + ancient, _ = NewBlockChain(ancientDb, gspec, ethash.NewFaker(), BlockchainOptionsWithScheme(scheme)) defer ancient.Stop() if num := ancient.CurrentBlock().Number.Uint64(); num != 0 { t.Errorf("head block mismatch: have #%v, want #%v", num, 0) @@ -1751,7 +1751,7 @@ func testLowDiffLongChain(t *testing.T, scheme string) { diskdb, _ := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), "", "", false) defer diskdb.Close() - chain, err := NewBlockChain(BlockchainOptionsWithScheme(scheme), diskdb, genesis, engine) + chain, err := NewBlockChain(diskdb, genesis, engine, BlockchainOptionsWithScheme(scheme)) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -1812,7 +1812,7 @@ func testSideImport(t *testing.T, numCanonBlocksInSidechain, blocksBetweenCommon mergeBlock = gomath.MaxInt32 ) // Generate and import the canonical chain - chain, err := NewBlockChain(nil, rawdb.NewMemoryDatabase(), gspec, engine) + chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), gspec, engine, nil) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -1966,7 +1966,7 @@ func testInsertKnownChainData(t *testing.T, typ string, scheme string) { } defer chaindb.Close() - chain, err := NewBlockChain(BlockchainOptionsWithScheme(scheme), chaindb, genesis, engine) + chain, err := NewBlockChain(chaindb, genesis, engine, BlockchainOptionsWithScheme(scheme)) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -2129,7 +2129,7 @@ func testInsertKnownChainDataWithMerging(t *testing.T, typ string, mergeHeight i } defer chaindb.Close() - chain, err := NewBlockChain(nil, chaindb, genesis, engine) + chain, err := NewBlockChain(chaindb, genesis, engine, nil) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -2235,7 +2235,7 @@ func getLongAndShortChains(scheme string) (*BlockChain, []*types.Block, []*types genDb, longChain, _ := GenerateChainWithGenesis(genesis, engine, 80, func(i int, b *BlockGen) { b.SetCoinbase(common.Address{1}) }) - chain, err := NewBlockChain(BlockchainOptionsWithScheme(scheme), rawdb.NewMemoryDatabase(), genesis, engine) + chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), genesis, engine, BlockchainOptionsWithScheme(scheme)) if err != nil { return nil, nil, nil, nil, fmt.Errorf("failed to create tester chain: %v", err) } @@ -2411,7 +2411,7 @@ func benchmarkLargeNumberOfValueToNonexisting(b *testing.B, numTxs, numBlocks in b.ResetTimer() for i := 0; i < b.N; i++ { // Import the shared chain and the original canonical one - chain, err := NewBlockChain(nil, rawdb.NewMemoryDatabase(), gspec, engine) + chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), gspec, engine, nil) if err != nil { b.Fatalf("failed to create tester chain: %v", err) } @@ -2503,7 +2503,7 @@ func testSideImportPrunedBlocks(t *testing.T, scheme string) { } defer db.Close() - chain, err := NewBlockChain(BlockchainOptionsWithScheme(scheme), db, genesis, engine) + chain, err := NewBlockChain(db, genesis, engine, BlockchainOptionsWithScheme(scheme)) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -2603,7 +2603,7 @@ func testDeleteCreateRevert(t *testing.T, scheme string) { }) // Import the canonical chain options := BlockchainOptionsWithScheme(scheme) - chain, err := NewBlockChain(options, rawdb.NewMemoryDatabase(), gspec, engine) + chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), gspec, engine, options) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -2720,7 +2720,7 @@ func testDeleteRecreateSlots(t *testing.T, scheme string) { options.VmConfig = vm.Config{ Tracer: logger.NewJSONLogger(nil, os.Stdout), } - chain, err := NewBlockChain(options, rawdb.NewMemoryDatabase(), gspec, engine) + chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), gspec, engine, options) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -2804,7 +2804,7 @@ func testDeleteRecreateAccount(t *testing.T, scheme string) { options.VmConfig = vm.Config{ Tracer: logger.NewJSONLogger(nil, os.Stdout), } - chain, err := NewBlockChain(options, rawdb.NewMemoryDatabase(), gspec, engine) + chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), gspec, engine, options) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -2982,7 +2982,7 @@ func testDeleteRecreateSlotsAcrossManyBlocks(t *testing.T, scheme string) { //Debug: true, //Tracer: vm.NewJSONLogger(nil, os.Stdout), } - chain, err := NewBlockChain(options, rawdb.NewMemoryDatabase(), gspec, engine) + chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), gspec, engine, options) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -3122,7 +3122,7 @@ func testInitThenFailCreateContract(t *testing.T, scheme string) { //Debug: true, //Tracer: vm.NewJSONLogger(nil, os.Stdout), } - chain, err := NewBlockChain(options, rawdb.NewMemoryDatabase(), gspec, engine) + chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), gspec, engine, options) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -3210,7 +3210,7 @@ func testEIP2718Transition(t *testing.T, scheme string) { // Import the canonical chain options := BlockchainOptionsWithScheme(scheme) - chain, err := NewBlockChain(options, rawdb.NewMemoryDatabase(), gspec, engine) + chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), gspec, engine, options) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -3305,7 +3305,7 @@ func testEIP1559Transition(t *testing.T, scheme string) { b.AddTx(tx) }) options := BlockchainOptionsWithScheme(scheme) - chain, err := NewBlockChain(options, rawdb.NewMemoryDatabase(), gspec, engine) + chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), gspec, engine, options) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -3419,7 +3419,7 @@ func testSetCanonical(t *testing.T, scheme string) { defer diskdb.Close() options := BlockchainOptionsWithScheme(scheme) - chain, err := NewBlockChain(options, diskdb, gspec, engine) + chain, err := NewBlockChain(diskdb, gspec, engine, options) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -3529,7 +3529,7 @@ func testCanonicalHashMarker(t *testing.T, scheme string) { // Initialize test chain options := BlockchainOptionsWithScheme(scheme) - chain, err := NewBlockChain(options, rawdb.NewMemoryDatabase(), gspec, engine) + chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), gspec, engine, options) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -3663,7 +3663,7 @@ func testCreateThenDelete(t *testing.T, config *params.ChainConfig) { nonce++ }) // Import the canonical chain - chain, err := NewBlockChain(nil, rawdb.NewMemoryDatabase(), gspec, engine) + chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), gspec, engine, nil) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -3775,7 +3775,7 @@ func TestDeleteThenCreate(t *testing.T) { } }) // Import the canonical chain - chain, err := NewBlockChain(nil, rawdb.NewMemoryDatabase(), gspec, engine) + chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), gspec, engine, nil) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -3862,7 +3862,7 @@ func TestTransientStorageReset(t *testing.T) { // Initialize the blockchain with 1153 enabled. options := *defaultOptions options.VmConfig = vmConfig - chain, err := NewBlockChain(&options, rawdb.NewMemoryDatabase(), gspec, engine) + chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), gspec, engine, &options) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -3960,7 +3960,7 @@ func TestEIP3651(t *testing.T) { options.VmConfig = vm.Config{ Tracer: logger.NewMarkdownLogger(&logger.Config{}, os.Stderr).Hooks(), } - chain, err := NewBlockChain(&options, rawdb.NewMemoryDatabase(), gspec, engine) + chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), gspec, engine, &options) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -4069,7 +4069,7 @@ func TestPragueRequests(t *testing.T) { } // Insert block to check validation. - chain, err := NewBlockChain(nil, rawdb.NewMemoryDatabase(), gspec, engine) + chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), gspec, engine, nil) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -4141,7 +4141,7 @@ func TestEIP7702(t *testing.T) { tx := types.MustSignNewTx(key1, signer, txdata) b.AddTx(tx) }) - chain, err := NewBlockChain(nil, rawdb.NewMemoryDatabase(), gspec, engine) + chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), gspec, engine, nil) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -4220,7 +4220,7 @@ func testChainReorgSnapSync(t *testing.T, ancientLimit uint64) { defer db.Close() options := BlockchainOptionsWithScheme(rawdb.PathScheme) - chain, _ := NewBlockChain(options, db, gspec, beacon.New(ethash.NewFaker())) + chain, _ := NewBlockChain(db, gspec, beacon.New(ethash.NewFaker()), options) defer chain.Stop() if n, err := chain.InsertReceiptChain(blocks, types.EncodeBlockReceiptLists(receipts), ancientLimit); err != nil { @@ -4337,7 +4337,7 @@ func testInsertChainWithCutoff(t *testing.T, cutoff uint64, ancientLimit uint64, defer db.Close() options := BlockchainOptionsWithScheme(rawdb.PathScheme) - chain, _ := NewBlockChain(options, db, genesis, beacon.New(ethash.NewFaker())) + chain, _ := NewBlockChain(db, genesis, beacon.New(ethash.NewFaker()), options) defer chain.Stop() var ( diff --git a/core/chain_makers_test.go b/core/chain_makers_test.go index 651d860f37..957b3b3180 100644 --- a/core/chain_makers_test.go +++ b/core/chain_makers_test.go @@ -118,7 +118,7 @@ func TestGeneratePOSChain(t *testing.T) { }) // Import the chain. This runs all block validation rules. - blockchain, _ := NewBlockChain(nil, db, gspec, engine) + blockchain, _ := NewBlockChain(db, gspec, engine, nil) defer blockchain.Stop() if i, err := blockchain.InsertChain(genchain); err != nil { @@ -233,7 +233,7 @@ func ExampleGenerateChain() { }) // Import the chain. This runs all block validation rules. - blockchain, _ := NewBlockChain(BlockchainOptionsWithScheme(rawdb.HashScheme), db, gspec, ethash.NewFaker()) + blockchain, _ := NewBlockChain(db, gspec, ethash.NewFaker(), BlockchainOptionsWithScheme(rawdb.HashScheme)) defer blockchain.Stop() if i, err := blockchain.InsertChain(chain); err != nil { diff --git a/core/dao_test.go b/core/dao_test.go index 503cc57af2..2d4a20e6b9 100644 --- a/core/dao_test.go +++ b/core/dao_test.go @@ -49,7 +49,7 @@ func TestDAOForkRangeExtradata(t *testing.T) { BaseFee: big.NewInt(params.InitialBaseFee), Config: &proConf, } - proBc, _ := NewBlockChain(nil, proDb, progspec, ethash.NewFaker()) + proBc, _ := NewBlockChain(proDb, progspec, ethash.NewFaker(), nil) defer proBc.Stop() conDb := rawdb.NewMemoryDatabase() @@ -61,7 +61,7 @@ func TestDAOForkRangeExtradata(t *testing.T) { BaseFee: big.NewInt(params.InitialBaseFee), Config: &conConf, } - conBc, _ := NewBlockChain(nil, conDb, congspec, ethash.NewFaker()) + conBc, _ := NewBlockChain(conDb, congspec, ethash.NewFaker(), nil) defer conBc.Stop() if _, err := proBc.InsertChain(prefix); err != nil { @@ -73,7 +73,7 @@ func TestDAOForkRangeExtradata(t *testing.T) { // Try to expand both pro-fork and non-fork chains iteratively with other camp's blocks for i := int64(0); i < params.DAOForkExtraRange.Int64(); i++ { // Create a pro-fork block, and try to feed into the no-fork chain - bc, _ := NewBlockChain(nil, rawdb.NewMemoryDatabase(), congspec, ethash.NewFaker()) + bc, _ := NewBlockChain(rawdb.NewMemoryDatabase(), congspec, ethash.NewFaker(), nil) blocks := conBc.GetBlocksFromHash(conBc.CurrentBlock().Hash(), int(conBc.CurrentBlock().Number.Uint64())) for j := 0; j < len(blocks)/2; j++ { @@ -96,7 +96,7 @@ func TestDAOForkRangeExtradata(t *testing.T) { t.Fatalf("contra-fork chain didn't accepted no-fork block: %v", err) } // Create a no-fork block, and try to feed into the pro-fork chain - bc, _ = NewBlockChain(nil, rawdb.NewMemoryDatabase(), progspec, ethash.NewFaker()) + bc, _ = NewBlockChain(rawdb.NewMemoryDatabase(), progspec, ethash.NewFaker(), nil) blocks = proBc.GetBlocksFromHash(proBc.CurrentBlock().Hash(), int(proBc.CurrentBlock().Number.Uint64())) for j := 0; j < len(blocks)/2; j++ { @@ -120,7 +120,7 @@ func TestDAOForkRangeExtradata(t *testing.T) { } } // Verify that contra-forkers accept pro-fork extra-datas after forking finishes - bc, _ := NewBlockChain(nil, rawdb.NewMemoryDatabase(), congspec, ethash.NewFaker()) + bc, _ := NewBlockChain(rawdb.NewMemoryDatabase(), congspec, ethash.NewFaker(), nil) defer bc.Stop() blocks := conBc.GetBlocksFromHash(conBc.CurrentBlock().Hash(), int(conBc.CurrentBlock().Number.Uint64())) @@ -138,7 +138,7 @@ func TestDAOForkRangeExtradata(t *testing.T) { t.Fatalf("contra-fork chain didn't accept pro-fork block post-fork: %v", err) } // Verify that pro-forkers accept contra-fork extra-datas after forking finishes - bc, _ = NewBlockChain(nil, rawdb.NewMemoryDatabase(), progspec, ethash.NewFaker()) + bc, _ = NewBlockChain(rawdb.NewMemoryDatabase(), progspec, ethash.NewFaker(), nil) defer bc.Stop() blocks = proBc.GetBlocksFromHash(proBc.CurrentBlock().Hash(), int(proBc.CurrentBlock().Number.Uint64())) diff --git a/core/genesis_test.go b/core/genesis_test.go index 2185972d2e..83e29e8caa 100644 --- a/core/genesis_test.go +++ b/core/genesis_test.go @@ -130,7 +130,7 @@ func testSetupGenesis(t *testing.T, scheme string) { tdb := triedb.NewDatabase(db, newDbConfig(scheme)) oldcustomg.Commit(db, tdb) - bc, _ := NewBlockChain(BlockchainOptionsWithScheme(scheme), db, &oldcustomg, ethash.NewFullFaker()) + bc, _ := NewBlockChain(db, &oldcustomg, ethash.NewFullFaker(), BlockchainOptionsWithScheme(scheme)) defer bc.Stop() _, blocks, _ := GenerateChainWithGenesis(&oldcustomg, ethash.NewFaker(), 4, nil) diff --git a/core/state_processor_test.go b/core/state_processor_test.go index ff40a1b732..d175b5eac5 100644 --- a/core/state_processor_test.go +++ b/core/state_processor_test.go @@ -124,7 +124,7 @@ func TestStateProcessorErrors(t *testing.T) { }, }, } - blockchain, _ = NewBlockChain(nil, db, gspec, beacon.New(ethash.NewFaker())) + blockchain, _ = NewBlockChain(db, gspec, beacon.New(ethash.NewFaker()), nil) tooBigInitCode = [params.MaxInitCodeSize + 1]byte{} ) @@ -292,7 +292,7 @@ func TestStateProcessorErrors(t *testing.T) { }, }, } - blockchain, _ = NewBlockChain(nil, db, gspec, ethash.NewFaker()) + blockchain, _ = NewBlockChain(db, gspec, ethash.NewFaker(), nil) ) defer blockchain.Stop() for i, tt := range []struct { @@ -331,7 +331,7 @@ func TestStateProcessorErrors(t *testing.T) { }, }, } - blockchain, _ = NewBlockChain(nil, db, gspec, beacon.New(ethash.NewFaker())) + blockchain, _ = NewBlockChain(db, gspec, beacon.New(ethash.NewFaker()), nil) ) defer blockchain.Stop() for i, tt := range []struct { diff --git a/core/txpool/locals/tx_tracker_test.go b/core/txpool/locals/tx_tracker_test.go index a080a84d3f..367fb6b6da 100644 --- a/core/txpool/locals/tx_tracker_test.go +++ b/core/txpool/locals/tx_tracker_test.go @@ -64,7 +64,7 @@ func newTestEnv(t *testing.T, n int, gasTip uint64, journal string) *testEnv { }) db := rawdb.NewMemoryDatabase() - chain, _ := core.NewBlockChain(nil, db, gspec, ethash.NewFaker()) + chain, _ := core.NewBlockChain(db, gspec, ethash.NewFaker(), nil) legacyPool := legacypool.New(legacypool.DefaultConfig, chain) pool, err := txpool.New(gasTip, chain, []txpool.SubPool{legacyPool}) diff --git a/core/verkle_witness_test.go b/core/verkle_witness_test.go index 4f6755d6c2..cdbb6ae240 100644 --- a/core/verkle_witness_test.go +++ b/core/verkle_witness_test.go @@ -121,7 +121,7 @@ func TestProcessVerkle(t *testing.T) { // genesis := gspec.MustCommit(bcdb, triedb) options := BlockchainOptionsWithScheme(rawdb.PathScheme) options.SnapshotLimit = 0 - blockchain, _ := NewBlockChain(options, bcdb, gspec, beacon.New(ethash.NewFaker())) + blockchain, _ := NewBlockChain(bcdb, gspec, beacon.New(ethash.NewFaker()), options) defer blockchain.Stop() txCost1 := params.TxGas diff --git a/eth/api_backend_test.go b/eth/api_backend_test.go index 9fcf4aed50..d0718ede1c 100644 --- a/eth/api_backend_test.go +++ b/eth/api_backend_test.go @@ -60,7 +60,7 @@ func initBackend(withLocal bool) *EthAPIBackend { db = rawdb.NewMemoryDatabase() engine = beacon.New(ethash.NewFaker()) ) - chain, _ := core.NewBlockChain(nil, db, gspec, engine) + chain, _ := core.NewBlockChain(db, gspec, engine, nil) txconfig := legacypool.DefaultConfig txconfig.Journal = "" // Don't litter the disk with test journals diff --git a/eth/api_debug_test.go b/eth/api_debug_test.go index 2eed20f1ad..2862041f70 100644 --- a/eth/api_debug_test.go +++ b/eth/api_debug_test.go @@ -75,7 +75,7 @@ func newTestBlockChain(t *testing.T, n int, gspec *core.Genesis, generator func( Preimages: true, ArchiveMode: true, // Archive mode } - chain, err := core.NewBlockChain(options, rawdb.NewMemoryDatabase(), gspec, engine) + chain, err := core.NewBlockChain(rawdb.NewMemoryDatabase(), gspec, engine, options) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } diff --git a/eth/backend.go b/eth/backend.go index 1d5288ea24..c8ec2bb410 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -230,7 +230,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { } options.Overrides = &overrides - eth.blockchain, err = core.NewBlockChain(options, chainDb, config.Genesis, eth.engine) + eth.blockchain, err = core.NewBlockChain(chainDb, config.Genesis, eth.engine, options) if err != nil { return nil, err } diff --git a/eth/downloader/downloader_test.go b/eth/downloader/downloader_test.go index 6be5b10f41..4162615de6 100644 --- a/eth/downloader/downloader_test.go +++ b/eth/downloader/downloader_test.go @@ -67,7 +67,7 @@ func newTesterWithNotification(t *testing.T, success func()) *downloadTester { Alloc: types.GenesisAlloc{testAddress: {Balance: big.NewInt(1000000000000000)}}, BaseFee: big.NewInt(params.InitialBaseFee), } - chain, err := core.NewBlockChain(nil, db, gspec, ethash.NewFaker()) + chain, err := core.NewBlockChain(db, gspec, ethash.NewFaker(), nil) if err != nil { panic(err) } diff --git a/eth/downloader/testchain_test.go b/eth/downloader/testchain_test.go index d270cddd9b..ecd7386f42 100644 --- a/eth/downloader/testchain_test.go +++ b/eth/downloader/testchain_test.go @@ -216,7 +216,7 @@ func newTestBlockchain(blocks []*types.Block) *core.BlockChain { if pregenerated { panic("Requested chain generation outside of init") } - chain, err := core.NewBlockChain(nil, rawdb.NewMemoryDatabase(), testGspec, ethash.NewFaker()) + chain, err := core.NewBlockChain(rawdb.NewMemoryDatabase(), testGspec, ethash.NewFaker(), nil) if err != nil { panic(err) } diff --git a/eth/filters/filter_test.go b/eth/filters/filter_test.go index eeb9f6546c..8dc2cded20 100644 --- a/eth/filters/filter_test.go +++ b/eth/filters/filter_test.go @@ -279,7 +279,7 @@ func testFilters(t *testing.T, history uint64, noHistory bool) { var l uint64 options := core.BlockchainOptionsWithScheme(rawdb.HashScheme) options.TxLookupLimit = &l - bc, err := core.NewBlockChain(options, db, gspec, ethash.NewFaker()) + bc, err := core.NewBlockChain(db, gspec, ethash.NewFaker(), options) if err != nil { t.Fatal(err) } @@ -439,7 +439,7 @@ func TestRangeLogs(t *testing.T) { var l uint64 options := core.BlockchainOptionsWithScheme(rawdb.HashScheme) options.TxLookupLimit = &l - bc, err := core.NewBlockChain(options, db, gspec, ethash.NewFaker()) + bc, err := core.NewBlockChain(db, gspec, ethash.NewFaker(), options) if err != nil { t.Fatal(err) } diff --git a/eth/handler_eth_test.go b/eth/handler_eth_test.go index 3dfe765430..058a0d5949 100644 --- a/eth/handler_eth_test.go +++ b/eth/handler_eth_test.go @@ -96,8 +96,8 @@ func testForkIDSplit(t *testing.T, protocol uint) { gspecNoFork = &core.Genesis{Config: configNoFork} gspecProFork = &core.Genesis{Config: configProFork} - chainNoFork, _ = core.NewBlockChain(nil, dbNoFork, gspecNoFork, engine) - chainProFork, _ = core.NewBlockChain(nil, dbProFork, gspecProFork, engine) + chainNoFork, _ = core.NewBlockChain(dbNoFork, gspecNoFork, engine, nil) + chainProFork, _ = core.NewBlockChain(dbProFork, gspecProFork, engine, nil) _, blocksNoFork, _ = core.GenerateChainWithGenesis(gspecNoFork, engine, 2, nil) _, blocksProFork, _ = core.GenerateChainWithGenesis(gspecProFork, engine, 2, nil) diff --git a/eth/handler_test.go b/eth/handler_test.go index 28db0aae3f..d0da098430 100644 --- a/eth/handler_test.go +++ b/eth/handler_test.go @@ -181,7 +181,7 @@ func newTestHandlerWithBlocks(blocks int) *testHandler { Config: params.TestChainConfig, Alloc: types.GenesisAlloc{testAddr: {Balance: big.NewInt(1000000)}}, } - chain, _ := core.NewBlockChain(nil, db, gspec, ethash.NewFaker()) + chain, _ := core.NewBlockChain(db, gspec, ethash.NewFaker(), nil) _, bs, _ := core.GenerateChainWithGenesis(gspec, ethash.NewFaker(), blocks, nil) if _, err := chain.InsertChain(bs); err != nil { diff --git a/eth/protocols/eth/handler_test.go b/eth/protocols/eth/handler_test.go index 5c1ca4c188..a3419d96ff 100644 --- a/eth/protocols/eth/handler_test.go +++ b/eth/protocols/eth/handler_test.go @@ -119,7 +119,7 @@ func newTestBackendWithGenerator(blocks int, shanghai bool, cancun bool, generat Alloc: types.GenesisAlloc{testAddr: {Balance: big.NewInt(100_000_000_000_000_000)}}, Difficulty: common.Big0, } - chain, _ := core.NewBlockChain(nil, db, gspec, engine) + chain, _ := core.NewBlockChain(db, gspec, engine, nil) _, bs, _ := core.GenerateChainWithGenesis(gspec, engine, blocks, generator) if _, err := chain.InsertChain(bs); err != nil { diff --git a/eth/protocols/snap/handler_fuzzing_test.go b/eth/protocols/snap/handler_fuzzing_test.go index aa67e50f92..33b957d851 100644 --- a/eth/protocols/snap/handler_fuzzing_test.go +++ b/eth/protocols/snap/handler_fuzzing_test.go @@ -125,7 +125,7 @@ func getChain() *core.BlockChain { SnapshotWait: true, } trieRoot = blocks[len(blocks)-1].Root() - bc, _ := core.NewBlockChain(options, rawdb.NewMemoryDatabase(), gspec, ethash.NewFaker()) + bc, _ := core.NewBlockChain(rawdb.NewMemoryDatabase(), gspec, ethash.NewFaker(), options) if _, err := bc.InsertChain(blocks); err != nil { panic(err) } diff --git a/eth/tracers/api_test.go b/eth/tracers/api_test.go index 68881c839d..b1413fe918 100644 --- a/eth/tracers/api_test.go +++ b/eth/tracers/api_test.go @@ -84,7 +84,7 @@ func newTestBackend(t *testing.T, n int, gspec *core.Genesis, generator func(i i SnapshotLimit: 0, ArchiveMode: true, // Archive mode } - chain, err := core.NewBlockChain(options, backend.chaindb, gspec, backend.engine) + chain, err := core.NewBlockChain(backend.chaindb, gspec, backend.engine, options) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -1151,7 +1151,7 @@ func newTestMergedBackend(t *testing.T, n int, gspec *core.Genesis, generator fu SnapshotLimit: 0, ArchiveMode: true, // Archive mode } - chain, err := core.NewBlockChain(options, backend.chaindb, gspec, backend.engine) + chain, err := core.NewBlockChain(backend.chaindb, gspec, backend.engine, options) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } diff --git a/eth/tracers/internal/tracetest/supply_test.go b/eth/tracers/internal/tracetest/supply_test.go index 57da0462d9..36292bd59e 100644 --- a/eth/tracers/internal/tracetest/supply_test.go +++ b/eth/tracers/internal/tracetest/supply_test.go @@ -556,7 +556,7 @@ func testSupplyTracer(t *testing.T, genesis *core.Genesis, gen func(*core.BlockG options := core.BlockchainOptionsWithScheme(rawdb.PathScheme) options.VmConfig = vm.Config{Tracer: tracer} - chain, err := core.NewBlockChain(options, rawdb.NewMemoryDatabase(), genesis, engine) + chain, err := core.NewBlockChain(rawdb.NewMemoryDatabase(), genesis, engine, options) if err != nil { return nil, nil, fmt.Errorf("failed to create tester chain: %v", err) } diff --git a/internal/ethapi/api_test.go b/internal/ethapi/api_test.go index 792f515b1f..2614a611f0 100644 --- a/internal/ethapi/api_test.go +++ b/internal/ethapi/api_test.go @@ -458,7 +458,7 @@ func newTestBackend(t *testing.T, n int, gspec *core.Genesis, engine consensus.E // Generate blocks for testing db, blocks, _ := core.GenerateChainWithGenesis(gspec, engine, n, generator) - chain, err := core.NewBlockChain(options, db, gspec, engine) + chain, err := core.NewBlockChain(db, gspec, engine, options) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } diff --git a/miner/miner_test.go b/miner/miner_test.go index 3cdefe827d..575ee4d0fd 100644 --- a/miner/miner_test.go +++ b/miner/miner_test.go @@ -151,7 +151,7 @@ func createMiner(t *testing.T) *Miner { // Create consensus engine engine := clique.New(chainConfig.Clique, chainDB) // Create Ethereum backend - bc, err := core.NewBlockChain(nil, chainDB, genesis, engine) + bc, err := core.NewBlockChain(chainDB, genesis, engine, nil) if err != nil { t.Fatalf("can't create new chain %v", err) } diff --git a/miner/payload_building_test.go b/miner/payload_building_test.go index f31b9f675f..78f3923974 100644 --- a/miner/payload_building_test.go +++ b/miner/payload_building_test.go @@ -117,7 +117,7 @@ func newTestWorkerBackend(t *testing.T, chainConfig *params.ChainConfig, engine default: t.Fatalf("unexpected consensus engine type: %T", engine) } - chain, err := core.NewBlockChain(&core.BlockchainOptions{ArchiveMode: true}, db, gspec, engine) + chain, err := core.NewBlockChain(db, gspec, engine, &core.BlockchainOptions{ArchiveMode: true}) if err != nil { t.Fatalf("core.NewBlockChain failed: %v", err) }