@@ -584,16 +584,6 @@ func forEachStorage(s *StateDB, addr common.Address, cb func(key, value common.H
584
584
}
585
585
}
586
586
}
587
- // Now visit any remaining dirty storage which is not in trie
588
- for key , value := range so .dirtyStorage {
589
- if visited [key ] {
590
- continue
591
- }
592
- if ! cb (key , value ) {
593
- return nil
594
- }
595
- }
596
-
597
587
return nil
598
588
}
599
589
@@ -628,6 +618,26 @@ func (test *snapshotTest) checkEqual(state, checkstate *StateDB) error {
628
618
forEachStorage (checkstate , addr , func (key , value common.Hash ) bool {
629
619
return checkeq ("GetState(" + key .Hex ()+ ")" , checkstate .GetState (addr , key ), value )
630
620
})
621
+ other := checkstate .getStateObject (addr )
622
+ // Check dirty storage which is not in trie
623
+ if ! maps .Equal (obj .dirtyStorage , other .dirtyStorage ) {
624
+ print := func (dirty map [common.Hash ]common.Hash ) string {
625
+ var keys []common.Hash
626
+ out := new (strings.Builder )
627
+ for key := range dirty {
628
+ keys = append (keys , key )
629
+ }
630
+ slices .SortFunc (keys , common .Hash .Cmp )
631
+ for i , key := range keys {
632
+ fmt .Fprintf (out , " %d. %v %v\n " , i , key , dirty [key ])
633
+ }
634
+ return out .String ()
635
+ }
636
+ return fmt .Errorf ("dirty storage err, have\n %v\n want\n %v" ,
637
+ print (obj .dirtyStorage ),
638
+ print (other .dirtyStorage ))
639
+ }
640
+
631
641
}
632
642
// Check transient storage.
633
643
{
0 commit comments