pub trait Call: LoadState<RpcConvert: RpcConvert<Evm = Self::Evm>, Error: FromEvmError<Self::Evm> + From<<Self::RpcConvert as RpcConvert>::Error> + From<ProviderError>> + SpawnBlocking {
Show 14 methods
// Required methods
fn call_gas_limit(&self) -> u64;
fn max_simulate_blocks(&self) -> u64;
fn compute_state_root_for_eth_simulate(&self) -> bool;
fn evm_memory_limit(&self) -> u64;
// Provided methods
fn caller_gas_allowance(
&self,
db: impl Database<Error: Into<EthApiError>>,
_evm_env: &EvmEnvFor<Self::Evm>,
tx_env: &TxEnvFor<Self::Evm>,
) -> Result<u64, Self::Error> { ... }
fn transact<DB>(
&self,
db: DB,
evm_env: EvmEnvFor<Self::Evm>,
tx_env: TxEnvFor<Self::Evm>,
) -> Result<ResultAndState<HaltReasonFor<Self::Evm>>, Self::Error>
where DB: Database<Error = EvmDatabaseError<ProviderError>> + Debug { ... }
fn transact_with_inspector<DB, I>(
&self,
db: DB,
evm_env: EvmEnvFor<Self::Evm>,
tx_env: TxEnvFor<Self::Evm>,
inspector: I,
) -> Result<ResultAndState<HaltReasonFor<Self::Evm>>, Self::Error>
where DB: Database<Error = EvmDatabaseError<ProviderError>> + Debug,
I: InspectorFor<Self::Evm, DB> { ... }
fn transact_call_at(
&self,
request: RpcTxReq<<Self::RpcConvert as RpcConvert>::Network>,
at: BlockId,
overrides: EvmOverrides,
) -> impl Future<Output = Result<ResultAndState<HaltReasonFor<Self::Evm>>, Self::Error>> + Send
where Self: LoadPendingBlock { ... }
fn spawn_with_state_at_block<F, R>(
&self,
at: impl Into<BlockId>,
f: F,
) -> impl Future<Output = Result<R, Self::Error>> + Send
where F: FnOnce(Self, StateCacheDb) -> Result<R, Self::Error> + Send + 'static,
R: Send + 'static { ... }
fn spawn_with_call_at<F, R>(
&self,
request: RpcTxReq<<Self::RpcConvert as RpcConvert>::Network>,
at: BlockId,
overrides: EvmOverrides,
f: F,
) -> impl Future<Output = Result<R, Self::Error>> + Send
where Self: LoadPendingBlock,
F: FnOnce(&mut StateCacheDb, EvmEnvFor<Self::Evm>, TxEnvFor<Self::Evm>) -> Result<R, Self::Error> + Send + 'static,
R: Send + 'static { ... }
fn spawn_replay_transaction<F, R>(
&self,
hash: B256,
f: F,
) -> impl Future<Output = Result<Option<R>, Self::Error>> + Send
where Self: LoadBlock + LoadTransaction,
F: FnOnce(TransactionInfo, ResultAndState<HaltReasonFor<Self::Evm>>, StateCacheDb) -> Result<R, Self::Error> + Send + 'static,
R: Send + 'static { ... }
fn replay_transactions_until_with_evm<'a, DB, I, Txs>(
&self,
evm: &mut EvmFor<Self::Evm, DB, I>,
transactions: Txs,
target_tx_index: usize,
) -> Result<(), Self::Error>
where DB: Database<Error = EvmDatabaseError<ProviderError>> + DatabaseCommit + Debug,
I: InspectorFor<Self::Evm, DB>,
Txs: IntoIterator<Item = Recovered<&'a ProviderTx<Self::Provider>>> { ... }
fn create_txn_env(
&self,
evm_env: &EvmEnvFor<Self::Evm>,
request: RpcTxReq<<Self::RpcConvert as RpcConvert>::Network>,
db: impl Database<Error: Into<EthApiError>>,
) -> Result<TxEnvFor<Self::Evm>, Self::Error> { ... }
fn prepare_call_env<DB>(
&self,
evm_env: EvmEnvFor<Self::Evm>,
request: RpcTxReq<<Self::RpcConvert as RpcConvert>::Network>,
db: &mut DB,
overrides: EvmOverrides,
) -> Result<(EvmEnvFor<Self::Evm>, TxEnvFor<Self::Evm>), Self::Error>
where DB: Database + DatabaseCommit + OverrideBlockHashes,
EthApiError: From<<DB as Database>::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 max_simulate_blocks(&self) -> u64
fn max_simulate_blocks(&self) -> u64
Returns the maximum number of blocks accepted for eth_simulateV1.
Sourcefn compute_state_root_for_eth_simulate(&self) -> bool
fn compute_state_root_for_eth_simulate(&self) -> bool
Returns whether eth_simulateV1 should compute state roots.
Sourcefn evm_memory_limit(&self) -> u64
fn evm_memory_limit(&self) -> u64
Returns the maximum memory the EVM can allocate per RPC request.
Provided Methods§
Sourcefn caller_gas_allowance(
&self,
db: impl Database<Error: Into<EthApiError>>,
_evm_env: &EvmEnvFor<Self::Evm>,
tx_env: &TxEnvFor<Self::Evm>,
) -> Result<u64, Self::Error>
fn caller_gas_allowance( &self, db: impl Database<Error: Into<EthApiError>>, _evm_env: &EvmEnvFor<Self::Evm>, tx_env: &TxEnvFor<Self::Evm>, ) -> Result<u64, Self::Error>
Returns the max gas limit that the caller can afford given a transaction environment.
Sourcefn transact<DB>(
&self,
db: DB,
evm_env: EvmEnvFor<Self::Evm>,
tx_env: TxEnvFor<Self::Evm>,
) -> Result<ResultAndState<HaltReasonFor<Self::Evm>>, Self::Error>where
DB: Database<Error = EvmDatabaseError<ProviderError>> + Debug,
fn transact<DB>(
&self,
db: DB,
evm_env: EvmEnvFor<Self::Evm>,
tx_env: TxEnvFor<Self::Evm>,
) -> Result<ResultAndState<HaltReasonFor<Self::Evm>>, Self::Error>where
DB: Database<Error = EvmDatabaseError<ProviderError>> + Debug,
Executes the TxEnv against the given [Database] without committing state
changes.
Sourcefn transact_with_inspector<DB, I>(
&self,
db: DB,
evm_env: EvmEnvFor<Self::Evm>,
tx_env: TxEnvFor<Self::Evm>,
inspector: I,
) -> Result<ResultAndState<HaltReasonFor<Self::Evm>>, Self::Error>where
DB: Database<Error = EvmDatabaseError<ProviderError>> + Debug,
I: InspectorFor<Self::Evm, DB>,
fn transact_with_inspector<DB, I>(
&self,
db: DB,
evm_env: EvmEnvFor<Self::Evm>,
tx_env: TxEnvFor<Self::Evm>,
inspector: I,
) -> Result<ResultAndState<HaltReasonFor<Self::Evm>>, Self::Error>where
DB: Database<Error = EvmDatabaseError<ProviderError>> + Debug,
I: InspectorFor<Self::Evm, DB>,
Executes the [reth_evm::EvmEnv] against the given [Database] without committing state
changes.
Sourcefn transact_call_at(
&self,
request: RpcTxReq<<Self::RpcConvert as RpcConvert>::Network>,
at: BlockId,
overrides: EvmOverrides,
) -> impl Future<Output = Result<ResultAndState<HaltReasonFor<Self::Evm>>, Self::Error>> + Sendwhere
Self: LoadPendingBlock,
fn transact_call_at(
&self,
request: RpcTxReq<<Self::RpcConvert as RpcConvert>::Network>,
at: BlockId,
overrides: EvmOverrides,
) -> impl Future<Output = Result<ResultAndState<HaltReasonFor<Self::Evm>>, Self::Error>> + Sendwhere
Self: LoadPendingBlock,
Executes the call request at the given [BlockId].
This spawns a new task that obtains the state for the given [BlockId] and then transacts
the call Self::transact. If the future is dropped before the (blocking) transact
call is invoked, then the task is cancelled early, (for example if the request is terminated
early client-side).
Sourcefn spawn_with_state_at_block<F, R>(
&self,
at: impl Into<BlockId>,
f: F,
) -> impl Future<Output = Result<R, Self::Error>> + Send
fn spawn_with_state_at_block<F, R>( &self, at: impl Into<BlockId>, f: F, ) -> impl Future<Output = Result<R, Self::Error>> + Send
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: RpcTxReq<<Self::RpcConvert as RpcConvert>::Network>,
at: BlockId,
overrides: EvmOverrides,
f: F,
) -> impl Future<Output = Result<R, Self::Error>> + Send
fn spawn_with_call_at<F, R>( &self, request: RpcTxReq<<Self::RpcConvert as RpcConvert>::Network>, at: BlockId, overrides: EvmOverrides, f: F, ) -> impl Future<Output = Result<R, Self::Error>> + Send
Prepares the state and env for the given RpcTxReq at the given [BlockId] and
executes the closure on a new task returning the result of the closure.
This returns the configured [reth_evm::EvmEnv] for the given RpcTxReq at
the given [BlockId] and with configured call settings: prepare_call_env.
This is primarily used by eth_call.
§Blocking behaviour
This assumes executing the call is relatively more expensive on IO than CPU because it
transacts a single transaction on an empty in memory database. Because eth_calls are
usually allowed to consume a lot of gas, this also allows a lot of memory operations so
we assume this is not primarily CPU bound and instead spawn the call on a regular tokio task
instead, where blocking IO is less problematic.
Sourcefn spawn_replay_transaction<F, R>(
&self,
hash: B256,
f: F,
) -> impl Future<Output = Result<Option<R>, Self::Error>> + Sendwhere
Self: LoadBlock + LoadTransaction,
F: FnOnce(TransactionInfo, ResultAndState<HaltReasonFor<Self::Evm>>, StateCacheDb) -> Result<R, Self::Error> + Send + 'static,
R: Send + 'static,
fn spawn_replay_transaction<F, R>(
&self,
hash: B256,
f: F,
) -> impl Future<Output = Result<Option<R>, Self::Error>> + Sendwhere
Self: LoadBlock + LoadTransaction,
F: FnOnce(TransactionInfo, ResultAndState<HaltReasonFor<Self::Evm>>, StateCacheDb) -> Result<R, Self::Error> + 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_with_evm<'a, DB, I, Txs>(
&self,
evm: &mut EvmFor<Self::Evm, DB, I>,
transactions: Txs,
target_tx_index: usize,
) -> Result<(), Self::Error>where
DB: Database<Error = EvmDatabaseError<ProviderError>> + DatabaseCommit + Debug,
I: InspectorFor<Self::Evm, DB>,
Txs: IntoIterator<Item = Recovered<&'a ProviderTx<Self::Provider>>>,
fn replay_transactions_until_with_evm<'a, DB, I, Txs>(
&self,
evm: &mut EvmFor<Self::Evm, DB, I>,
transactions: Txs,
target_tx_index: usize,
) -> Result<(), Self::Error>where
DB: Database<Error = EvmDatabaseError<ProviderError>> + DatabaseCommit + Debug,
I: InspectorFor<Self::Evm, DB>,
Txs: IntoIterator<Item = Recovered<&'a ProviderTx<Self::Provider>>>,
Replays all transactions before the target transaction index on the given EVM.
This executes on a caller provided EVM, so the target transaction can then be run on the
same EVM, keeping any block-scoped EVM state intact. The EVM’s inspector configuration is
left untouched; see
Trace::inspect_transaction_in_block to replay without inspection and trace the target.
If the target index is greater than or equal to the iterator length, all transactions are replayed.
Sourcefn create_txn_env(
&self,
evm_env: &EvmEnvFor<Self::Evm>,
request: RpcTxReq<<Self::RpcConvert as RpcConvert>::Network>,
db: impl Database<Error: Into<EthApiError>>,
) -> Result<TxEnvFor<Self::Evm>, Self::Error>
fn create_txn_env( &self, evm_env: &EvmEnvFor<Self::Evm>, request: RpcTxReq<<Self::RpcConvert as RpcConvert>::Network>, db: impl Database<Error: Into<EthApiError>>, ) -> Result<TxEnvFor<Self::Evm>, Self::Error>
All TxEnv fields are derived from the given RpcTxReq, if fields are
None, they fall back to the [reth_evm::EvmEnv]’s settings.
Sourcefn prepare_call_env<DB>(
&self,
evm_env: EvmEnvFor<Self::Evm>,
request: RpcTxReq<<Self::RpcConvert as RpcConvert>::Network>,
db: &mut DB,
overrides: EvmOverrides,
) -> Result<(EvmEnvFor<Self::Evm>, TxEnvFor<Self::Evm>), Self::Error>where
DB: Database + DatabaseCommit + OverrideBlockHashes,
EthApiError: From<<DB as Database>::Error>,
fn prepare_call_env<DB>(
&self,
evm_env: EvmEnvFor<Self::Evm>,
request: RpcTxReq<<Self::RpcConvert as RpcConvert>::Network>,
db: &mut DB,
overrides: EvmOverrides,
) -> Result<(EvmEnvFor<Self::Evm>, TxEnvFor<Self::Evm>), Self::Error>where
DB: Database + DatabaseCommit + OverrideBlockHashes,
EthApiError: From<<DB as Database>::Error>,
Prepares the [reth_evm::EvmEnv] for execution of calls.
Does not commit any changes to the underlying database.
§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_eip3607is set totruedisable_base_feeis set totruenonceis set toNone
In addition, this changes the block’s gas limit to the configured Self::call_gas_limit.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".