From 97a4b1257c0be9e7451b738b9b951fa7da7758d4 Mon Sep 17 00:00:00 2001 From: SangIlMo Date: Wed, 8 May 2024 23:41:14 +0900 Subject: [PATCH] internal/ethapi: recap higher args.Gas with block GasLimit in DoEstimateGas --- internal/ethapi/api.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index d308cead62..fda0341a17 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1202,6 +1202,11 @@ func DoEstimateGas(ctx context.Context, b Backend, args TransactionArgs, blockNr if err := args.CallDefaults(gasCap, header.BaseFee, b.ChainConfig().ChainID); err != nil { return 0, err } + // when gas is over header.GasLimit, just recap with header.GasLimit + if uint64(*args.Gas) > header.GasLimit { + *args.Gas = (hexutil.Uint64)(header.GasLimit) + } + call := args.ToMessage(header.BaseFee) // Run the gas estimation andwrap any revertals into a custom return estimate, revert, err := gasestimator.Estimate(ctx, call, opts, gasCap)