Trait reth::rpc::api::servers::eth::helpers::call::Call

source ·
pub trait Call: LoadState + SpawnBlocking {
Show 16 methods // Required methods fn call_gas_limit(&self) -> u64; fn evm_config(&self) -> &impl ConfigureEvm; // Provided methods fn with_state_at_block<F, T>( &self, at: BlockId, f: F, ) -> Result<T, EthApiError> where F: FnOnce(StateProviderTraitObjWrapper<'_>) -> Result<T, EthApiError> { ... } fn transact<DB>( &self, db: DB, env: EnvWithHandlerCfg, ) -> Result<(ResultAndState, EnvWithHandlerCfg), EthApiError> where DB: Database, <DB as Database>::Error: Into<EthApiError> { ... } fn transact_call_at( &self, request: TransactionRequest, at: BlockId, overrides: EvmOverrides, ) -> impl Future<Output = Result<(ResultAndState, EnvWithHandlerCfg), EthApiError>> + Send where Self: LoadPendingBlock { ... } fn spawn_with_state_at_block<F, T>( &self, at: BlockId, f: F, ) -> impl Future<Output = Result<T, EthApiError>> + Send where F: FnOnce(StateProviderTraitObjWrapper<'_>) -> Result<T, EthApiError> + Send + 'static, T: Send + 'static { ... } fn spawn_with_call_at<F, R>( &self, request: TransactionRequest, at: BlockId, overrides: EvmOverrides, f: F, ) -> impl Future<Output = Result<R, EthApiError>> + Send where Self: LoadPendingBlock, F: FnOnce(StateCacheDbRefMutWrapper<'_, '_>, EnvWithHandlerCfg) -> Result<R, EthApiError> + Send + 'static, R: Send + 'static { ... } fn spawn_replay_transaction<F, R>( &self, hash: FixedBytes<32>, f: F, ) -> impl Future<Output = Result<Option<R>, EthApiError>> + Send where Self: LoadBlock + LoadPendingBlock + LoadTransaction, F: FnOnce(TransactionInfo, ResultAndState, CacheDB<StateProviderDatabase<StateProviderTraitObjWrapper<'_>>>) -> Result<R, EthApiError> + Send + 'static, R: Send + 'static { ... } fn replay_transactions_until<DB>( &self, db: &mut CacheDB<DB>, cfg: CfgEnvWithHandlerCfg, block_env: BlockEnv, transactions: impl IntoIterator<Item = TransactionSignedEcRecovered>, target_tx_hash: FixedBytes<32>, ) -> Result<usize, EthApiError> where DB: DatabaseRef, EthApiError: From<<DB as DatabaseRef>::Error> { ... } fn estimate_gas_at( &self, request: TransactionRequest, at: BlockId, state_override: Option<HashMap<Address, AccountOverride>>, ) -> impl Future<Output = Result<Uint<256, 4>, EthApiError>> + Send where Self: LoadPendingBlock { ... } fn estimate_gas_with<S>( &self, cfg: CfgEnvWithHandlerCfg, block: BlockEnv, request: TransactionRequest, state: S, state_override: Option<HashMap<Address, AccountOverride>>, ) -> Result<Uint<256, 4>, EthApiError> where S: StateProvider { ... } fn update_estimated_gas_range( &self, result: ExecutionResult, tx_gas_limit: u64, highest_gas_limit: &mut u64, lowest_gas_limit: &mut u64, ) -> Result<(), EthApiError> { ... } fn map_out_of_gas_err<S>( &self, env_gas_limit: Uint<256, 4>, env: EnvWithHandlerCfg, db: &mut CacheDB<StateProviderDatabase<S>>, ) -> EthApiError where S: StateProvider { ... } fn create_txn_env( &self, block_env: &BlockEnv, request: TransactionRequest, ) -> Result<TxEnv, EthApiError> { ... } fn build_call_evm_env( &self, cfg: CfgEnvWithHandlerCfg, block: BlockEnv, request: TransactionRequest, ) -> Result<EnvWithHandlerCfg, EthApiError> { ... } fn prepare_call_env<DB>( &self, cfg: CfgEnvWithHandlerCfg, block: BlockEnv, request: TransactionRequest, gas_limit: u64, db: &mut CacheDB<DB>, overrides: EvmOverrides, ) -> Result<EnvWithHandlerCfg, EthApiError> where DB: DatabaseRef, EthApiError: From<<DB as DatabaseRef>::Error> { ... }
}
Expand description

Executes code on state.

Required Methods§

source

fn call_gas_limit(&self) -> u64

Returns default gas limit to use for eth_call and tracing RPC methods.

Data access in default trait method implementations.

source

fn evm_config(&self) -> &impl ConfigureEvm

Returns a handle for reading evm config.

Data access in default (L1) trait method implementations.

Provided Methods§

source

fn with_state_at_block<F, T>(&self, at: BlockId, f: F) -> Result<T, EthApiError>

Executes the closure with the state that corresponds to the given BlockId.

source

