Skip to content

Commit

Permalink
internal/ethapi: recap higher args.Gas with block GasLimit in DoEstim…
Browse files Browse the repository at this point in the history
…ateGas
  • Loading branch information
SangIlMo committed May 8, 2024
1 parent eeb2208 commit 97a4b12
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 97a4b12

Please sign in to comment.