Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal/ethapi: recap higher args.Gas with block GasLimit in DoEstimateGas #29738

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SangIlMo
Copy link

@SangIlMo SangIlMo commented May 8, 2024

Fix the issue (#29695)

We can just recap the args.Gas with block GasLimit when gas is over block GasLimit.

It still enables check the case when args.Gas == nil, and makes args.Gas is capped with block GasLimit

@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change it so that args.Gas is cleared to nil if it was previously nil before the call to args.CallDefaults. @karalabe and I think it's cleaner this way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason is that gasestimator.Estimate is meant to be self-contained (and already has support for capping to the block gas limit). This PR as is currently leaks one of the decisions out to the outside world and that's going to get messy long term, so our best solution is to "undo" the bad default that "CallDefaults" sets. That way at least the "error" is self contained to this few lines of code and doesn't keep bubbling further on the stack.

@fjl fjl removed the status:triage label May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants