mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
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
This commit is contained in:
parent
d14dceb396
commit
19c8193876
1 changed files with 11 additions and 0 deletions
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue