diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-08-16 22:09:29 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-08-17 21:50:35 +0800 |
commit | f9fb70d2eeebfc27d3a4f8ae3ea93c67d7fb0e6b (patch) | |
tree | ea623fa39c51265de09020ead1840ba881748bc9 /core/vm/evm.go | |
parent | b70a73cd3e49e249a9ab2c41c2dd268786dcd1a3 (diff) | |
download | dexon-f9fb70d2eeebfc27d3a4f8ae3ea93c67d7fb0e6b.tar dexon-f9fb70d2eeebfc27d3a4f8ae3ea93c67d7fb0e6b.tar.gz dexon-f9fb70d2eeebfc27d3a4f8ae3ea93c67d7fb0e6b.tar.bz2 dexon-f9fb70d2eeebfc27d3a4f8ae3ea93c67d7fb0e6b.tar.lz dexon-f9fb70d2eeebfc27d3a4f8ae3ea93c67d7fb0e6b.tar.xz dexon-f9fb70d2eeebfc27d3a4f8ae3ea93c67d7fb0e6b.tar.zst dexon-f9fb70d2eeebfc27d3a4f8ae3ea93c67d7fb0e6b.zip |
core/vm: rework reversion to work on a higher level
Diffstat (limited to 'core/vm/evm.go')
-rw-r--r-- | core/vm/evm.go | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/core/vm/evm.go b/core/vm/evm.go index 448acd469..8d654c666 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -168,8 +168,10 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas // above we revert to the snapshot and consume any gas remaining. Additionally // when we're in homestead this also counts for code storage gas errors. if err != nil { - contract.UseGas(contract.Gas) evm.StateDB.RevertToSnapshot(snapshot) + if err != errExecutionReverted { + contract.UseGas(contract.Gas) + } } return ret, contract.Gas, err } @@ -207,10 +209,11 @@ func (evm *EVM) CallCode(caller ContractRef, addr common.Address, input []byte, ret, err = run(evm, snapshot, contract, input) if err != nil { - contract.UseGas(contract.Gas) evm.StateDB.RevertToSnapshot(snapshot) + if err != errExecutionReverted { + contract.UseGas(contract.Gas) + } } - return ret, contract.Gas, err } @@ -239,10 +242,11 @@ func (evm *EVM) DelegateCall(caller ContractRef, addr common.Address, input []by ret, err = run(evm, snapshot, contract, input) if err != nil { - contract.UseGas(contract.Gas) evm.StateDB.RevertToSnapshot(snapshot) + if err != errExecutionReverted { + contract.UseGas(contract.Gas) + } } - return ret, contract.Gas, err } @@ -281,8 +285,10 @@ func (evm *EVM) StaticCall(caller ContractRef, addr common.Address, input []byte // when we're in Homestead this also counts for code storage gas errors. ret, err = run(evm, snapshot, contract, input) if err != nil { - contract.UseGas(contract.Gas) evm.StateDB.RevertToSnapshot(snapshot) + if err != errExecutionReverted { + contract.UseGas(contract.Gas) + } } return ret, contract.Gas, err } @@ -339,18 +345,12 @@ func (evm *EVM) Create(caller ContractRef, code []byte, gas uint64, value *big.I // When an error was returned by the EVM or when setting the creation code // above we revert to the snapshot and consume any gas remaining. Additionally // when we're in homestead this also counts for code storage gas errors. - if maxCodeSizeExceeded || - (err != nil && (evm.ChainConfig().IsHomestead(evm.BlockNumber) || err != ErrCodeStoreOutOfGas)) { - contract.UseGas(contract.Gas) + if maxCodeSizeExceeded || (err != nil && (evm.ChainConfig().IsHomestead(evm.BlockNumber) || err != ErrCodeStoreOutOfGas)) { evm.StateDB.RevertToSnapshot(snapshot) + if err != errExecutionReverted { + contract.UseGas(contract.Gas) + } } - // If the vm returned with an error the return value should be set to nil. - // This isn't consensus critical but merely to for behaviour reasons such as - // tests, RPC calls, etc. - if err != nil { - ret = nil - } - return ret, contractAddr, contract.Gas, err } |