Skip to main content

Module builder

Module builder 

Source
Expand description

Block and checkpoint construction (SPEC §6).

§Modules

ModuleRequirementPurpose
block_builderBLD-001 — BLD-007Accumulates spend bundles → produces signed crate::L2Block
checkpoint_builderCKP-006Accumulates block hashes → produces crate::Checkpoint

§Design principle

“Build correct, validate everything” (SPEC §1.1): builders compute all derived header fields (Merkle roots, counts, costs, filter hash, version) so the output is structurally valid by construction. The validation pipeline (crate::validation) then re-derives everything from scratch and rejects any mismatch — it trusts nothing from the header. This split means builders never need to call validators internally, and validators never assume the block came from a builder.

§Chia parity

The builder pattern parallels chia-blockchain/chia/consensus/block_creation.py where create_unfinished_block() assembles header fields from body data. DIG’s builder goes further by enforcing cost/size budgets during accumulation (BLD-002/003), not just at validation time.

Modules§

block_builder
BlockBuilder — incremental construction of signed crate::L2Block instances.
checkpoint_builder
Incremental construction of crate::Checkpoint for an L2 epoch (CKP-006).