fix DoEstimateGas docs and document errorRatio parameter

This commit is contained in:
William Morriss 2024-05-07 18:04:51 -07:00
parent f5e0fecc2e
commit 50729ecb0b

View file

@ -1178,10 +1178,11 @@ func (s *BlockChainAPI) Call(ctx context.Context, args TransactionArgs, blockNrO
return result.Return(), result.Err return result.Return(), result.Err
} }
// DoEstimateGas returns the lowest possible gas limit that allows the transaction to run // DoEstimateGas returns some gas limit that allows the transaction to run
// successfully at block `blockNrOrHash`. It returns error if the transaction would revert, or if // successfully at block `blockNrOrHash`. It returns error if the transaction would revert, or if
// there are unexpected failures. The gas limit is capped by both `args.Gas` (if non-nil & // there are unexpected failures. The gas limit is capped by both `args.Gas` (if non-nil &
// non-zero) and `gasCap` (if non-zero). // non-zero) and `gasCap` (if non-zero).
// The errorRatio specifies how much larger than the minimum necessary gas the result can be.
func DoEstimateGas(ctx context.Context, b Backend, args TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *StateOverride, gasCap uint64, errorRatio float64) (hexutil.Uint64, error) { func DoEstimateGas(ctx context.Context, b Backend, args TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *StateOverride, gasCap uint64, errorRatio float64) (hexutil.Uint64, error) {
// Retrieve the base state and mutate it with any overrides // Retrieve the base state and mutate it with any overrides
state, header, err := b.StateAndHeaderByNumberOrHash(ctx, blockNrOrHash) state, header, err := b.StateAndHeaderByNumberOrHash(ctx, blockNrOrHash)