Trait reth_rpc_eth_api::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, R>(
&self,
at: BlockId,
f: F,
) -> Result<R, Self::Error>
where F: FnOnce(StateProviderTraitObjWrapper<'_>) -> Result<R, Self::Error> { ... }
fn transact<DB>(
&self,
db: DB,
env: EnvWithHandlerCfg,
) -> Result<(ResultAndState, EnvWithHandlerCfg), Self::Error>
where DB: Database,
EthApiError: From<DB::Error> { ... }
fn transact_call_at(
&self,
request: TransactionRequest,
at: BlockId,
overrides: EvmOverrides,
) -> impl Future<Output = Result<(ResultAndState, EnvWithHandlerCfg), Self::Error>> + Send
where Self: LoadPendingBlock { ... }
fn spawn_with_state_at_block<F, R>(
&self,
at: BlockId,
f: F,
) -> impl Future<Output = Result<R, Self::Error>> + Send
where F: FnOnce(StateProviderTraitObjWrapper<'_>) -> Result<R, Self::Error> + 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, Self::Error>> + Send
where Self: LoadPendingBlock,
F: FnOnce(StateCacheDbRefMutWrapper<'_, '_>, EnvWithHandlerCfg) -> 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 + LoadPendingBlock + LoadTransaction,
F: FnOnce(TransactionInfo, ResultAndState, StateCacheDb<'_>) -> Result<R, Self::Error> + 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: B256,
) -> Result<usize, Self::Error>
where DB: DatabaseRef,
EthApiError: From<DB::Error> { ... }
fn estimate_gas_at(
&self,
request: TransactionRequest,
at: BlockId,
state_override: Option<StateOverride>,
) -> impl Future<Output = Result<U256, Self::Error>> + Send
where Self: LoadPendingBlock { ... }
fn estimate_gas_with<S>(
&self,
cfg: CfgEnvWithHandlerCfg,
block: BlockEnv,
request: TransactionRequest,
state: S,
state_override: Option<StateOverride>,
) -> Result<U256, Self::Error>
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<(), Self::Error> { ... }
fn map_out_of_gas_err<S>(
&self,
env_gas_limit: U256,
env: EnvWithHandlerCfg,
db: &mut CacheDB<StateProviderDatabase<S>>,
) -> Self::Error
where S: StateProvider { ... }
fn create_txn_env(
&self,
block_env: &BlockEnv,
request: TransactionRequest,
) -> Result<TxEnv, Self::Error> { ... }
fn build_call_evm_env(
&self,
cfg: CfgEnvWithHandlerCfg,
block: BlockEnv,
request: TransactionRequest,
) -> Result<EnvWithHandlerCfg, Self::Error> { ... }
fn prepare_call_env<DB>(
&self,
cfg: CfgEnvWithHandlerCfg,
block: BlockEnv,
request: TransactionRequest,
gas_limit: u64,
db: &mut CacheDB<DB>,
overrides: EvmOverrides,
) -> Result<EnvWithHandlerCfg, Self::Error>
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, R>(&self, at: BlockId, f: F) -> Result<R, Self::Error>
fn with_state_at_block<F, R>(&self, at: BlockId, f: F) -> Result<R, Self::Error>
Executes the closure with the state that corresponds to the given [BlockId
].
sourcefn transact<DB>(
&self,
db: DB,
env: EnvWithHandlerCfg,
) -> Result<(ResultAndState, EnvWithHandlerCfg), Self::Error>where
DB: Database,
EthApiError: From<DB::Error>,
fn transact<DB>(
&self,
db: DB,
env: EnvWithHandlerCfg,
) -> Result<(ResultAndState, EnvWithHandlerCfg), Self::Error>where
DB: Database,
EthApiError: From<DB::Error>,
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), Self::Error>> + Sendwhere
Self: LoadPendingBlock,
fn transact_call_at(
&self,
request: TransactionRequest,
at: BlockId,
overrides: EvmOverrides,
) -> impl Future<Output = Result<(ResultAndState, EnvWithHandlerCfg), Self::Error>> + Sendwhere
Self: LoadPendingBlock,
Executes the call request at the given [BlockId
].
sourcefn spawn_with_state_at_block<F, R>(
&self,
at: BlockId,
f: F,
) -> impl Future<Output = Result<R, Self::Error>> + Send
fn spawn_with_state_at_block<F, R>( &self, at: 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: TransactionRequest,
at: BlockId,
overrides: EvmOverrides,
f: F,
) -> impl Future<Output = Result<R, Self::Error>> + Send
fn spawn_with_call_at<F, R>( &self, request: TransactionRequest, at: BlockId, overrides: EvmOverrides, f: F, ) -> impl Future<Output = Result<R, Self::Error>> + Send
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: B256,
f: F,
) -> impl Future<Output = Result<Option<R>, Self::Error>> + Sendwhere
Self: LoadBlock + LoadPendingBlock + LoadTransaction,
F: FnOnce(TransactionInfo, ResultAndState, 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 + LoadPendingBlock + LoadTransaction,
F: FnOnce(TransactionInfo, ResultAndState, 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<DB>(
&self,
db: &mut CacheDB<DB>,
cfg: CfgEnvWithHandlerCfg,
block_env: BlockEnv,
transactions: impl IntoIterator<Item = TransactionSignedEcRecovered>,
target_tx_hash: B256,
) -> Result<usize, Self::Error>where
DB: DatabaseRef,
EthApiError: From<DB::Error>,
fn replay_transactions_until<DB>(
&self,
db: &mut CacheDB<DB>,
cfg: CfgEnvWithHandlerCfg,
block_env: BlockEnv,
transactions: impl IntoIterator<Item = TransactionSignedEcRecovered>,
target_tx_hash: B256,
) -> Result<usize, Self::Error>where
DB: DatabaseRef,
EthApiError: From<DB::Error>,
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<StateOverride>,
) -> impl Future<Output = Result<U256, Self::Error>> + Sendwhere
Self: LoadPendingBlock,
fn estimate_gas_at(
&self,
request: TransactionRequest,
at: BlockId,
state_override: Option<StateOverride>,
) -> impl Future<Output = Result<U256, Self::Error>> + 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<StateOverride>,
) -> Result<U256, Self::Error>where
S: StateProvider,
fn estimate_gas_with<S>(
&self,
cfg: CfgEnvWithHandlerCfg,
block: BlockEnv,
request: TransactionRequest,
state: S,
state_override: Option<StateOverride>,
) -> Result<U256, 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 totrue
disable_base_fee
is set totrue
nonce
is set toNone
sourcefn update_estimated_gas_range(
&self,
result: ExecutionResult,
tx_gas_limit: u64,
highest_gas_limit: &mut u64,
lowest_gas_limit: &mut u64,
) -> Result<(), Self::Error>
fn update_estimated_gas_range( &self, result: ExecutionResult, tx_gas_limit: u64, highest_gas_limit: &mut u64, lowest_gas_limit: &mut u64, ) -> Result<(), Self::Error>
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: U256,
env: EnvWithHandlerCfg,
db: &mut CacheDB<StateProviderDatabase<S>>,
) -> Self::Errorwhere
S: StateProvider,
fn map_out_of_gas_err<S>(
&self,
env_gas_limit: U256,
env: EnvWithHandlerCfg,
db: &mut CacheDB<StateProviderDatabase<S>>,
) -> Self::Errorwhere
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, Self::Error>
fn create_txn_env( &self, block_env: &BlockEnv, request: TransactionRequest, ) -> Result<TxEnv, Self::Error>
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, Self::Error>
fn build_call_evm_env( &self, cfg: CfgEnvWithHandlerCfg, block: BlockEnv, request: TransactionRequest, ) -> Result<EnvWithHandlerCfg, Self::Error>
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, Self::Error>where
DB: DatabaseRef,
EthApiError: From<<DB as DatabaseRef>::Error>,
fn prepare_call_env<DB>(
&self,
cfg: CfgEnvWithHandlerCfg,
block: BlockEnv,
request: TransactionRequest,
gas_limit: u64,
db: &mut CacheDB<DB>,
overrides: EvmOverrides,
) -> Result<EnvWithHandlerCfg, Self::Error>where
DB: DatabaseRef,
EthApiError: From<<DB as DatabaseRef>::Error>,
Prepares the [EnvWithHandlerCfg
] for execution.
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_eip3607
is set totrue
disable_base_fee
is set totrue
nonce
is set toNone
Additionally, the block gas limit so that higher tx gas limits can be used in eth_call
.
disable_block_gas_limit
is set totrue