Skip to content

Commit

Permalink
Fix the problem thrown by error
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiLoy committed Sep 10, 2021
1 parent e21f2bf commit aed6b88
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 19 deletions.
10 changes: 5 additions & 5 deletions core/vm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
// when we're in homestead this also counts for code storage gas errors.
if err != nil {
evm.RevertToDBSnapshot(snapshotForSnapshotDB, snapshotForStateDB)
if err != errExecutionReverted {
if err != ErrExecutionReverted {
contract.UseGas(contract.Gas)
}
}
Expand Down Expand Up @@ -343,7 +343,7 @@ func (evm *EVM) CallCode(caller ContractRef, addr common.Address, input []byte,
ret, err = run(evm, contract, input, false)
if err != nil {
evm.RevertToDBSnapshot(snapshotForSnapshotDB, snapshotForStateDB)
if err != errExecutionReverted {
if err != ErrExecutionReverted {
contract.UseGas(contract.Gas)
}
}
Expand Down Expand Up @@ -376,7 +376,7 @@ func (evm *EVM) DelegateCall(caller ContractRef, addr common.Address, input []by
ret, err = run(evm, contract, input, false)
if err != nil {
evm.RevertToDBSnapshot(snapshotForSnapshotDB, snapshotForStateDB)
if err != errExecutionReverted {
if err != ErrExecutionReverted {
contract.UseGas(contract.Gas)
}
}
Expand Down Expand Up @@ -418,7 +418,7 @@ func (evm *EVM) StaticCall(caller ContractRef, addr common.Address, input []byte
ret, err = run(evm, contract, input, true)
if err != nil {
evm.RevertToDBSnapshot(snapshotForSnapshotDB, snapshotForStateDB)
if err != errExecutionReverted {
if err != ErrExecutionReverted {
contract.UseGas(contract.Gas)
}
}
Expand Down Expand Up @@ -505,7 +505,7 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
// when we're in homestead this also counts for code storage gas errors.
if maxCodeSizeExceeded || (err != nil && err != ErrCodeStoreOutOfGas) {
evm.RevertToDBSnapshot(snapshotForSnapshotDB, snapshotForStateDB)
if err != errExecutionReverted {
if err != ErrExecutionReverted {
contract.UseGas(contract.Gas)
}
}
Expand Down
5 changes: 0 additions & 5 deletions core/vm/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,13 @@
package vm

import (
"errors"
"github.com/PlatONnetwork/PlatON-Go/common"
"github.com/PlatONnetwork/PlatON-Go/core/types"
"github.com/PlatONnetwork/PlatON-Go/params"
"github.com/holiman/uint256"
"golang.org/x/crypto/sha3"
)

var (
errExecutionReverted = errors.New("execution reverted")
)

func opAdd(pc *uint64, interpreter *EVMInterpreter, callContext *callCtx) ([]byte, error) {
x, y := callContext.stack.pop(), callContext.stack.peek()
y.Add(&x, y)
Expand Down
4 changes: 2 additions & 2 deletions core/vm/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func NewEVMInterpreter(evm *EVM, cfg Config) *EVMInterpreter {
//
// It's important to note that any errors returned by the interpreter should be
// considered a revert-and-consume-all-gas operation except for
// errExecutionReverted which means revert-and-keep-gas-left.
// ErrExecutionReverted which means revert-and-keep-gas-left.
func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (ret []byte, err error) {

go func(ctx context.Context) {
Expand Down Expand Up @@ -286,7 +286,7 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
case err != nil:
return nil, err
case operation.reverts:
return res, errExecutionReverted
return res, ErrExecutionReverted
case operation.halts:
return res, nil
case !operation.jumps:
Expand Down
10 changes: 5 additions & 5 deletions core/vm/wagon_runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,7 @@ func CallContract(proc *exec.Process, addrPtr, args, argsLen, val, valLen, callC
status = 0
}

if err == nil || err == errExecutionReverted {
if err == nil || err == ErrExecutionReverted {
ctx.CallOut = ret
}

Expand Down Expand Up @@ -1365,7 +1365,7 @@ func DelegateCallContract(proc *exec.Process, addrPtr, params, paramsLen, callCo
status = 0
}

if err == nil || err == errExecutionReverted {
if err == nil || err == ErrExecutionReverted {
ctx.CallOut = ret
}

Expand Down Expand Up @@ -1433,7 +1433,7 @@ func StaticCallContract(proc *exec.Process, addrPtr, params, paramsLen, callCost
status = 0
}

if err == nil || err == errExecutionReverted {
if err == nil || err == ErrExecutionReverted {
ctx.CallOut = ret
}

Expand Down Expand Up @@ -1623,7 +1623,7 @@ func MigrateInnerContract(proc *exec.Process, newAddr, val, valLen, callCost, ca
// when we're in homestead this also counts for code storage gas errors.
if maxCodeSizeExceeded || (err != nil && err != ErrCodeStoreOutOfGas) {
ctx.evm.RevertToDBSnapshot(snapshotForSnapshotDB, snapshotForStateDB)
if err != errExecutionReverted {
if err != ErrExecutionReverted {
contract.UseGas(contract.Gas)
}
}
Expand Down Expand Up @@ -2251,7 +2251,7 @@ func CreateContract(proc *exec.Process, newAddr, val, valLen, callCost, callCost
// when we're in homestead this also counts for code storage gas errors.
if maxCodeSizeExceeded || (err != nil && err != ErrCodeStoreOutOfGas) {
ctx.evm.RevertToDBSnapshot(snapshotForSnapshotDB, snapshotForStateDB)
if err != errExecutionReverted {
if err != ErrExecutionReverted {
contract.UseGas(contract.Gas)
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/vm/wasm_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (engine *wagonEngine) exec(index int64) (ret []byte, err error) {

switch {
case ctx.Revert:
return nil, errExecutionReverted
return nil, ErrExecutionReverted
case engine.vm.Abort():
return nil, ErrAbort
}
Expand Down
2 changes: 1 addition & 1 deletion core/vm/wasm_interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func NewWASMInterpreter(evm *EVM, cfg Config) *WASMInterpreter {
//
// It's important to note that any errors returned by the interpreter should be
// considered a revert-and-consume-all-gas operations except for
// errExecutionReverted which means revert-and-keep-gas-lfet.
// ErrExecutionReverted which means revert-and-keep-gas-lfet.
func (in *WASMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (ret []byte, err error) {
defer func() {
if r := recover(); r != nil {
Expand Down

0 comments on commit aed6b88

Please sign in to comment.