Repository navigation
fix(proof)!: prove a path through an empty provable tree (GROVE_V4) - #1010
Conversation
An aggregate-on-range proof (AggregateCountOnRange, AggregateSumOnRange, AggregateCountAndSumOnRange, leaf or carrier shape) whose path, or whose carrier key followed by a subquery_path, runs through an EMPTY ProvableCountTree, ProvableCountSumTree, ProvableSumTree or ProvableCountProvableSumTree above the aggregate terminal failed to generate with "Cannot create proof for empty tree". The V1 prover's empty-host arms descend into such a tree so that an empty terminal answers with the aggregate short-circuit's authenticated zero, but above the terminal the descent reaches an ordinary layer over an empty Merk, which has no Merk proof. From GROVE_V4 (new slot proof.empty_tree_above_aggregate_terminal: 1) those arms descend only into the aggregate terminal itself. An empty tree above it falls through to the generic empty-tree arm and is proved in its parent layer with no lower layer, as an empty tree of any other type there already was; its value hash binds it to the empty child root, and verify_query with the single-key query over the same path verifies the proof (the proof is byte-identical to that query's own proof). The aggregate verifiers are unchanged and still refuse a path that ends before the terminal. An empty terminal is still descended into, with identical proof bytes under GROVE_V3 and GROVE_V4. GROVE_V1..V3 keep failing, so released proofs and refusals do not change. Breaking: GroveDBOperationsProofVersions gains a field. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (10)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughGROVE_V4 proves an empty aggregate tree above an aggregate-on-range terminal in its parent layer without a lower layer. GROVE_V1–V3 retain the prior descent behavior. Aggregate verifiers remain unchanged, and empty trees at the terminal are still descended into. ChangesAggregate proofs through empty trees
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant AggregateRangeQuery
participant V1Prover
participant GroveVersion
participant ParentLayer
AggregateRangeQuery->>V1Prover: request aggregate-range proof
V1Prover->>GroveVersion: read empty-tree descent version
GroveVersion-->>V1Prover: return selector
V1Prover->>ParentLayer: prove empty tree without a lower layer when above terminal
Merge Risk: ⚪ Minimal · up to No identified issue blocks merging the versioned empty-tree proof behavior after normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change is narrowly version-gated and preserves the inspected proof-authentication controls. The new proofs still require different handling from ordinary aggregate proofs. Correct downstream fallback and trusted-root comparison were not established, so some integration uncertainty remains. Retained concerns Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 73.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 30 functions across 8 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Waiting for bot review — coderabbitai ✓ · thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
|
✅ Final review complete — no blockers (commit 0741852) · triage: normal · Phase 2 only (no Phase 1 for this repository) |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1010 +/- ##
===========================================
+ Coverage 93.14% 93.19% +0.04%
===========================================
Files 336 336
Lines 105645 105687 +42
===========================================
+ Hits 98399 98490 +91
+ Misses 7246 7197 -49
🚀 New features to boost your workflow:
|
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 2 only (no Phase 1 for this repository)
The GROVE_V4 change correctly limits descent into empty aggregate trees to the aggregate terminal and reuses the existing authenticated empty-tree handling above it, while preserving older-version behavior. The aggregate verifiers’ continued refusal is real, but extending their result semantics is explicitly outside this PR’s prover-and-single-key-fallback contract; no in-scope actionable findings remain. Validation was static only; the supplied exact-head CI snapshot reports all Ubuntu test shards, linting, formatting, security audit, and book build passing, with PR Hygiene pending.
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
normalbygpt-6.1-sol(effort low) — The version-gated change to prove_subqueries_v1 in grovedb/src/operations/proof/generate.rs changes authenticated proof generation, but its contained empty-tree routing logic is not large or intricate enough to meet the critical tier. - Phase 1 reviewers: not run (disabled for this repository)
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort high); agentphase2-reviewer
|
Bots are done — your move: post |
Protocol versions up to 13 verify and answer as released: - The six range-total verifiers keep version 0 as released. A new version 1, selected only by protocol version 14 (DRIVE_VERIFY_METHOD_VERSIONS_V3), wraps it and reads a proof that the range holds nothing (a missing key, or an empty tree of a kind the read does not aggregate) as a zero total or no carrier branch (`or_empty_range_total`). - The unproven range total reads an absent value as zero only where that verifier is at version 1 (`aggregate_or_zero_when_absent`); before, it fails as released. - The composite verifier gains a version 1 (protocol version 14) that reads sum-bearing items as documents; version 0 reads them as released. Other fixes: - The chained verifier reads a sum-bearing outer document. Edited in place: a chained query needs an indexOnly inner type, which only protocol version 14 parses. - Chained and composite reads without a proof are refused before any read when an indexOnly index lacks a property, as a documents query through it is (`refuse_an_uncovered_index_only_projection`). - drive-abci maps a missing required property to a query error only for indexOnly documents, with the refusal text Drive shares. - Two preallocated indexes sharing leading properties queue each tree once. - The meta-schema v3 description and the book list only the `where` values a reference can name, and say group counts need rangeCountable. - Counter chain comments, private range refusals, the shared absence predicate at three more sites. Tests: the absent-brand total errors and its proof is refused at protocol version 13 and both read zero at 14; a carrier under an empty sum tree; a chained join into summable posts; the chained no-proof refusal (Drive and drive-abci; the join tests use a like that byLiker holds whole); composite refusals; two preallocated counters sharing a prefix; a range total through an empty count tree (ignored until the grovedb pin carries dashpay/grovedb#1010); a shared dpp refusal assertion, widget helpers, a literal Swift assertion. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e version (#1011) #1010 gated its prover change behind proof.empty_tree_above_aggregate_terminal so GROVE_V1..V3 kept their behaviour, but that behaviour was a failure: proving an aggregate-on-range query whose path runs through an empty provable tree above the terminal always ended in "Cannot create proof for empty tree". No proof that generated before changes, so the gate protected nothing and cost a public version field, a dispatcher, and GROVE_V3 users keeping the failure. prove_subqueries_v1 now descends into an empty aggregate tree only when it is the aggregate terminal, at every grove version that proves aggregate queries (GROVE_V3 and later; GROVE_V1 and V2 use the untouched V0 prover). The slot, its values in GROVE_V1..V4 and the dispatcher are removed; the tests run under GROVE_V3 and GROVE_V4; the changelog entry and the book paragraph drop the version. The slot was never released, so nothing breaks relative to the last release. Co-authored-by: Claude Opus 5.5 <[email protected]>
Basic explanation
Some range totals cannot be proved today. If the path to the counted range goes through a provable count or sum tree that is still empty, the prover fails with "Cannot create proof for empty tree", even though the answer (zero) is obvious. With this change, from
GROVE_V4, the prover proves that tree empty and stops there, the same way it already proves any other empty tree it meets. Older grove versions behave exactly as before.Issue being fixed or feature implemented
Dash Platform keeps a provable count tree for an index's first property from the moment a contract is registered. Before the first document, that tree is empty. A count over a range below it (for example
brand == "acme" AND color > "blue"through an index[brand, color], while arangeCountableindex on[brand]makesbrandaProvableCountTree) builds this path query:Before (any grove version):
The unproven read answers zero, so a client asking for a proof gets an internal error for a valid query. The same happens for sums (an empty
ProvableSumTree), count-and-sum reads (an emptyProvableCountProvableSumTree), and carrier queries whoseINkeys sit under the empty tree.After (
GROVE_V4):What was done?
prove_subqueries_v1(grovedb/src/operations/proof/generate.rs), the empty-host arms forProvableCountTree/ProvableCountSumTree/ProvableCountProvableSumTree(count),ProvableSumTree/ProvableCountProvableSumTree(sum) andProvableCountProvableSumTree(count and sum) descend into any empty tree of those types the query routes through. That descent is meant for the aggregate terminal, whereaggregate_at_depthshort-circuits and an empty Merk answers zero. Above the terminal, the child is an ordinary layer over an empty Merk, andgenerate_merk_proofcannot prove an empty Merk.descends_into_empty_aggregate_tree, keeps those arms for the aggregate terminal only. An empty tree above the terminal falls through to the existing generic empty-tree arm: it is proved in its parent layer with no lower layer (and charged as an empty layer), and its value hash binds it to the empty child root. The resulting proof is byte-identical to the proof of the single-key query over the same path.GroveDBOperationsProofVersions::empty_tree_above_aggregate_terminal:0inGROVE_V1..GROVE_V3(always descend, the old behaviour) and1inGROVE_V4(descend only at the terminal). Any other value is aVersionError. Released grove versions produce the same proofs and the same refusals.verify_querywith the single-key query over the same path verifies them, which is what Platform's verifiers fall back to. Extending the aggregate verifiers to read such a proof as zero is left out: it touches about a dozen descent sites across the three axes and needs a decision on how an empty tree at the terminal and an empty carrier key should read.GROVE_V3andGROVE_V4.CHANGELOG.mdentry, and a paragraph in the book's "Empty subtrees" section (docs/book/src/aggregate-count-queries.md).How Has This Been Tested?
New module
grovedb/src/tests/aggregate_through_empty_tree_tests.rs. Each test runs six cases: count over an empty PCT, PCST and PCPS; sum over an empty PST and PCPS; count and sum over an empty PCPS.grove_v3_still_refuses_to_prove_through_an_empty_aggregate_tree: the leaf and carrier shapes still fail underGROVE_V3, and the plain single-key query proves and verifies.grove_v4_proves_a_leaf_aggregate_through_an_empty_aggregate_tree: the proof generates, has no layer under the empty tree, is byte-identical to the single-key query's proof, andverify_queryreturns an empty result against the real root; the aggregate verifiers' refusal is pinned.grove_v4_proves_a_carrier_aggregate_whose_path_ends_in_an_empty_aggregate_tree: the same for the carrier shape.grove_v4_proves_a_carrier_key_that_is_an_empty_aggregate_tree_above_the_terminal: a populated key is descended into, an empty one is proved without a layer.an_empty_aggregate_terminal_is_proved_identically_under_grove_v3_and_v4: unchanged bytes at the terminal, verifying to zero.a_populated_tree_cannot_be_passed_off_as_the_empty_tree_on_the_path: an honest proof over a populated tree, rewritten to claim an empty tree with its lower layer dropped, is rejected byverify_query("empty tree value hash mismatch", the [audit][P20] V1 descent can treat unbound tree classification as verified absence #869 binding) and by the aggregate verifier.an_unknown_empty_tree_above_aggregate_terminal_version_is_refused: slot value 2 is aVersionError.With the old
generate.rsrestored, the threegrove_v4_proves_*tests fail with "Cannot create proof for empty tree", and the unknown-version test fails too.cargo test -p grovedb -p grovedb-version: grovedb lib 3545 passed (8 ignored), integration tests passed, grovedb-version 56 passed, doc tests passed.cargo clippy -p grovedb -p grovedb-version --all-targets -- -D warningsandcargo fmt --all -- --checkare clean.Breaking Changes
GroveDBOperationsProofVersionsgains a public field,empty_tree_above_aggregate_terminal, so code that builds the struct by hand must set it. Proof bytes and refusals underGROVE_V1..GROVE_V3do not change.Checklist:
For repository code-owners and collaborators only
🤖 Generated with Claude Code
Summary by CodeRabbit
PR Hygiene ·
0741852/self-reviewedWhen every box is checked the
PR Hygienecheck passes and this can merge.