aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm/evm.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-08-21 17:23:03 +0800
committerGitHub <noreply@github.com>2017-08-21 17:23:03 +0800
commitafdfdebd87535032c7796bfcca0ce158dea7e32c (patch)
tree04385e7070a2bfd29e3136f7817000ba9aa07e07 /core/vm/evm.go
parente311bb520a1869e42ed30eb1487a751fa30cd0b4 (diff)
parent1bbd400899304152b15a0fcd3cf1946442171c29 (diff)
downloaddexon-afdfdebd87535032c7796bfcca0ce158dea7e32c.tar
dexon-afdfdebd87535032c7796bfcca0ce158dea7e32c.tar.gz
dexon-afdfdebd87535032c7796bfcca0ce158dea7e32c.tar.bz2
dexon-afdfdebd87535032c7796bfcca0ce158dea7e32c.tar.lz
dexon-afdfdebd87535032c7796bfcca0ce158dea7e32c.tar.xz
dexon-afdfdebd87535032c7796bfcca0ce158dea7e32c.tar.zst
dexon-afdfdebd87535032c7796bfcca0ce158dea7e32c.zip
Merge pull request #14983 from karalabe/metropolis-revert
core/vm: implement REVERT metropolis opcode
Diffstat (limited to 'core/vm/evm.go')
-rw-r--r--core/vm/evm.go32
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
}