@@ -696,18 +696,18 @@ func (s *StateDB) Copy() *StateDB {
696
696
db : s .db ,
697
697
trie : s .db .CopyTrie (s .trie ),
698
698
originalRoot : s .originalRoot ,
699
- accounts : make ( map [common. Hash ][] byte ),
700
- storages : make ( map [common. Hash ] map [common. Hash ][] byte ),
701
- accountsOrigin : make ( map [common. Address ][] byte ),
702
- storagesOrigin : make ( map [common. Address ] map [common. Hash ][] byte ),
699
+ accounts : copySet ( s . accounts ),
700
+ storages : copy2DSet ( s . storages ),
701
+ accountsOrigin : copySet ( s . accountsOrigin ),
702
+ storagesOrigin : copy2DSet ( s . storagesOrigin ),
703
703
stateObjects : make (map [common.Address ]* stateObject , len (s .journal .dirties )),
704
704
stateObjectsPending : make (map [common.Address ]struct {}, len (s .stateObjectsPending )),
705
705
stateObjectsDirty : make (map [common.Address ]struct {}, len (s .journal .dirties )),
706
- stateObjectsDestruct : make ( map [common. Address ] * types. StateAccount , len (s .stateObjectsDestruct ) ),
706
+ stateObjectsDestruct : maps . Clone (s .stateObjectsDestruct ),
707
707
refund : s .refund ,
708
708
logs : make (map [common.Hash ][]* types.Log , len (s .logs )),
709
709
logSize : s .logSize ,
710
- preimages : make ( map [common. Hash ][] byte , len (s .preimages ) ),
710
+ preimages : maps . Clone (s .preimages ),
711
711
journal : newJournal (),
712
712
hasher : crypto .NewKeccakState (),
713
713
@@ -750,15 +750,6 @@ func (s *StateDB) Copy() *StateDB {
750
750
}
751
751
state .stateObjectsDirty [addr ] = struct {}{}
752
752
}
753
- // Deep copy the destruction markers.
754
- state .stateObjectsDestruct = maps .Clone (s .stateObjectsDestruct )
755
-
756
- // Deep copy the state changes made in the scope of block
757
- // along with their original values.
758
- state .accounts = copySet (s .accounts )
759
- state .storages = copy2DSet (s .storages )
760
- state .accountsOrigin = copySet (state .accountsOrigin )
761
- state .storagesOrigin = copy2DSet (state .storagesOrigin )
762
753
763
754
// Deep copy the logs occurred in the scope of block
764
755
for hash , logs := range s .logs {
@@ -769,8 +760,7 @@ func (s *StateDB) Copy() *StateDB {
769
760
}
770
761
state .logs [hash ] = cpy
771
762
}
772
- // Deep copy the preimages occurred in the scope of block
773
- state .preimages = maps .Clone (s .preimages )
763
+
774
764
// Do we need to copy the access list and transient storage?
775
765
// In practice: No. At the start of a transaction, these two lists are empty.
776
766
// In practice, we only ever copy state _between_ transactions/blocks, never
0 commit comments