fn transact<DB>( &self, db: DB, env: EnvWithHandlerCfg, ) -> Result<(ResultAndState, EnvWithHandlerCfg), EthApiError>
where DB: Database, <DB as Database>::Error: Into<EthApiError>,

Executes the EnvWithHandlerCfg against the given Database without committing state changes.

source

fn transact_call_at( &self, request: TransactionRequest, at: BlockId, overrides: EvmOverrides, ) -> impl Future<Output = Result<(ResultAndState, EnvWithHandlerCfg), EthApiError>> + Send
where Self: LoadPendingBlock,

Executes the call request at the given BlockId.

source

fn spawn_with_state_at_block<F, T>( &self, at: BlockId, f: F, ) -> impl Future<Output = Result<T, EthApiError>> + Send
where F: FnOnce(StateProviderTraitObjWrapper<'_>) -> Result<T, EthApiError> + Send + 'static, T: Send + 'static,

Executes the closure with the state that corresponds to the given BlockId on a new task

source

fn spawn_with_call_at<F, R>( &self, request: TransactionRequest, at: BlockId, overrides: EvmOverrides, f: F, ) -> impl Future<Output = Result<R, EthApiError>> + Send
where Self: LoadPendingBlock, F: FnOnce(StateCacheDbRefMutWrapper<'_, '_>, EnvWithHandlerCfg) -> Result<R, EthApiError> + Send + 'static, R: Send + 'static,

Prepares the state and env for the given TransactionRequest at the given BlockId and executes the closure on a new task returning the result of the closure.

This returns the configured EnvWithHandlerCfg for the given TransactionRequest at the given BlockId and with configured call settings: prepare_call_env.

source

fn spawn_replay_transaction<F, R>( &self, hash: FixedBytes<32>, f: F, ) -> impl Future<Output = Result<Option<R>, EthApiError>> + Send

Retrieves the transaction if it exists and executes it.

Before the transaction is executed, all previous transaction in the block are applied to the state by executing them first. The callback f is invoked with the ResultAndState after the transaction was executed and the database that points to the beginning of the transaction.

Note: Implementers should use a threadpool where blocking is allowed, such as BlockingTaskPool.

source

fn replay_transactions_until<DB>( &self, db: &mut CacheDB<DB>, cfg: CfgEnvWithHandlerCfg, block_env: BlockEnv, transactions: impl IntoIterator<Item = TransactionSignedEcRecovered>, target_tx_hash: FixedBytes<32>, ) -> Result<usize, EthApiError>

Replays all the transactions until the target transaction is found.

All transactions before the target transaction are executed and their changes are written to the runtime db (CacheDB).

Note: This assumes the target transaction is in the given iterator. Returns the index of the target transaction in the given iterator.

source

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

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

source

fn estimate_gas_with<S>( &self, cfg: CfgEnvWithHandlerCfg, block: BlockEnv, request: TransactionRequest, state: S, state_override: Option<HashMap<Address, AccountOverride>>, ) -> Result<Uint<256, 4>, EthApiError>
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

source

fn update_estimated_gas_range( &self, result: ExecutionResult, tx_gas_limit: u64, highest_gas_limit: &mut u64, lowest_gas_limit: &mut u64, ) -> Result<(), EthApiError>

Updates the highest and lowest gas limits for binary search based on the execution result.

This function refines the gas limit estimates used in a binary search to find the optimal gas limit for a transaction. It adjusts the highest or lowest gas limits depending on whether the execution succeeded, reverted, or halted due to specific reasons.

source

fn map_out_of_gas_err<S>( &self, env_gas_limit: Uint<256, 4>, env: EnvWithHandlerCfg, db: &mut CacheDB<StateProviderDatabase<S>>, ) -> EthApiError
where S: StateProvider,

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

source

fn create_txn_env( &self, block_env: &BlockEnv, request: TransactionRequest, ) -> Result<TxEnv, EthApiError>

Configures a new TxEnv for the TransactionRequest

All TxEnv fields are derived from the given TransactionRequest, if fields are None, they fall back to the BlockEnv’s settings.

source

fn build_call_evm_env( &self, cfg: CfgEnvWithHandlerCfg, block: BlockEnv, request: TransactionRequest, ) -> Result<EnvWithHandlerCfg, EthApiError>

Creates a new EnvWithHandlerCfg to be used for executing the TransactionRequest in eth_call.

Note: this does not access the Database to check the sender.

source

fn prepare_call_env<DB>( &self, cfg: CfgEnvWithHandlerCfg, block: BlockEnv, request: TransactionRequest, gas_limit: u64, db: &mut CacheDB<DB>, overrides: EvmOverrides, ) -> Result<EnvWithHandlerCfg, EthApiError>

Prepares the EnvWithHandlerCfg for execution.

Does not commit any changes to the underlying database.

EVM settings:

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

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<Provider, Pool, Network, EvmConfig> Call for EthApi<Provider, Pool, Network, EvmConfig>
where EthApi<Provider, Pool, Network, EvmConfig>: LoadState + SpawnBlocking, EvmConfig: ConfigureEvm,