reth_rpc_eth_api::helpers::pending_block

Trait LoadPendingBlock

Source
pub trait LoadPendingBlock: EthApiTypes<NetworkTypes: Network<HeaderResponse = Header<ProviderHeader<Self::Provider>>>> + RpcNodeCore<Provider: BlockReaderIdExt<Receipt: Receipt> + ChainSpecProvider<ChainSpec: EthChainSpec + EthereumHardforks> + StateProviderFactory, Pool: TransactionPool<Transaction: PoolTransaction<Consensus = ProviderTx<Self::Provider>>>, Evm: ConfigureEvm<Header = ProviderHeader<Self::Provider>, Transaction = ProviderTx<Self::Provider>>> {
    // Required methods
    fn pending_block(
        &self,
    ) -> &Mutex<Option<PendingBlock<ProviderBlock<Self::Provider>, ProviderReceipt<Self::Provider>>>>;
    fn assemble_receipt(
        &self,
        tx: &ProviderTx<Self::Provider>,
        result: ExecutionResult,
        cumulative_gas_used: u64,
    ) -> ProviderReceipt<Self::Provider>;
    fn assemble_block(
        &self,
        block_env: &BlockEnv,
        parent_hash: B256,
        state_root: B256,
        transactions: Vec<ProviderTx<Self::Provider>>,
        receipts: &[ProviderReceipt<Self::Provider>],
    ) -> ProviderBlock<Self::Provider>;

    // Provided methods
    fn pending_block_env_and_cfg(
        &self,
    ) -> Result<PendingBlockEnv<ProviderBlock<Self::Provider>, ProviderReceipt<Self::Provider>>, Self::Error> { ... }
    fn local_pending_block(
        &self,
    ) -> impl Future<Output = Result<Option<(SealedBlockWithSenders<<Self::Provider as BlockReader>::Block>, Vec<ProviderReceipt<Self::Provider>>)>, Self::Error>> + Send
       where Self: SpawnBlocking { ... }
    fn assemble_block_and_receipts(
        &self,
        block_env: &BlockEnv,
        parent_hash: B256,
        state_root: B256,
        transactions: Vec<ProviderTx<Self::Provider>>,
        results: Vec<ExecutionResult>,
    ) -> (ProviderBlock<Self::Provider>, Vec<ProviderReceipt<Self::Provider>>) { ... }
    fn build_block(
        &self,
        cfg: CfgEnvWithHandlerCfg,
        block_env: BlockEnv,
        parent_hash: B256,
    ) -> Result<(SealedBlockWithSenders<ProviderBlock<Self::Provider>>, Vec<ProviderReceipt<Self::Provider>>), 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<ProviderBlock<Self::Provider>, ProviderReceipt<Self::Provider>>>>

Returns a handle to the pending block.

Data access in default (L1) trait method implementations.

Source

fn assemble_receipt( &self, tx: &ProviderTx<Self::Provider>, result: ExecutionResult, cumulative_gas_used: u64, ) -> ProviderReceipt<Self::Provider>

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

Source

fn assemble_block( &self, block_env: &BlockEnv, parent_hash: B256, state_root: B256, transactions: Vec<ProviderTx<Self::Provider>>, receipts: &[ProviderReceipt<Self::Provider>], ) -> ProviderBlock<Self::Provider>

Assembles a pending block.

Provided Methods§

Source

fn pending_block_env_and_cfg( &self, ) -> Result<PendingBlockEnv<ProviderBlock<Self::Provider>, ProviderReceipt<Self::Provider>>, 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<ProviderReceipt<Self::Provider>>)>, Self::Error>> + Send
where Self: SpawnBlocking,

Returns the locally built pending block

Source

fn assemble_block_and_receipts( &self, block_env: &BlockEnv, parent_hash: B256, state_root: B256, transactions: Vec<ProviderTx<Self::Provider>>, results: Vec<ExecutionResult>, ) -> (ProviderBlock<Self::Provider>, Vec<ProviderReceipt<Self::Provider>>)

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

Source

fn build_block( &self, cfg: CfgEnvWithHandlerCfg, block_env: BlockEnv, parent_hash: B256, ) -> Result<(SealedBlockWithSenders<ProviderBlock<Self::Provider>>, Vec<ProviderReceipt<Self::Provider>>), Self::Error>
where EthApiError: From<ProviderError>,

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§