Repository navigation
Commit 59a59a7
fix(merk): hash_for_link missing arms for indexed-tree primaries
Pre-existing PCIT bug surfaced by the V1 PCIT subquery test
(test_v1_proof_supports_count_indexed_tree_subquery).
Root cause: Tree::hash_for_link(tree_type) had arms only for
ProvableCountTree / ProvableSumTree / ProvableCountSumTree /
ProvableCountProvableSumTree. The three indexed-tree primaries
(ProvableSumIndexedTree, ProvableCountIndexedTree,
ProvableCountProvableSumIndexedTree) fell through to plain
self.hash() which uses node_hash (no aggregate baked in).
Meanwhile the proof emitter in merk/proofs/query/mod.rs keyed off
the node's feature_type (ProvableCountedMerkNode / etc.) and
correctly emitted KVCount-style proof ops, which the verifier
reconstructed via node_hash_with_count. Result: Merk's stored root
hash for a PCIT primary disagreed with what the proof reconstructed,
causing 'V1 mismatch in cidx lower-layer hash' on every V1 PCIT
subquery.
The bug was masked under the legacy non-provable CountIndexedTree
(now removed in Phase 1) because that variant used CountNode (count
not in hash) so the proof emitter also emitted plain KV nodes — the
two sides agreed by accident.
Fix: add arms in hash_for_link that delegate the indexed variants
to their plain Provable* counterparts. PCIT -> ProvableCountTree,
PSIT -> ProvableSumTree, PCPSIT -> ProvableCountProvableSumTree.
Test: un-#[ignore] the V1 PCIT subquery test (now passes), and add
a low-level regression test indexed_primaries_match_non_indexed_provable_hashes
in merk/tree/test_provable_count.rs asserting that every indexed
primary's hash_for_link result is byte-identical to the corresponding
non-indexed Provable* arm.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>1 parent c781b52 commit 59a59a7
3 files changed
Lines changed: 76 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1311 | 1311 | | |
1312 | 1312 | | |
1313 | 1313 | | |
1314 | | - | |
1315 | | - | |
1316 | 1314 | | |
1317 | 1315 | | |
1318 | 1316 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
768 | 768 | | |
769 | 769 | | |
770 | 770 | | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
771 | 785 | | |
772 | 786 | | |
773 | 787 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
115 | 177 | | |
0 commit comments