Skip to content

Commit

Permalink
core/state: fixed (self)destructed objects
Browse files Browse the repository at this point in the history
Add the object to the list of destructed objects during a selfdestruct /
suicide operation and also remove it from the list once the journal
reverts.
  • Loading branch information
obscuren committed May 18, 2017
1 parent a5f6a1c commit e7119ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions core/state/journal.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ type (
hash common.Hash
}
touchChange struct {
account *common.Address
prev bool
account *common.Address
prev bool
prevDirty bool
}
)
Expand All @@ -91,6 +91,11 @@ func (ch suicideChange) undo(s *StateDB) {
if obj != nil {
obj.suicided = ch.prev
obj.setBalance(ch.prevbalance)
// if the object wasn't suicided before, remove
// it from the list of destructed objects as well.
if !obj.suicided {
delete(s.stateObjectsDestructed, *ch.account)
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@ func (self *StateDB) Suicide(addr common.Address) bool {
})
stateObject.markSuicided()
stateObject.data.Balance = new(big.Int)
self.stateObjectsDestructed[addr] = struct{}{}

return true
}

Expand Down

0 comments on commit e7119ce

Please sign in to comment.