|
|
@ -54,11 +54,15 @@ var ( |
|
|
|
func newCanonical(engine consensus.Engine, n int, full bool) (ethdb.Database, *BlockChain, error) { |
|
|
|
func newCanonical(engine consensus.Engine, n int, full bool) (ethdb.Database, *BlockChain, error) { |
|
|
|
var ( |
|
|
|
var ( |
|
|
|
db = rawdb.NewMemoryDatabase() |
|
|
|
db = rawdb.NewMemoryDatabase() |
|
|
|
genesis = (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db) |
|
|
|
gspec = &Genesis{ |
|
|
|
|
|
|
|
BaseFee: big.NewInt(params.InitialBaseFee), |
|
|
|
|
|
|
|
Config: params.AllEthashProtocolChanges, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
genesis = gspec.MustCommit(db) |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// Initialize a fresh chain with only a genesis block
|
|
|
|
// Initialize a fresh chain with only a genesis block
|
|
|
|
blockchain, _ := NewBlockChain(db, nil, params.AllEthashProtocolChanges, engine, vm.Config{}, nil, nil) |
|
|
|
blockchain, _ := NewBlockChain(db, nil, gspec, nil, engine, vm.Config{}, nil, nil) |
|
|
|
// Create and inject the requested chain
|
|
|
|
// Create and inject the requested chain
|
|
|
|
if n == 0 { |
|
|
|
if n == 0 { |
|
|
|
return db, blockchain, nil |
|
|
|
return db, blockchain, nil |
|
|
@ -654,7 +658,11 @@ func testReorgBadHashes(t *testing.T, full bool) { |
|
|
|
blockchain.Stop() |
|
|
|
blockchain.Stop() |
|
|
|
|
|
|
|
|
|
|
|
// Create a new BlockChain and check that it rolled back the state.
|
|
|
|
// Create a new BlockChain and check that it rolled back the state.
|
|
|
|
ncm, err := NewBlockChain(blockchain.db, nil, blockchain.chainConfig, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
gspec := &Genesis{ |
|
|
|
|
|
|
|
BaseFee: big.NewInt(params.InitialBaseFee), |
|
|
|
|
|
|
|
Config: params.AllEthashProtocolChanges, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ncm, err := NewBlockChain(blockchain.db, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
t.Fatalf("failed to create new chain manager: %v", err) |
|
|
|
t.Fatalf("failed to create new chain manager: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
@ -767,7 +775,7 @@ func TestFastVsFullChains(t *testing.T) { |
|
|
|
// Import the chain as an archive node for the comparison baseline
|
|
|
|
// Import the chain as an archive node for the comparison baseline
|
|
|
|
archiveDb := rawdb.NewMemoryDatabase() |
|
|
|
archiveDb := rawdb.NewMemoryDatabase() |
|
|
|
gspec.MustCommit(archiveDb) |
|
|
|
gspec.MustCommit(archiveDb) |
|
|
|
archive, _ := NewBlockChain(archiveDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
archive, _ := NewBlockChain(archiveDb, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
defer archive.Stop() |
|
|
|
defer archive.Stop() |
|
|
|
|
|
|
|
|
|
|
|
if n, err := archive.InsertChain(blocks); err != nil { |
|
|
|
if n, err := archive.InsertChain(blocks); err != nil { |
|
|
@ -776,7 +784,7 @@ func TestFastVsFullChains(t *testing.T) { |
|
|
|
// Fast import the chain as a non-archive node to test
|
|
|
|
// Fast import the chain as a non-archive node to test
|
|
|
|
fastDb := rawdb.NewMemoryDatabase() |
|
|
|
fastDb := rawdb.NewMemoryDatabase() |
|
|
|
gspec.MustCommit(fastDb) |
|
|
|
gspec.MustCommit(fastDb) |
|
|
|
fast, _ := NewBlockChain(fastDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
fast, _ := NewBlockChain(fastDb, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
defer fast.Stop() |
|
|
|
defer fast.Stop() |
|
|
|
|
|
|
|
|
|
|
|
headers := make([]*types.Header, len(blocks)) |
|
|
|
headers := make([]*types.Header, len(blocks)) |
|
|
@ -797,7 +805,7 @@ func TestFastVsFullChains(t *testing.T) { |
|
|
|
} |
|
|
|
} |
|
|
|
defer ancientDb.Close() |
|
|
|
defer ancientDb.Close() |
|
|
|
gspec.MustCommit(ancientDb) |
|
|
|
gspec.MustCommit(ancientDb) |
|
|
|
ancient, _ := NewBlockChain(ancientDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
ancient, _ := NewBlockChain(ancientDb, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
defer ancient.Stop() |
|
|
|
defer ancient.Stop() |
|
|
|
|
|
|
|
|
|
|
|
if n, err := ancient.InsertHeaderChain(headers, 1); err != nil { |
|
|
|
if n, err := ancient.InsertHeaderChain(headers, 1); err != nil { |
|
|
@ -915,7 +923,7 @@ func TestLightVsFastVsFullChainHeads(t *testing.T) { |
|
|
|
archiveCaching := *defaultCacheConfig |
|
|
|
archiveCaching := *defaultCacheConfig |
|
|
|
archiveCaching.TrieDirtyDisabled = true |
|
|
|
archiveCaching.TrieDirtyDisabled = true |
|
|
|
|
|
|
|
|
|
|
|
archive, _ := NewBlockChain(archiveDb, &archiveCaching, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
archive, _ := NewBlockChain(archiveDb, &archiveCaching, gspec, nil, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
if n, err := archive.InsertChain(blocks); err != nil { |
|
|
|
if n, err := archive.InsertChain(blocks); err != nil { |
|
|
|
t.Fatalf("failed to process block %d: %v", n, err) |
|
|
|
t.Fatalf("failed to process block %d: %v", n, err) |
|
|
|
} |
|
|
|
} |
|
|
@ -928,7 +936,7 @@ func TestLightVsFastVsFullChainHeads(t *testing.T) { |
|
|
|
// Import the chain as a non-archive node and ensure all pointers are updated
|
|
|
|
// Import the chain as a non-archive node and ensure all pointers are updated
|
|
|
|
fastDb := makeDb() |
|
|
|
fastDb := makeDb() |
|
|
|
defer fastDb.Close() |
|
|
|
defer fastDb.Close() |
|
|
|
fast, _ := NewBlockChain(fastDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
fast, _ := NewBlockChain(fastDb, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
defer fast.Stop() |
|
|
|
defer fast.Stop() |
|
|
|
|
|
|
|
|
|
|
|
headers := make([]*types.Header, len(blocks)) |
|
|
|
headers := make([]*types.Header, len(blocks)) |
|
|
@ -948,7 +956,7 @@ func TestLightVsFastVsFullChainHeads(t *testing.T) { |
|
|
|
// Import the chain as a ancient-first node and ensure all pointers are updated
|
|
|
|
// Import the chain as a ancient-first node and ensure all pointers are updated
|
|
|
|
ancientDb := makeDb() |
|
|
|
ancientDb := makeDb() |
|
|
|
defer ancientDb.Close() |
|
|
|
defer ancientDb.Close() |
|
|
|
ancient, _ := NewBlockChain(ancientDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
ancient, _ := NewBlockChain(ancientDb, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
defer ancient.Stop() |
|
|
|
defer ancient.Stop() |
|
|
|
|
|
|
|
|
|
|
|
if n, err := ancient.InsertHeaderChain(headers, 1); err != nil { |
|
|
|
if n, err := ancient.InsertHeaderChain(headers, 1); err != nil { |
|
|
@ -967,7 +975,7 @@ func TestLightVsFastVsFullChainHeads(t *testing.T) { |
|
|
|
// Import the chain as a light node and ensure all pointers are updated
|
|
|
|
// Import the chain as a light node and ensure all pointers are updated
|
|
|
|
lightDb := makeDb() |
|
|
|
lightDb := makeDb() |
|
|
|
defer lightDb.Close() |
|
|
|
defer lightDb.Close() |
|
|
|
light, _ := NewBlockChain(lightDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
light, _ := NewBlockChain(lightDb, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
if n, err := light.InsertHeaderChain(headers, 1); err != nil { |
|
|
|
if n, err := light.InsertHeaderChain(headers, 1); err != nil { |
|
|
|
t.Fatalf("failed to insert header %d: %v", n, err) |
|
|
|
t.Fatalf("failed to insert header %d: %v", n, err) |
|
|
|
} |
|
|
|
} |
|
|
@ -1036,7 +1044,7 @@ func TestChainTxReorgs(t *testing.T) { |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
// Import the chain. This runs all block validation rules.
|
|
|
|
// Import the chain. This runs all block validation rules.
|
|
|
|
blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
blockchain, _ := NewBlockChain(db, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
if i, err := blockchain.InsertChain(chain); err != nil { |
|
|
|
if i, err := blockchain.InsertChain(chain); err != nil { |
|
|
|
t.Fatalf("failed to insert original chain[%d]: %v", i, err) |
|
|
|
t.Fatalf("failed to insert original chain[%d]: %v", i, err) |
|
|
|
} |
|
|
|
} |
|
|
@ -1106,7 +1114,7 @@ func TestLogReorgs(t *testing.T) { |
|
|
|
signer = types.LatestSigner(gspec.Config) |
|
|
|
signer = types.LatestSigner(gspec.Config) |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
blockchain, _ := NewBlockChain(db, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
defer blockchain.Stop() |
|
|
|
defer blockchain.Stop() |
|
|
|
|
|
|
|
|
|
|
|
rmLogsCh := make(chan RemovedLogsEvent) |
|
|
|
rmLogsCh := make(chan RemovedLogsEvent) |
|
|
@ -1159,7 +1167,7 @@ func TestLogRebirth(t *testing.T) { |
|
|
|
genesis = gspec.MustCommit(db) |
|
|
|
genesis = gspec.MustCommit(db) |
|
|
|
signer = types.LatestSigner(gspec.Config) |
|
|
|
signer = types.LatestSigner(gspec.Config) |
|
|
|
engine = ethash.NewFaker() |
|
|
|
engine = ethash.NewFaker() |
|
|
|
blockchain, _ = NewBlockChain(db, nil, gspec.Config, engine, vm.Config{}, nil, nil) |
|
|
|
blockchain, _ = NewBlockChain(db, nil, gspec, nil, engine, vm.Config{}, nil, nil) |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
defer blockchain.Stop() |
|
|
|
defer blockchain.Stop() |
|
|
@ -1222,7 +1230,7 @@ func TestSideLogRebirth(t *testing.T) { |
|
|
|
gspec = &Genesis{Config: params.TestChainConfig, Alloc: GenesisAlloc{addr1: {Balance: big.NewInt(10000000000000000)}}} |
|
|
|
gspec = &Genesis{Config: params.TestChainConfig, Alloc: GenesisAlloc{addr1: {Balance: big.NewInt(10000000000000000)}}} |
|
|
|
genesis = gspec.MustCommit(db) |
|
|
|
genesis = gspec.MustCommit(db) |
|
|
|
signer = types.LatestSigner(gspec.Config) |
|
|
|
signer = types.LatestSigner(gspec.Config) |
|
|
|
blockchain, _ = NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
blockchain, _ = NewBlockChain(db, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
defer blockchain.Stop() |
|
|
|
defer blockchain.Stop() |
|
|
@ -1296,7 +1304,7 @@ func TestReorgSideEvent(t *testing.T) { |
|
|
|
signer = types.LatestSigner(gspec.Config) |
|
|
|
signer = types.LatestSigner(gspec.Config) |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
blockchain, _ := NewBlockChain(db, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
defer blockchain.Stop() |
|
|
|
defer blockchain.Stop() |
|
|
|
|
|
|
|
|
|
|
|
chain, _ := GenerateChain(gspec.Config, genesis, ethash.NewFaker(), db, 3, func(i int, gen *BlockGen) {}) |
|
|
|
chain, _ := GenerateChain(gspec.Config, genesis, ethash.NewFaker(), db, 3, func(i int, gen *BlockGen) {}) |
|
|
@ -1427,7 +1435,7 @@ func TestEIP155Transition(t *testing.T) { |
|
|
|
genesis = gspec.MustCommit(db) |
|
|
|
genesis = gspec.MustCommit(db) |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
blockchain, _ := NewBlockChain(db, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
defer blockchain.Stop() |
|
|
|
defer blockchain.Stop() |
|
|
|
|
|
|
|
|
|
|
|
blocks, _ := GenerateChain(gspec.Config, genesis, ethash.NewFaker(), db, 4, func(i int, block *BlockGen) { |
|
|
|
blocks, _ := GenerateChain(gspec.Config, genesis, ethash.NewFaker(), db, 4, func(i int, block *BlockGen) { |
|
|
@ -1535,7 +1543,7 @@ func TestEIP161AccountRemoval(t *testing.T) { |
|
|
|
} |
|
|
|
} |
|
|
|
genesis = gspec.MustCommit(db) |
|
|
|
genesis = gspec.MustCommit(db) |
|
|
|
) |
|
|
|
) |
|
|
|
blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
blockchain, _ := NewBlockChain(db, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
defer blockchain.Stop() |
|
|
|
defer blockchain.Stop() |
|
|
|
|
|
|
|
|
|
|
|
blocks, _ := GenerateChain(gspec.Config, genesis, ethash.NewFaker(), db, 3, func(i int, block *BlockGen) { |
|
|
|
blocks, _ := GenerateChain(gspec.Config, genesis, ethash.NewFaker(), db, 3, func(i int, block *BlockGen) { |
|
|
@ -1592,7 +1600,11 @@ func TestBlockchainHeaderchainReorgConsistency(t *testing.T) { |
|
|
|
engine := ethash.NewFaker() |
|
|
|
engine := ethash.NewFaker() |
|
|
|
|
|
|
|
|
|
|
|
db := rawdb.NewMemoryDatabase() |
|
|
|
db := rawdb.NewMemoryDatabase() |
|
|
|
genesis := (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db) |
|
|
|
gspec := &Genesis{ |
|
|
|
|
|
|
|
Config: params.TestChainConfig, |
|
|
|
|
|
|
|
BaseFee: big.NewInt(params.InitialBaseFee), |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
genesis := gspec.MustCommit(db) |
|
|
|
blocks, _ := GenerateChain(params.TestChainConfig, genesis, engine, db, 64, func(i int, b *BlockGen) { b.SetCoinbase(common.Address{1}) }) |
|
|
|
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
|
|
|
|
// Generate a bunch of fork blocks, each side forking from the canonical chain
|
|
|
@ -1610,7 +1622,7 @@ func TestBlockchainHeaderchainReorgConsistency(t *testing.T) { |
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
(&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(diskdb) |
|
|
|
(&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(diskdb) |
|
|
|
|
|
|
|
|
|
|
|
chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) |
|
|
|
chain, err := NewBlockChain(diskdb, nil, gspec, nil, engine, vm.Config{}, nil, nil) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
@ -1637,7 +1649,11 @@ func TestTrieForkGC(t *testing.T) { |
|
|
|
engine := ethash.NewFaker() |
|
|
|
engine := ethash.NewFaker() |
|
|
|
|
|
|
|
|
|
|
|
db := rawdb.NewMemoryDatabase() |
|
|
|
db := rawdb.NewMemoryDatabase() |
|
|
|
genesis := (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db) |
|
|
|
gspec := &Genesis{ |
|
|
|
|
|
|
|
BaseFee: big.NewInt(params.InitialBaseFee), |
|
|
|
|
|
|
|
Config: params.TestChainConfig, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
genesis := gspec.MustCommit(db) |
|
|
|
blocks, _ := GenerateChain(params.TestChainConfig, genesis, engine, db, 2*TriesInMemory, func(i int, b *BlockGen) { b.SetCoinbase(common.Address{1}) }) |
|
|
|
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
|
|
|
|
// Generate a bunch of fork blocks, each side forking from the canonical chain
|
|
|
@ -1652,9 +1668,9 @@ func TestTrieForkGC(t *testing.T) { |
|
|
|
} |
|
|
|
} |
|
|
|
// Import the canonical and fork chain side by side, forcing the trie cache to cache both
|
|
|
|
// Import the canonical and fork chain side by side, forcing the trie cache to cache both
|
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
(&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(diskdb) |
|
|
|
gspec.MustCommit(diskdb) |
|
|
|
|
|
|
|
|
|
|
|
chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) |
|
|
|
chain, err := NewBlockChain(diskdb, nil, gspec, nil, engine, vm.Config{}, nil, nil) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
@ -1683,7 +1699,11 @@ func TestLargeReorgTrieGC(t *testing.T) { |
|
|
|
engine := ethash.NewFaker() |
|
|
|
engine := ethash.NewFaker() |
|
|
|
|
|
|
|
|
|
|
|
db := rawdb.NewMemoryDatabase() |
|
|
|
db := rawdb.NewMemoryDatabase() |
|
|
|
genesis := (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db) |
|
|
|
gspec := &Genesis{ |
|
|
|
|
|
|
|
BaseFee: big.NewInt(params.InitialBaseFee), |
|
|
|
|
|
|
|
Config: params.TestChainConfig, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
genesis := gspec.MustCommit(db) |
|
|
|
|
|
|
|
|
|
|
|
shared, _ := GenerateChain(params.TestChainConfig, genesis, engine, db, 64, func(i int, b *BlockGen) { b.SetCoinbase(common.Address{1}) }) |
|
|
|
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}) }) |
|
|
|
original, _ := GenerateChain(params.TestChainConfig, shared[len(shared)-1], engine, db, 2*TriesInMemory, func(i int, b *BlockGen) { b.SetCoinbase(common.Address{2}) }) |
|
|
@ -1691,9 +1711,9 @@ func TestLargeReorgTrieGC(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
// Import the shared chain and the original canonical one
|
|
|
|
// Import the shared chain and the original canonical one
|
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
(&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(diskdb) |
|
|
|
gspec.MustCommit(diskdb) |
|
|
|
|
|
|
|
|
|
|
|
chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) |
|
|
|
chain, err := NewBlockChain(diskdb, nil, gspec, nil, engine, vm.Config{}, nil, nil) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
@ -1751,7 +1771,7 @@ func TestBlockchainRecovery(t *testing.T) { |
|
|
|
} |
|
|
|
} |
|
|
|
defer ancientDb.Close() |
|
|
|
defer ancientDb.Close() |
|
|
|
gspec.MustCommit(ancientDb) |
|
|
|
gspec.MustCommit(ancientDb) |
|
|
|
ancient, _ := NewBlockChain(ancientDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
ancient, _ := NewBlockChain(ancientDb, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
|
|
|
|
|
|
|
|
headers := make([]*types.Header, len(blocks)) |
|
|
|
headers := make([]*types.Header, len(blocks)) |
|
|
|
for i, block := range blocks { |
|
|
|
for i, block := range blocks { |
|
|
@ -1771,7 +1791,7 @@ func TestBlockchainRecovery(t *testing.T) { |
|
|
|
rawdb.WriteHeadFastBlockHash(ancientDb, midBlock.Hash()) |
|
|
|
rawdb.WriteHeadFastBlockHash(ancientDb, midBlock.Hash()) |
|
|
|
|
|
|
|
|
|
|
|
// Reopen broken blockchain again
|
|
|
|
// Reopen broken blockchain again
|
|
|
|
ancient, _ = NewBlockChain(ancientDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
ancient, _ = NewBlockChain(ancientDb, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
defer ancient.Stop() |
|
|
|
defer ancient.Stop() |
|
|
|
if num := ancient.CurrentBlock().NumberU64(); num != 0 { |
|
|
|
if num := ancient.CurrentBlock().NumberU64(); num != 0 { |
|
|
|
t.Errorf("head block mismatch: have #%v, want #%v", num, 0) |
|
|
|
t.Errorf("head block mismatch: have #%v, want #%v", num, 0) |
|
|
@ -1812,15 +1832,15 @@ func TestInsertReceiptChainRollback(t *testing.T) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Set up a BlockChain that uses the ancient store.
|
|
|
|
// Set up a BlockChain that uses the ancient store.
|
|
|
|
frdir := t.TempDir() |
|
|
|
ancientDb, err := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), t.TempDir(), "", false) |
|
|
|
ancientDb, err := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), frdir, "", false) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
t.Fatalf("failed to create temp freezer db: %v", err) |
|
|
|
t.Fatalf("failed to create temp freezer db: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
|
defer ancientDb.Close() |
|
|
|
defer ancientDb.Close() |
|
|
|
|
|
|
|
|
|
|
|
gspec := Genesis{Config: params.AllEthashProtocolChanges} |
|
|
|
gspec := Genesis{Config: params.AllEthashProtocolChanges} |
|
|
|
gspec.MustCommit(ancientDb) |
|
|
|
gspec.MustCommit(ancientDb) |
|
|
|
ancientChain, _ := NewBlockChain(ancientDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
ancientChain, _ := NewBlockChain(ancientDb, nil, &gspec, nil, ethash.NewFaker(), vm.Config{}, nil, nil) |
|
|
|
defer ancientChain.Stop() |
|
|
|
defer ancientChain.Stop() |
|
|
|
|
|
|
|
|
|
|
|
// Import the canonical header chain.
|
|
|
|
// Import the canonical header chain.
|
|
|
@ -1868,7 +1888,11 @@ func TestLowDiffLongChain(t *testing.T) { |
|
|
|
// Generate a canonical chain to act as the main dataset
|
|
|
|
// Generate a canonical chain to act as the main dataset
|
|
|
|
engine := ethash.NewFaker() |
|
|
|
engine := ethash.NewFaker() |
|
|
|
db := rawdb.NewMemoryDatabase() |
|
|
|
db := rawdb.NewMemoryDatabase() |
|
|
|
genesis := (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db) |
|
|
|
gspec := &Genesis{ |
|
|
|
|
|
|
|
BaseFee: big.NewInt(params.InitialBaseFee), |
|
|
|
|
|
|
|
Config: params.TestChainConfig, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
genesis := gspec.MustCommit(db) |
|
|
|
|
|
|
|
|
|
|
|
// We must use a pretty long chain to ensure that the fork doesn't overtake us
|
|
|
|
// We must use a pretty long chain to ensure that the fork doesn't overtake us
|
|
|
|
// until after at least 128 blocks post tip
|
|
|
|
// until after at least 128 blocks post tip
|
|
|
@ -1879,9 +1903,9 @@ func TestLowDiffLongChain(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
// Import the canonical chain
|
|
|
|
// Import the canonical chain
|
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
(&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(diskdb) |
|
|
|
gspec.MustCommit(diskdb) |
|
|
|
|
|
|
|
|
|
|
|
chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) |
|
|
|
chain, err := NewBlockChain(diskdb, nil, gspec, nil, engine, vm.Config{}, nil, nil) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
@ -1947,7 +1971,7 @@ func testSideImport(t *testing.T, numCanonBlocksInSidechain, blocksBetweenCommon |
|
|
|
// Generate and import the canonical chain
|
|
|
|
// Generate and import the canonical chain
|
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
gspec.MustCommit(diskdb) |
|
|
|
gspec.MustCommit(diskdb) |
|
|
|
chain, err := NewBlockChain(diskdb, nil, &chainConfig, runEngine, vm.Config{}, nil, nil) |
|
|
|
chain, err := NewBlockChain(diskdb, nil, gspec, nil, runEngine, vm.Config{}, nil, nil) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
@ -2063,7 +2087,11 @@ func testInsertKnownChainData(t *testing.T, typ string) { |
|
|
|
engine := ethash.NewFaker() |
|
|
|
engine := ethash.NewFaker() |
|
|
|
|
|
|
|
|
|
|
|
db := rawdb.NewMemoryDatabase() |
|
|
|
db := rawdb.NewMemoryDatabase() |
|
|
|
genesis := (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db) |
|
|
|
gspec := &Genesis{ |
|
|
|
|
|
|
|
Config: params.TestChainConfig, |
|
|
|
|
|
|
|
BaseFee: big.NewInt(params.InitialBaseFee), |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
genesis := gspec.MustCommit(db) |
|
|
|
|
|
|
|
|
|
|
|
blocks, receipts := GenerateChain(params.TestChainConfig, genesis, engine, db, 32, func(i int, b *BlockGen) { b.SetCoinbase(common.Address{1}) }) |
|
|
|
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.
|
|
|
|
// A longer chain but total difficulty is lower.
|
|
|
@ -2074,15 +2102,14 @@ func testInsertKnownChainData(t *testing.T, typ string) { |
|
|
|
b.OffsetTime(-9) // A higher difficulty
|
|
|
|
b.OffsetTime(-9) // A higher difficulty
|
|
|
|
}) |
|
|
|
}) |
|
|
|
// Import the shared chain and the original canonical one
|
|
|
|
// Import the shared chain and the original canonical one
|
|
|
|
dir := t.TempDir() |
|
|
|
chaindb, err := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), t.TempDir(), "", false) |
|
|
|
chaindb, err := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), dir, "", false) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
t.Fatalf("failed to create temp freezer db: %v", err) |
|
|
|
t.Fatalf("failed to create temp freezer db: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
|
(&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(chaindb) |
|
|
|
gspec.MustCommit(chaindb) |
|
|
|
defer chaindb.Close() |
|
|
|
defer chaindb.Close() |
|
|
|
|
|
|
|
|
|
|
|
chain, err := NewBlockChain(chaindb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) |
|
|
|
chain, err := NewBlockChain(chaindb, nil, gspec, nil, engine, vm.Config{}, nil, nil) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
@ -2203,7 +2230,11 @@ func testInsertKnownChainDataWithMerging(t *testing.T, typ string, mergeHeight i |
|
|
|
chainConfig := *params.TestChainConfig |
|
|
|
chainConfig := *params.TestChainConfig |
|
|
|
var ( |
|
|
|
var ( |
|
|
|
db = rawdb.NewMemoryDatabase() |
|
|
|
db = rawdb.NewMemoryDatabase() |
|
|
|
genesis = (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee), Config: &chainConfig}).MustCommit(db) |
|
|
|
gspec = &Genesis{ |
|
|
|
|
|
|
|
BaseFee: big.NewInt(params.InitialBaseFee), |
|
|
|
|
|
|
|
Config: &chainConfig, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
genesis = gspec.MustCommit(db) |
|
|
|
runMerger = consensus.NewMerger(db) |
|
|
|
runMerger = consensus.NewMerger(db) |
|
|
|
runEngine = beacon.New(ethash.NewFaker()) |
|
|
|
runEngine = beacon.New(ethash.NewFaker()) |
|
|
|
genEngine = beacon.New(ethash.NewFaker()) |
|
|
|
genEngine = beacon.New(ethash.NewFaker()) |
|
|
@ -2242,7 +2273,7 @@ func testInsertKnownChainDataWithMerging(t *testing.T, typ string, mergeHeight i |
|
|
|
(&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(chaindb) |
|
|
|
(&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(chaindb) |
|
|
|
defer chaindb.Close() |
|
|
|
defer chaindb.Close() |
|
|
|
|
|
|
|
|
|
|
|
chain, err := NewBlockChain(chaindb, nil, &chainConfig, runEngine, vm.Config{}, nil, nil) |
|
|
|
chain, err := NewBlockChain(chaindb, nil, gspec, nil, runEngine, vm.Config{}, nil, nil) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
@ -2350,7 +2381,11 @@ func getLongAndShortChains() (bc *BlockChain, longChain []*types.Block, heavyCha |
|
|
|
// Generate a canonical chain to act as the main dataset
|
|
|
|
// Generate a canonical chain to act as the main dataset
|
|
|
|
engine := ethash.NewFaker() |
|
|
|
engine := ethash.NewFaker() |
|
|
|
db := rawdb.NewMemoryDatabase() |
|
|
|
db := rawdb.NewMemoryDatabase() |
|
|
|
genesis := (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db) |
|
|
|
gspec := &Genesis{ |
|
|
|
|
|
|
|
BaseFee: big.NewInt(params.InitialBaseFee), |
|
|
|
|
|
|
|
Config: params.TestChainConfig, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
genesis := gspec.MustCommit(db) |
|
|
|
|
|
|
|
|
|
|
|
// Generate and import the canonical chain,
|
|
|
|
// Generate and import the canonical chain,
|
|
|
|
// Offset the time, to keep the difficulty low
|
|
|
|
// Offset the time, to keep the difficulty low
|
|
|
@ -2358,9 +2393,9 @@ func getLongAndShortChains() (bc *BlockChain, longChain []*types.Block, heavyCha |
|
|
|
b.SetCoinbase(common.Address{1}) |
|
|
|
b.SetCoinbase(common.Address{1}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
(&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(diskdb) |
|
|
|
gspec.MustCommit(diskdb) |
|
|
|
|
|
|
|
|
|
|
|
chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) |
|
|
|
chain, err := NewBlockChain(diskdb, nil, gspec, nil, engine, vm.Config{}, nil, nil) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return nil, nil, nil, fmt.Errorf("failed to create tester chain: %v", err) |
|
|
|
return nil, nil, nil, fmt.Errorf("failed to create tester chain: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
@ -2390,12 +2425,12 @@ func getLongAndShortChains() (bc *BlockChain, longChain []*types.Block, heavyCha |
|
|
|
shorterTd.Add(shorterTd, b.Difficulty()) |
|
|
|
shorterTd.Add(shorterTd, b.Difficulty()) |
|
|
|
} |
|
|
|
} |
|
|
|
if shorterTd.Cmp(longerTd) <= 0 { |
|
|
|
if shorterTd.Cmp(longerTd) <= 0 { |
|
|
|
return nil, nil, nil, fmt.Errorf("Test is moot, heavyChain td (%v) must be larger than canon td (%v)", shorterTd, longerTd) |
|
|
|
return nil, nil, nil, fmt.Errorf("test is moot, heavyChain td (%v) must be larger than canon td (%v)", shorterTd, longerTd) |
|
|
|
} |
|
|
|
} |
|
|
|
longerNum := longChain[len(longChain)-1].NumberU64() |
|
|
|
longerNum := longChain[len(longChain)-1].NumberU64() |
|
|
|
shorterNum := heavyChain[len(heavyChain)-1].NumberU64() |
|
|
|
shorterNum := heavyChain[len(heavyChain)-1].NumberU64() |
|
|
|
if shorterNum >= longerNum { |
|
|
|
if shorterNum >= longerNum { |
|
|
|
return nil, nil, nil, fmt.Errorf("Test is moot, heavyChain num (%v) must be lower than canon num (%v)", shorterNum, longerNum) |
|
|
|
return nil, nil, nil, fmt.Errorf("test is moot, heavyChain num (%v) must be lower than canon num (%v)", shorterNum, longerNum) |
|
|
|
} |
|
|
|
} |
|
|
|
return chain, longChain, heavyChain, nil |
|
|
|
return chain, longChain, heavyChain, nil |
|
|
|
} |
|
|
|
} |
|
|
@ -2549,7 +2584,7 @@ func TestTransactionIndices(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
// Import all blocks into ancient db
|
|
|
|
// Import all blocks into ancient db
|
|
|
|
l := uint64(0) |
|
|
|
l := uint64(0) |
|
|
|
chain, err := NewBlockChain(ancientDb, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, &l) |
|
|
|
chain, err := NewBlockChain(ancientDb, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil, &l) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
@ -2575,7 +2610,7 @@ func TestTransactionIndices(t *testing.T) { |
|
|
|
} |
|
|
|
} |
|
|
|
gspec.MustCommit(ancientDb) |
|
|
|
gspec.MustCommit(ancientDb) |
|
|
|
l := l |
|
|
|
l := l |
|
|
|
chain, err = NewBlockChain(ancientDb, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, &l) |
|
|
|
chain, err = NewBlockChain(ancientDb, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil, &l) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
@ -2601,7 +2636,7 @@ func TestTransactionIndices(t *testing.T) { |
|
|
|
tails := []uint64{0, 67 /* 130 - 64 + 1 */, 100 /* 131 - 32 + 1 */, 69 /* 132 - 64 + 1 */, 0} |
|
|
|
tails := []uint64{0, 67 /* 130 - 64 + 1 */, 100 /* 131 - 32 + 1 */, 69 /* 132 - 64 + 1 */, 0} |
|
|
|
for i, l := range limit { |
|
|
|
for i, l := range limit { |
|
|
|
l := l |
|
|
|
l := l |
|
|
|
chain, err = NewBlockChain(ancientDb, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, &l) |
|
|
|
chain, err = NewBlockChain(ancientDb, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil, &l) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
@ -2676,7 +2711,7 @@ func TestSkipStaleTxIndicesInSnapSync(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
// Import all blocks into ancient db, only HEAD-32 indices are kept.
|
|
|
|
// Import all blocks into ancient db, only HEAD-32 indices are kept.
|
|
|
|
l := uint64(32) |
|
|
|
l := uint64(32) |
|
|
|
chain, err := NewBlockChain(ancientDb, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, &l) |
|
|
|
chain, err := NewBlockChain(ancientDb, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil, &l) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
@ -2702,7 +2737,7 @@ func benchmarkLargeNumberOfValueToNonexisting(b *testing.B, numTxs, numBlocks in |
|
|
|
testBankKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") |
|
|
|
testBankKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") |
|
|
|
testBankAddress = crypto.PubkeyToAddress(testBankKey.PublicKey) |
|
|
|
testBankAddress = crypto.PubkeyToAddress(testBankKey.PublicKey) |
|
|
|
bankFunds = big.NewInt(100000000000000000) |
|
|
|
bankFunds = big.NewInt(100000000000000000) |
|
|
|
gspec = Genesis{ |
|
|
|
gspec = &Genesis{ |
|
|
|
Config: params.TestChainConfig, |
|
|
|
Config: params.TestChainConfig, |
|
|
|
Alloc: GenesisAlloc{ |
|
|
|
Alloc: GenesisAlloc{ |
|
|
|
testBankAddress: {Balance: bankFunds}, |
|
|
|
testBankAddress: {Balance: bankFunds}, |
|
|
@ -2740,7 +2775,7 @@ func benchmarkLargeNumberOfValueToNonexisting(b *testing.B, numTxs, numBlocks in |
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
gspec.MustCommit(diskdb) |
|
|
|
gspec.MustCommit(diskdb) |
|
|
|
|
|
|
|
|
|
|
|
chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) |
|
|
|
chain, err := NewBlockChain(diskdb, nil, gspec, nil, engine, vm.Config{}, nil, nil) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
b.Fatalf("failed to create tester chain: %v", err) |
|
|
|
b.Fatalf("failed to create tester chain: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
@ -2815,14 +2850,18 @@ func TestSideImportPrunedBlocks(t *testing.T) { |
|
|
|
// Generate a canonical chain to act as the main dataset
|
|
|
|
// Generate a canonical chain to act as the main dataset
|
|
|
|
engine := ethash.NewFaker() |
|
|
|
engine := ethash.NewFaker() |
|
|
|
db := rawdb.NewMemoryDatabase() |
|
|
|
db := rawdb.NewMemoryDatabase() |
|
|
|
genesis := (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(db) |
|
|
|
gspec := &Genesis{ |
|
|
|
|
|
|
|
BaseFee: big.NewInt(params.InitialBaseFee), |
|
|
|
|
|
|
|
Config: params.TestChainConfig, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
genesis := gspec.MustCommit(db) |
|
|
|
|
|
|
|
|
|
|
|
// Generate and import the canonical chain
|
|
|
|
// Generate and import the canonical chain
|
|
|
|
blocks, _ := GenerateChain(params.TestChainConfig, genesis, engine, db, 2*TriesInMemory, nil) |
|
|
|
blocks, _ := GenerateChain(params.TestChainConfig, genesis, engine, db, 2*TriesInMemory, nil) |
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
|
|
|
|
|
|
|
|
(&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(diskdb) |
|
|
|
gspec.MustCommit(diskdb) |
|
|
|
chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) |
|
|
|
chain, err := NewBlockChain(diskdb, nil, gspec, nil, engine, vm.Config{}, nil, nil) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
@ -2916,7 +2955,7 @@ func TestDeleteCreateRevert(t *testing.T) { |
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
gspec.MustCommit(diskdb) |
|
|
|
gspec.MustCommit(diskdb) |
|
|
|
|
|
|
|
|
|
|
|
chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) |
|
|
|
chain, err := NewBlockChain(diskdb, nil, gspec, nil, engine, vm.Config{}, nil, nil) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
@ -3027,7 +3066,7 @@ func TestDeleteRecreateSlots(t *testing.T) { |
|
|
|
// Import the canonical chain
|
|
|
|
// Import the canonical chain
|
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
gspec.MustCommit(diskdb) |
|
|
|
gspec.MustCommit(diskdb) |
|
|
|
chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{ |
|
|
|
chain, err := NewBlockChain(diskdb, nil, gspec, nil, engine, vm.Config{ |
|
|
|
Debug: true, |
|
|
|
Debug: true, |
|
|
|
Tracer: logger.NewJSONLogger(nil, os.Stdout), |
|
|
|
Tracer: logger.NewJSONLogger(nil, os.Stdout), |
|
|
|
}, nil, nil) |
|
|
|
}, nil, nil) |
|
|
@ -3107,7 +3146,7 @@ func TestDeleteRecreateAccount(t *testing.T) { |
|
|
|
// Import the canonical chain
|
|
|
|
// Import the canonical chain
|
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
gspec.MustCommit(diskdb) |
|
|
|
gspec.MustCommit(diskdb) |
|
|
|
chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{ |
|
|
|
chain, err := NewBlockChain(diskdb, nil, gspec, nil, engine, vm.Config{ |
|
|
|
Debug: true, |
|
|
|
Debug: true, |
|
|
|
Tracer: logger.NewJSONLogger(nil, os.Stdout), |
|
|
|
Tracer: logger.NewJSONLogger(nil, os.Stdout), |
|
|
|
}, nil, nil) |
|
|
|
}, nil, nil) |
|
|
@ -3280,7 +3319,7 @@ func TestDeleteRecreateSlotsAcrossManyBlocks(t *testing.T) { |
|
|
|
// Import the canonical chain
|
|
|
|
// Import the canonical chain
|
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
gspec.MustCommit(diskdb) |
|
|
|
gspec.MustCommit(diskdb) |
|
|
|
chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{ |
|
|
|
chain, err := NewBlockChain(diskdb, nil, gspec, nil, engine, vm.Config{ |
|
|
|
//Debug: true,
|
|
|
|
//Debug: true,
|
|
|
|
//Tracer: vm.NewJSONLogger(nil, os.Stdout),
|
|
|
|
//Tracer: vm.NewJSONLogger(nil, os.Stdout),
|
|
|
|
}, nil, nil) |
|
|
|
}, nil, nil) |
|
|
@ -3414,7 +3453,7 @@ func TestInitThenFailCreateContract(t *testing.T) { |
|
|
|
// Import the canonical chain
|
|
|
|
// Import the canonical chain
|
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
gspec.MustCommit(diskdb) |
|
|
|
gspec.MustCommit(diskdb) |
|
|
|
chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{ |
|
|
|
chain, err := NewBlockChain(diskdb, nil, gspec, nil, engine, vm.Config{ |
|
|
|
//Debug: true,
|
|
|
|
//Debug: true,
|
|
|
|
//Tracer: vm.NewJSONLogger(nil, os.Stdout),
|
|
|
|
//Tracer: vm.NewJSONLogger(nil, os.Stdout),
|
|
|
|
}, nil, nil) |
|
|
|
}, nil, nil) |
|
|
@ -3504,7 +3543,7 @@ func TestEIP2718Transition(t *testing.T) { |
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
gspec.MustCommit(diskdb) |
|
|
|
gspec.MustCommit(diskdb) |
|
|
|
|
|
|
|
|
|
|
|
chain, err := NewBlockChain(diskdb, nil, gspec.Config, engine, vm.Config{}, nil, nil) |
|
|
|
chain, err := NewBlockChain(diskdb, nil, gspec, nil, engine, vm.Config{}, nil, nil) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
@ -3598,7 +3637,7 @@ func TestEIP1559Transition(t *testing.T) { |
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
gspec.MustCommit(diskdb) |
|
|
|
gspec.MustCommit(diskdb) |
|
|
|
|
|
|
|
|
|
|
|
chain, err := NewBlockChain(diskdb, nil, gspec.Config, engine, vm.Config{}, nil, nil) |
|
|
|
chain, err := NewBlockChain(diskdb, nil, gspec, nil, engine, vm.Config{}, nil, nil) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
@ -3705,7 +3744,7 @@ func TestSetCanonical(t *testing.T) { |
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
gspec.MustCommit(diskdb) |
|
|
|
gspec.MustCommit(diskdb) |
|
|
|
|
|
|
|
|
|
|
|
chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) |
|
|
|
chain, err := NewBlockChain(diskdb, nil, gspec, nil, engine, vm.Config{}, nil, nil) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
@ -3811,7 +3850,7 @@ func TestCanonicalHashMarker(t *testing.T) { |
|
|
|
// Initialize test chain
|
|
|
|
// Initialize test chain
|
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
diskdb := rawdb.NewMemoryDatabase() |
|
|
|
gspec.MustCommit(diskdb) |
|
|
|
gspec.MustCommit(diskdb) |
|
|
|
chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) |
|
|
|
chain, err := NewBlockChain(diskdb, nil, gspec, nil, engine, vm.Config{}, nil, nil) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
t.Fatalf("failed to create tester chain: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
|