dig_block/builder/mod.rs
1//! Block and checkpoint construction ([SPEC §6](docs/resources/SPEC.md)).
2//!
3//! ## Modules
4//!
5//! | Module | Requirement | Purpose |
6//! |--------|------------|---------|
7//! | [`block_builder`] | BLD-001 — BLD-007 | Accumulates spend bundles → produces signed [`crate::L2Block`] |
8//! | [`checkpoint_builder`] | CKP-006 | Accumulates block hashes → produces [`crate::Checkpoint`] |
9//!
10//! ## Design principle
11//!
12//! **"Build correct, validate everything"** ([SPEC §1.1](docs/resources/SPEC.md)): builders compute all
13//! derived header fields (Merkle roots, counts, costs, filter hash, version) so the output is structurally
14//! valid by construction. The validation pipeline ([`crate::validation`]) then re-derives everything from
15//! scratch and rejects any mismatch — it trusts nothing from the header. This split means builders never
16//! need to call validators internally, and validators never assume the block came from a builder.
17//!
18//! ## Chia parity
19//!
20//! The builder pattern parallels [`chia-blockchain/chia/consensus/block_creation.py`](https://github.com/Chia-Network/chia-blockchain/blob/main/chia/consensus/block_creation.py)
21//! where `create_unfinished_block()` assembles header fields from body data. DIG's builder goes further
22//! by enforcing cost/size budgets during accumulation (BLD-002/003), not just at validation time.
23
24pub mod block_builder;
25pub mod checkpoint_builder;