internal/ethapi: use block GasLimit if gas is nil in DoEstimateGas

This commit is contained in:
Darioush Jalali 2024-04-10 18:16:54 -07:00
parent 34aac1d756
commit 2767f16b69
No known key found for this signature in database
GPG key ID: 3A24B01A606B0548

View file

@ -1182,6 +1182,12 @@ func DoEstimateGas(ctx context.Context, b Backend, args TransactionArgs, blockNr
State: state, State: state,
ErrorRatio: estimateGasErrorRatio, ErrorRatio: estimateGasErrorRatio,
} }
// If the user has not specified a gas limit, use the block gas limit
if args.Gas == nil {
args.Gas = new(hexutil.Uint64)
*args.Gas = hexutil.Uint64(header.GasLimit)
}
if err := args.CallDefaults(gasCap, header.BaseFee, b.ChainConfig().ChainID); err != nil { if err := args.CallDefaults(gasCap, header.BaseFee, b.ChainConfig().ChainID); err != nil {
return 0, err return 0, err
} }