aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorgary rong <garyrong0905@gmail.com>2017-04-05 06:44:16 +0800
committerFelix Lange <fjl@users.noreply.github.com>2017-04-05 06:44:16 +0800
commit49437a02c981199c62048fae00c6b80976f6e6b9 (patch)
tree5c3244fe0cd41774a2ed9bc776e348192abe1492 /core
parentb319f027a0be232a9cb307336b0349b36737c7f1 (diff)
downloaddexon-49437a02c981199c62048fae00c6b80976f6e6b9.tar
dexon-49437a02c981199c62048fae00c6b80976f6e6b9.tar.gz
dexon-49437a02c981199c62048fae00c6b80976f6e6b9.tar.bz2
dexon-49437a02c981199c62048fae00c6b80976f6e6b9.tar.lz
dexon-49437a02c981199c62048fae00c6b80976f6e6b9.tar.xz
dexon-49437a02c981199c62048fae00c6b80976f6e6b9.tar.zst
dexon-49437a02c981199c62048fae00c6b80976f6e6b9.zip
core/state: make TestSnapshotRandom work again (#3816)
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.
Diffstat (limited to 'core')
-rw-r--r--core/state/journal.go7
-rw-r--r--core/state/state_object.go5
-rw-r--r--core/state/statedb_test.go1
3 files changed, 8 insertions, 5 deletions
diff --git a/core/state/journal.go b/core/state/journal.go
index 5cd41477d..73218dd28 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 7f994ee6d..7d3315303 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())
diff --git a/core/state/statedb_test.go b/core/state/statedb_test.go
index 597de3be5..72b638f97 100644
--- a/core/state/statedb_test.go
+++ b/core/state/statedb_test.go
@@ -116,7 +116,6 @@ func TestIntermediateLeaks(t *testing.T) {
}
func TestSnapshotRandom(t *testing.T) {
- t.Skip("@fjl fix me please")
config := &quick.Config{MaxCount: 1000}
err := quick.Check((*snapshotTest).run, config)
if cerr, ok := err.(*quick.CheckError); ok {