BlockAssembler

Trait BlockAssembler 

pub trait BlockAssembler<F>{
    type Block: Block;

    // Required method
    fn assemble_block(
        &self,
        input: BlockAssemblerInput<'_, '_, F, <Self::Block as Block>::Header>,
    ) -> Result<Self::Block, BlockExecutionError>;
}
Available on crate feature evm only.
Expand description

A type that knows how to assemble a block from execution results.

The BlockAssembler is the final step in block production. After transactions have been executed by the BlockExecutor, the assembler takes all the execution outputs and creates a properly formatted block.

§Responsibilities

The assembler is responsible for:

  • Setting the correct block header fields (gas used, receipts root, logs bloom, etc.)
  • Including the executed transactions in the correct order
  • Setting the state root from the post-execution state
  • Applying any chain-specific rules or adjustments

§Example Flow

// 1. Execute transactions and get results
let execution_result = block_executor.finish()?;

// 2. Calculate state root from changes
let state_root = state_provider.state_root(&bundle_state)?;

// 3. Assemble the final block
let block = assembler.assemble_block(BlockAssemblerInput {
    evm_env,           // Environment used during execution
    execution_ctx,     // Context like withdrawals, ommers
    parent,            // Parent block header
    transactions,      // Executed transactions
    output,            // Execution results (receipts, gas)
    bundle_state,      // All state changes
    state_provider,    // For additional lookups if needed
    state_root,        // Computed state root
})?;

§Relationship with Block Building

The assembler works together with:

  • NextBlockEnvAttributes: Provides the configuration for the new block
  • BlockExecutor: Executes transactions and produces results
  • BlockBuilder: Orchestrates the entire process and calls the assembler

Required Associated Types§

type Block: Block

The block type produced by the assembler.

Required Methods§

fn assemble_block( &self, input: BlockAssemblerInput<'_, '_, F, <Self::Block as Block>::Header>, ) -> Result<Self::Block, BlockExecutionError>

Builds a block. see BlockAssemblerInput documentation for more details.

Implementations on Foreign Types§

§

impl<'a, F, T> BlockAssembler<F> for &'a T
where F: BlockExecutorFactory, T: 'a + BlockAssembler<F> + ?Sized,

§

impl<F, T> BlockAssembler<F> for Arc<T>

§

type Block = <T as BlockAssembler<F>>::Block

§

fn assemble_block( &self, input: BlockAssemblerInput<'_, '_, F, <<Arc<T> as BlockAssembler<F>>::Block as Block>::Header>, ) -> Result<<Arc<T> as BlockAssembler<F>>::Block, BlockExecutionError>

Implementors§

§

impl<F, ChainSpec> BlockAssembler<F> for EthBlockAssembler<ChainSpec>
where F: for<'a> BlockExecutorFactory<ExecutionCtx<'a> = EthBlockExecutionCtx<'a>, Transaction = EthereumTxEnvelope<TxEip4844>, Receipt = Receipt>, ChainSpec: EthChainSpec + EthereumHardforks,

§

type Block = Block<EthereumTxEnvelope<TxEip4844>>