@@ -1712,7 +1712,7 @@ func TestTrieForkGC(t *testing.T) {
1712
1712
Config : params .TestChainConfig ,
1713
1713
BaseFee : big .NewInt (params .InitialBaseFee ),
1714
1714
}
1715
- genDb , blocks , _ := GenerateChainWithGenesis (genesis , engine , 2 * TriesInMemory , func (i int , b * BlockGen ) { b .SetCoinbase (common.Address {1 }) })
1715
+ genDb , blocks , _ := GenerateChainWithGenesis (genesis , engine , 2 * state . TriesInMemory , func (i int , b * BlockGen ) { b .SetCoinbase (common.Address {1 }) })
1716
1716
1717
1717
// Generate a bunch of fork blocks, each side forking from the canonical chain
1718
1718
forks := make ([]* types.Block , len (blocks ))
@@ -1740,7 +1740,7 @@ func TestTrieForkGC(t *testing.T) {
1740
1740
}
1741
1741
}
1742
1742
// Dereference all the recent tries and ensure no past trie is left in
1743
- for i := 0 ; i < TriesInMemory ; i ++ {
1743
+ for i := 0 ; i < state . TriesInMemory ; i ++ {
1744
1744
chain .TrieDB ().Dereference (blocks [len (blocks )- 1 - i ].Root ())
1745
1745
chain .TrieDB ().Dereference (forks [len (blocks )- 1 - i ].Root ())
1746
1746
}
@@ -1764,8 +1764,8 @@ func testLargeReorgTrieGC(t *testing.T, scheme string) {
1764
1764
BaseFee : big .NewInt (params .InitialBaseFee ),
1765
1765
}
1766
1766
genDb , shared , _ := GenerateChainWithGenesis (genesis , engine , 64 , func (i int , b * BlockGen ) { b .SetCoinbase (common.Address {1 }) })
1767
- original , _ := GenerateChain (genesis .Config , shared [len (shared )- 1 ], engine , genDb , 2 * TriesInMemory , func (i int , b * BlockGen ) { b .SetCoinbase (common.Address {2 }) })
1768
- competitor , _ := GenerateChain (genesis .Config , shared [len (shared )- 1 ], engine , genDb , 2 * TriesInMemory + 1 , func (i int , b * BlockGen ) { b .SetCoinbase (common.Address {3 }) })
1767
+ original , _ := GenerateChain (genesis .Config , shared [len (shared )- 1 ], engine , genDb , 2 * state . TriesInMemory , func (i int , b * BlockGen ) { b .SetCoinbase (common.Address {2 }) })
1768
+ competitor , _ := GenerateChain (genesis .Config , shared [len (shared )- 1 ], engine , genDb , 2 * state . TriesInMemory + 1 , func (i int , b * BlockGen ) { b .SetCoinbase (common.Address {3 }) })
1769
1769
1770
1770
// Import the shared chain and the original canonical one
1771
1771
db , _ := rawdb .NewDatabaseWithFreezer (rawdb .NewMemoryDatabase (), t .TempDir (), "" , false )
@@ -1804,7 +1804,7 @@ func testLargeReorgTrieGC(t *testing.T, scheme string) {
1804
1804
}
1805
1805
// In path-based trie database implementation, it will keep 128 diff + 1 disk
1806
1806
// layers, totally 129 latest states available. In hash-based it's 128.
1807
- states := TriesInMemory
1807
+ states := state . TriesInMemory
1808
1808
if scheme == rawdb .PathScheme {
1809
1809
states = states + 1
1810
1810
}
@@ -1972,7 +1972,7 @@ func testLowDiffLongChain(t *testing.T, scheme string) {
1972
1972
}
1973
1973
// We must use a pretty long chain to ensure that the fork doesn't overtake us
1974
1974
// until after at least 128 blocks post tip
1975
- genDb , blocks , _ := GenerateChainWithGenesis (genesis , engine , 6 * TriesInMemory , func (i int , b * BlockGen ) {
1975
+ genDb , blocks , _ := GenerateChainWithGenesis (genesis , engine , 6 * state . TriesInMemory , func (i int , b * BlockGen ) {
1976
1976
b .SetCoinbase (common.Address {1 })
1977
1977
b .OffsetTime (- 9 )
1978
1978
})
@@ -1992,7 +1992,7 @@ func testLowDiffLongChain(t *testing.T, scheme string) {
1992
1992
}
1993
1993
// Generate fork chain, starting from an early block
1994
1994
parent := blocks [10 ]
1995
- fork , _ := GenerateChain (genesis .Config , parent , engine , genDb , 8 * TriesInMemory , func (i int , b * BlockGen ) {
1995
+ fork , _ := GenerateChain (genesis .Config , parent , engine , genDb , 8 * state . TriesInMemory , func (i int , b * BlockGen ) {
1996
1996
b .SetCoinbase (common.Address {2 })
1997
1997
})
1998
1998
@@ -2055,7 +2055,7 @@ func testSideImport(t *testing.T, numCanonBlocksInSidechain, blocksBetweenCommon
2055
2055
// Set the terminal total difficulty in the config
2056
2056
gspec .Config .TerminalTotalDifficulty = big .NewInt (0 )
2057
2057
}
2058
- genDb , blocks , _ := GenerateChainWithGenesis (gspec , engine , 2 * TriesInMemory , func (i int , gen * BlockGen ) {
2058
+ genDb , blocks , _ := GenerateChainWithGenesis (gspec , engine , 2 * state . TriesInMemory , func (i int , gen * BlockGen ) {
2059
2059
tx , err := types .SignTx (types .NewTransaction (nonce , common .HexToAddress ("deadbeef" ), big .NewInt (100 ), 21000 , big .NewInt (int64 (i + 1 )* params .GWei ), nil ), signer , key )
2060
2060
if err != nil {
2061
2061
t .Fatalf ("failed to create tx: %v" , err )
@@ -2070,9 +2070,9 @@ func testSideImport(t *testing.T, numCanonBlocksInSidechain, blocksBetweenCommon
2070
2070
t .Fatalf ("block %d: failed to insert into chain: %v" , n , err )
2071
2071
}
2072
2072
2073
- lastPrunedIndex := len (blocks ) - TriesInMemory - 1
2073
+ lastPrunedIndex := len (blocks ) - state . TriesInMemory - 1
2074
2074
lastPrunedBlock := blocks [lastPrunedIndex ]
2075
- firstNonPrunedBlock := blocks [len (blocks )- TriesInMemory ]
2075
+ firstNonPrunedBlock := blocks [len (blocks )- state . TriesInMemory ]
2076
2076
2077
2077
// Verify pruning of lastPrunedBlock
2078
2078
if chain .HasBlockAndState (lastPrunedBlock .Hash (), lastPrunedBlock .NumberU64 ()) {
@@ -2099,7 +2099,7 @@ func testSideImport(t *testing.T, numCanonBlocksInSidechain, blocksBetweenCommon
2099
2099
// Generate fork chain, make it longer than canon
2100
2100
parentIndex := lastPrunedIndex + blocksBetweenCommonAncestorAndPruneblock
2101
2101
parent := blocks [parentIndex ]
2102
- fork , _ := GenerateChain (gspec .Config , parent , engine , genDb , 2 * TriesInMemory , func (i int , b * BlockGen ) {
2102
+ fork , _ := GenerateChain (gspec .Config , parent , engine , genDb , 2 * state . TriesInMemory , func (i int , b * BlockGen ) {
2103
2103
b .SetCoinbase (common.Address {2 })
2104
2104
if int (b .header .Number .Uint64 ()) >= mergeBlock {
2105
2105
b .SetPoS ()
@@ -2742,7 +2742,7 @@ func testSideImportPrunedBlocks(t *testing.T, scheme string) {
2742
2742
BaseFee : big .NewInt (params .InitialBaseFee ),
2743
2743
}
2744
2744
// Generate and import the canonical chain
2745
- _ , blocks , _ := GenerateChainWithGenesis (genesis , engine , 2 * TriesInMemory , nil )
2745
+ _ , blocks , _ := GenerateChainWithGenesis (genesis , engine , 2 * state . TriesInMemory , nil )
2746
2746
2747
2747
chain , err := NewBlockChain (rawdb .NewMemoryDatabase (), DefaultCacheConfigWithScheme (scheme ), genesis , nil , engine , vm.Config {}, nil , nil )
2748
2748
if err != nil {
@@ -2755,9 +2755,9 @@ func testSideImportPrunedBlocks(t *testing.T, scheme string) {
2755
2755
}
2756
2756
// In path-based trie database implementation, it will keep 128 diff + 1 disk
2757
2757
// layers, totally 129 latest states available. In hash-based it's 128.
2758
- states := TriesInMemory
2758
+ states := state . TriesInMemory
2759
2759
if scheme == rawdb .PathScheme {
2760
- states = TriesInMemory + 1
2760
+ states = state . TriesInMemory + 1
2761
2761
}
2762
2762
lastPrunedIndex := len (blocks ) - states - 1
2763
2763
lastPrunedBlock := blocks [lastPrunedIndex ]
@@ -3638,7 +3638,7 @@ func testSetCanonical(t *testing.T, scheme string) {
3638
3638
engine = ethash .NewFaker ()
3639
3639
)
3640
3640
// Generate and import the canonical chain
3641
- _ , canon , _ := GenerateChainWithGenesis (gspec , engine , 2 * TriesInMemory , func (i int , gen * BlockGen ) {
3641
+ _ , canon , _ := GenerateChainWithGenesis (gspec , engine , 2 * state . TriesInMemory , func (i int , gen * BlockGen ) {
3642
3642
tx , err := types .SignTx (types .NewTransaction (gen .TxNonce (address ), common.Address {0x00 }, big .NewInt (1000 ), params .TxGas , gen .header .BaseFee , nil ), signer , key )
3643
3643
if err != nil {
3644
3644
panic (err )
@@ -3659,7 +3659,7 @@ func testSetCanonical(t *testing.T, scheme string) {
3659
3659
}
3660
3660
3661
3661
// Generate the side chain and import them
3662
- _ , side , _ := GenerateChainWithGenesis (gspec , engine , 2 * TriesInMemory , func (i int , gen * BlockGen ) {
3662
+ _ , side , _ := GenerateChainWithGenesis (gspec , engine , 2 * state . TriesInMemory , func (i int , gen * BlockGen ) {
3663
3663
tx , err := types .SignTx (types .NewTransaction (gen .TxNonce (address ), common.Address {0x00 }, big .NewInt (1 ), params .TxGas , gen .header .BaseFee , nil ), signer , key )
3664
3664
if err != nil {
3665
3665
panic (err )
@@ -3698,8 +3698,8 @@ func testSetCanonical(t *testing.T, scheme string) {
3698
3698
verify (side [len (side )- 1 ])
3699
3699
3700
3700
// Reset the chain head to original chain
3701
- chain .SetCanonical (canon [TriesInMemory - 1 ])
3702
- verify (canon [TriesInMemory - 1 ])
3701
+ chain .SetCanonical (canon [state . TriesInMemory - 1 ])
3702
+ verify (canon [state . TriesInMemory - 1 ])
3703
3703
}
3704
3704
3705
3705
// TestCanonicalHashMarker tests all the canonical hash markers are updated/deleted
0 commit comments