From e7119ce12d86634dd487ab3c55bf9b98f327236c Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Fri, 12 May 2017 21:47:09 +0200 Subject: core/state: fixed (self)destructed objects 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. --- core/state/journal.go | 9 +++++++-- core/state/statedb.go | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/core/state/journal.go b/core/state/journal.go index 73218dd28..b5c8ca9a2 100644 --- a/core/state/journal.go +++ b/core/state/journal.go @@ -71,8 +71,8 @@ type ( hash common.Hash } touchChange struct { - account *common.Address - prev bool + account *common.Address + prev bool prevDirty bool } ) @@ -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) + } } } diff --git a/core/state/statedb.go b/core/state/statedb.go index 8e4ba21c0..05869a0c8 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -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 } -- cgit v1.2.3