internal/ethapi: use block GasLimit if gas is nil in DoEstimateGas #29509
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi. Prior to the refactor made in https://github.com/ethereum/go-ethereum/pull/28600/files, when
args.Gas == nil
, the block'sGasLimit
was used as the upper limit for gas estimation: https://github.com/ethereum/go-ethereum/pull/28600/files#diff-c426ecd2f7d247753b9ea8c1cc003f21fa412661c1f967d203d4edf8163da344L1208-L1216After the mentioned PR, when
args.Gas == nil
, in case the default set inargs.ToMessage
(usually globalGasCap) is greater than the block's GasLimit, this can result in an estimation higher than the block GasLimit as it would be overwritten here: https://github.com/ethereum/go-ethereum/pull/28600/files#diff-66f4d55a856f5b04d4c6e1ee99582788b0510add7bd64c7332b948c2aeadbfdfR57-R60This PR restores the previous behavior by setting the header's
GasLimit
in args prior to callingCallDefaults
orToMessage
. Thanks for your consideration.