From 19c81938763c74228852b3fb759202978a200b48 Mon Sep 17 00:00:00 2001 From: rjl493456442 Date: Thu, 15 Jun 2017 21:49:12 +0800 Subject: [PATCH] core/vm: add a reverted flag in vm contract which is used to indicate whether state revert happen during state transition. if child's revert flag been set, it will also affect its parent recursively --- core/vm/contract.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/vm/contract.go b/core/vm/contract.go index 66748e8215..810a1a8b46 100644 --- a/core/vm/contract.go +++ b/core/vm/contract.go @@ -62,6 +62,8 @@ type Contract struct { Args []byte DelegateCall bool + Reverted bool // use to represent whether transaction is reverted during state transition + // child's reverted field changed will also affect parent. } // NewContract returns a new contract environment for the execution of EVM. @@ -151,3 +153,12 @@ func (self *Contract) SetCallCode(addr *common.Address, hash common.Hash, code [ self.CodeHash = hash self.CodeAddr = addr } + +// MarkReverted mark current transaction's execution has meet revert. +func (self *Contract) MarkReverted() { + self.Reverted = true + // affect parent recursively + if parent, ok := self.caller.(*Contract); ok { + parent.MarkReverted() + } +}