From 2767f16b69167317d6638cba0f528577b752d584 Mon Sep 17 00:00:00 2001 From: Darioush Jalali Date: Wed, 10 Apr 2024 18:16:54 -0700 Subject: [PATCH] internal/ethapi: use block GasLimit if gas is nil in DoEstimateGas --- internal/ethapi/api.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index f965c91375..79c0beccb2 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1182,6 +1182,12 @@ func DoEstimateGas(ctx context.Context, b Backend, args TransactionArgs, blockNr State: state, ErrorRatio: estimateGasErrorRatio, } + + // If the user has not specified a gas limit, use the block gas limit + if args.Gas == nil { + args.Gas = new(hexutil.Uint64) + *args.Gas = hexutil.Uint64(header.GasLimit) + } if err := args.CallDefaults(gasCap, header.BaseFee, b.ChainConfig().ChainID); err != nil { return 0, err }