pub trait LoadState:
LoadPendingBlock
+ EthApiTypes
+ RpcNodeCoreExtwhere
Self::Error: FromEvmError<Self::Evm> + FromEthApiError,
Self::RpcConvert: RpcConvert<Network = Self::NetworkTypes>,{
// Provided methods
fn state_at_hash(
&self,
block_hash: FixedBytes<32>,
) -> Result<Box<dyn StateProvider + Send>, Self::Error> { ... }
fn state_at_block_id(
&self,
at: BlockId,
) -> impl Future<Output = Result<Box<dyn StateProvider + Send>, Self::Error>> + Send
where Self: SpawnBlocking { ... }
fn latest_state(&self) -> Result<Box<dyn StateProvider + Send>, Self::Error> { ... }
fn state_at_block_id_or_latest(
&self,
block_id: Option<BlockId>,
) -> impl Future<Output = Result<Box<dyn StateProvider + Send>, 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, Box<dyn StateProvider + Send>) -> Result<R, Self::Error> + Send + 'static,
R: Send + 'static { ... }
fn evm_env_for_header(
&self,
header: &SealedHeader<<Self::Primitives as NodePrimitives>::BlockHeader>,
) -> Result<EvmEnv<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Spec, <<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::BlockEnv>, Self::Error> { ... }
fn evm_env_at(
&self,
at: BlockId,
) -> impl Future<Output = Result<(EvmEnv<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Spec, <<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::BlockEnv>, BlockId), Self::Error>> + Send
where Self: SpawnBlocking { ... }
fn evm_env_and_recovered_block_at(
&self,
at: BlockId,
) -> impl Future<Output = Result<(Arc<RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>>, EvmEnv<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Spec, <<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::BlockEnv>, BlockId), Self::Error>> + Send
where Self: SpawnBlocking + LoadBlock { ... }
fn next_available_nonce_for(
&self,
request: &<Self::NetworkTypes as RpcTypes>::TransactionRequest,
) -> 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<Uint<256, 4>, 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 { ... }
}rpc only.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: FixedBytes<32>,
) -> Result<Box<dyn StateProvider + Send>, Self::Error>
fn state_at_hash( &self, block_hash: FixedBytes<32>, ) -> Result<Box<dyn StateProvider + Send>, Self::Error>
Returns the state at the given block number
Sourcefn state_at_block_id(
&self,
at: BlockId,
) -> impl Future<Output = Result<Box<dyn StateProvider + Send>, Self::Error>> + Sendwhere
Self: SpawnBlocking,
fn state_at_block_id(
&self,
at: BlockId,
) -> impl Future<Output = Result<Box<dyn StateProvider + Send>, 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<Box<dyn StateProvider + Send>, Self::Error>
fn latest_state(&self) -> Result<Box<dyn StateProvider + Send>, Self::Error>
Returns the latest state
Sourcefn state_at_block_id_or_latest(
&self,
block_id: Option<BlockId>,
) -> impl Future<Output = Result<Box<dyn StateProvider + Send>, Self::Error>> + Sendwhere
Self: SpawnBlocking,
fn state_at_block_id_or_latest(
&self,
block_id: Option<BlockId>,
) -> impl Future<Output = Result<Box<dyn StateProvider + Send>, 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, Box<dyn StateProvider + Send>) -> 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, Box<dyn StateProvider + Send>) -> 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: &SealedHeader<<Self::Primitives as NodePrimitives>::BlockHeader>,
) -> Result<EvmEnv<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Spec, <<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::BlockEnv>, Self::Error>
fn evm_env_for_header( &self, header: &SealedHeader<<Self::Primitives as NodePrimitives>::BlockHeader>, ) -> Result<EvmEnv<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Spec, <<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::BlockEnv>, Self::Error>
Returns the EVM environment for the given sealed header.
Sourcefn evm_env_at(
&self,
at: BlockId,
) -> impl Future<Output = Result<(EvmEnv<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Spec, <<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::BlockEnv>, BlockId), Self::Error>> + Sendwhere
Self: SpawnBlocking,
fn evm_env_at(
&self,
at: BlockId,
) -> impl Future<Output = Result<(EvmEnv<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Spec, <<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::BlockEnv>, BlockId), Self::Error>> + Sendwhere
Self: SpawnBlocking,
Sourcefn evm_env_and_recovered_block_at(
&self,
at: BlockId,
) -> impl Future<Output = Result<(Arc<RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>>, EvmEnv<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Spec, <<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::BlockEnv>, BlockId), Self::Error>> + Sendwhere
Self: SpawnBlocking + LoadBlock,
fn evm_env_and_recovered_block_at(
&self,
at: BlockId,
) -> impl Future<Output = Result<(Arc<RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>>, EvmEnv<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Spec, <<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::BlockEnv>, 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: &<Self::NetworkTypes as RpcTypes>::TransactionRequest,
) -> impl Future<Output = Result<u64, Self::Error>> + Sendwhere
Self: SpawnBlocking,
fn next_available_nonce_for(
&self,
request: &<Self::NetworkTypes as RpcTypes>::TransactionRequest,
) -> 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<Uint<256, 4>, Self::Error>> + Sendwhere
Self: SpawnBlocking,
fn transaction_count(
&self,
address: Address,
block_id: Option<BlockId>,
) -> impl Future<Output = Result<Uint<256, 4>, 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".