pub trait BlockAssembler<F: BlockExecutorFactory> {
type Block: Block;
// Required method
fn assemble_block(
&self,
input: BlockAssemblerInput<'_, '_, F, <Self::Block as Block>::Header>,
) -> Result<Self::Block, BlockExecutionError>;
}
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 blockBlockExecutor
: Executes transactions and produces resultsBlockBuilder
: Orchestrates the entire process and calls the assembler
Required Associated Types§
Required Methods§
Sourcefn assemble_block(
&self,
input: BlockAssemblerInput<'_, '_, F, <Self::Block as Block>::Header>,
) -> Result<Self::Block, BlockExecutionError>
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.