mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 22:26:42 +00:00
core: make options last parameter
This commit is contained in:
parent
2198d0f15b
commit
cd9ae930b6
32 changed files with 104 additions and 103 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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()))
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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})
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue