Skip to content

Commit 86b527b

Browse files
docs: clarify appendix-a Element/TreeType discriminant columns
CodeRabbit flagged the TreeType column for ProvableSumTree as "should be 17" — the technical claim was wrong (11 is the correct TreeType discriminant per `merk/src/tree_type/mod.rs:77`), but the confusion was fair: the column header "TreeType" was ambiguous and the table had several pre-existing inaccuracies in adjacent rows. This commit fixes the ambiguity AND the bugs. Changes: - Rename column header from "TreeType" to "TreeType disc" and add an intro paragraph explaining that "Element disc" and "TreeType disc" are discriminants of two SEPARATE enums. - Add the TreeType-variant label to every tree row for consistency (some had it, most didn't). The new format is `N (VariantName)` — e.g. `5 (ProvableCountTree)` — which CodeRabbit-style auto-review can't misread. - Fix three pre-existing wrong TreeType disc values: `BigSumTree`: 4 -> 2 `CountTree`: 2 -> 3 `CountSumTree`: 3 -> 4 (These were drift from the actual `TreeType::discriminant()` implementation; the file had `4 (BigSumTree)` etc. but those labels were wrong.) - Swap the row order at Element discriminants 8 and 9 to match the actual `Element` enum order: 8 = `ProvableCountTree` (was incorrectly listed as `ItemWithSumItem`) 9 = `ItemWithSumItem` (was incorrectly listed as `ProvableCountTree`) - Tighten the `ProvableCountSumTree` Purpose blurb to note "only count in hash" since the sum is tracked metadata, not bound — this is the half-step variant a future `ProvableCountAndSumTree` would replace. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent b1027dc commit 86b527b

1 file changed

Lines changed: 20 additions & 12 deletions

File tree

docs/book/src/appendix-a.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
# Appendix A: Complete Element Type Reference
22

3-
| Discriminant | Variant | TreeType | Fields | Cost Size | Purpose |
3+
> **Reading the table.** "Element disc" is the bincode discriminant of
4+
> the `Element` enum (one byte; persisted at the start of every
5+
> serialized element). "TreeType disc" is the discriminant of the
6+
> *separate* `TreeType` enum in `merk/src/tree_type/mod.rs` — it is NOT
7+
> the same numbering. Most rows list both the TreeType disc and its
8+
> variant name (e.g. `0 (NormalTree)`) to keep the distinction obvious;
9+
> `N/A` means the Element variant is not a tree.
10+
11+
| Element disc | Variant | TreeType disc | Fields | Cost Size | Purpose |
412
|---|---|---|---|---|---|
513
| 0 | `Item` | N/A | `(value, flags)` | varies | Basic key-value storage |
614
| 1 | `Reference` | N/A | `(path, max_hop, flags)` | varies | Link between elements |
715
| 2 | `Tree` | 0 (NormalTree) | `(root_key, flags)` | TREE_COST_SIZE | Container for subtrees |
816
| 3 | `SumItem` | N/A | `(value, flags)` | varies | Contributes to parent sum |
917
| 4 | `SumTree` | 1 (SumTree) | `(root_key, sum, flags)` | SUM_TREE_COST_SIZE | Maintains sum of descendants |
10-
| 5 | `BigSumTree` | 4 (BigSumTree) | `(root_key, sum128, flags)` | BIG_SUM_TREE_COST_SIZE | 128-bit sum tree |
11-
| 6 | `CountTree` | 2 (CountTree) | `(root_key, count, flags)` | COUNT_TREE_COST_SIZE | Element counting tree |
12-
| 7 | `CountSumTree` | 3 (CountSumTree) | `(root_key, count, sum, flags)` | COUNT_SUM_TREE_COST_SIZE | Combined count + sum |
13-
| 8 | `ItemWithSumItem` | N/A | `(value, sum, flags)` | varies | Item with sum contribution |
14-
| 9 | `ProvableCountTree` | 5 | `(root_key, count, flags)` | COUNT_TREE_COST_SIZE | Provable count tree |
15-
| 10 | `ProvableCountSumTree` | 6 | `(root_key, count, sum, flags)` | COUNT_SUM_TREE_COST_SIZE | Provable count + sum |
16-
| 11 | `CommitmentTree` | 7 | `(total_count: u64, chunk_power: u8, flags)` | 12 | ZK-friendly Sinsemilla + BulkAppendTree |
17-
| 12 | `MmrTree` | 8 | `(mmr_size: u64, flags)` | 11 | Append-only MMR log |
18-
| 13 | `BulkAppendTree` | 9 | `(total_count: u64, chunk_power: u8, flags)` | 12 | High-throughput append-only log |
19-
| 14 | `DenseAppendOnlyFixedSizeTree` | 10 | `(count: u16, height: u8, flags)` | 6 | Dense fixed-capacity Merkle storage |
18+
| 5 | `BigSumTree` | 2 (BigSumTree) | `(root_key, sum128, flags)` | BIG_SUM_TREE_COST_SIZE | 128-bit sum tree |
19+
| 6 | `CountTree` | 3 (CountTree) | `(root_key, count, flags)` | COUNT_TREE_COST_SIZE | Element counting tree |
20+
| 7 | `CountSumTree` | 4 (CountSumTree) | `(root_key, count, sum, flags)` | COUNT_SUM_TREE_COST_SIZE | Combined count + sum |
21+
| 8 | `ProvableCountTree` | 5 (ProvableCountTree) | `(root_key, count, flags)` | COUNT_TREE_COST_SIZE | Provable count tree |
22+
| 9 | `ItemWithSumItem` | N/A | `(value, sum, flags)` | varies | Item with sum contribution |
23+
| 10 | `ProvableCountSumTree` | 6 (ProvableCountSumTree) | `(root_key, count, sum, flags)` | COUNT_SUM_TREE_COST_SIZE | Provable count + sum (only count in hash) |
24+
| 11 | `CommitmentTree` | 7 (CommitmentTree) | `(total_count: u64, chunk_power: u8, flags)` | 12 | ZK-friendly Sinsemilla + BulkAppendTree |
25+
| 12 | `MmrTree` | 8 (MmrTree) | `(mmr_size: u64, flags)` | 11 | Append-only MMR log |
26+
| 13 | `BulkAppendTree` | 9 (BulkAppendTree) | `(total_count: u64, chunk_power: u8, flags)` | 12 | High-throughput append-only log |
27+
| 14 | `DenseAppendOnlyFixedSizeTree` | 10 (DenseAppendOnlyFixedSizeTree) | `(count: u16, height: u8, flags)` | 6 | Dense fixed-capacity Merkle storage |
2028
| 15 | `NonCounted` | wrapper | `Box<Element>` | inner + 1 byte | Opts inner out of parent count aggregation |
2129
| 16 | `NotSummed` | wrapper | `Box<Element>` | inner + 1 byte | Opts inner out of parent sum aggregation |
22-
| 17 | `ProvableSumTree` | 11 | `(root_key, sum: i64, flags)` | SUM_TREE_COST_SIZE | Sum baked into hash (see [Aggregate Sum on Range Queries](aggregate-sum-on-range-queries.md)) |
30+
| 17 | `ProvableSumTree` | 11 (ProvableSumTree) | `(root_key, sum: i64, flags)` | SUM_TREE_COST_SIZE | Sum baked into hash (see [Aggregate Sum on Range Queries](aggregate-sum-on-range-queries.md)) |
2331

2432
**Notes:**
2533
- Discriminants 11–14 are **non-Merk trees**: data lives outside a child Merk subtree

0 commit comments

Comments
 (0)