From 1d7d63141fe8c08e28f2d22bda5c2afd7665a27a Mon Sep 17 00:00:00 2001 From: ANOTHEL Date: Tue, 14 May 2019 12:02:56 +0900 Subject: [PATCH] move error variable to error.go --- core/vm/contracts.go | 6 +-- core/vm/errors.go | 46 +++++++++++++++++--- core/vm/evm.go | 12 ++--- core/vm/gas.go | 2 +- core/vm/gas_table.go | 92 +++++++++++++++++++-------------------- core/vm/gas_table_test.go | 4 +- core/vm/instructions.go | 28 +++++------- core/vm/interpreter.go | 10 ++--- core/vm/jump_table.go | 4 -- 9 files changed, 112 insertions(+), 92 deletions(-) diff --git a/core/vm/contracts.go b/core/vm/contracts.go index 20b741f8f1..5d0603bc1d 100644 --- a/core/vm/contracts.go +++ b/core/vm/contracts.go @@ -18,7 +18,6 @@ package vm import ( "crypto/sha256" - "errors" "math/big" "github.com/ethereum/go-ethereum/common" @@ -317,9 +316,6 @@ var ( // false32Byte is returned if the bn256 pairing check fails. false32Byte = make([]byte, 32) - - // errBadPairingInput is returned if the bn256 pairing input is invalid. - errBadPairingInput = errors.New("bad elliptic curve pairing size") ) // bn256Pairing implements a pairing pre-compile for the bn256 curve @@ -333,7 +329,7 @@ func (c *bn256Pairing) RequiredGas(input []byte) uint64 { func (c *bn256Pairing) Run(input []byte) ([]byte, error) { // Handle some corner cases cheaply if len(input)%192 > 0 { - return nil, errBadPairingInput + return nil, ErrBadPairingInput } // Convert the input into a set of coordinates var ( diff --git a/core/vm/errors.go b/core/vm/errors.go index 7f88f324ea..ff23582b92 100644 --- a/core/vm/errors.go +++ b/core/vm/errors.go @@ -20,11 +20,45 @@ import "errors" // List execution errors var ( - ErrOutOfGas = errors.New("out of gas") - ErrCodeStoreOutOfGas = errors.New("contract creation code storage out of gas") - ErrDepth = errors.New("max call depth exceeded") - ErrTraceLimitReached = errors.New("the number of logs reached the specified limit") - ErrInsufficientBalance = errors.New("insufficient balance for transfer") + // ErrOutOfGas is returned when + ErrOutOfGas = errors.New("out of gas") + + // ErrCodeStoreOutOfGas is returned when + ErrCodeStoreOutOfGas = errors.New("contract creation code storage out of gas") + + // ErrDepth is returned when + ErrDepth = errors.New("max call depth exceeded") + + // ErrTraceLimitReached is returned when + ErrTraceLimitReached = errors.New("the number of logs reached the specified limit") + + // ErrInsufficientBalance is returned when + ErrInsufficientBalance = errors.New("insufficient balance for transfer") + + // ErrContractAddressCollision is returned when ErrContractAddressCollision = errors.New("contract address collision") - ErrNoCompatibleInterpreter = errors.New("no compatible interpreter") + + // ErrNoCompatibleInterpreter is returned when + ErrNoCompatibleInterpreter = errors.New("no compatible interpreter") + + // ErrBadPairingInput is returned if the bn256 pairing input is invalid. + ErrBadPairingInput = errors.New("bad elliptic curve pairing size") + + // ErrWriteProtection is returned when + ErrWriteProtection = errors.New("evm: write protection") + + // ErrReturnDataOutOfBounds is returned when + ErrReturnDataOutOfBounds = errors.New("evm: return data out of bounds") + + // ErrExecutionReverted is returned when + ErrExecutionReverted = errors.New("evm: execution reverted") + + // ErrMaxCodeSizeExceeded is returned when + ErrMaxCodeSizeExceeded = errors.New("evm: max code size exceeded") + + // ErrInvalidJump is returned when + ErrInvalidJump = errors.New("evm: invalid jump destination") + + // ErrGasUintOverflow is returned when + ErrGasUintOverflow = errors.New("gas uint64 overflow") ) diff --git a/core/vm/evm.go b/core/vm/evm.go index 70e1cd1b87..b578cf0468 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -235,7 +235,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.StateDB.RevertToSnapshot(snapshot) - if err != errExecutionReverted { + if err != ErrExecutionReverted { contract.UseGas(contract.Gas) } } @@ -275,7 +275,7 @@ func (evm *EVM) CallCode(caller ContractRef, addr common.Address, input []byte, ret, err = run(evm, contract, input, false) if err != nil { evm.StateDB.RevertToSnapshot(snapshot) - if err != errExecutionReverted { + if err != ErrExecutionReverted { contract.UseGas(contract.Gas) } } @@ -308,7 +308,7 @@ func (evm *EVM) DelegateCall(caller ContractRef, addr common.Address, input []by ret, err = run(evm, contract, input, false) if err != nil { evm.StateDB.RevertToSnapshot(snapshot) - if err != errExecutionReverted { + if err != ErrExecutionReverted { contract.UseGas(contract.Gas) } } @@ -349,7 +349,7 @@ func (evm *EVM) StaticCall(caller ContractRef, addr common.Address, input []byte ret, err = run(evm, contract, input, true) if err != nil { evm.StateDB.RevertToSnapshot(snapshot) - if err != errExecutionReverted { + if err != ErrExecutionReverted { contract.UseGas(contract.Gas) } } @@ -430,13 +430,13 @@ 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 && (evm.ChainConfig().IsHomestead(evm.BlockNumber) || err != ErrCodeStoreOutOfGas)) { evm.StateDB.RevertToSnapshot(snapshot) - if err != errExecutionReverted { + if err != ErrExecutionReverted { contract.UseGas(contract.Gas) } } // Assign err if contract code size exceeds the max while the err is still empty. if maxCodeSizeExceeded && err == nil { - err = errMaxCodeSizeExceeded + err = ErrMaxCodeSizeExceeded } if evm.vmConfig.Debug && evm.depth == 0 { evm.vmConfig.Tracer.CaptureEnd(ret, gas-contract.Gas, time.Since(start), err) diff --git a/core/vm/gas.go b/core/vm/gas.go index 022a84f243..aa34646c5f 100644 --- a/core/vm/gas.go +++ b/core/vm/gas.go @@ -48,7 +48,7 @@ func callGas(gasTable params.GasTable, availableGas, base uint64, callCost *big. } } if !callCost.IsUint64() { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } return callCost.Uint64(), nil diff --git a/core/vm/gas_table.go b/core/vm/gas_table.go index 8270300ba7..fcd690cebe 100644 --- a/core/vm/gas_table.go +++ b/core/vm/gas_table.go @@ -34,7 +34,7 @@ func memoryGasCost(mem *Memory, newMemSize uint64) (uint64, error) { // overflow. The constant 0x1FFFFFFFE0 is the highest number that can be used // without overflowing the gas calculation. if newMemSize > 0x1FFFFFFFE0 { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } newMemSizeWords := toWordSize(newMemSize) newMemSize = newMemSizeWords * 32 @@ -61,20 +61,20 @@ func gasCallDataCopy(gt params.GasTable, evm *EVM, contract *Contract, stack *St var overflow bool if gas, overflow = math.SafeAdd(gas, GasFastestStep); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } words, overflow := bigUint64(stack.Back(2)) if overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } if words, overflow = math.SafeMul(toWordSize(words), params.CopyGas); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } if gas, overflow = math.SafeAdd(gas, words); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } return gas, nil } @@ -87,20 +87,20 @@ func gasReturnDataCopy(gt params.GasTable, evm *EVM, contract *Contract, stack * var overflow bool if gas, overflow = math.SafeAdd(gas, GasFastestStep); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } words, overflow := bigUint64(stack.Back(2)) if overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } if words, overflow = math.SafeMul(toWordSize(words), params.CopyGas); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } if gas, overflow = math.SafeAdd(gas, words); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } return gas, nil } @@ -178,7 +178,7 @@ func makeGasLog(n uint64) gasFunc { return func(gt params.GasTable, evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) { requestedSize, overflow := bigUint64(stack.Back(1)) if overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } gas, err := memoryGasCost(mem, memorySize) @@ -187,18 +187,18 @@ func makeGasLog(n uint64) gasFunc { } if gas, overflow = math.SafeAdd(gas, params.LogGas); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } if gas, overflow = math.SafeAdd(gas, n*params.LogTopicGas); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } var memorySizeGas uint64 if memorySizeGas, overflow = math.SafeMul(requestedSize, params.LogDataGas); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } if gas, overflow = math.SafeAdd(gas, memorySizeGas); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } return gas, nil } @@ -212,18 +212,18 @@ func gasSha3(gt params.GasTable, evm *EVM, contract *Contract, stack *Stack, mem } if gas, overflow = math.SafeAdd(gas, params.Sha3Gas); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } wordGas, overflow := bigUint64(stack.Back(1)) if overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } if wordGas, overflow = math.SafeMul(toWordSize(wordGas), params.Sha3WordGas); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } if gas, overflow = math.SafeAdd(gas, wordGas); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } return gas, nil } @@ -236,18 +236,18 @@ func gasCodeCopy(gt params.GasTable, evm *EVM, contract *Contract, stack *Stack, var overflow bool if gas, overflow = math.SafeAdd(gas, GasFastestStep); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } wordGas, overflow := bigUint64(stack.Back(2)) if overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } if wordGas, overflow = math.SafeMul(toWordSize(wordGas), params.CopyGas); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } if gas, overflow = math.SafeAdd(gas, wordGas); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } return gas, nil } @@ -260,20 +260,20 @@ func gasExtCodeCopy(gt params.GasTable, evm *EVM, contract *Contract, stack *Sta var overflow bool if gas, overflow = math.SafeAdd(gas, gt.ExtcodeCopy); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } wordGas, overflow := bigUint64(stack.Back(3)) if overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } if wordGas, overflow = math.SafeMul(toWordSize(wordGas), params.CopyGas); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } if gas, overflow = math.SafeAdd(gas, wordGas); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } return gas, nil } @@ -286,10 +286,10 @@ func gasMLoad(gt params.GasTable, evm *EVM, contract *Contract, stack *Stack, me var overflow bool gas, err := memoryGasCost(mem, memorySize) if err != nil { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } if gas, overflow = math.SafeAdd(gas, GasFastestStep); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } return gas, nil } @@ -298,10 +298,10 @@ func gasMStore8(gt params.GasTable, evm *EVM, contract *Contract, stack *Stack, var overflow bool gas, err := memoryGasCost(mem, memorySize) if err != nil { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } if gas, overflow = math.SafeAdd(gas, GasFastestStep); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } return gas, nil } @@ -310,10 +310,10 @@ func gasMStore(gt params.GasTable, evm *EVM, contract *Contract, stack *Stack, m var overflow bool gas, err := memoryGasCost(mem, memorySize) if err != nil { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } if gas, overflow = math.SafeAdd(gas, GasFastestStep); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } return gas, nil } @@ -325,7 +325,7 @@ func gasCreate(gt params.GasTable, evm *EVM, contract *Contract, stack *Stack, m return 0, err } if gas, overflow = math.SafeAdd(gas, params.CreateGas); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } return gas, nil } @@ -337,17 +337,17 @@ func gasCreate2(gt params.GasTable, evm *EVM, contract *Contract, stack *Stack, return 0, err } if gas, overflow = math.SafeAdd(gas, params.Create2Gas); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } wordGas, overflow := bigUint64(stack.Back(2)) if overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } if wordGas, overflow = math.SafeMul(toWordSize(wordGas), params.Sha3WordGas); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } if gas, overflow = math.SafeAdd(gas, wordGas); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } return gas, nil @@ -373,7 +373,7 @@ func gasExp(gt params.GasTable, evm *EVM, contract *Contract, stack *Stack, mem overflow bool ) if gas, overflow = math.SafeAdd(gas, params.ExpGas); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } return gas, nil } @@ -401,7 +401,7 @@ func gasCall(gt params.GasTable, evm *EVM, contract *Contract, stack *Stack, mem } var overflow bool if gas, overflow = math.SafeAdd(gas, memoryGas); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } evm.callGasTemp, err = callGas(gt, contract.Gas, gas, stack.Back(0)) @@ -409,7 +409,7 @@ func gasCall(gt params.GasTable, evm *EVM, contract *Contract, stack *Stack, mem return 0, err } if gas, overflow = math.SafeAdd(gas, evm.callGasTemp); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } return gas, nil } @@ -425,7 +425,7 @@ func gasCallCode(gt params.GasTable, evm *EVM, contract *Contract, stack *Stack, } var overflow bool if gas, overflow = math.SafeAdd(gas, memoryGas); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } evm.callGasTemp, err = callGas(gt, contract.Gas, gas, stack.Back(0)) @@ -433,7 +433,7 @@ func gasCallCode(gt params.GasTable, evm *EVM, contract *Contract, stack *Stack, return 0, err } if gas, overflow = math.SafeAdd(gas, evm.callGasTemp); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } return gas, nil } @@ -479,7 +479,7 @@ func gasDelegateCall(gt params.GasTable, evm *EVM, contract *Contract, stack *St } var overflow bool if gas, overflow = math.SafeAdd(gas, gt.Calls); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } evm.callGasTemp, err = callGas(gt, contract.Gas, gas, stack.Back(0)) @@ -487,7 +487,7 @@ func gasDelegateCall(gt params.GasTable, evm *EVM, contract *Contract, stack *St return 0, err } if gas, overflow = math.SafeAdd(gas, evm.callGasTemp); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } return gas, nil } @@ -499,7 +499,7 @@ func gasStaticCall(gt params.GasTable, evm *EVM, contract *Contract, stack *Stac } var overflow bool if gas, overflow = math.SafeAdd(gas, gt.Calls); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } evm.callGasTemp, err = callGas(gt, contract.Gas, gas, stack.Back(0)) @@ -507,7 +507,7 @@ func gasStaticCall(gt params.GasTable, evm *EVM, contract *Contract, stack *Stac return 0, err } if gas, overflow = math.SafeAdd(gas, evm.callGasTemp); overflow { - return 0, errGasUintOverflow + return 0, ErrGasUintOverflow } return gas, nil } diff --git a/core/vm/gas_table_test.go b/core/vm/gas_table_test.go index 2c1e11894f..bc196e57dd 100644 --- a/core/vm/gas_table_test.go +++ b/core/vm/gas_table_test.go @@ -29,8 +29,8 @@ func TestMemoryGasCost(t *testing.T) { } for i, tt := range tests { v, err := memoryGasCost(&Memory{}, tt.size) - if (err == errGasUintOverflow) != tt.overflow { - t.Errorf("test %d: overflow mismatch: have %v, want %v", i, err == errGasUintOverflow, tt.overflow) + if (err == ErrGasUintOverflow) != tt.overflow { + t.Errorf("test %d: overflow mismatch: have %v, want %v", i, err == ErrGasUintOverflow, tt.overflow) } if v != tt.cost { t.Errorf("test %d: gas cost mismatch: have %v, want %v", i, v, tt.cost) diff --git a/core/vm/instructions.go b/core/vm/instructions.go index 2a062d7e77..648fbe8582 100644 --- a/core/vm/instructions.go +++ b/core/vm/instructions.go @@ -17,7 +17,6 @@ package vm import ( - "errors" "math/big" "github.com/ethereum/go-ethereum/common" @@ -28,13 +27,8 @@ import ( ) var ( - bigZero = new(big.Int) - tt255 = math.BigPow(2, 255) - errWriteProtection = errors.New("evm: write protection") - errReturnDataOutOfBounds = errors.New("evm: return data out of bounds") - errExecutionReverted = errors.New("evm: execution reverted") - errMaxCodeSizeExceeded = errors.New("evm: max code size exceeded") - errInvalidJump = errors.New("evm: invalid jump destination") + bigZero = new(big.Int) + tt255 = math.BigPow(2, 255) ) func opAdd(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { @@ -468,7 +462,7 @@ func opReturnDataCopy(pc *uint64, interpreter *EVMInterpreter, contract *Contrac defer interpreter.intPool.put(memOffset, dataOffset, length, end) if !end.IsUint64() || uint64(len(interpreter.returnData)) < end.Uint64() { - return nil, errReturnDataOutOfBounds + return nil, ErrReturnDataOutOfBounds } memory.Set(memOffset.Uint64(), length.Uint64(), interpreter.returnData[dataOffset.Uint64():end.Uint64()]) @@ -645,7 +639,7 @@ func opSstore(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memor func opJump(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { pos := stack.pop() if !contract.validJumpdest(pos) { - return nil, errInvalidJump + return nil, ErrInvalidJump } *pc = pos.Uint64() @@ -657,7 +651,7 @@ func opJumpi(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory pos, cond := stack.pop(), stack.pop() if cond.Sign() != 0 { if !contract.validJumpdest(pos) { - return nil, errInvalidJump + return nil, ErrInvalidJump } *pc = pos.Uint64() } else { @@ -714,7 +708,7 @@ func opCreate(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memor contract.Gas += returnGas interpreter.intPool.put(value, offset, size) - if suberr == errExecutionReverted { + if suberr == ErrExecutionReverted { return res, nil } return nil, nil @@ -742,7 +736,7 @@ func opCreate2(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memo contract.Gas += returnGas interpreter.intPool.put(endowment, offset, size, salt) - if suberr == errExecutionReverted { + if suberr == ErrExecutionReverted { return res, nil } return nil, nil @@ -768,7 +762,7 @@ func opCall(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory } else { stack.push(interpreter.intPool.get().SetUint64(1)) } - if err == nil || err == errExecutionReverted { + if err == nil || err == ErrExecutionReverted { memory.Set(retOffset.Uint64(), retSize.Uint64(), ret) } contract.Gas += returnGas @@ -797,7 +791,7 @@ func opCallCode(pc *uint64, interpreter *EVMInterpreter, contract *Contract, mem } else { stack.push(interpreter.intPool.get().SetUint64(1)) } - if err == nil || err == errExecutionReverted { + if err == nil || err == ErrExecutionReverted { memory.Set(retOffset.Uint64(), retSize.Uint64(), ret) } contract.Gas += returnGas @@ -822,7 +816,7 @@ func opDelegateCall(pc *uint64, interpreter *EVMInterpreter, contract *Contract, } else { stack.push(interpreter.intPool.get().SetUint64(1)) } - if err == nil || err == errExecutionReverted { + if err == nil || err == ErrExecutionReverted { memory.Set(retOffset.Uint64(), retSize.Uint64(), ret) } contract.Gas += returnGas @@ -847,7 +841,7 @@ func opStaticCall(pc *uint64, interpreter *EVMInterpreter, contract *Contract, m } else { stack.push(interpreter.intPool.get().SetUint64(1)) } - if err == nil || err == errExecutionReverted { + if err == nil || err == ErrExecutionReverted { memory.Set(retOffset.Uint64(), retSize.Uint64(), ret) } contract.Gas += returnGas diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index 989f85f5d3..b82ead162c 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -114,7 +114,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) { if in.intPool == nil { in.intPool = poolOfIntPools.get() @@ -206,7 +206,7 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) ( // account to the others means the state is modified and should also // return with an error. if operation.writes || (op == CALL && stack.Back(2).Sign() != 0) { - return nil, errWriteProtection + return nil, ErrWriteProtection } } // Static portion of gas @@ -222,12 +222,12 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) ( if operation.memorySize != nil { memSize, overflow := operation.memorySize(stack) if overflow { - return nil, errGasUintOverflow + return nil, ErrGasUintOverflow } // memory is expanded in words of 32 bytes. Gas // is also calculated in words. if memorySize, overflow = math.SafeMul(toWordSize(memSize), 32); overflow { - return nil, errGasUintOverflow + return nil, ErrGasUintOverflow } } // Dynamic portion of gas @@ -265,7 +265,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: diff --git a/core/vm/jump_table.go b/core/vm/jump_table.go index 425436f9e5..a0756bf645 100644 --- a/core/vm/jump_table.go +++ b/core/vm/jump_table.go @@ -17,8 +17,6 @@ package vm import ( - "errors" - "github.com/ethereum/go-ethereum/params" ) @@ -29,8 +27,6 @@ type ( memorySizeFunc func(*Stack) (size uint64, overflow bool) ) -var errGasUintOverflow = errors.New("gas uint64 overflow") - type operation struct { // execute is the operation function execute executionFunc