aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-06-14 21:54:46 +0800
committerGitHub <noreply@github.com>2016-06-14 21:54:46 +0800
commit22ef7370e7932b085cc0bd7d1a07d58b0ef596a7 (patch)
tree5ba7df42f48641bfc2e3ae823eadeb5f85bd1b2f
parenta38be3eb488a349693a9c9905ab015278281f8db (diff)
parentbb3651abc865c6f6babec0d357afa85f5a539d83 (diff)
downloadgo-tangerine-22ef7370e7932b085cc0bd7d1a07d58b0ef596a7.tar
go-tangerine-22ef7370e7932b085cc0bd7d1a07d58b0ef596a7.tar.gz
go-tangerine-22ef7370e7932b085cc0bd7d1a07d58b0ef596a7.tar.bz2
go-tangerine-22ef7370e7932b085cc0bd7d1a07d58b0ef596a7.tar.lz
go-tangerine-22ef7370e7932b085cc0bd7d1a07d58b0ef596a7.tar.xz
go-tangerine-22ef7370e7932b085cc0bd7d1a07d58b0ef596a7.tar.zst
go-tangerine-22ef7370e7932b085cc0bd7d1a07d58b0ef596a7.zip
Merge pull request #2686 from obscuren/issue-2542
core/state, eth: Updated suicides objects when tracing transactions
-rw-r--r--core/state/statedb.go21
-rw-r--r--eth/api.go1
2 files changed, 22 insertions, 0 deletions
diff --git a/core/state/statedb.go b/core/state/statedb.go
index 70673799e..3e25e0c16 100644
--- a/core/state/statedb.go
+++ b/core/state/statedb.go
@@ -370,6 +370,27 @@ func (s *StateDB) IntermediateRoot() common.Hash {
return s.trie.Hash()
}
+// DeleteSuicides flags the suicided objects for deletion so that it
+// won't be referenced again when called / queried up on.
+//
+// DeleteSuicides should not be used for consensus related updates
+// under any circumstances.
+func (s *StateDB) DeleteSuicides() {
+ // Reset refund so that any used-gas calculations can use
+ // this method.
+ s.refund = new(big.Int)
+ for _, stateObject := range s.stateObjects {
+ if stateObject.dirty {
+ // If the object has been removed by a suicide
+ // flag the object as deleted.
+ if stateObject.remove {
+ stateObject.deleted = true
+ }
+ stateObject.dirty = false
+ }
+ }
+}
+
// Commit commits all state changes to the database.
func (s *StateDB) Commit() (root common.Hash, err error) {
root, batch := s.CommitBatch()
diff --git a/eth/api.go b/eth/api.go
index 3cb6c4d10..9f5f2e677 100644
--- a/eth/api.go
+++ b/eth/api.go
@@ -1876,6 +1876,7 @@ func (api *PrivateDebugAPI) TraceTransaction(txHash common.Hash, logger *vm.LogC
if err != nil {
return nil, fmt.Errorf("mutation failed: %v", err)
}
+ stateDb.DeleteSuicides()
continue
}
// Otherwise trace the transaction and return