Documentation ¶
Index ¶
Constants ¶
View Source
const EstimateGasErrorRatio = 0.015
EstimateGasErrorRatio is the amount of overestimation eth_estimateGas is allowed to produce in order to speed up calculations.
Variables ¶
This section is empty.
Functions ¶
func Estimate ¶
func Estimate(ctx context.Context, call *core.Message, opts *Options, gasCap uint64) (uint64, []byte, error)
Estimate returns the lowest possible gas limit that allows the transaction to run successfully with the provided context options. It returns an error if the transaction would always revert, or if there are unexpected failures.
Types ¶
type Options ¶
type Options struct { Config *params.ChainConfig // Chain configuration for hard fork selection Chain core.ChainContext // Chain context to access past block hashes Header *types.Header // Header defining the block context to execute in State *state.StateDB // Pre-state on top of which to estimate the gas Backend core.NodeInterfaceBackendAPI RunScheduledTxes func(context.Context, core.NodeInterfaceBackendAPI, *state.StateDB, *types.Header, vm.BlockContext, core.MessageRunMode, *core.ExecutionResult) (*core.ExecutionResult, error) ErrorRatio float64 // Allowed overestimation ratio for faster estimation termination }
Options are the contextual parameters to execute the requested call.
Whilst it would be possible to pass a blockchain object that aggregates all these together, it would be excessively hard to test. Splitting the parts out allows testing without needing a proper live chain.
Click to show internal directories.
Click to hide internal directories.