From d53768423704c99c7e208a98ab388e24f7dccb9b Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Mon, 20 Sep 2021 11:03:18 +0200 Subject: [PATCH] revert the signature of MustCommit to its original form --- accounts/abi/bind/backends/simulated.go | 2 +- consensus/clique/clique_test.go | 4 +- core/bench_test.go | 2 +- core/block_validator_test.go | 6 +- core/blockchain_repair_test.go | 2 +- core/blockchain_sethead_test.go | 2 +- core/blockchain_snapshot_test.go | 2 +- core/blockchain_test.go | 112 ++++++++++++------------ core/chain_makers_test.go | 2 +- core/dao_test.go | 14 +-- core/genesis.go | 6 +- core/genesis_test.go | 12 +-- core/headerchain_test.go | 2 +- core/rlp_test.go | 2 +- core/state_processor_test.go | 6 +- eth/filters/filter_system_test.go | 2 +- eth/handler_eth_test.go | 4 +- eth/handler_test.go | 2 +- eth/protocols/eth/handler_test.go | 2 +- eth/tracers/api_test.go | 4 +- les/test_helper.go | 4 +- light/lightchain_test.go | 4 +- light/odr_test.go | 4 +- light/trie_test.go | 4 +- light/txpool_test.go | 4 +- miner/worker_test.go | 4 +- tests/fuzzers/les/les-fuzzer.go | 2 +- 27 files changed, 108 insertions(+), 108 deletions(-) diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go index 35ad005503d3..06cd0908e746 100644 --- a/accounts/abi/bind/backends/simulated.go +++ b/accounts/abi/bind/backends/simulated.go @@ -77,7 +77,7 @@ type SimulatedBackend struct { // A simulated backend always uses chainID 1337. func NewSimulatedBackendWithDatabase(database ethdb.Database, alloc core.GenesisAlloc, gasLimit uint64) *SimulatedBackend { genesis := core.Genesis{Config: params.AllEthashProtocolChanges, GasLimit: gasLimit, Alloc: alloc} - genesis.MustCommit(database, nil) + genesis.MustCommit(database) blockchain, _ := core.NewBlockChain(database, nil, genesis.Config, ethash.NewFaker(), vm.Config{}, nil, nil) backend := &SimulatedBackend{ diff --git a/consensus/clique/clique_test.go b/consensus/clique/clique_test.go index b5fe2d8529b8..1bd32acd3746 100644 --- a/consensus/clique/clique_test.go +++ b/consensus/clique/clique_test.go @@ -52,7 +52,7 @@ func TestReimportMirroredState(t *testing.T) { BaseFee: big.NewInt(params.InitialBaseFee), } copy(genspec.ExtraData[extraVanity:], addr[:]) - genesis := genspec.MustCommit(db, nil) + genesis := genspec.MustCommit(db) // Generate a batch of blocks, each properly signed chain, _ := core.NewBlockChain(db, nil, params.AllCliqueProtocolChanges, engine, vm.Config{}, nil, nil) @@ -87,7 +87,7 @@ func TestReimportMirroredState(t *testing.T) { } // Insert the first two blocks and make sure the chain is valid db = rawdb.NewMemoryDatabase() - genspec.MustCommit(db, nil) + genspec.MustCommit(db) chain, _ = core.NewBlockChain(db, nil, params.AllCliqueProtocolChanges, engine, vm.Config{}, nil, nil) defer chain.Stop() diff --git a/core/bench_test.go b/core/bench_test.go index 8afc91564535..ce288d372e08 100644 --- a/core/bench_test.go +++ b/core/bench_test.go @@ -170,7 +170,7 @@ func benchInsertChain(b *testing.B, disk bool, gen func(int, *BlockGen)) { Config: params.TestChainConfig, Alloc: GenesisAlloc{benchRootAddr: {Balance: benchRootFunds}}, } - genesis := gspec.MustCommit(db, nil) + genesis := gspec.MustCommit(db) chain, _ := GenerateChain(gspec.Config, genesis, ethash.NewFaker(), db, b.N, gen) // Time the insertion of the new chain. diff --git a/core/block_validator_test.go b/core/block_validator_test.go index a234a0387761..3b4de337891c 100644 --- a/core/block_validator_test.go +++ b/core/block_validator_test.go @@ -34,7 +34,7 @@ func TestHeaderVerification(t *testing.T) { var ( testdb = rawdb.NewMemoryDatabase() gspec = &Genesis{Config: params.TestChainConfig} - genesis = gspec.MustCommit(testdb, nil) + genesis = gspec.MustCommit(testdb) blocks, _ = GenerateChain(params.TestChainConfig, genesis, ethash.NewFaker(), testdb, 8, nil) ) headers := make([]*types.Header, len(blocks)) @@ -86,7 +86,7 @@ func testHeaderConcurrentVerification(t *testing.T, threads int) { var ( testdb = rawdb.NewMemoryDatabase() gspec = &Genesis{Config: params.TestChainConfig} - genesis = gspec.MustCommit(testdb, nil) + genesis = gspec.MustCommit(testdb) blocks, _ = GenerateChain(params.TestChainConfig, genesis, ethash.NewFaker(), testdb, 8, nil) ) headers := make([]*types.Header, len(blocks)) @@ -158,7 +158,7 @@ func testHeaderConcurrentAbortion(t *testing.T, threads int) { var ( testdb = rawdb.NewMemoryDatabase() gspec = &Genesis{Config: params.TestChainConfig} - genesis = gspec.MustCommit(testdb, nil) + genesis = gspec.MustCommit(testdb) blocks, _ = GenerateChain(params.TestChainConfig, genesis, ethash.NewFaker(), testdb, 1024, nil) ) headers := make([]*types.Header, len(blocks)) diff --git a/core/blockchain_repair_test.go b/core/blockchain_repair_test.go index f5c0db563341..aca5546e2048 100644 --- a/core/blockchain_repair_test.go +++ b/core/blockchain_repair_test.go @@ -1770,7 +1770,7 @@ func testRepair(t *testing.T, tt *rewindTest, snapshots bool) { // Initialize a fresh chain var ( - genesis = (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db, nil) + genesis = (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db) engine = ethash.NewFullFaker() config = &CacheConfig{ TrieCleanLimit: 256, diff --git a/core/blockchain_sethead_test.go b/core/blockchain_sethead_test.go index 67ba9c8d63b6..27b6be6e1363 100644 --- a/core/blockchain_sethead_test.go +++ b/core/blockchain_sethead_test.go @@ -1969,7 +1969,7 @@ func testSetHead(t *testing.T, tt *rewindTest, snapshots bool) { // Initialize a fresh chain var ( - genesis = (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db, nil) + genesis = (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db) engine = ethash.NewFullFaker() config = &CacheConfig{ TrieCleanLimit: 256, diff --git a/core/blockchain_snapshot_test.go b/core/blockchain_snapshot_test.go index 5e195b56846d..94ec6879b79d 100644 --- a/core/blockchain_snapshot_test.go +++ b/core/blockchain_snapshot_test.go @@ -71,7 +71,7 @@ func (basic *snapshotTestBasic) prepare(t *testing.T) (*BlockChain, []*types.Blo } // Initialize a fresh chain var ( - genesis = (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db, nil) + genesis = (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db) engine = ethash.NewFullFaker() gendb = rawdb.NewMemoryDatabase() diff --git a/core/blockchain_test.go b/core/blockchain_test.go index ae3fd54ab0dc..b0926c606176 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -52,7 +52,7 @@ var ( func newCanonical(engine consensus.Engine, n int, full bool) (ethdb.Database, *BlockChain, error) { var ( db = rawdb.NewMemoryDatabase() - genesis = (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db, nil) + genesis = (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db) ) // Initialize a fresh chain with only a genesis block @@ -604,7 +604,7 @@ func TestFastVsFullChains(t *testing.T) { Alloc: GenesisAlloc{address: {Balance: funds}}, BaseFee: big.NewInt(params.InitialBaseFee), } - genesis = gspec.MustCommit(gendb, nil) + genesis = gspec.MustCommit(gendb) signer = types.LatestSigner(gspec.Config) ) blocks, receipts := GenerateChain(gspec.Config, genesis, ethash.NewFaker(), gendb, 1024, func(i int, block *BlockGen) { @@ -627,7 +627,7 @@ func TestFastVsFullChains(t *testing.T) { }) // Import the chain as an archive node for the comparison baseline archiveDb := rawdb.NewMemoryDatabase() - gspec.MustCommit(archiveDb, nil) + gspec.MustCommit(archiveDb) archive, _ := NewBlockChain(archiveDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) defer archive.Stop() @@ -636,7 +636,7 @@ func TestFastVsFullChains(t *testing.T) { } // Fast import the chain as a non-archive node to test fastDb := rawdb.NewMemoryDatabase() - gspec.MustCommit(fastDb, nil) + gspec.MustCommit(fastDb) fast, _ := NewBlockChain(fastDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) defer fast.Stop() @@ -660,7 +660,7 @@ func TestFastVsFullChains(t *testing.T) { if err != nil { t.Fatalf("failed to create temp freezer db: %v", err) } - gspec.MustCommit(ancientDb, nil) + gspec.MustCommit(ancientDb) ancient, _ := NewBlockChain(ancientDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) defer ancient.Stop() @@ -722,7 +722,7 @@ func TestLightVsFastVsFullChainHeads(t *testing.T) { Alloc: GenesisAlloc{address: {Balance: funds}}, BaseFee: big.NewInt(params.InitialBaseFee), } - genesis = gspec.MustCommit(gendb, nil) + genesis = gspec.MustCommit(gendb) ) height := uint64(1024) blocks, receipts := GenerateChain(gspec.Config, genesis, ethash.NewFaker(), gendb, int(height), nil) @@ -738,7 +738,7 @@ func TestLightVsFastVsFullChainHeads(t *testing.T) { if err != nil { t.Fatalf("failed to create temp freezer db: %v", err) } - gspec.MustCommit(db, nil) + gspec.MustCommit(db) return db, func() { os.RemoveAll(dir) } } // Configure a subchain to roll back @@ -847,7 +847,7 @@ func TestChainTxReorgs(t *testing.T) { addr3: {Balance: big.NewInt(1000000000000000)}, }, } - genesis = gspec.MustCommit(db, nil) + genesis = gspec.MustCommit(db) signer = types.LatestSigner(gspec.Config) ) @@ -952,7 +952,7 @@ func TestLogReorgs(t *testing.T) { // this code generates a log code = common.Hex2Bytes("60606040525b7f24ec1d3ff24c2f6ff210738839dbc339cd45a5294d85c79361016243157aae7b60405180905060405180910390a15b600a8060416000396000f360606040526008565b00") gspec = &Genesis{Config: params.TestChainConfig, Alloc: GenesisAlloc{addr1: {Balance: big.NewInt(10000000000000000)}}} - genesis = gspec.MustCommit(db, nil) + genesis = gspec.MustCommit(db) signer = types.LatestSigner(gspec.Config) ) @@ -1006,7 +1006,7 @@ func TestLogRebirth(t *testing.T) { addr1 = crypto.PubkeyToAddress(key1.PublicKey) db = rawdb.NewMemoryDatabase() gspec = &Genesis{Config: params.TestChainConfig, Alloc: GenesisAlloc{addr1: {Balance: big.NewInt(10000000000000000)}}} - genesis = gspec.MustCommit(db, nil) + genesis = gspec.MustCommit(db) signer = types.LatestSigner(gspec.Config) engine = ethash.NewFaker() blockchain, _ = NewBlockChain(db, nil, gspec.Config, engine, vm.Config{}, nil, nil) @@ -1070,7 +1070,7 @@ func TestSideLogRebirth(t *testing.T) { addr1 = crypto.PubkeyToAddress(key1.PublicKey) db = rawdb.NewMemoryDatabase() gspec = &Genesis{Config: params.TestChainConfig, Alloc: GenesisAlloc{addr1: {Balance: big.NewInt(10000000000000000)}}} - genesis = gspec.MustCommit(db, nil) + genesis = gspec.MustCommit(db) signer = types.LatestSigner(gspec.Config) blockchain, _ = NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) ) @@ -1143,7 +1143,7 @@ func TestReorgSideEvent(t *testing.T) { Config: params.TestChainConfig, Alloc: GenesisAlloc{addr1: {Balance: big.NewInt(10000000000000000)}}, } - genesis = gspec.MustCommit(db, nil) + genesis = gspec.MustCommit(db) signer = types.LatestSigner(gspec.Config) ) @@ -1276,7 +1276,7 @@ func TestEIP155Transition(t *testing.T) { Config: ¶ms.ChainConfig{ChainID: big.NewInt(1), EIP150Block: big.NewInt(0), EIP155Block: big.NewInt(2), HomesteadBlock: new(big.Int)}, Alloc: GenesisAlloc{address: {Balance: funds}, deleteAddr: {Balance: new(big.Int)}}, } - genesis = gspec.MustCommit(db, nil) + genesis = gspec.MustCommit(db) ) blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) @@ -1385,7 +1385,7 @@ func TestEIP161AccountRemoval(t *testing.T) { }, Alloc: GenesisAlloc{address: {Balance: funds}}, } - genesis = gspec.MustCommit(db, nil) + genesis = gspec.MustCommit(db) ) blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) defer blockchain.Stop() @@ -1444,7 +1444,7 @@ func TestBlockchainHeaderchainReorgConsistency(t *testing.T) { engine := ethash.NewFaker() db := rawdb.NewMemoryDatabase() - genesis := (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db, nil) + genesis := (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db) blocks, _ := GenerateChain(params.TestChainConfig, genesis, engine, db, 64, func(i int, b *BlockGen) { b.SetCoinbase(common.Address{1}) }) // Generate a bunch of fork blocks, each side forking from the canonical chain @@ -1460,7 +1460,7 @@ func TestBlockchainHeaderchainReorgConsistency(t *testing.T) { // Import the canonical and fork chain side by side, verifying the current block // and current header consistency diskdb := rawdb.NewMemoryDatabase() - (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(diskdb, nil) + (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(diskdb) chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) if err != nil { @@ -1489,7 +1489,7 @@ func TestTrieForkGC(t *testing.T) { engine := ethash.NewFaker() db := rawdb.NewMemoryDatabase() - genesis := (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db, nil) + genesis := (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db) blocks, _ := GenerateChain(params.TestChainConfig, genesis, engine, db, 2*TriesInMemory, func(i int, b *BlockGen) { b.SetCoinbase(common.Address{1}) }) // Generate a bunch of fork blocks, each side forking from the canonical chain @@ -1504,7 +1504,7 @@ func TestTrieForkGC(t *testing.T) { } // Import the canonical and fork chain side by side, forcing the trie cache to cache both diskdb := rawdb.NewMemoryDatabase() - (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(diskdb, nil) + (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(diskdb) chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) if err != nil { @@ -1535,7 +1535,7 @@ func TestLargeReorgTrieGC(t *testing.T) { engine := ethash.NewFaker() db := rawdb.NewMemoryDatabase() - genesis := (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db, nil) + genesis := (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db) shared, _ := GenerateChain(params.TestChainConfig, genesis, engine, db, 64, func(i int, b *BlockGen) { b.SetCoinbase(common.Address{1}) }) original, _ := GenerateChain(params.TestChainConfig, shared[len(shared)-1], engine, db, 2*TriesInMemory, func(i int, b *BlockGen) { b.SetCoinbase(common.Address{2}) }) @@ -1543,7 +1543,7 @@ func TestLargeReorgTrieGC(t *testing.T) { // Import the shared chain and the original canonical one diskdb := rawdb.NewMemoryDatabase() - (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(diskdb, nil) + (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(diskdb) chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) if err != nil { @@ -1589,7 +1589,7 @@ func TestBlockchainRecovery(t *testing.T) { address = crypto.PubkeyToAddress(key.PublicKey) funds = big.NewInt(1000000000) gspec = &Genesis{Config: params.TestChainConfig, Alloc: GenesisAlloc{address: {Balance: funds}}} - genesis = gspec.MustCommit(gendb, nil) + genesis = gspec.MustCommit(gendb) ) height := uint64(1024) blocks, receipts := GenerateChain(gspec.Config, genesis, ethash.NewFaker(), gendb, int(height), nil) @@ -1605,7 +1605,7 @@ func TestBlockchainRecovery(t *testing.T) { if err != nil { t.Fatalf("failed to create temp freezer db: %v", err) } - gspec.MustCommit(ancientDb, nil) + gspec.MustCommit(ancientDb) ancient, _ := NewBlockChain(ancientDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) headers := make([]*types.Header, len(blocks)) @@ -1647,7 +1647,7 @@ func TestIncompleteAncientReceiptChainInsertion(t *testing.T) { address = crypto.PubkeyToAddress(key.PublicKey) funds = big.NewInt(1000000000) gspec = &Genesis{Config: params.TestChainConfig, Alloc: GenesisAlloc{address: {Balance: funds}}} - genesis = gspec.MustCommit(gendb, nil) + genesis = gspec.MustCommit(gendb) ) height := uint64(1024) blocks, receipts := GenerateChain(gspec.Config, genesis, ethash.NewFaker(), gendb, int(height), nil) @@ -1662,7 +1662,7 @@ func TestIncompleteAncientReceiptChainInsertion(t *testing.T) { if err != nil { t.Fatalf("failed to create temp freezer db: %v", err) } - gspec.MustCommit(ancientDb, nil) + gspec.MustCommit(ancientDb) ancient, _ := NewBlockChain(ancientDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) defer ancient.Stop() @@ -1707,7 +1707,7 @@ func TestLowDiffLongChain(t *testing.T) { // Generate a canonical chain to act as the main dataset engine := ethash.NewFaker() db := rawdb.NewMemoryDatabase() - genesis := (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db, nil) + genesis := (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db) // We must use a pretty long chain to ensure that the fork doesn't overtake us // until after at least 128 blocks post tip @@ -1718,7 +1718,7 @@ func TestLowDiffLongChain(t *testing.T) { // Import the canonical chain diskdb := rawdb.NewMemoryDatabase() - (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(diskdb, nil) + (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(diskdb) chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) if err != nil { @@ -1761,12 +1761,12 @@ func testSideImport(t *testing.T, numCanonBlocksInSidechain, blocksBetweenCommon // Generate a canonical chain to act as the main dataset engine := ethash.NewFaker() db := rawdb.NewMemoryDatabase() - genesis := (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db, nil) + genesis := (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db) // Generate and import the canonical chain blocks, _ := GenerateChain(params.TestChainConfig, genesis, engine, db, 2*TriesInMemory, nil) diskdb := rawdb.NewMemoryDatabase() - (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(diskdb, nil) + (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(diskdb) chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) if err != nil { t.Fatalf("failed to create tester chain: %v", err) @@ -1841,7 +1841,7 @@ func testInsertKnownChainData(t *testing.T, typ string) { engine := ethash.NewFaker() db := rawdb.NewMemoryDatabase() - genesis := (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db, nil) + genesis := (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db) blocks, receipts := GenerateChain(params.TestChainConfig, genesis, engine, db, 32, func(i int, b *BlockGen) { b.SetCoinbase(common.Address{1}) }) // A longer chain but total difficulty is lower. @@ -1861,7 +1861,7 @@ func testInsertKnownChainData(t *testing.T, typ string) { if err != nil { t.Fatalf("failed to create temp freezer db: %v", err) } - (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(chaindb, nil) + (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(chaindb) defer os.RemoveAll(dir) chain, err := NewBlockChain(chaindb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) @@ -1964,7 +1964,7 @@ func getLongAndShortChains() (*BlockChain, []*types.Block, []*types.Block, error // Generate a canonical chain to act as the main dataset engine := ethash.NewFaker() db := rawdb.NewMemoryDatabase() - genesis := (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db, nil) + genesis := (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db) // Generate and import the canonical chain, // Offset the time, to keep the difficulty low @@ -1972,7 +1972,7 @@ func getLongAndShortChains() (*BlockChain, []*types.Block, []*types.Block, error b.SetCoinbase(common.Address{1}) }) diskdb := rawdb.NewMemoryDatabase() - (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(diskdb, nil) + (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(diskdb) chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) if err != nil { @@ -2090,7 +2090,7 @@ func TestTransactionIndices(t *testing.T) { Alloc: GenesisAlloc{address: {Balance: funds}}, BaseFee: big.NewInt(params.InitialBaseFee), } - genesis = gspec.MustCommit(gendb, nil) + genesis = gspec.MustCommit(gendb) signer = types.LatestSigner(gspec.Config) ) height := uint64(128) @@ -2145,7 +2145,7 @@ func TestTransactionIndices(t *testing.T) { if err != nil { t.Fatalf("failed to create temp freezer db: %v", err) } - gspec.MustCommit(ancientDb, nil) + gspec.MustCommit(ancientDb) // Import all blocks into ancient db l := uint64(0) @@ -2173,7 +2173,7 @@ func TestTransactionIndices(t *testing.T) { if err != nil { t.Fatalf("failed to create temp freezer db: %v", err) } - gspec.MustCommit(ancientDb, nil) + gspec.MustCommit(ancientDb) chain, err = NewBlockChain(ancientDb, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, &l) if err != nil { t.Fatalf("failed to create tester chain: %v", err) @@ -2193,7 +2193,7 @@ func TestTransactionIndices(t *testing.T) { if err != nil { t.Fatalf("failed to create temp freezer db: %v", err) } - gspec.MustCommit(ancientDb, nil) + gspec.MustCommit(ancientDb) limit = []uint64{0, 64 /* drop stale */, 32 /* shorten history */, 64 /* extend history */, 0 /* restore all */} tails := []uint64{0, 67 /* 130 - 64 + 1 */, 100 /* 131 - 32 + 1 */, 69 /* 132 - 64 + 1 */, 0} @@ -2217,7 +2217,7 @@ func TestSkipStaleTxIndicesInFastSync(t *testing.T) { address = crypto.PubkeyToAddress(key.PublicKey) funds = big.NewInt(100000000000000000) gspec = &Genesis{Config: params.TestChainConfig, Alloc: GenesisAlloc{address: {Balance: funds}}} - genesis = gspec.MustCommit(gendb, nil) + genesis = gspec.MustCommit(gendb) signer = types.LatestSigner(gspec.Config) ) height := uint64(128) @@ -2272,7 +2272,7 @@ func TestSkipStaleTxIndicesInFastSync(t *testing.T) { if err != nil { t.Fatalf("failed to create temp freezer db: %v", err) } - gspec.MustCommit(ancientDb, nil) + gspec.MustCommit(ancientDb) // Import all blocks into ancient db, only HEAD-32 indices are kept. l := uint64(32) @@ -2317,7 +2317,7 @@ func benchmarkLargeNumberOfValueToNonexisting(b *testing.B, numTxs, numBlocks in // Generate the original common chain segment and the two competing forks engine := ethash.NewFaker() db := rawdb.NewMemoryDatabase() - genesis := gspec.MustCommit(db, nil) + genesis := gspec.MustCommit(db) blockGenerator := func(i int, block *BlockGen) { block.SetCoinbase(common.Address{1}) @@ -2338,7 +2338,7 @@ func benchmarkLargeNumberOfValueToNonexisting(b *testing.B, numTxs, numBlocks in for i := 0; i < b.N; i++ { // Import the shared chain and the original canonical one diskdb := rawdb.NewMemoryDatabase() - gspec.MustCommit(diskdb, nil) + gspec.MustCommit(diskdb) chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) if err != nil { @@ -2416,12 +2416,12 @@ func TestSideImportPrunedBlocks(t *testing.T) { // Generate a canonical chain to act as the main dataset engine := ethash.NewFaker() db := rawdb.NewMemoryDatabase() - genesis := (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db, nil) + genesis := (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db) // Generate and import the canonical chain blocks, _ := GenerateChain(params.TestChainConfig, genesis, engine, db, 2*TriesInMemory, nil) diskdb := rawdb.NewMemoryDatabase() - (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(diskdb, nil) + (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(diskdb) chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) if err != nil { t.Fatalf("failed to create tester chain: %v", err) @@ -2498,7 +2498,7 @@ func TestDeleteCreateRevert(t *testing.T) { }, }, } - genesis = gspec.MustCommit(db, nil) + genesis = gspec.MustCommit(db) ) blocks, _ := GenerateChain(params.TestChainConfig, genesis, engine, db, 1, func(i int, b *BlockGen) { @@ -2514,7 +2514,7 @@ func TestDeleteCreateRevert(t *testing.T) { }) // Import the canonical chain diskdb := rawdb.NewMemoryDatabase() - gspec.MustCommit(diskdb, nil) + gspec.MustCommit(diskdb) chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) if err != nil { @@ -2611,7 +2611,7 @@ func TestDeleteRecreateSlots(t *testing.T) { }, }, } - genesis := gspec.MustCommit(db, nil) + genesis := gspec.MustCommit(db) blocks, _ := GenerateChain(params.TestChainConfig, genesis, engine, db, 1, func(i int, b *BlockGen) { b.SetCoinbase(common.Address{1}) @@ -2626,7 +2626,7 @@ func TestDeleteRecreateSlots(t *testing.T) { }) // Import the canonical chain diskdb := rawdb.NewMemoryDatabase() - gspec.MustCommit(diskdb, nil) + gspec.MustCommit(diskdb) chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{ Debug: true, Tracer: vm.NewJSONLogger(nil, os.Stdout), @@ -2691,7 +2691,7 @@ func TestDeleteRecreateAccount(t *testing.T) { }, }, } - genesis := gspec.MustCommit(db, nil) + genesis := gspec.MustCommit(db) blocks, _ := GenerateChain(params.TestChainConfig, genesis, engine, db, 1, func(i int, b *BlockGen) { b.SetCoinbase(common.Address{1}) @@ -2706,7 +2706,7 @@ func TestDeleteRecreateAccount(t *testing.T) { }) // Import the canonical chain diskdb := rawdb.NewMemoryDatabase() - gspec.MustCommit(diskdb, nil) + gspec.MustCommit(diskdb) chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{ Debug: true, Tracer: vm.NewJSONLogger(nil, os.Stdout), @@ -2815,7 +2815,7 @@ func TestDeleteRecreateSlotsAcrossManyBlocks(t *testing.T) { }, }, } - genesis := gspec.MustCommit(db, nil) + genesis := gspec.MustCommit(db) var nonce uint64 type expectation struct { @@ -2879,7 +2879,7 @@ func TestDeleteRecreateSlotsAcrossManyBlocks(t *testing.T) { }) // Import the canonical chain diskdb := rawdb.NewMemoryDatabase() - gspec.MustCommit(diskdb, nil) + gspec.MustCommit(diskdb) chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{ //Debug: true, //Tracer: vm.NewJSONLogger(nil, os.Stdout), @@ -3000,7 +3000,7 @@ func TestInitThenFailCreateContract(t *testing.T) { }, }, } - genesis := gspec.MustCommit(db, nil) + genesis := gspec.MustCommit(db) nonce := uint64(0) blocks, _ := GenerateChain(params.TestChainConfig, genesis, engine, db, 4, func(i int, b *BlockGen) { b.SetCoinbase(common.Address{1}) @@ -3013,7 +3013,7 @@ func TestInitThenFailCreateContract(t *testing.T) { // Import the canonical chain diskdb := rawdb.NewMemoryDatabase() - gspec.MustCommit(diskdb, nil) + gspec.MustCommit(diskdb) chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{ //Debug: true, //Tracer: vm.NewJSONLogger(nil, os.Stdout), @@ -3078,7 +3078,7 @@ func TestEIP2718Transition(t *testing.T) { }, }, } - genesis = gspec.MustCommit(db, nil) + genesis = gspec.MustCommit(db) ) blocks, _ := GenerateChain(gspec.Config, genesis, engine, db, 1, func(i int, b *BlockGen) { @@ -3102,7 +3102,7 @@ func TestEIP2718Transition(t *testing.T) { // Import the canonical chain diskdb := rawdb.NewMemoryDatabase() - gspec.MustCommit(diskdb, nil) + gspec.MustCommit(diskdb) chain, err := NewBlockChain(diskdb, nil, gspec.Config, engine, vm.Config{}, nil, nil) if err != nil { @@ -3168,7 +3168,7 @@ func TestEIP1559Transition(t *testing.T) { gspec.Config.BerlinBlock = common.Big0 gspec.Config.LondonBlock = common.Big0 - genesis := gspec.MustCommit(db, nil) + genesis := gspec.MustCommit(db) signer := types.LatestSigner(gspec.Config) blocks, _ := GenerateChain(gspec.Config, genesis, engine, db, 1, func(i int, b *BlockGen) { @@ -3197,7 +3197,7 @@ func TestEIP1559Transition(t *testing.T) { }) diskdb := rawdb.NewMemoryDatabase() - gspec.MustCommit(diskdb, nil) + gspec.MustCommit(diskdb) chain, err := NewBlockChain(diskdb, nil, gspec.Config, engine, vm.Config{}, nil, nil) if err != nil { diff --git a/core/chain_makers_test.go b/core/chain_makers_test.go index 21e73eebf2bb..85a029f7c757 100644 --- a/core/chain_makers_test.go +++ b/core/chain_makers_test.go @@ -44,7 +44,7 @@ func ExampleGenerateChain() { Config: ¶ms.ChainConfig{HomesteadBlock: new(big.Int)}, Alloc: GenesisAlloc{addr1: {Balance: big.NewInt(1000000)}}, } - genesis := gspec.MustCommit(db, nil) + genesis := gspec.MustCommit(db) // This call generates a chain of 5 blocks. The function runs for // each block and adds different features to gen based on the diff --git a/core/dao_test.go b/core/dao_test.go index 7158ec153134..c9c765a3832a 100644 --- a/core/dao_test.go +++ b/core/dao_test.go @@ -34,12 +34,12 @@ func TestDAOForkRangeExtradata(t *testing.T) { // Generate a common prefix for both pro-forkers and non-forkers db := rawdb.NewMemoryDatabase() gspec := &Genesis{BaseFee: big.NewInt(params.InitialBaseFee)} - genesis := gspec.MustCommit(db, nil) + genesis := gspec.MustCommit(db) prefix, _ := GenerateChain(params.TestChainConfig, genesis, ethash.NewFaker(), db, int(forkBlock.Int64()-1), func(i int, gen *BlockGen) {}) // Create the concurrent, conflicting two nodes proDb := rawdb.NewMemoryDatabase() - gspec.MustCommit(proDb, nil) + gspec.MustCommit(proDb) proConf := *params.TestChainConfig proConf.DAOForkBlock = forkBlock @@ -49,7 +49,7 @@ func TestDAOForkRangeExtradata(t *testing.T) { defer proBc.Stop() conDb := rawdb.NewMemoryDatabase() - gspec.MustCommit(conDb, nil) + gspec.MustCommit(conDb) conConf := *params.TestChainConfig conConf.DAOForkBlock = forkBlock @@ -68,7 +68,7 @@ func TestDAOForkRangeExtradata(t *testing.T) { for i := int64(0); i < params.DAOForkExtraRange.Int64(); i++ { // Create a pro-fork block, and try to feed into the no-fork chain db = rawdb.NewMemoryDatabase() - gspec.MustCommit(db, nil) + gspec.MustCommit(db) bc, _ := NewBlockChain(db, nil, &conConf, ethash.NewFaker(), vm.Config{}, nil, nil) defer bc.Stop() @@ -93,7 +93,7 @@ func TestDAOForkRangeExtradata(t *testing.T) { } // Create a no-fork block, and try to feed into the pro-fork chain db = rawdb.NewMemoryDatabase() - gspec.MustCommit(db, nil) + gspec.MustCommit(db) bc, _ = NewBlockChain(db, nil, &proConf, ethash.NewFaker(), vm.Config{}, nil, nil) defer bc.Stop() @@ -119,7 +119,7 @@ func TestDAOForkRangeExtradata(t *testing.T) { } // Verify that contra-forkers accept pro-fork extra-datas after forking finishes db = rawdb.NewMemoryDatabase() - gspec.MustCommit(db, nil) + gspec.MustCommit(db) bc, _ := NewBlockChain(db, nil, &conConf, ethash.NewFaker(), vm.Config{}, nil, nil) defer bc.Stop() @@ -139,7 +139,7 @@ func TestDAOForkRangeExtradata(t *testing.T) { } // Verify that pro-forkers accept contra-fork extra-datas after forking finishes db = rawdb.NewMemoryDatabase() - gspec.MustCommit(db, nil) + gspec.MustCommit(db) bc, _ = NewBlockChain(db, nil, &proConf, ethash.NewFaker(), vm.Config{}, nil, nil) defer bc.Stop() diff --git a/core/genesis.go b/core/genesis.go index 2cd5977d17bf..8f93d1682a32 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -342,8 +342,8 @@ func (g *Genesis) Commit(db ethdb.Database, snaps *snapshot.Tree) (*types.Block, // MustCommit writes the genesis block and state to db, panicking on error. // The block is committed as the canonical head block. -func (g *Genesis) MustCommit(db ethdb.Database, snaps *snapshot.Tree) *types.Block { - block, err := g.Commit(db, snaps) +func (g *Genesis) MustCommit(db ethdb.Database) *types.Block { + block, err := g.Commit(db, nil) if err != nil { panic(err) } @@ -356,7 +356,7 @@ func GenesisBlockForTesting(db ethdb.Database, addr common.Address, balance *big Alloc: GenesisAlloc{addr: {Balance: balance}}, BaseFee: big.NewInt(params.InitialBaseFee), } - return g.MustCommit(db, nil) + return g.MustCommit(db) } // DefaultGenesisBlock returns the Ethereum main net genesis block. diff --git a/core/genesis_test.go b/core/genesis_test.go index 60a89e8f23fb..f21a8ea828f8 100644 --- a/core/genesis_test.go +++ b/core/genesis_test.go @@ -79,7 +79,7 @@ func TestSetupGenesis(t *testing.T) { { name: "mainnet block in DB, genesis == nil", fn: func(db ethdb.Database) (*params.ChainConfig, common.Hash, error) { - DefaultGenesisBlock().MustCommit(db, nil) + DefaultGenesisBlock().MustCommit(db) return SetupGenesisBlock(db, nil) }, wantHash: params.MainnetGenesisHash, @@ -88,7 +88,7 @@ func TestSetupGenesis(t *testing.T) { { name: "custom block in DB, genesis == nil", fn: func(db ethdb.Database) (*params.ChainConfig, common.Hash, error) { - customg.MustCommit(db, nil) + customg.MustCommit(db) return SetupGenesisBlock(db, nil) }, wantHash: customghash, @@ -97,7 +97,7 @@ func TestSetupGenesis(t *testing.T) { { name: "custom block in DB, genesis == ropsten", fn: func(db ethdb.Database) (*params.ChainConfig, common.Hash, error) { - customg.MustCommit(db, nil) + customg.MustCommit(db) return SetupGenesisBlock(db, DefaultRopstenGenesisBlock()) }, wantErr: &GenesisMismatchError{Stored: customghash, New: params.RopstenGenesisHash}, @@ -107,7 +107,7 @@ func TestSetupGenesis(t *testing.T) { { name: "compatible config in DB", fn: func(db ethdb.Database) (*params.ChainConfig, common.Hash, error) { - oldcustomg.MustCommit(db, nil) + oldcustomg.MustCommit(db) return SetupGenesisBlock(db, &customg) }, wantHash: customghash, @@ -118,7 +118,7 @@ func TestSetupGenesis(t *testing.T) { fn: func(db ethdb.Database) (*params.ChainConfig, common.Hash, error) { // Commit the 'old' genesis block with Homestead transition at #2. // Advance to block #4, past the homestead transition block of customg. - genesis := oldcustomg.MustCommit(db, nil) + genesis := oldcustomg.MustCommit(db) bc, _ := NewBlockChain(db, nil, oldcustomg.Config, ethash.NewFullFaker(), vm.Config{}, nil, nil) defer bc.Stop() @@ -191,7 +191,7 @@ func TestGenesisHashes(t *testing.T) { }, } for i, c := range cases { - b := c.genesis.MustCommit(rawdb.NewMemoryDatabase(), nil) + b := c.genesis.MustCommit(rawdb.NewMemoryDatabase()) if got := b.Hash(); got != c.hash { t.Errorf("case: %d, want: %s, got: %s", i, c.hash.Hex(), got.Hex()) } diff --git a/core/headerchain_test.go b/core/headerchain_test.go index e79cdb5e58e4..f3e40b6213f3 100644 --- a/core/headerchain_test.go +++ b/core/headerchain_test.go @@ -71,7 +71,7 @@ func testInsert(t *testing.T, hc *HeaderChain, chain []*types.Header, wantStatus func TestHeaderInsertion(t *testing.T) { var ( db = rawdb.NewMemoryDatabase() - genesis = (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db, nil) + genesis = (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db) ) hc, err := NewHeaderChain(db, params.AllEthashProtocolChanges, ethash.NewFaker(), func() bool { return false }) diff --git a/core/rlp_test.go b/core/rlp_test.go index 95a08af656dc..3a90811e7461 100644 --- a/core/rlp_test.go +++ b/core/rlp_test.go @@ -45,7 +45,7 @@ func getBlock(transactions int, uncles int, dataSize int) *types.Block { Config: params.TestChainConfig, Alloc: GenesisAlloc{address: {Balance: funds}}, } - genesis = gspec.MustCommit(db, nil) + genesis = gspec.MustCommit(db) ) // We need to generate as many blocks +1 as uncles diff --git a/core/state_processor_test.go b/core/state_processor_test.go index 82ff27f12823..bb3c906493b6 100644 --- a/core/state_processor_test.go +++ b/core/state_processor_test.go @@ -84,7 +84,7 @@ func TestStateProcessorErrors(t *testing.T) { }, }, } - genesis = gspec.MustCommit(db, nil) + genesis = gspec.MustCommit(db) blockchain, _ = NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) ) defer blockchain.Stop() @@ -219,7 +219,7 @@ func TestStateProcessorErrors(t *testing.T) { }, }, } - genesis = gspec.MustCommit(db, nil) + genesis = gspec.MustCommit(db) blockchain, _ = NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) ) defer blockchain.Stop() @@ -321,7 +321,7 @@ func TestProcessStateless(t *testing.T) { ) // Verkle trees use the snapshot, which must be enabled before the // data is saved into the tree+database. - genesis := gspec.MustCommit(db, nil) + genesis := gspec.MustCommit(db) blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) defer blockchain.Stop() chain, _ := GenerateVerkleChain(gspec.Config, genesis, ethash.NewFaker(), db, 1, func(_ int, gen *BlockGen) { diff --git a/eth/filters/filter_system_test.go b/eth/filters/filter_system_test.go index a1f13ba02402..d55674f3094e 100644 --- a/eth/filters/filter_system_test.go +++ b/eth/filters/filter_system_test.go @@ -169,7 +169,7 @@ func TestBlockSubscription(t *testing.T) { db = rawdb.NewMemoryDatabase() backend = &testBackend{db: db} api = NewPublicFilterAPI(backend, false, deadline) - genesis = (&core.Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db, nil) + genesis = (&core.Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db) chain, _ = core.GenerateChain(params.TestChainConfig, genesis, ethash.NewFaker(), db, 10, func(i int, gen *core.BlockGen) {}) chainEvents = []core.ChainEvent{} ) diff --git a/eth/handler_eth_test.go b/eth/handler_eth_test.go index e79b0562a965..038de469908e 100644 --- a/eth/handler_eth_test.go +++ b/eth/handler_eth_test.go @@ -103,8 +103,8 @@ func testForkIDSplit(t *testing.T, protocol uint) { gspecNoFork = &core.Genesis{Config: configNoFork} gspecProFork = &core.Genesis{Config: configProFork} - genesisNoFork = gspecNoFork.MustCommit(dbNoFork, nil) - genesisProFork = gspecProFork.MustCommit(dbProFork, nil) + genesisNoFork = gspecNoFork.MustCommit(dbNoFork) + genesisProFork = gspecProFork.MustCommit(dbProFork) chainNoFork, _ = core.NewBlockChain(dbNoFork, nil, configNoFork, engine, vm.Config{}, nil, nil) chainProFork, _ = core.NewBlockChain(dbProFork, nil, configProFork, engine, vm.Config{}, nil, nil) diff --git a/eth/handler_test.go b/eth/handler_test.go index 00b12378e116..090bd9239c2e 100644 --- a/eth/handler_test.go +++ b/eth/handler_test.go @@ -135,7 +135,7 @@ func newTestHandlerWithBlocks(blocks int) *testHandler { (&core.Genesis{ Config: params.TestChainConfig, Alloc: core.GenesisAlloc{testAddr: {Balance: big.NewInt(1000000)}}, - }).MustCommit(db, nil) + }).MustCommit(db) chain, _ := core.NewBlockChain(db, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, nil) diff --git a/eth/protocols/eth/handler_test.go b/eth/protocols/eth/handler_test.go index daae79e0cb4e..473be3f9b77e 100644 --- a/eth/protocols/eth/handler_test.go +++ b/eth/protocols/eth/handler_test.go @@ -67,7 +67,7 @@ func newTestBackendWithGenerator(blocks int, generator func(int, *core.BlockGen) (&core.Genesis{ Config: params.TestChainConfig, Alloc: core.GenesisAlloc{testAddr: {Balance: big.NewInt(100_000_000_000_000_000)}}, - }).MustCommit(db, nil) + }).MustCommit(db) chain, _ := core.NewBlockChain(db, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, nil) diff --git a/eth/tracers/api_test.go b/eth/tracers/api_test.go index c68684282bee..4a4e5bbc33d2 100644 --- a/eth/tracers/api_test.go +++ b/eth/tracers/api_test.go @@ -68,12 +68,12 @@ func newTestBackend(t *testing.T, n int, gspec *core.Genesis, generator func(i i gspec.Config = backend.chainConfig var ( gendb = rawdb.NewMemoryDatabase() - genesis = gspec.MustCommit(gendb, nil) + genesis = gspec.MustCommit(gendb) ) blocks, _ := core.GenerateChain(backend.chainConfig, genesis, backend.engine, gendb, n, generator) // Import the canonical chain - gspec.MustCommit(backend.chaindb, nil) + gspec.MustCommit(backend.chaindb) cacheConfig := &core.CacheConfig{ TrieCleanLimit: 256, TrieDirtyLimit: 256, diff --git a/les/test_helper.go b/les/test_helper.go index 24d576f10826..9ff2583b9765 100644 --- a/les/test_helper.go +++ b/les/test_helper.go @@ -201,7 +201,7 @@ func newTestClientHandler(backend *backends.SimulatedBackend, odr *LesOdr, index } oracle *checkpointoracle.CheckpointOracle ) - genesis := gspec.MustCommit(db, nil) + genesis := gspec.MustCommit(db) chain, _ := light.NewLightChain(odr, gspec.Config, engine, nil) if indexers != nil { checkpointConfig := ¶ms.CheckpointOracleConfig{ @@ -261,7 +261,7 @@ func newTestServerHandler(blocks int, indexers []*core.ChainIndexer, db ethdb.Da } oracle *checkpointoracle.CheckpointOracle ) - genesis := gspec.MustCommit(db, nil) + genesis := gspec.MustCommit(db) // create a simulation backend and pre-commit several customized block to the database. simulation := backends.NewSimulatedBackendWithDatabase(db, gspec.Alloc, 100000000) diff --git a/light/lightchain_test.go b/light/lightchain_test.go index fcba1681dffa..af36ebd96a23 100644 --- a/light/lightchain_test.go +++ b/light/lightchain_test.go @@ -55,7 +55,7 @@ func makeHeaderChain(parent *types.Header, n int, db ethdb.Database, seed int) [ func newCanonical(n int) (ethdb.Database, *LightChain, error) { db := rawdb.NewMemoryDatabase() gspec := core.Genesis{Config: params.TestChainConfig} - genesis := gspec.MustCommit(db, nil) + genesis := gspec.MustCommit(db) blockchain, _ := NewLightChain(&dummyOdr{db: db, indexerConfig: TestClientIndexerConfig}, gspec.Config, ethash.NewFaker(), nil) // Create and inject the requested chain @@ -75,7 +75,7 @@ func newTestLightChain() *LightChain { Difficulty: big.NewInt(1), Config: params.TestChainConfig, } - gspec.MustCommit(db, nil) + gspec.MustCommit(db) lc, err := NewLightChain(&dummyOdr{db: db}, gspec.Config, ethash.NewFullFaker(), nil) if err != nil { panic(err) diff --git a/light/odr_test.go b/light/odr_test.go index 7d510dbddd7f..b31e54d28a90 100644 --- a/light/odr_test.go +++ b/light/odr_test.go @@ -257,9 +257,9 @@ func testChainOdr(t *testing.T, protocol int, fn odrTestFn) { Alloc: core.GenesisAlloc{testBankAddress: {Balance: testBankFunds}}, BaseFee: big.NewInt(params.InitialBaseFee), } - genesis = gspec.MustCommit(sdb, nil) + genesis = gspec.MustCommit(sdb) ) - gspec.MustCommit(ldb, nil) + gspec.MustCommit(ldb) // Assemble the test environment blockchain, _ := core.NewBlockChain(sdb, nil, params.TestChainConfig, ethash.NewFullFaker(), vm.Config{}, nil, nil) gchain, _ := core.GenerateChain(params.TestChainConfig, genesis, ethash.NewFaker(), sdb, 4, testChainGen) diff --git a/light/trie_test.go b/light/trie_test.go index c1e0c2960d13..e8294cc2a235 100644 --- a/light/trie_test.go +++ b/light/trie_test.go @@ -41,9 +41,9 @@ func TestNodeIterator(t *testing.T) { Alloc: core.GenesisAlloc{testBankAddress: {Balance: testBankFunds}}, BaseFee: big.NewInt(params.InitialBaseFee), } - genesis = gspec.MustCommit(fulldb, nil) + genesis = gspec.MustCommit(fulldb) ) - gspec.MustCommit(lightdb, nil) + gspec.MustCommit(lightdb) blockchain, _ := core.NewBlockChain(fulldb, nil, params.TestChainConfig, ethash.NewFullFaker(), vm.Config{}, nil, nil) gchain, _ := core.GenerateChain(params.TestChainConfig, genesis, ethash.NewFaker(), fulldb, 4, testChainGen) if _, err := blockchain.InsertChain(gchain); err != nil { diff --git a/light/txpool_test.go b/light/txpool_test.go index 17655c808b7f..cc2651d29ae5 100644 --- a/light/txpool_test.go +++ b/light/txpool_test.go @@ -87,9 +87,9 @@ func TestTxPool(t *testing.T) { Alloc: core.GenesisAlloc{testBankAddress: {Balance: testBankFunds}}, BaseFee: big.NewInt(params.InitialBaseFee), } - genesis = gspec.MustCommit(sdb, nil) + genesis = gspec.MustCommit(sdb) ) - gspec.MustCommit(ldb, nil) + gspec.MustCommit(ldb) // Assemble the test environment blockchain, _ := core.NewBlockChain(sdb, nil, params.TestChainConfig, ethash.NewFullFaker(), vm.Config{}, nil, nil) gchain, _ := core.GenerateChain(params.TestChainConfig, genesis, ethash.NewFaker(), sdb, poolTestBlocks, txPoolTestChainGen) diff --git a/miner/worker_test.go b/miner/worker_test.go index afa43d9ae9ae..2bb6c9407bbe 100644 --- a/miner/worker_test.go +++ b/miner/worker_test.go @@ -132,7 +132,7 @@ func newTestWorkerBackend(t *testing.T, chainConfig *params.ChainConfig, engine default: t.Fatalf("unexpected consensus engine type: %T", engine) } - genesis := gspec.MustCommit(db, nil) + genesis := gspec.MustCommit(db) chain, _ := core.NewBlockChain(db, &core.CacheConfig{TrieDirtyDisabled: true}, gspec.Config, engine, vm.Config{}, nil, nil) txpool := core.NewTxPool(testTxPoolConfig, chainConfig, chain) @@ -230,7 +230,7 @@ func testGenerateBlockAndImport(t *testing.T, isClique bool) { // This test chain imports the mined blocks. db2 := rawdb.NewMemoryDatabase() - b.genesis.MustCommit(db2, nil) + b.genesis.MustCommit(db2) chain, _ := core.NewBlockChain(db2, nil, b.chain.Config(), engine, vm.Config{}, nil, nil) defer chain.Stop() diff --git a/tests/fuzzers/les/les-fuzzer.go b/tests/fuzzers/les/les-fuzzer.go index 4265ec43d7ae..3e1017187345 100644 --- a/tests/fuzzers/les/les-fuzzer.go +++ b/tests/fuzzers/les/les-fuzzer.go @@ -60,7 +60,7 @@ func makechain() (bc *core.BlockChain, addrHashes, txHashes []common.Hash) { Alloc: core.GenesisAlloc{bankAddr: {Balance: bankFunds}}, GasLimit: 100000000, } - genesis := gspec.MustCommit(db, nil) + genesis := gspec.MustCommit(db) signer := types.HomesteadSigner{} blocks, _ := core.GenerateChain(gspec.Config, genesis, ethash.NewFaker(), db, testChainLen, func(i int, gen *core.BlockGen) {