Skip to content

fix(proof): prove a path through an empty provable tree at every grove version - #1011

Merged
QuantumExplorer merged 1 commit into
developfrom
fix/ungate-empty-tree-above-aggregate-proof
Oct 6, 2026
Merged

QuantumExplorer merged 1 commit into
developfrom
fix/ungate-empty-tree-above-aggregate-proof

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Basic explanation

#1010 fixed range totals that could not be proved when their path ran through an empty provable count or sum tree, but only from GROVE_V4. That version gate is not needed, so this removes it: the prover now proves such a path at every grove version that proves aggregate queries (GROVE_V3 and later). Nothing that already worked changes, because every proof the fix touches used to fail.

Issue being fixed or feature implemented

#1010 gated its prover change behind a new slot, proof.empty_tree_above_aggregate_terminal (0 in GROVE_V1..GROVE_V3, 1 in GROVE_V4), so that released grove versions kept their exact behaviour. That behaviour was a failure: under GROVE_V3, proving an aggregate-on-range query whose path runs through an empty provable tree above the terminal always ends in "Cannot create proof for empty tree". Gating it kept an error, not a proof anyone could rely on.

The gate only protects bytes no caller has, and it costs a public field in GroveDBOperationsProofVersions, a v0/v1 dispatcher, and GROVE_V3 users (Dash Platform's shipped protocol versions) keeping the failure.

Before (GROVE_V3, path [.., "widget", "brand", "acme", "color"], brand an empty ProvableCountTree):

prove_query(AggregateCountOnRange(RangeAfter("blue"..))) -> Err(.. "Cannot create proof for empty tree")

After (GROVE_V3 and GROVE_V4 alike):

prove_query(..) -> Ok(proof)   // brand proved empty in its parent layer, no lower layer
verify_query(proof, PathQuery::new_single_key([.., "widget", "brand", "acme"], "color")) -> Ok((root, []))

What was done?

  • prove_subqueries_v1 decides directly whether to descend into an empty aggregate tree: only when it is the aggregate terminal (validated.aggregate_at_depth(path.len() + 1)), as GROVE_V4 did. The descends_into_empty_aggregate_tree dispatcher and its _v0 / _v1 are removed.
  • GroveDBOperationsProofVersions::empty_tree_above_aggregate_terminal is removed, with its value in GROVE_V1..GROVE_V4 and its notes in grovedb_versions.rs and v4.rs.
  • GROVE_V1 and GROVE_V2 use the V0 prover, which this does not touch.
  • Proofs that generated before do not change: a descent into an empty tree above the terminal always failed, and an empty tree that is the terminal is still descended into, with identical bytes (an_empty_aggregate_terminal_is_proved_identically_under_grove_v3_and_v4). Verifiers are unchanged.
  • The changelog entry of fix(proof)!: prove a path through an empty provable tree (GROVE_V4) #1010 and the book's "Empty subtrees" paragraph no longer mention a version.

How Has This Been Tested?

grovedb/src/tests/aggregate_through_empty_tree_tests.rs, over every empty provable tree type with each aggregate it serves:

  • proves_a_leaf_aggregate_through_an_empty_aggregate_tree, proves_a_carrier_aggregate_whose_path_ends_in_an_empty_aggregate_tree and proves_a_carrier_key_that_is_an_empty_aggregate_tree_above_the_terminal now run under GROVE_V3 and GROVE_V4: the proof generates with no lower layer under the empty tree, equals the single-key query's proof, verifies with verify_query to the real root, and the aggregate verifiers' refusal is pinned.
  • an_empty_aggregate_terminal_is_proved_identically_under_grove_v3_and_v4 and a_populated_tree_cannot_be_passed_off_as_the_empty_tree_on_the_path are unchanged.
  • The GROVE_V3 refusal test and the unknown-slot-version test are removed with the slot.
  • With the old always-descend rule put back, the three proves_* tests fail.

cargo test -p grovedb -p grovedb-version, cargo clippy -p grovedb -p grovedb-version --all-targets -- -D warnings and cargo fmt --all -- --check pass.

Breaking Changes

None relative to the last release: empty_tree_above_aggregate_terminal was added by #1010 and has not been released. Code built against develop since #1010 that sets the field by hand must drop it. Under GROVE_V3, queries that failed to prove now produce a proof; no proof that generated before changes.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

PR Hygiene · 1e3c230

  • Bots — coderabbitai ✓ · thepastaclaw not yet — /skip-bots proceeds without the ones not yet reported
  • Self-review — post /self-reviewed
  • Within your 5 open PRs
  • Build running
  • Approvals — you own every area touched; none needed

When every box is checked the PR Hygiene check passes and this can merge.

Summary by CodeRabbit

  • Bug Fixes
    • Empty aggregate trees above an aggregate terminal can now be proved without descending into a lower layer, starting with Grove V3. Previously, this proof generation failed for versions supporting aggregate queries.
    • Aggregate verifiers continue to reject proofs that omit a descent required for verification.
  • Documentation
    • Updated the aggregate-query guidance to describe this behavior without distinguishing between Grove versions.

…e version

#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]>
@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d5f5cc93-0250-4074-b541-65108bade013
📥 Commits

Reviewing files that changed from the base of the PR and between 02db008 and 1e3c230.

📒 Files selected for processing (9)
  • CHANGELOG.md
  • docs/book/src/aggregate-count-queries.md
  • grovedb-version/src/version/grovedb_versions.rs
  • grovedb-version/src/version/v1.rs
  • grovedb-version/src/version/v2.rs
  • grovedb-version/src/version/v3.rs
  • grovedb-version/src/version/v4.rs
  • grovedb/src/operations/proof/generate.rs
  • grovedb/src/tests/aggregate_through_empty_tree_tests.rs
💤 Files with no reviewable changes (5)
  • grovedb-version/src/version/v2.rs
  • grovedb-version/src/version/grovedb_versions.rs
  • grovedb-version/src/version/v3.rs
  • grovedb-version/src/version/v1.rs
  • grovedb-version/src/version/v4.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Proof generation no longer uses a GroveVersion setting to decide whether to descend into empty aggregate trees. It descends only when the empty tree is the aggregate terminal. Tests cover parent-layer proofs at GROVE_V3 and GROVE_V4, and documentation removes the V4-only boundary.

Changes

Empty aggregate-tree proofs

Layer / File(s) Summary
Apply the depth-based proof rule
grovedb-version/src/version/*, grovedb/src/operations/proof/generate.rs
The proof generator now uses the aggregate terminal’s depth to decide whether to descend into an empty aggregate tree. The version configurations no longer include the related proof-version slot.
Validate proofs across versions
grovedb/src/tests/aggregate_through_empty_tree_tests.rs, docs/book/src/aggregate-count-queries.md, CHANGELOG.md
Tests cover the proof behavior at GROVE_V3 and GROVE_V4, including aggregate-verifier rejection when a proof omits a required descent. Documentation and the changelog remove the GROVE_V4-only boundary.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 1e3c2

This change makes proofs through empty aggregate trees work at GROVE_V3 and later, and it removes an unreleased version setting. No merge-blocking issue was found. Code built against develop that sets the removed slot will need to drop it.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 1e3c2

The change preserves the inspected proof-authentication controls and does not establish a new security weakness. It nevertheless changes GROVE_V3 failure behavior and removes a public configuration field; downstream integration compatibility remains unconfirmed.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The established exposure is proof correctness for aggregate queries traversing empty provable-tree ancestors, including GROVE_V3 callers. The inspected change does not grant new storage-write authority; tenant, service, and deployment exposure beyond this library is not established.

Security Findings and Attack Paths

  • observed — The inspected adversarial test replaces a populated tree with empty-tree bytes while retaining its committed hash and removing its lower layer. Its assertions require public verification to reject the value-hash mismatch and aggregate verification to reject the forgery. This is V4 test-source counterevidence, not an executed test result.

Trust Boundaries and Controls

  • observed — Untrusted empty-tree element bytes are bound to the committed value hash before the verifier treats a matching subtree as empty. A nonempty matching tree without a lower layer is rejected. The public verifier returns a reconstructed root; the inspected tests compare it against the database root.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 72.73% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 2 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: proving paths through empty provable trees at every Grove version.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 72.73% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 2 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Waiting for bot review — coderabbitai ✓ · thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added the waiting-bots Waiting for the review bots to report on this head label Oct 6, 2026
@thepastaclaw

Copy link
Copy Markdown
Contributor

🕓 Review not started yet because the new head is waiting for the 30-minute push debounce.

  • Request normal review — click when the PR is ready for review.
  • Request priority review — click to move this review to the front of the queue.

Commit 1e3c230. Normal review starts when eligible; priority review starts as soon as a slot is available.

@codecov

codecov Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.18%. Comparing base (02db008) to head (1e3c230).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1011      +/-   ##
===========================================
- Coverage    93.19%   93.18%   -0.01%     
===========================================
  Files          336      336              
  Lines       105687   105653      -34     
===========================================
- Hits         98490    98449      -41     
- Misses        7197     7204       +7     
Components Coverage Δ
grovedb-core 91.57% <100.00%> (-0.02%) ⬇️
merk 94.03% <ø> (ø)
storage 91.94% <ø> (ø)
commitment-tree 95.62% <ø> (ø)
mmr 95.43% <ø> (ø)
bulk-append-tree 93.72% <ø> (ø)
element 97.18% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@QuantumExplorer
QuantumExplorer merged commit c4362dc into develop Oct 6, 2026
16 of 17 checks passed
@QuantumExplorer
QuantumExplorer deleted the fix/ungate-empty-tree-above-aggregate-proof branch October 6, 2026 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-bots Waiting for the review bots to report on this head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants