@@ -569,12 +569,19 @@ func (s *StateDB) GetOrNewStateObject(addr common.Address) *stateObject {
569
569
func (s * StateDB ) createObject (addr common.Address ) (newobj , prev * stateObject ) {
570
570
prev = s .getDeletedStateObject (addr ) // Note, prev might have been deleted, we need that!
571
571
572
+ var prevdestruct bool
573
+ if s .snap != nil && prev != nil {
574
+ _ , prevdestruct = s .snapDestructs [prev .addrHash ]
575
+ if ! prevdestruct {
576
+ s .snapDestructs [prev .addrHash ] = struct {}{}
577
+ }
578
+ }
572
579
newobj = newObject (s , addr , Account {})
573
580
newobj .setNonce (0 ) // sets the object to dirty
574
581
if prev == nil {
575
582
s .journal .append (createObjectChange {account : & addr })
576
583
} else {
577
- s .journal .append (resetObjectChange {prev : prev })
584
+ s .journal .append (resetObjectChange {prev : prev , prevdestruct : prevdestruct })
578
585
}
579
586
s .setStateObject (newobj )
580
587
return newobj , prev
@@ -595,12 +602,6 @@ func (s *StateDB) CreateAccount(addr common.Address) {
595
602
if prev != nil {
596
603
newObj .setBalance (prev .data .Balance )
597
604
}
598
- // This has been removed. A Create action may be cancelled, if the initcode
599
- // exits with error. In that case, we would need to clean up the snapDestructs,
600
- // Better to not put it there in the first place, if we can get away with it.
601
- //if s.snap != nil && prev != nil {
602
- // s.snapDestructs[prev.addrHash] = struct{}{}
603
- //}
604
605
}
605
606
606
607
func (db * StateDB ) ForEachStorage (addr common.Address , cb func (key , value common.Hash ) bool ) error {
0 commit comments