pub trait LoadState:
LoadPendingBlock
+ EthApiTypes<Error: FromEvmError<Self::Evm> + FromEthApiError, RpcConvert: RpcConvert<Network = Self::NetworkTypes>>
+ RpcNodeCoreExt {
// Provided methods
fn state_at_hash(
&self,
block_hash: B256,
) -> Result<StateProviderBox, Self::Error> { ... }
fn state_at_block_id(
&self,
at: BlockId,
) -> impl Future<Output = Result<StateProviderBox, Self::Error>> + Send
where Self: SpawnBlocking { ... }
fn latest_state(&self) -> Result<StateProviderBox, Self::Error> { ... }
fn state_at_block_id_or_latest(
&self,
block_id: Option<BlockId>,
) -> impl Future<Output = Result<StateProviderBox, Self::Error>> + Send
where Self: SpawnBlocking { ... }
fn spawn_blocking_io_with_state<F, R>(
&self,
at: BlockId,
f: F,
) -> impl Future<Output = Result<R, Self::Error>> + Send
where Self: SpawnBlocking,
F: FnOnce(Self, StateProviderBox) -> Result<R, Self::Error> + Send + 'static,
R: Send + 'static { ... }
fn evm_env_for_header(
&self,
header: &SealedHeaderFor<Self::Primitives>,
) -> Result<EvmEnvFor<Self::Evm>, Self::Error> { ... }
fn evm_env_at(
&self,
at: BlockId,
) -> impl Future<Output = Result<(EvmEnvFor<Self::Evm>, BlockId), Self::Error>> + Send
where Self: SpawnBlocking { ... }
fn evm_env_and_recovered_block_at(
&self,
at: BlockId,
) -> impl Future<Output = Result<(Arc<RecoveredBlock<BlockTy<Self::Primitives>>>, EvmEnvFor<Self::Evm>, BlockId), Self::Error>> + Send
where Self: SpawnBlocking + LoadBlock { ... }
fn next_available_nonce_for(
&self,
request: &RpcTxReq<Self::NetworkTypes>,
) -> impl Future<Output = Result<u64, Self::Error>> + Send
where Self: SpawnBlocking { ... }
fn transaction_count(
&self,
address: Address,
block_id: Option<BlockId>,
) -> impl Future<Output = Result<U256, Self::Error>> + Send
where Self: SpawnBlocking { ... }
fn get_code(
&self,
address: Address,
block_id: Option<BlockId>,
) -> impl Future<Output = Result<Bytes, Self::Error>> + Send
where Self: SpawnBlocking { ... }
}Expand description
Loads state from database.
Behaviour shared by several eth_ RPC methods, not exclusive to eth_ state RPC methods.
Provided Methods§
Sourcefn state_at_hash(
&self,
block_hash: B256,
) -> Result<StateProviderBox, Self::Error>
fn state_at_hash( &self, block_hash: B256, ) -> Result<StateProviderBox, Self::Error>
Returns the state at the given block number
Sourcefn state_at_block_id(
&self,
at: BlockId,
) -> impl Future<Output = Result<StateProviderBox, Self::Error>> + Sendwhere
Self: SpawnBlocking,
fn state_at_block_id(
&self,
at: BlockId,
) -> impl Future<Output = Result<StateProviderBox, Self::Error>> + Sendwhere
Self: SpawnBlocking,
Returns the state at the given [BlockId], preferring locally built state for pending.
If local pending state is unavailable or fails to build, falls back to the provider’s pending state. Other block IDs resolve only canonical state. See https://github.com/paradigmxyz/reth/issues/4515.
Pending block construction may spawn blocking work, so await this outside a blocking task.
The fallback provider lookup is synchronous on the calling task; RPC handlers should use
Self::spawn_blocking_io_with_state to keep that read on the blocking pool.
Sourcefn latest_state(&self) -> Result<StateProviderBox, Self::Error>
fn latest_state(&self) -> Result<StateProviderBox, Self::Error>
Returns the latest state
Sourcefn state_at_block_id_or_latest(
&self,
block_id: Option<BlockId>,
) -> impl Future<Output = Result<StateProviderBox, Self::Error>> + Sendwhere
Self: SpawnBlocking,
fn state_at_block_id_or_latest(
&self,
block_id: Option<BlockId>,
) -> impl Future<Output = Result<StateProviderBox, Self::Error>> + Sendwhere
Self: SpawnBlocking,
Returns the state at the given [BlockId] enum or the latest.
Convenience function to interprets None as BlockId::Number(BlockNumberOrTag::Latest)
Sourcefn spawn_blocking_io_with_state<F, R>(
&self,
at: BlockId,
f: F,
) -> impl Future<Output = Result<R, Self::Error>> + Sendwhere
Self: SpawnBlocking,
F: FnOnce(Self, StateProviderBox) -> Result<R, Self::Error> + Send + 'static,
R: Send + 'static,
fn spawn_blocking_io_with_state<F, R>(
&self,
at: BlockId,
f: F,
) -> impl Future<Output = Result<R, Self::Error>> + Sendwhere
Self: SpawnBlocking,
F: FnOnce(Self, StateProviderBox) -> Result<R, Self::Error> + Send + 'static,
R: Send + 'static,
Executes f with the state at the given [BlockId] on a blocking IO task.
Resolves the chain’s pending-state source before occupying a blocking thread, since building a pending block may need a blocking thread of its own.
Sourcefn evm_env_for_header(
&self,
header: &SealedHeaderFor<Self::Primitives>,
) -> Result<EvmEnvFor<Self::Evm>, Self::Error>
fn evm_env_for_header( &self, header: &SealedHeaderFor<Self::Primitives>, ) -> Result<EvmEnvFor<Self::Evm>, Self::Error>
Returns the EVM environment for the given sealed header.
Sourcefn evm_env_at(
&self,
at: BlockId,
) -> impl Future<Output = Result<(EvmEnvFor<Self::Evm>, BlockId), Self::Error>> + Sendwhere
Self: SpawnBlocking,
fn evm_env_at(
&self,
at: BlockId,
) -> impl Future<Output = Result<(EvmEnvFor<Self::Evm>, BlockId), Self::Error>> + Sendwhere
Self: SpawnBlocking,
Returns the EVM environment for the requested [BlockId]
If the [BlockId] this will return the [BlockId] of the block the env was configured
for.
If the [BlockId] is pending, this will return the “Pending” tag, otherwise this returns
the hash of the exact block.
Sourcefn evm_env_and_recovered_block_at(
&self,
at: BlockId,
) -> impl Future<Output = Result<(Arc<RecoveredBlock<BlockTy<Self::Primitives>>>, EvmEnvFor<Self::Evm>, BlockId), Self::Error>> + Sendwhere
Self: SpawnBlocking + LoadBlock,
fn evm_env_and_recovered_block_at(
&self,
at: BlockId,
) -> impl Future<Output = Result<(Arc<RecoveredBlock<BlockTy<Self::Primitives>>>, EvmEnvFor<Self::Evm>, BlockId), Self::Error>> + Sendwhere
Self: SpawnBlocking + LoadBlock,
Returns the recovered block, EVM environment, and state block id for the requested
[BlockId].
For pending blocks, this preserves the state id returned by Self::evm_env_at, which can
be the pending tag for an actual pending block or the latest block hash when the pending env
is derived from latest.
Sourcefn next_available_nonce_for(
&self,
request: &RpcTxReq<Self::NetworkTypes>,
) -> impl Future<Output = Result<u64, Self::Error>> + Sendwhere
Self: SpawnBlocking,
fn next_available_nonce_for(
&self,
request: &RpcTxReq<Self::NetworkTypes>,
) -> impl Future<Output = Result<u64, Self::Error>> + Sendwhere
Self: SpawnBlocking,
Returns the next available nonce without gaps for the given address Next available nonce is either the on chain nonce of the account or the highest consecutive nonce in the pool + 1
The provided request must have a from address set.
Sourcefn transaction_count(
&self,
address: Address,
block_id: Option<BlockId>,
) -> impl Future<Output = Result<U256, Self::Error>> + Sendwhere
Self: SpawnBlocking,
fn transaction_count(
&self,
address: Address,
block_id: Option<BlockId>,
) -> impl Future<Output = Result<U256, Self::Error>> + Sendwhere
Self: SpawnBlocking,
Returns the number of transactions sent from an address at the given block identifier.
If this is BlockNumberOrTag::Pending then this will
look up the highest transaction in pool and return the next nonce (highest + 1).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".