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§
sourcefn call_gas_limit(&self) -> u64
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.
sourcefn evm_config(&self) -> &impl ConfigureEvm
fn evm_config(&self) -> &impl ConfigureEvm
Returns a handle for reading evm config.
Data access in default (L1) trait method implementations.
Provided Methods§
sourcefn with_state_at_block<F, T>(&self, at: BlockId, f: F) -> Result<T, EthApiError>
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
.
sourcefn transact<DB>(
&self,
db: DB,
env: EnvWithHandlerCfg,
) -> Result<(ResultAndState, EnvWithHandlerCfg), EthApiError>
fn transact<DB>( &self, db: DB, env: EnvWithHandlerCfg, ) -> Result<(ResultAndState, EnvWithHandlerCfg), EthApiError>
Executes the EnvWithHandlerCfg
against the given Database without committing state
changes.
sourcefn transact_call_at(
&self,
request: TransactionRequest,
at: BlockId,
overrides: EvmOverrides,
) -> impl Future<Output = Result<(ResultAndState, EnvWithHandlerCfg), EthApiError>> + Sendwhere
Self: LoadPendingBlock,
fn transact_call_at(
&self,
request: TransactionRequest,
at: BlockId,
overrides: EvmOverrides,
) -> impl Future<Output = Result<(ResultAndState, EnvWithHandlerCfg), EthApiError>> + Sendwhere
Self: LoadPendingBlock,
Executes the call request at the given BlockId
.
sourcefn spawn_with_state_at_block<F, T>(
&self,
at: BlockId,
f: F,
) -> impl Future<Output = Result<T, EthApiError>> + Sendwhere
F: FnOnce(StateProviderTraitObjWrapper<'_>) -> Result<T, EthApiError> + Send + 'static,
T: Send + 'static,
fn spawn_with_state_at_block<F, T>(
&self,
at: BlockId,
f: F,
) -> impl Future<Output = Result<T, EthApiError>> + Sendwhere
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
sourcefn spawn_with_call_at<F, R>(
&self,
request: TransactionRequest,
at: BlockId,
overrides: EvmOverrides,
f: F,
) -> impl Future<Output = Result<R, EthApiError>> + Sendwhere
Self: LoadPendingBlock,
F: FnOnce(StateCacheDbRefMutWrapper<'_, '_>, EnvWithHandlerCfg) -> Result<R, EthApiError> + Send + 'static,
R: Send + 'static,
fn spawn_with_call_at<F, R>(
&self,
request: TransactionRequest,
at: BlockId,
overrides: EvmOverrides,
f: F,
) -> impl Future<Output = Result<R, EthApiError>> + Sendwhere
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
.
sourcefn spawn_replay_transaction<F, R>(
&self,
hash: FixedBytes<32>,
f: F,
) -> impl Future<Output = Result<Option<R>, EthApiError>> + Sendwhere
Self: LoadBlock + LoadPendingBlock + LoadTransaction,
F: FnOnce(TransactionInfo, ResultAndState, CacheDB<StateProviderDatabase<StateProviderTraitObjWrapper<'_>>>) -> 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>> + Sendwhere
Self: LoadBlock + LoadPendingBlock + LoadTransaction,
F: FnOnce(TransactionInfo, ResultAndState, CacheDB<StateProviderDatabase<StateProviderTraitObjWrapper<'_>>>) -> Result<R, EthApiError> + Send + 'static,
R: Send + 'static,
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
.
sourcefn 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>
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.
sourcefn estimate_gas_at(
&self,
request: TransactionRequest,
at: BlockId,
state_override: Option<HashMap<Address, AccountOverride>>,
) -> impl Future<Output = Result<Uint<256, 4>, EthApiError>> + Sendwhere
Self: LoadPendingBlock,
fn estimate_gas_at(
&self,
request: TransactionRequest,
at: BlockId,
state_override: Option<HashMap<Address, AccountOverride>>,
) -> impl Future<Output = Result<Uint<256, 4>, EthApiError>> + Sendwhere
Self: LoadPendingBlock,
Estimate gas needed for execution of the request
at the BlockId
.
sourcefn 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 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
sourcefn update_estimated_gas_range(
&self,
result: ExecutionResult,
tx_gas_limit: u64,
highest_gas_limit: &mut u64,
lowest_gas_limit: &mut u64,
) -> Result<(), EthApiError>
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.
sourcefn map_out_of_gas_err<S>(
&self,
env_gas_limit: Uint<256, 4>,
env: EnvWithHandlerCfg,
db: &mut CacheDB<StateProviderDatabase<S>>,
) -> EthApiErrorwhere
S: StateProvider,
fn map_out_of_gas_err<S>(
&self,
env_gas_limit: Uint<256, 4>,
env: EnvWithHandlerCfg,
db: &mut CacheDB<StateProviderDatabase<S>>,
) -> EthApiErrorwhere
S: StateProvider,
Executes the requests again after an out of gas error to check if the error is gas related or not
sourcefn create_txn_env(
&self,
block_env: &BlockEnv,
request: TransactionRequest,
) -> Result<TxEnv, EthApiError>
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.
sourcefn build_call_evm_env(
&self,
cfg: CfgEnvWithHandlerCfg,
block: BlockEnv,
request: TransactionRequest,
) -> Result<EnvWithHandlerCfg, EthApiError>
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.
sourcefn prepare_call_env<DB>(
&self,
cfg: CfgEnvWithHandlerCfg,
block: BlockEnv,
request: TransactionRequest,
gas_limit: u64,
db: &mut CacheDB<DB>,
overrides: EvmOverrides,
) -> 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>
Prepares the EnvWithHandlerCfg
for execution.
Does not commit any changes to the underlying database.
EVM settings:
disable_block_gas_limit
is set totrue
disable_eip3607
is set totrue
disable_base_fee
is set totrue
nonce
is set toNone