@@ -73,10 +73,10 @@ const (
7373
7474type genctx struct {
7575 stateRoot common.Hash
76- accounts map [common.Hash ][]byte
77- storages map [common.Hash ]map [common.Hash ][]byte
78- accountOrigin map [common.Address ][]byte
79- storageOrigin map [common.Address ]map [common.Hash ][]byte
76+ accounts map [common.Hash ][]byte // Keyed by the hash of account address
77+ storages map [common.Hash ]map [common.Hash ][]byte // Keyed by the hash of account address and the hash of storage key
78+ accountOrigin map [common.Address ][]byte // Keyed by the account address
79+ storageOrigin map [common.Address ]map [common.Hash ][]byte // Keyed by the account address and the hash of storage key
8080 nodes * trienode.MergedNodeSet
8181}
8282
@@ -113,22 +113,23 @@ type tester struct {
113113 preimages map [common.Hash ][]byte
114114
115115 // current state set
116- accounts map [common.Hash ][]byte
117- storages map [common.Hash ]map [common.Hash ][]byte
116+ accounts map [common.Hash ][]byte // Keyed by the hash of account address
117+ storages map [common.Hash ]map [common.Hash ][]byte // Keyed by the hash of account address and the hash of storage key
118118
119119 // state snapshots
120- snapAccounts map [common.Hash ]map [common.Hash ][]byte
121- snapStorages map [common.Hash ]map [common.Hash ]map [common.Hash ][]byte
120+ snapAccounts map [common.Hash ]map [common.Hash ][]byte // Keyed by the hash of account address
121+ snapStorages map [common.Hash ]map [common.Hash ]map [common.Hash ][]byte // Keyed by the hash of account address and the hash of storage key
122122}
123123
124- func newTester (t * testing.T , historyLimit uint64 , isVerkle bool ) * tester {
124+ func newTester (t * testing.T , historyLimit uint64 , isVerkle bool , layers int ) * tester {
125125 var (
126126 disk , _ = rawdb .NewDatabaseWithFreezer (rawdb .NewMemoryDatabase (), t .TempDir (), "" , false )
127127 db = New (disk , & Config {
128128 StateHistory : historyLimit ,
129- CleanCacheSize : 16 * 1024 ,
130- WriteBufferSize : 16 * 1024 ,
129+ CleanCacheSize : 256 * 1024 ,
130+ WriteBufferSize : 256 * 1024 ,
131131 }, isVerkle )
132+
132133 obj = & tester {
133134 db : db ,
134135 preimages : make (map [common.Hash ][]byte ),
@@ -138,7 +139,7 @@ func newTester(t *testing.T, historyLimit uint64, isVerkle bool) *tester {
138139 snapStorages : make (map [common.Hash ]map [common.Hash ]map [common.Hash ][]byte ),
139140 }
140141 )
141- for i := 0 ; i < 12 ; i ++ {
142+ for i := 0 ; i < layers ; i ++ {
142143 var parent = types .EmptyRootHash
143144 if len (obj .roots ) != 0 {
144145 parent = obj .roots [len (obj .roots )- 1 ]
@@ -264,11 +265,11 @@ func (t *tester) generate(parent common.Hash, rawStorageKey bool) (common.Hash,
264265 addr := testrand .Address ()
265266 addrHash := crypto .Keccak256Hash (addr .Bytes ())
266267
267- // short circuit if the account was already existent
268+ // Short circuit if the account was already existent
268269 if _ , ok := t .accounts [addrHash ]; ok {
269270 continue
270271 }
271- // short circuit if the account has been modified within the same transition
272+ // Short circuit if the account has been modified within the same transition
272273 if _ , ok := dirties [addrHash ]; ok {
273274 continue
274275 }
@@ -448,7 +449,7 @@ func TestDatabaseRollback(t *testing.T) {
448449 }()
449450
450451 // Verify state histories
451- tester := newTester (t , 0 , false )
452+ tester := newTester (t , 0 , false , 32 )
452453 defer tester .release ()
453454
454455 if err := tester .verifyHistory (); err != nil {
@@ -482,7 +483,7 @@ func TestDatabaseRecoverable(t *testing.T) {
482483 }()
483484
484485 var (
485- tester = newTester (t , 0 , false )
486+ tester = newTester (t , 0 , false , 12 )
486487 index = tester .bottomIndex ()
487488 )
488489 defer tester .release ()
@@ -526,7 +527,7 @@ func TestDisable(t *testing.T) {
526527 maxDiffLayers = 128
527528 }()
528529
529- tester := newTester (t , 0 , false )
530+ tester := newTester (t , 0 , false , 32 )
530531 defer tester .release ()
531532
532533 stored := crypto .Keccak256Hash (rawdb .ReadAccountTrieNode (tester .db .diskdb , nil ))
@@ -568,7 +569,7 @@ func TestCommit(t *testing.T) {
568569 maxDiffLayers = 128
569570 }()
570571
571- tester := newTester (t , 0 , false )
572+ tester := newTester (t , 0 , false , 12 )
572573 defer tester .release ()
573574
574575 if err := tester .db .Commit (tester .lastHash (), false ); err != nil {
@@ -598,7 +599,7 @@ func TestJournal(t *testing.T) {
598599 maxDiffLayers = 128
599600 }()
600601
601- tester := newTester (t , 0 , false )
602+ tester := newTester (t , 0 , false , 12 )
602603 defer tester .release ()
603604
604605 if err := tester .db .Journal (tester .lastHash ()); err != nil {
@@ -628,7 +629,7 @@ func TestCorruptedJournal(t *testing.T) {
628629 maxDiffLayers = 128
629630 }()
630631
631- tester := newTester (t , 0 , false )
632+ tester := newTester (t , 0 , false , 12 )
632633 defer tester .release ()
633634
634635 if err := tester .db .Journal (tester .lastHash ()); err != nil {
@@ -676,7 +677,7 @@ func TestTailTruncateHistory(t *testing.T) {
676677 maxDiffLayers = 128
677678 }()
678679
679- tester := newTester (t , 10 , false )
680+ tester := newTester (t , 10 , false , 12 )
680681 defer tester .release ()
681682
682683 tester .db .Close ()
0 commit comments