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 <peterke@gmail.com>
ci-i386-disable-cache
SangIlMo 6 months ago committed by GitHub
parent 68c0ec0815
commit 682ae838b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      internal/ethapi/api.go

@ -1199,10 +1199,16 @@ func DoEstimateGas(ctx context.Context, b Backend, args TransactionArgs, blockNr
State: state,
ErrorRatio: estimateGasErrorRatio,
}
// Set any required transaction default, but make sure the gas cap itself is not messed with
// if it was not specified in the original argument list.
if args.Gas == nil {
args.Gas = new(hexutil.Uint64)
}
if err := args.CallDefaults(gasCap, header.BaseFee, b.ChainConfig().ChainID); err != nil {
return 0, err
}
call := args.ToMessage(header.BaseFee)
// Run the gas estimation and wrap any revertals into a custom return
estimate, revert, err := gasestimator.Estimate(ctx, call, opts, gasCap)
if err != nil {

Loading…
Cancel
Save