diff --git a/consensus/misc/eip1559/eip1559.go b/consensus/misc/eip1559/eip1559.go index 0763ebd9c9..219122ce83 100644 --- a/consensus/misc/eip1559/eip1559.go +++ b/consensus/misc/eip1559/eip1559.go @@ -17,6 +17,7 @@ package eip1559 import ( + "errors" "fmt" "math/big" @@ -39,7 +40,7 @@ func VerifyEip1559Header(config *params.ChainConfig, header *types.Header) error // Verify the header is not malformed if header.BaseFee == nil { - return fmt.Errorf("header is missing baseFee") + return errors.New("header is missing baseFee") } // Verify the baseFee is correct based on the current header. diff --git a/eth/tracers/tracer.go b/eth/tracers/tracer.go index 2fa04cd1ad..741c2655af 100644 --- a/eth/tracers/tracer.go +++ b/eth/tracers/tracer.go @@ -552,7 +552,7 @@ func NewJsTracer(code string, ctx *Context) (*JsTracer, error) { hasExit := tracer.vm.GetPropString(tracer.tracerObject, "exit") tracer.vm.Pop() if hasEnter != hasExit { - return nil, fmt.Errorf("trace object must expose either both or none of enter() and exit()") + return nil, errors.New("trace object must expose either both or none of enter() and exit()") } tracer.traceCallFrames = hasEnter && hasExit tracer.traceSteps = hasStep diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 78b1353daf..1665607151 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -482,7 +482,7 @@ func (s *PersonalAccountAPI) SignTransaction(ctx context.Context, args Transacti // No need to obtain the noncelock mutex, since we won't be sending this // tx into the transaction pool, but right back to the user if args.From == nil { - return nil, fmt.Errorf("sender not specified") + return nil, errors.New("sender not specified") } if args.Gas == nil { return nil, errors.New("gas not specified") diff --git a/internal/ethapi/transaction_args_test.go b/internal/ethapi/transaction_args_test.go index 960b81d076..16de689df1 100644 --- a/internal/ethapi/transaction_args_test.go +++ b/internal/ethapi/transaction_args_test.go @@ -19,7 +19,6 @@ package ethapi import ( "context" "errors" - "fmt" "math/big" "reflect" "testing" @@ -159,28 +158,28 @@ func TestSetFeeDefaults(t *testing.T) { false, &TransactionArgs{MaxFeePerGas: maxFee}, nil, - fmt.Errorf("maxFeePerGas and maxPriorityFeePerGas are not valid before EIP-1559 is active"), + errors.New("maxFeePerGas and maxPriorityFeePerGas are not valid before EIP-1559 is active"), }, { "dynamic fee tx pre-London, priorityFee set", false, &TransactionArgs{MaxPriorityFeePerGas: fortytwo}, nil, - fmt.Errorf("maxFeePerGas and maxPriorityFeePerGas are not valid before EIP-1559 is active"), + errors.New("maxFeePerGas and maxPriorityFeePerGas are not valid before EIP-1559 is active"), }, { "dynamic fee tx, maxFee < priorityFee", true, &TransactionArgs{MaxFeePerGas: maxFee, MaxPriorityFeePerGas: (*hexutil.Big)(big.NewInt(1000))}, nil, - fmt.Errorf("maxFeePerGas (0x3e) < maxPriorityFeePerGas (0x3e8)"), + errors.New("maxFeePerGas (0x3e) < maxPriorityFeePerGas (0x3e8)"), }, { "dynamic fee tx, maxFee < priorityFee while setting default", true, &TransactionArgs{MaxFeePerGas: (*hexutil.Big)(big.NewInt(7))}, nil, - fmt.Errorf("maxFeePerGas (0x7) < maxPriorityFeePerGas (0x2a)"), + errors.New("maxFeePerGas (0x7) < maxPriorityFeePerGas (0x2a)"), }, { "dynamic fee tx post-London, explicit gas price", @@ -196,21 +195,21 @@ func TestSetFeeDefaults(t *testing.T) { false, &TransactionArgs{GasPrice: fortytwo, MaxFeePerGas: maxFee, MaxPriorityFeePerGas: fortytwo}, nil, - fmt.Errorf("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified"), + errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified"), }, { "set gas price and maxPriorityFee", false, &TransactionArgs{GasPrice: fortytwo, MaxPriorityFeePerGas: fortytwo}, nil, - fmt.Errorf("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified"), + errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified"), }, { "set gas price and maxFee", true, &TransactionArgs{GasPrice: fortytwo, MaxFeePerGas: maxFee}, nil, - fmt.Errorf("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified"), + errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified"), }, } diff --git a/node/rpcstack.go b/node/rpcstack.go index e079b14acb..6605036e27 100644 --- a/node/rpcstack.go +++ b/node/rpcstack.go @@ -19,6 +19,7 @@ package node import ( "compress/gzip" "context" + "errors" "fmt" "io" "net" @@ -296,7 +297,7 @@ func (h *httpServer) enableRPC(apis []rpc.API, config httpConfig) error { defer h.mu.Unlock() if h.rpcAllowed() { - return fmt.Errorf("JSON-RPC over HTTP is already enabled") + return errors.New("JSON-RPC over HTTP is already enabled") } // Create RPC server and handler. @@ -332,7 +333,7 @@ func (h *httpServer) enableWS(apis []rpc.API, config wsConfig) error { defer h.mu.Unlock() if h.wsAllowed() { - return fmt.Errorf("JSON-RPC over WebSocket is already enabled") + return errors.New("JSON-RPC over WebSocket is already enabled") } // Create RPC server and handler.