Skip to content

fix: enforce succinctness and completeness for non-Merk V1 proof verification - #415

Merged
QuantumExplorer merged 1 commit into
developfrom
fix/v1-non-merk-query-succinctness
Feb 27, 2026
Merged

QuantumExplorer merged 1 commit into
developfrom
fix/v1-non-merk-query-succinctness

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Feb 27, 2026 •

Copy link
Copy Markdown
Member

Summary

  • MMR, BulkAppendTree, and DenseTree verifiers now enforce that V1 proofs contain exactly the entries requested by the query — no extra entries (soundness) and no missing entries (completeness)
  • DenseAppendOnlyFixedSizeTree added to check_subtree_exists match arm, fixing is_empty_tree and other APIs that rely on this check for dense tree subtree paths
  • u64 overflow fix in range expansion helpers — s + 1 replaced with s.saturating_add(1) to prevent panic when s == u64::MAX

Test plan

  • 3 new succinctness tests: test_bulk_append_tree_v1_proof_disjoint_query_succinctness, test_dense_tree_v1_proof_disjoint_query_succinctness, test_mmr_tree_v1_proof_disjoint_query_succinctness
  • 1 new regression test: test_is_empty_tree_dense_tree_subtree
  • All 565 existing tests pass

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced proof verification with comprehensive soundness and completeness checks to ensure all requested data is included and no unrequested data is proven.
  • Tests

    • Added regression tests for empty tree behavior validation.
    • Added succinctness verification tests across multiple tree type scenarios.

…fication

MMR, BulkAppendTree, and DenseTree verifiers now check that proofs contain
exactly the entries requested by the query — no extras (soundness) and no
missing (completeness). Also adds the missing DenseAppendOnlyFixedSizeTree
arm in check_subtree_exists and fixes potential u64 overflow in range
expansion helpers.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@coderabbitai

coderabbitai Bot commented Feb 27, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 793d116 and 5930d1a.

📒 Files selected for processing (4)
  • grovedb/src/operations/get/mod.rs
  • grovedb/src/operations/proof/verify.rs
  • grovedb/src/tests/dense_tree_tests.rs
  • grovedb/src/tests/v1_proof_tests.rs

📝 Walkthrough

Walkthrough

This PR enhances GroveDB's proof operations by extending get path handling to treat DenseAppendOnlyFixedSizeTree equivalently to BulkAppendTree, implementing comprehensive soundness and completeness verification checks across multiple lower-layer proof types (MMR, BulkAppendTree, DenseTree), and adding corresponding regression and V1 proof tests.

Changes

Cohort / File(s) Summary
Get Path Handling
grovedb/src/operations/get/mod.rs
Extends cost-wrapping logic to include DenseAppendOnlyFixedSizeTree alongside BulkAppendTree in subtree existence checks.
Proof Verification Enhancements
grovedb/src/operations/proof/verify.rs
Adds comprehensive soundness and completeness validation for lower-layer proofs (MMR, BulkAppendTree, DenseTree). Introduces helper to expand QueryItems into position sets, enforces position caps, and integrates sub-query derivation into verification flow. Replaces arithmetic with saturating operations for safer bounds handling.
Test Coverage
grovedb/src/tests/dense_tree_tests.rs, grovedb/src/tests/v1_proof_tests.rs
Adds regression test for is_empty_tree behavior on DenseAppendOnlyFixedSizeTree subtrees and expands V1 proof succinctness tests across multiple tree types with disjoint query scenarios.

Sequence Diagram

sequenceDiagram
    participant Client as Client/Caller
    participant Verify as Verification Logic
    participant SubQuery as Sub-Query Derivation
    participant Check as Soundness/Completeness Check
    participant Layer as Lower-Layer Proof
    participant Result as Result Set

    Client->>Verify: Verify proof with query items
    Verify->>SubQuery: Derive sub-query items for path
    SubQuery->>SubQuery: Expand items to position set
    SubQuery-->>Check: Return expected positions
    
    Verify->>Layer: Extract proven indices/positions
    Layer-->>Check: Return proven positions
    
    Check->>Check: Validate completeness<br/>(all expected present?)
    Check->>Check: Validate soundness<br/>(no unrequested items?)
    
    alt Validation passes
        Check->>Result: Filter results by query match
        Result-->>Client: Return verified results
    else Validation fails
        Check-->>Client: Return error
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Dense trees now dance with equal grace,
Proofs verified in every place,
With soundness checks and completeness glow,
Completeness checks and completeness flow—
A bunny's code, both safe and sound! 🌿✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: enforcing succinctness and completeness checks for non-Merk V1 proof verification, which is the core objective of the PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/v1-non-merk-query-succinctness

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 and usage tips.

@QuantumExplorer QuantumExplorer left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self Reviewed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant