@@ -735,24 +735,24 @@ func (s *StateDB) Copy() *StateDB {
735735 // and force the miner to operate trie-backed only
736736 state .snaps = s .snaps
737737 state .snap = s .snap
738- // TODO: Should we copy or make new (empty) ones here?
739- // If we copy, we need to ensure concurrency safety.
740- // If we don't copy, we run the risk of consensus breaking.
741- // In theory, as the state is copied, it's still 'fresh', and these
742- // should be empty.
743- //
744- // It might be good to check the size first, and if any are non-zero,
745- // simply avoid copying over the snap
738+ // deep copy needed
746739 state .snapDestructs = make (map [common.Hash ]struct {})
740+ for k , v := range s .snapDestructs {
741+ state .snapDestructs [k ] = v
742+ }
747743 state .snapAccounts = make (map [common.Hash ][]byte )
744+ for k , v := range s .snapAccounts {
745+ state .snapAccounts [k ] = v
746+ }
748747 state .snapStorage = make (map [common.Hash ]map [common.Hash ][]byte )
749- if len (s .snapAccounts )+ len (s .snapDestructs )+ len (s .snapStorage ) != 0 {
750- panic ("Oy vey!" )
748+ for k , v := range s .snapStorage {
749+ temp := make (map [common.Hash ][]byte )
750+ for kk , vv := range v {
751+ temp [kk ] = vv
752+ }
753+ state .snapStorage [k ] = temp
751754 }
752-
753755 }
754-
755- state .snaps = s .snaps
756756 return state
757757}
758758
0 commit comments