Trait EstimateCall

pub trait EstimateCall: Call {
    // Provided methods
    fn estimate_gas_with<S>(
        &self,
        evm_env: EvmEnv<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Spec>,
        request: TransactionRequest,
        state: S,
        state_override: Option<HashMap<Address, AccountOverride, FbBuildHasher<20>>>,
    ) -> Result<Uint<256, 4>, Self::Error>
       where S: StateProvider { ... }
    fn estimate_gas_at(
        &self,
        request: TransactionRequest,
        at: BlockId,
        state_override: Option<HashMap<Address, AccountOverride, FbBuildHasher<20>>>,
    ) -> impl Future<Output = Result<Uint<256, 4>, Self::Error>> + Send
       where Self: LoadPendingBlock { ... }
    fn map_out_of_gas_err<DB>(
        &self,
        env_gas_limit: u64,
        evm_env: EvmEnv<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Spec>,
        tx_env: <<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Tx,
        db: &mut DB,
    ) -> Self::Error
       where DB: Database<Error = ProviderError>,
             EthApiError: From<<DB as Database>::Error> { ... }
}
Available on crate feature rpc only.
Expand description

Gas execution estimates

Provided Methods§

fn estimate_gas_with<S>( &self, evm_env: EvmEnv<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Spec>, request: TransactionRequest, state: S, state_override: Option<HashMap<Address, AccountOverride, FbBuildHasher<20>>>, ) -> Result<Uint<256, 4>, Self::Error>
where S: StateProvider,

Estimates the gas usage of the request with the state.

This will execute the TransactionRequest and find the best gas limit via binary search.

§EVM settings

This modifies certain EVM settings to mirror geth’s SkipAccountChecks when transacting requests, see also: https://github.com/ethereum/go-ethereum/blob/380688c636a654becc8f114438c2a5d93d2db032/core/state_transition.go#L145-L148:

  • disable_eip3607 is set to true
  • disable_base_fee is set to true
  • nonce is set to None

fn estimate_gas_at( &self, request: TransactionRequest, at: BlockId, state_override: Option<HashMap<Address, AccountOverride, FbBuildHasher<20>>>, ) -> impl Future<Output = Result<Uint<256, 4>, Self::Error>> + Send
where Self: LoadPendingBlock,

Estimate gas needed for execution of the request at the BlockId.

fn map_out_of_gas_err<DB>( &self, env_gas_limit: u64, evm_env: EvmEnv<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Spec>, tx_env: <<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Tx, db: &mut DB, ) -> Self::Error
where DB: Database<Error = ProviderError>, EthApiError: From<<DB as Database>::Error>,

Executes the requests again after an out of gas error to check if the error is gas related or not

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<Provider, Pool, Network, EvmConfig> EstimateCall for EthApi<Provider, Pool, Network, EvmConfig>
where EthApi<Provider, Pool, Network, EvmConfig>: Call, Provider: BlockReader,

impl<N> EstimateCall for OpEthApi<N>
where Self: Call, Self::Error: From<OpEthApiError>, N: OpNodeCore,