Expand description
§Architecture Overview
The block building mechanism operates through two coordinated tasks:
- Block Builder Task: Orchestrates the timing and execution of parachain block production
- Collator Task: Processes built blocks into collations for relay chain submission
§Block Builder Task Details
The block builder task manages block production timing and execution through an iterative process:
- Awaits the next production signal from the internal timer
- Retrieves the current best relay chain block and identifies a valid parent block (see [find_parent_for_building][cumulus_client_consensus_common::find_parent_for_building] for parent selection criteria)
- Validates that:
- The parachain has an assigned core on the relay chain
- No block has been previously built on the target core
- Executes block building and import operations
- Transmits the completed block to the collator task
§Block Production Timing
When a block is produced is determined by the following parameters:
- Parachain slot duration
- Number of assigned parachain cores
- The
target_block_rateruntime API, which determines how many blocks to produce per relay chain slot. When this API is unavailable, the block builder falls back to one block per core. When the target exceeds the number of cores, multiple blocks are bundled per core.
§Timing Examples
The following table demonstrates various timing configurations and their effects. The “AURA Slot” column shows which author is responsible for the block.
| Slot Duration (ms) | Cores | Production Attempts (ms) | AURA Slot |
|---|---|---|---|
| 2000 | 3 | 0, 2000, 4000, 6000 | 0, 1, 2, 3 |
| 6000 | 1 | 0, 6000, 12000, 18000 | 0, 1, 2, 3 |
| 6000 | 3 | 0, 2000, 4000, 6000 | 0, 0, 0, 1 |
| 12000 | 1 | 0, 6000, 12000, 18000 | 0, 0, 1, 1 |
| 12000 | 3 | 0, 2000, 4000, 6000 | 0, 0, 0, 0 |
§Collator Task Details
The collator task receives built blocks from the block builder task and performs two primary functions:
- Block compression
- Submission to the collation-generation subsystem
Structs§
- Params
- Parameters for
run. - Slot
Based Block Import - Special block import for the slot based collator.
- Slot
Based Block Import Handle - Handle for receiving the block and the storage proof from the
SlotBasedBlockImport.
Functions§
- run
- Run aura-based block building and collation task.