From 5079dbea6e146d732553883c2e28e0c8de048c3b Mon Sep 17 00:00:00 2001 From: rjl493456442 Date: Fri, 24 Mar 2017 16:37:17 +0800 Subject: [PATCH] core/state: modify touch undo function in `touch` operation, only `touched` filed has been changed. Therefore in the related undo function, only `touched` field should be reverted. In addition, whether remove this obj from dirty map should depend on prevDirty flag. --- core/state/journal.go | 7 +++++-- core/state/state_object.go | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/core/state/journal.go b/core/state/journal.go index 5cd41477d9..73218dd283 100644 --- a/core/state/journal.go +++ b/core/state/journal.go @@ -73,6 +73,7 @@ type ( touchChange struct { account *common.Address prev bool + prevDirty bool } ) @@ -97,8 +98,10 @@ var ripemd = common.HexToAddress("0000000000000000000000000000000000000003") func (ch touchChange) undo(s *StateDB) { if !ch.prev && *ch.account != ripemd { - delete(s.stateObjects, *ch.account) - delete(s.stateObjectsDirty, *ch.account) + s.getStateObject(*ch.account).touched = ch.prev + if !ch.prevDirty { + delete(s.stateObjectsDirty, *ch.account) + } } } diff --git a/core/state/state_object.go b/core/state/state_object.go index 7f994ee6d6..7d33153037 100644 --- a/core/state/state_object.go +++ b/core/state/state_object.go @@ -137,8 +137,9 @@ func (self *stateObject) markSuicided() { func (c *stateObject) touch() { c.db.journal = append(c.db.journal, touchChange{ - account: &c.address, - prev: c.touched, + account: &c.address, + prev: c.touched, + prevDirty: c.onDirty == nil, }) if c.onDirty != nil { c.onDirty(c.Address())