From d59298fd7aa4e0172269a13f1048a97f5f59fd8b Mon Sep 17 00:00:00 2001 From: jsvisa Date: Wed, 16 Aug 2023 01:44:27 +0800 Subject: [PATCH] add eip1559 zero check too Signed-off-by: jsvisa --- internal/ethapi/transaction_args.go | 3 +++ internal/ethapi/transaction_args_test.go | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/internal/ethapi/transaction_args.go b/internal/ethapi/transaction_args.go index c17650f96d..a155cabd1b 100644 --- a/internal/ethapi/transaction_args.go +++ b/internal/ethapi/transaction_args.go @@ -143,6 +143,9 @@ func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend) erro eip1559ParamsSet := args.MaxFeePerGas != nil && args.MaxPriorityFeePerGas != nil if args.GasPrice == nil && eip1559ParamsSet { // Sanity check the EIP-1559 fee parameters if present. + if args.MaxFeePerGas.ToInt().Sign() == 0 { + return errors.New("maxFeePerGas must be non-zero") + } if args.MaxFeePerGas.ToInt().Cmp(args.MaxPriorityFeePerGas.ToInt()) < 0 { return fmt.Errorf("maxFeePerGas (%v) < maxPriorityFeePerGas (%v)", args.MaxFeePerGas, args.MaxPriorityFeePerGas) } diff --git a/internal/ethapi/transaction_args_test.go b/internal/ethapi/transaction_args_test.go index 39feb4c08c..3740d655d7 100644 --- a/internal/ethapi/transaction_args_test.go +++ b/internal/ethapi/transaction_args_test.go @@ -176,6 +176,13 @@ func TestSetFeeDefaults(t *testing.T) { nil, errors.New("maxFeePerGas (0x7) < maxPriorityFeePerGas (0x2a)"), }, + { + "dynamic fee tx post-London, explicit gas price", + true, + &TransactionArgs{MaxFeePerGas: zero, MaxPriorityFeePerGas: zero}, + nil, + errors.New("maxFeePerGas must be non-zero"), + }, // Misc {