gasestimator

package
v0.0.0-...-8b90792 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

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            vm.StateDB          // Pre-state on top of which to estimate the gas
	Backend          core.NodeInterfaceBackendAPI
	RunScheduledTxes func(context.Context, core.NodeInterfaceBackendAPI, vm.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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL