core/vm: use generic error message for jump/jumpi, to avoid string interpolation

This commit is contained in:
Martin Holst Swende 2019-03-04 11:39:20 +01:00
parent e5945d58f0
commit df98ba391a
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0

View file

@ -18,7 +18,6 @@ package vm
import ( import (
"errors" "errors"
"fmt"
"math/big" "math/big"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
@ -35,6 +34,7 @@ var (
errReturnDataOutOfBounds = errors.New("evm: return data out of bounds") errReturnDataOutOfBounds = errors.New("evm: return data out of bounds")
errExecutionReverted = errors.New("evm: execution reverted") errExecutionReverted = errors.New("evm: execution reverted")
errMaxCodeSizeExceeded = errors.New("evm: max code size exceeded") errMaxCodeSizeExceeded = errors.New("evm: max code size exceeded")
errInvalidJump = errors.New("evm: invalid jump destination")
) )
func opAdd(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { func opAdd(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
@ -645,8 +645,7 @@ func opSstore(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memor
func opJump(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { func opJump(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
pos := stack.pop() pos := stack.pop()
if !contract.validJumpdest(pos) { if !contract.validJumpdest(pos) {
nop := contract.GetOp(pos.Uint64()) return nil, errInvalidJump
return nil, fmt.Errorf("invalid jump destination (%v) %v", nop, pos)
} }
*pc = pos.Uint64() *pc = pos.Uint64()
@ -658,8 +657,7 @@ func opJumpi(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory
pos, cond := stack.pop(), stack.pop() pos, cond := stack.pop(), stack.pop()
if cond.Sign() != 0 { if cond.Sign() != 0 {
if !contract.validJumpdest(pos) { if !contract.validJumpdest(pos) {
nop := contract.GetOp(pos.Uint64()) return nil, errInvalidJump
return nil, fmt.Errorf("invalid jump destination (%v) %v", nop, pos)
} }
*pc = pos.Uint64() *pc = pos.Uint64()
} else { } else {