reth::rpc::api::servers::eth::helpers

Trait LoadPendingBlock

Source
pub trait LoadPendingBlock: EthApiTypes + RpcNodeCore{
    // Required methods
    fn pending_block(
        &self,
    ) -> &Mutex<Option<PendingBlock<<Self::Provider as BlockReader>::Block, <Self::Provider as ReceiptProvider>::Receipt>>>;
    fn assemble_receipt(
        &self,
        tx: &<Self::Provider as TransactionsProvider>::Transaction,
        result: ExecutionResult,
        cumulative_gas_used: u64,
    ) -> <Self::Provider as ReceiptProvider>::Receipt;
    fn assemble_block(
        &self,
        block_env: &BlockEnv,
        parent_hash: FixedBytes<32>,
        state_root: FixedBytes<32>,
        transactions: Vec<<Self::Provider as TransactionsProvider>::Transaction>,
        receipts: &[<Self::Provider as ReceiptProvider>::Receipt],
    ) -> <Self::Provider as BlockReader>::Block;

    // Provided methods
    fn pending_block_env_and_cfg(
        &self,
    ) -> Result<PendingBlockEnv<<Self::Provider as BlockReader>::Block, <Self::Provider as ReceiptProvider>::Receipt>, Self::Error> { ... }
    fn local_pending_block(
        &self,
    ) -> impl Future<Output = Result<Option<(SealedBlockWithSenders<<Self::Provider as BlockReader>::Block>, Vec<<Self::Provider as ReceiptProvider>::Receipt>)>, Self::Error>> + Send
       where Self: SpawnBlocking { ... }
    fn assemble_block_and_receipts(
        &self,
        block_env: &BlockEnv,
        parent_hash: FixedBytes<32>,
        state_root: FixedBytes<32>,
        transactions: Vec<<Self::Provider as TransactionsProvider>::Transaction>,
        results: Vec<ExecutionResult>,
    ) -> (<Self::Provider as BlockReader>::Block, Vec<<Self::Provider as ReceiptProvider>::Receipt>) { ... }
    fn build_block(
        &self,
        cfg: CfgEnvWithHandlerCfg,
        block_env: BlockEnv,
        parent_hash: FixedBytes<32>,
    ) -> Result<(SealedBlockWithSenders<<Self::Provider as BlockReader>::Block>, Vec<<Self::Provider as ReceiptProvider>::Receipt>), Self::Error>
       where EthApiError: From<ProviderError> { ... }
}
Expand description

Loads a pending block from database.

Behaviour shared by several eth_ RPC methods, not exclusive to eth_ blocks RPC methods.

Required Methods§

Source

fn pending_block( &self, ) -> &Mutex<Option<PendingBlock<<Self::Provider as BlockReader>::Block, <Self::Provider as ReceiptProvider>::Receipt>>>

Returns a handle to the pending block.

Data access in default (L1) trait method implementations.

Source

fn assemble_receipt( &self, tx: &<Self::Provider as TransactionsProvider>::Transaction, result: ExecutionResult, cumulative_gas_used: u64, ) -> <Self::Provider as ReceiptProvider>::Receipt

Assembles a receipt for a transaction, based on its ExecutionResult.

Source

fn assemble_block( &self, block_env: &BlockEnv, parent_hash: FixedBytes<32>, state_root: FixedBytes<32>, transactions: Vec<<Self::Provider as TransactionsProvider>::Transaction>, receipts: &[<Self::Provider as ReceiptProvider>::Receipt], ) -> <Self::Provider as BlockReader>::Block

Assembles a pending block.

Provided Methods§

Source

fn pending_block_env_and_cfg( &self, ) -> Result<PendingBlockEnv<<Self::Provider as BlockReader>::Block, <Self::Provider as ReceiptProvider>::Receipt>, Self::Error>

Configures the CfgEnvWithHandlerCfg and BlockEnv for the pending block

If no pending block is available, this will derive it from the latest block

Source

fn local_pending_block( &self, ) -> impl Future<Output = Result<Option<(SealedBlockWithSenders<<Self::Provider as BlockReader>::Block>, Vec<<Self::Provider as ReceiptProvider>::Receipt>)>, Self::Error>> + Send
where Self: SpawnBlocking,

Returns the locally built pending block

Source

fn assemble_block_and_receipts( &self, block_env: &BlockEnv, parent_hash: FixedBytes<32>, state_root: FixedBytes<32>, transactions: Vec<<Self::Provider as TransactionsProvider>::Transaction>, results: Vec<ExecutionResult>, ) -> (<Self::Provider as BlockReader>::Block, Vec<<Self::Provider as ReceiptProvider>::Receipt>)

Helper to invoke both Self::assemble_block and Self::assemble_receipt.

Source

fn build_block( &self, cfg: CfgEnvWithHandlerCfg, block_env: BlockEnv, parent_hash: FixedBytes<32>, ) -> Result<(SealedBlockWithSenders<<Self::Provider as BlockReader>::Block>, Vec<<Self::Provider as ReceiptProvider>::Receipt>), Self::Error>

Builds a pending block using the configured provider and pool.

If the origin is the actual pending block, the block is built with withdrawals.

After Cancun, if the origin is the actual pending block, the block includes the EIP-4788 pre block contract call using the parent beacon block root received from the CL.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<Provider, Pool, Network, EvmConfig> LoadPendingBlock for EthApi<Provider, Pool, Network, EvmConfig>
where EthApi<Provider, Pool, Network, EvmConfig>: SpawnBlocking + RpcNodeCore, <EthApi<Provider, Pool, Network, EvmConfig> as RpcNodeCore>::Provider: EvmEnvProvider + ChainSpecProvider + StateProviderFactory + BlockReaderIdExt<Transaction = TransactionSigned, Block = Block, Receipt = Receipt, Header = Header>, <<EthApi<Provider, Pool, Network, EvmConfig> as RpcNodeCore>::Provider as ChainSpecProvider>::ChainSpec: EthChainSpec + EthereumHardforks, <EthApi<Provider, Pool, Network, EvmConfig> as RpcNodeCore>::Pool: TransactionPool, <<EthApi<Provider, Pool, Network, EvmConfig> as RpcNodeCore>::Pool as TransactionPool>::Transaction: PoolTransaction<Consensus = <<EthApi<Provider, Pool, Network, EvmConfig> as RpcNodeCore>::Provider as TransactionsProvider>::Transaction>, <EthApi<Provider, Pool, Network, EvmConfig> as EthApiTypes>::NetworkTypes: Network<HeaderResponse = Header>, <EthApi<Provider, Pool, Network, EvmConfig> as RpcNodeCore>::Evm: ConfigureEvm<Header = Header, Transaction = <<EthApi<Provider, Pool, Network, EvmConfig> as RpcNodeCore>::Provider as TransactionsProvider>::Transaction>, Provider: BlockReader<Block = Block, Receipt = Receipt>,