Skip to content

Commit 682ae83

Browse files
SangIlMokaralabe
andauthored
internal/ethapi: recap higher args.Gas with block GasLimit in DoEstimateGas (#29738)
* internal/ethapi: recap higher args.Gas with block GasLimit in DoEstimateGas * internal/ethapi: fix gas estimator capping code * internal/ethapi: fix test * fix goimports lint (remove space) --------- Co-authored-by: Péter Szilágyi <[email protected]>
1 parent 68c0ec0 commit 682ae83

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

internal/ethapi/api.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,10 +1199,16 @@ func DoEstimateGas(ctx context.Context, b Backend, args TransactionArgs, blockNr
11991199
State: state,
12001200
ErrorRatio: estimateGasErrorRatio,
12011201
}
1202+
// Set any required transaction default, but make sure the gas cap itself is not messed with
1203+
// if it was not specified in the original argument list.
1204+
if args.Gas == nil {
1205+
args.Gas = new(hexutil.Uint64)
1206+
}
12021207
if err := args.CallDefaults(gasCap, header.BaseFee, b.ChainConfig().ChainID); err != nil {
12031208
return 0, err
12041209
}
12051210
call := args.ToMessage(header.BaseFee)
1211+
12061212
// Run the gas estimation and wrap any revertals into a custom return
12071213
estimate, revert, err := gasestimator.Estimate(ctx, call, opts, gasCap)
12081214
if err != nil {

0 commit comments

Comments
 (0)