Merge pull request #2686 from obscuren/issue-2542

core/state, eth: Updated suicides objects when tracing transactions
This commit is contained in:
Péter Szilágyi 2016-06-14 16:54:46 +03:00 committed by GitHub
commit 22ef7370e7
2 changed files with 22 additions and 0 deletions

@ -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()

@ -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