@ -22,6 +22,7 @@ import (
"math/big"
"math/rand"
"os"
"path"
"sync"
"testing"
"time"
@ -61,7 +62,7 @@ func newCanonical(engine consensus.Engine, n int, full bool, scheme string) (eth
}
)
// Initialize a fresh chain with only a genesis block
blockchain , _ := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , genesis , nil , engine , vm . Config { } , nil , nil )
blockchain , _ := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , genesis , nil , engine , vm . Config { } , nil )
// Create and inject the requested chain
if n == 0 {
@ -763,7 +764,7 @@ func testFastVsFullChains(t *testing.T, scheme string) {
} )
// Import the chain as an archive node for the comparison baseline
archiveDb := rawdb . NewMemoryDatabase ( )
archive , _ := NewBlockChain ( archiveDb , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil , nil )
archive , _ := NewBlockChain ( archiveDb , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil )
defer archive . Stop ( )
if n , err := archive . InsertChain ( blocks ) ; err != nil {
@ -771,7 +772,7 @@ func testFastVsFullChains(t *testing.T, scheme string) {
}
// Fast import the chain as a non-archive node to test
fastDb := rawdb . NewMemoryDatabase ( )
fast , _ := NewBlockChain ( fastDb , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil , nil )
fast , _ := NewBlockChain ( fastDb , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil )
defer fast . Stop ( )
headers := make ( [ ] * types . Header , len ( blocks ) )
@ -791,7 +792,7 @@ func testFastVsFullChains(t *testing.T, scheme string) {
}
defer ancientDb . Close ( )
ancient , _ := NewBlockChain ( ancientDb , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil , nil )
ancient , _ := NewBlockChain ( ancientDb , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil )
defer ancient . Stop ( )
if n , err := ancient . InsertHeaderChain ( headers ) ; err != nil {
@ -911,7 +912,7 @@ func testLightVsFastVsFullChainHeads(t *testing.T, scheme string) {
archiveCaching . TrieDirtyDisabled = true
archiveCaching . StateScheme = scheme
archive , _ := NewBlockChain ( archiveDb , & archiveCaching , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil , nil )
archive , _ := NewBlockChain ( archiveDb , & archiveCaching , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil )
if n , err := archive . InsertChain ( blocks ) ; err != nil {
t . Fatalf ( "failed to process block %d: %v" , n , err )
}
@ -924,7 +925,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 ( fastDb , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil , nil )
fast , _ := NewBlockChain ( fastDb , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil )
defer fast . Stop ( )
headers := make ( [ ] * types . Header , len ( blocks ) )
@ -944,7 +945,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 ( ancientDb , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil , nil )
ancient , _ := NewBlockChain ( ancientDb , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil )
defer ancient . Stop ( )
if n , err := ancient . InsertHeaderChain ( headers ) ; err != nil {
@ -963,7 +964,7 @@ func testLightVsFastVsFullChainHeads(t *testing.T, scheme string) {
// Import the chain as a light node and ensure all pointers are updated
lightDb := makeDb ( )
defer lightDb . Close ( )
light , _ := NewBlockChain ( lightDb , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil , nil )
light , _ := NewBlockChain ( lightDb , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil )
if n , err := light . InsertHeaderChain ( headers ) ; err != nil {
t . Fatalf ( "failed to insert header %d: %v" , n , err )
}
@ -1036,7 +1037,7 @@ func testChainTxReorgs(t *testing.T, scheme string) {
} )
// Import the chain. This runs all block validation rules.
db := rawdb . NewMemoryDatabase ( )
blockchain , _ := NewBlockChain ( db , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil , nil )
blockchain , _ := NewBlockChain ( db , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil )
if i , err := blockchain . InsertChain ( chain ) ; err != nil {
t . Fatalf ( "failed to insert original chain[%d]: %v" , i , err )
}
@ -1110,7 +1111,7 @@ func testLogReorgs(t *testing.T, scheme string) {
signer = types . LatestSigner ( gspec . Config )
)
blockchain , _ := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil , nil )
blockchain , _ := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil )
defer blockchain . Stop ( )
rmLogsCh := make ( chan RemovedLogsEvent )
@ -1166,7 +1167,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 ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , engine , vm . Config { } , nil , nil )
blockchain , _ = NewBlockChain ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , engine , vm . Config { } , nil )
)
defer blockchain . Stop ( )
@ -1247,7 +1248,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 ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil , nil )
blockchain , _ = NewBlockChain ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil )
)
defer blockchain . Stop ( )
@ -1266,7 +1267,7 @@ func testSideLogRebirth(t *testing.T, scheme string) {
}
checkLogEvents ( t , newLogCh , rmLogsCh , 0 , 0 )
// Generate side chain with lower difficulty
// Generate side chain with lower difficulty, after the merge, the chain will be accepted even if it is lower difficulty
genDb , sideChain , _ := GenerateChainWithGenesis ( gspec , ethash . NewFaker ( ) , 2 , func ( i int , gen * BlockGen ) {
if i == 1 {
tx , err := types . SignTx ( types . NewContractCreation ( gen . TxNonce ( addr1 ) , new ( big . Int ) , 1000000 , gen . header . BaseFee , logCode ) , signer , key1 )
@ -1279,14 +1280,14 @@ func testSideLogRebirth(t *testing.T, scheme string) {
if _ , err := blockchain . InsertChain ( sideChain ) ; err != nil {
t . Fatalf ( "failed to insert forked chain: %v" , err )
}
checkLogEvents ( t , newLogCh , rmLogsCh , 0 , 0 )
checkLogEvents ( t , newLogCh , rmLogsCh , 1 , 0 )
// Generate a new block based on side chain.
// Generate a new block based on side chain. Should not emit any events anymore.
newBlocks , _ := GenerateChain ( gspec . Config , sideChain [ len ( sideChain ) - 1 ] , ethash . NewFaker ( ) , genDb , 1 , func ( i int , gen * BlockGen ) { } )
if _ , err := blockchain . InsertChain ( newBlocks ) ; err != nil {
t . Fatalf ( "failed to insert forked chain: %v" , err )
}
checkLogEvents ( t , newLogCh , rmLogsCh , 1 , 0 )
checkLogEvents ( t , newLogCh , rmLogsCh , 0 , 0 )
}
func checkLogEvents ( t * testing . T , logsCh <- chan [ ] * types . Log , rmLogsCh <- chan RemovedLogsEvent , wantNew , wantRemoved int ) {
@ -1346,7 +1347,7 @@ func testReorgSideEvent(t *testing.T, scheme string) {
}
signer = types . LatestSigner ( gspec . Config )
)
blockchain , _ := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil , nil )
blockchain , _ := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil )
defer blockchain . Stop ( )
_ , chain , _ := GenerateChainWithGenesis ( gspec , ethash . NewFaker ( ) , 3 , func ( i int , gen * BlockGen ) { } )
@ -1370,12 +1371,7 @@ func testReorgSideEvent(t *testing.T, scheme string) {
t . Fatalf ( "failed to insert chain: %v" , err )
}
// first two block of the secondary chain are for a brief moment considered
// side chains because up to that point the first one is considered the
// heavier chain.
expectedSideHashes := map [ common . Hash ] bool {
replacementBlocks [ 0 ] . Hash ( ) : true ,
replacementBlocks [ 1 ] . Hash ( ) : true ,
chain [ 0 ] . Hash ( ) : true ,
chain [ 1 ] . Hash ( ) : true ,
chain [ 2 ] . Hash ( ) : true ,
@ -1403,7 +1399,7 @@ done:
timeout . Reset ( timeoutDura )
case <- timeout . C :
t . Fatal ( "Timeout. Possibly not all blocks were triggered for sideevent" )
t . Fatalf ( "Timeout. Possibly not all blocks were triggered for sideevent: %v " , i )
}
}
@ -1530,7 +1526,7 @@ func testEIP155Transition(t *testing.T, scheme string) {
}
} )
blockchain , _ := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil , nil )
blockchain , _ := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil )
defer blockchain . Stop ( )
if _ , err := blockchain . InsertChain ( blocks ) ; err != nil {
@ -1623,7 +1619,7 @@ func testEIP161AccountRemoval(t *testing.T, scheme string) {
block . AddTx ( tx )
} )
// account must exist pre eip 161
blockchain , _ := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil , nil )
blockchain , _ := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil )
defer blockchain . Stop ( )
if _ , err := blockchain . InsertChain ( types . Blocks { blocks [ 0 ] } ) ; err != nil {
@ -1681,7 +1677,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 ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , genesis , nil , engine , vm . Config { } , nil , nil )
chain , err := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , genesis , nil , engine , vm . Config { } , nil )
if err != nil {
t . Fatalf ( "failed to create tester chain: %v" , err )
}
@ -1725,7 +1721,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 ( rawdb . NewMemoryDatabase ( ) , nil , genesis , nil , engine , vm . Config { } , nil , nil )
chain , err := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , nil , genesis , nil , engine , vm . Config { } , nil )
if err != nil {
t . Fatalf ( "failed to create tester chain: %v" , err )
}
@ -1771,7 +1767,7 @@ func testLargeReorgTrieGC(t *testing.T, scheme string) {
db , _ := rawdb . NewDatabaseWithFreezer ( rawdb . NewMemoryDatabase ( ) , "" , "" , false )
defer db . Close ( )
chain , err := NewBlockChain ( db , DefaultCacheConfigWithScheme ( scheme ) , genesis , nil , engine , vm . Config { } , nil , nil )
chain , err := NewBlockChain ( db , DefaultCacheConfigWithScheme ( scheme ) , genesis , nil , engine , vm . Config { } , nil )
if err != nil {
t . Fatalf ( "failed to create tester chain: %v" , err )
}
@ -1787,18 +1783,15 @@ func testLargeReorgTrieGC(t *testing.T, scheme string) {
if chain . HasState ( shared [ len ( shared ) - 1 ] . Root ( ) ) {
t . Fatalf ( "common-but-old ancestor still cache" )
}
// Import the competitor chain without exceeding the canonical's TD and ensure
// we have not processed any of the blocks (protection against malicious blocks)
// Import the competitor chain without exceeding the canonical's TD.
// Post-merge the side chain should be executed
if _ , err := chain . InsertChain ( competitor [ : len ( competitor ) - 2 ] ) ; err != nil {
t . Fatalf ( "failed to insert competitor chain: %v" , err )
}
for i , block := range competitor [ : len ( competitor ) - 2 ] {
if chain . HasState ( block . Root ( ) ) {
t . Fatalf ( "competitor %d: low TD chain became processed" , i )
}
if ! chain . HasState ( competitor [ len ( competitor ) - 3 ] . Root ( ) ) {
t . Fatalf ( "failed to insert low-TD chain" )
}
// Import the head of the competitor chain, triggering the reorg and ensure we
// successfully reprocess all the stashed away blocks.
// Import the head of the competitor chain.
if _ , err := chain . InsertChain ( competitor [ len ( competitor ) - 2 : ] ) ; err != nil {
t . Fatalf ( "failed to finalize competitor chain: %v" , err )
}
@ -1842,7 +1835,7 @@ func testBlockchainRecovery(t *testing.T, scheme string) {
t . Fatalf ( "failed to create temp freezer db: %v" , err )
}
defer ancientDb . Close ( )
ancient , _ := NewBlockChain ( ancientDb , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil , nil )
ancient , _ := NewBlockChain ( ancientDb , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil )
headers := make ( [ ] * types . Header , len ( blocks ) )
for i , block := range blocks {
@ -1862,7 +1855,7 @@ func testBlockchainRecovery(t *testing.T, scheme string) {
rawdb . WriteHeadFastBlockHash ( ancientDb , midBlock . Hash ( ) )
// Reopen broken blockchain again
ancient , _ = NewBlockChain ( ancientDb , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil , nil )
ancient , _ = NewBlockChain ( ancientDb , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil )
defer ancient . Stop ( )
if num := ancient . CurrentBlock ( ) . Number . Uint64 ( ) ; num != 0 {
t . Errorf ( "head block mismatch: have #%v, want #%v" , num , 0 )
@ -1914,7 +1907,7 @@ func testInsertReceiptChainRollback(t *testing.T, scheme string) {
}
defer ancientDb . Close ( )
ancientChain , _ := NewBlockChain ( ancientDb , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil , nil )
ancientChain , _ := NewBlockChain ( ancientDb , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , ethash . NewFaker ( ) , vm . Config { } , nil )
defer ancientChain . Stop ( )
// Import the canonical header chain.
@ -1981,7 +1974,7 @@ func testLowDiffLongChain(t *testing.T, scheme string) {
diskdb , _ := rawdb . NewDatabaseWithFreezer ( rawdb . NewMemoryDatabase ( ) , "" , "" , false )
defer diskdb . Close ( )
chain , err := NewBlockChain ( diskdb , DefaultCacheConfigWithScheme ( scheme ) , genesis , nil , engine , vm . Config { } , nil , nil )
chain , err := NewBlockChain ( diskdb , DefaultCacheConfigWithScheme ( scheme ) , genesis , nil , engine , vm . Config { } , nil )
if err != nil {
t . Fatalf ( "failed to create tester chain: %v" , err )
}
@ -2042,7 +2035,7 @@ func testSideImport(t *testing.T, numCanonBlocksInSidechain, blocksBetweenCommon
mergeBlock = math . MaxInt32
)
// Generate and import the canonical chain
chain , err := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , nil , gspec , nil , engine , vm . Config { } , nil , nil )
chain , err := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , nil , gspec , nil , engine , vm . Config { } , nil )
if err != nil {
t . Fatalf ( "failed to create tester chain: %v" , err )
}
@ -2196,7 +2189,7 @@ func testInsertKnownChainData(t *testing.T, typ string, scheme string) {
}
defer chaindb . Close ( )
chain , err := NewBlockChain ( chaindb , DefaultCacheConfigWithScheme ( scheme ) , genesis , nil , engine , vm . Config { } , nil , nil )
chain , err := NewBlockChain ( chaindb , DefaultCacheConfigWithScheme ( scheme ) , genesis , nil , engine , vm . Config { } , nil )
if err != nil {
t . Fatalf ( "failed to create tester chain: %v" , err )
}
@ -2280,10 +2273,10 @@ func testInsertKnownChainData(t *testing.T, typ string, scheme string) {
if err := inserter ( append ( blocks , blocks2 ... ) , append ( receipts , receipts2 ... ) ) ; err != nil {
t . Fatalf ( "failed to insert chain data: %v" , err )
}
// The head shouldn't change .
asserter ( t , blocks3 [ len ( blocks3 ) - 1 ] )
// Post-merge the chain should change even if td is lower .
asserter ( t , blocks2 [ len ( blocks2 ) - 1 ] )
// Rollback the heavier chain and re-insert the longer chain again
// Rollback the heavier chain and re-insert the longer chain again.
chain . SetHead ( rollback - 1 )
if err := inserter ( append ( blocks , blocks2 ... ) , append ( receipts , receipts2 ... ) ) ; err != nil {
t . Fatalf ( "failed to insert chain data: %v" , err )
@ -2367,7 +2360,7 @@ func testInsertKnownChainDataWithMerging(t *testing.T, typ string, mergeHeight i
}
defer chaindb . Close ( )
chain , err := NewBlockChain ( chaindb , nil , genesis , nil , engine , vm . Config { } , nil , nil )
chain , err := NewBlockChain ( chaindb , nil , genesis , nil , engine , vm . Config { } , nil )
if err != nil {
t . Fatalf ( "failed to create tester chain: %v" , err )
}
@ -2481,7 +2474,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 ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , genesis , nil , engine , vm . Config { } , nil , nil )
chain , err := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , genesis , nil , engine , vm . Config { } , nil )
if err != nil {
return nil , nil , nil , nil , fmt . Errorf ( "failed to create tester chain: %v" , err )
}
@ -2657,7 +2650,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 ( rawdb . NewMemoryDatabase ( ) , nil , gspec , nil , engine , vm . Config { } , nil , nil )
chain , err := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , nil , gspec , nil , engine , vm . Config { } , nil )
if err != nil {
b . Fatalf ( "failed to create tester chain: %v" , err )
}
@ -2744,7 +2737,21 @@ func testSideImportPrunedBlocks(t *testing.T, scheme string) {
// Generate and import the canonical chain
_ , blocks , _ := GenerateChainWithGenesis ( genesis , engine , 2 * state . TriesInMemory , nil )
chain , err := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , genesis , nil , engine , vm . Config { } , nil , nil )
// Construct a database with freezer enabled
datadir := t . TempDir ( )
ancient := path . Join ( datadir , "ancient" )
db , err := rawdb . Open ( rawdb . OpenOptions {
Directory : datadir ,
AncientsDirectory : ancient ,
Ephemeral : true ,
} )
if err != nil {
t . Fatalf ( "Failed to create persistent database: %v" , err )
}
defer db . Close ( )
chain , err := NewBlockChain ( db , DefaultCacheConfigWithScheme ( scheme ) , genesis , nil , engine , vm . Config { } , nil )
if err != nil {
t . Fatalf ( "failed to create tester chain: %v" , err )
}
@ -2771,7 +2778,6 @@ func testSideImportPrunedBlocks(t *testing.T, scheme string) {
if ! chain . HasBlockAndState ( firstNonPrunedBlock . Hash ( ) , firstNonPrunedBlock . NumberU64 ( ) ) {
t . Errorf ( "Block %d pruned" , firstNonPrunedBlock . NumberU64 ( ) )
}
// Now re-import some old blocks
blockToReimport := blocks [ 5 : 8 ]
_ , err = chain . InsertChain ( blockToReimport )
if err != nil {
@ -2844,7 +2850,7 @@ func testDeleteCreateRevert(t *testing.T, scheme string) {
b . AddTx ( tx )
} )
// Import the canonical chain
chain , err := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , engine , vm . Config { } , nil , nil )
chain , err := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , engine , vm . Config { } , nil )
if err != nil {
t . Fatalf ( "failed to create tester chain: %v" , err )
}
@ -2959,7 +2965,7 @@ func testDeleteRecreateSlots(t *testing.T, scheme string) {
// Import the canonical chain
chain , err := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , engine , vm . Config {
Tracer : logger . NewJSONLogger ( nil , os . Stdout ) ,
} , nil , nil )
} , nil )
if err != nil {
t . Fatalf ( "failed to create tester chain: %v" , err )
}
@ -3041,7 +3047,7 @@ func testDeleteRecreateAccount(t *testing.T, scheme string) {
// Import the canonical chain
chain , err := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , engine , vm . Config {
Tracer : logger . NewJSONLogger ( nil , os . Stdout ) ,
} , nil , nil )
} , nil )
if err != nil {
t . Fatalf ( "failed to create tester chain: %v" , err )
}
@ -3217,7 +3223,7 @@ func testDeleteRecreateSlotsAcrossManyBlocks(t *testing.T, scheme string) {
chain , err := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , engine , vm . Config {
//Debug: true,
//Tracer: vm.NewJSONLogger(nil, os.Stdout),
} , nil , nil )
} , nil )
if err != nil {
t . Fatalf ( "failed to create tester chain: %v" , err )
}
@ -3355,7 +3361,7 @@ func testInitThenFailCreateContract(t *testing.T, scheme string) {
chain , err := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , engine , vm . Config {
//Debug: true,
//Tracer: vm.NewJSONLogger(nil, os.Stdout),
} , nil , nil )
} , nil )
if err != nil {
t . Fatalf ( "failed to create tester chain: %v" , err )
}
@ -3442,7 +3448,7 @@ func testEIP2718Transition(t *testing.T, scheme string) {
} )
// Import the canonical chain
chain , err := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , engine , vm . Config { } , nil , nil )
chain , err := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , engine , vm . Config { } , nil )
if err != nil {
t . Fatalf ( "failed to create tester chain: %v" , err )
}
@ -3536,7 +3542,7 @@ func testEIP1559Transition(t *testing.T, scheme string) {
b . AddTx ( tx )
} )
chain , err := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , engine , vm . Config { } , nil , nil )
chain , err := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , engine , vm . Config { } , nil )
if err != nil {
t . Fatalf ( "failed to create tester chain: %v" , err )
}
@ -3649,7 +3655,7 @@ func testSetCanonical(t *testing.T, scheme string) {
diskdb , _ := rawdb . NewDatabaseWithFreezer ( rawdb . NewMemoryDatabase ( ) , "" , "" , false )
defer diskdb . Close ( )
chain , err := NewBlockChain ( diskdb , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , engine , vm . Config { } , nil , nil )
chain , err := NewBlockChain ( diskdb , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , engine , vm . Config { } , nil )
if err != nil {
t . Fatalf ( "failed to create tester chain: %v" , err )
}
@ -3758,7 +3764,7 @@ func testCanonicalHashMarker(t *testing.T, scheme string) {
_ , forkB , _ := GenerateChainWithGenesis ( gspec , engine , c . forkB , func ( i int , gen * BlockGen ) { } )
// Initialize test chain
chain , err := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , engine , vm . Config { } , nil , nil )
chain , err := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , DefaultCacheConfigWithScheme ( scheme ) , gspec , nil , engine , vm . Config { } , nil )
if err != nil {
t . Fatalf ( "failed to create tester chain: %v" , err )
}
@ -3895,7 +3901,7 @@ func testCreateThenDelete(t *testing.T, config *params.ChainConfig) {
chain , err := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , nil , gspec , nil , engine , vm . Config {
//Debug: true,
//Tracer: logger.NewJSONLogger(nil, os.Stdout),
} , nil , nil )
} , nil )
if err != nil {
t . Fatalf ( "failed to create tester chain: %v" , err )
}
@ -4007,7 +4013,7 @@ func TestDeleteThenCreate(t *testing.T) {
}
} )
// Import the canonical chain
chain , err := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , nil , gspec , nil , engine , vm . Config { } , nil , nil )
chain , err := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , nil , gspec , nil , engine , vm . Config { } , nil )
if err != nil {
t . Fatalf ( "failed to create tester chain: %v" , err )
}
@ -4092,7 +4098,7 @@ func TestTransientStorageReset(t *testing.T) {
} )
// Initialize the blockchain with 1153 enabled.
chain , err := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , nil , gspec , nil , engine , vmConfig , nil , nil )
chain , err := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , nil , gspec , nil , engine , vmConfig , nil )
if err != nil {
t . Fatalf ( "failed to create tester chain: %v" , err )
}
@ -4187,7 +4193,7 @@ func TestEIP3651(t *testing.T) {
b . AddTx ( tx )
} )
chain , err := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , nil , gspec , nil , engine , vm . Config { Tracer : logger . NewMarkdownLogger ( & logger . Config { } , os . Stderr ) . Hooks ( ) } , nil , nil )
chain , err := NewBlockChain ( rawdb . NewMemoryDatabase ( ) , nil , gspec , nil , engine , vm . Config { Tracer : logger . NewMarkdownLogger ( & logger . Config { } , os . Stderr ) . Hooks ( ) } , nil )
if err != nil {
t . Fatalf ( "failed to create tester chain: %v" , err )
}