Skip to content

feat(private-document-store)!: read and prove a store's entries by position range (GROVE_V4) - #1027

Merged
QuantumExplorer merged 5 commits into
developfrom
feat/private-document-store-range-reads
Nov 1, 2026
Merged

QuantumExplorer merged 5 commits into
developfrom
feat/private-document-store-range-reads

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Basic explanation

What this does: a PrivateDocumentStore keeps fixed-size entries in append order, but until now nothing could read them back a page at a time, and a proof could not reach below the store element: V1 proofs refused any subquery into a store. This adds both. private_document_store_get_range reads the entries at positions [start, start + limit), and the existing prove_bulk_position_range / verify_bulk_position_range_proof now accept a store, as does any V1 path query that descends into one.

Value: Dash Platform's private document types (protocol version 15) keep each private type's encrypted entries in a store. Wallets page through a store from their cursor to find entries meant for them, and need to trust what a node returns. With this, a node can serve a page with a proof that binds it to the GroveDB root hash, and a reader knows when it reached the end (the proof authenticates the store's count).

Risks: low. A store's data is its bulk append tree, stored exactly as a BulkAppendTree's, so the proof is the existing bulk proof; the only new step is on the verifier, which binds the bulk root through the store's committed config, blake3("pds_state" || config_hash || bulk_state_root), using entry_size and chunk_power from the authenticated element. The proof envelope gains no variant. Everything is gated by two new GROVE_V4 slots (0 before), so a version without them refuses as before. V0 proofs are untouched.

Before:

prove_query(path [root], key docs, subquery: every position)
  -> Err(NotSupported("V1 proofs do not yet support subqueries into PrivateDocumentStore elements"))
prove_bulk_position_range([root], docs, 0, 10)
  -> Err(InvalidInput("prove_bulk_position_range requires a BulkAppendTree or CommitmentTree element"))

After (a store of 10 entries, chunk power 2: two compacted chunks and two buffered entries):

private_document_store_get_range([root], docs, 6, 4)   -> entries 6, 7, 8, 9; total_count 10
prove_bulk_position_range([root], docs, 6, 4)
  -> verify_bulk_position_range_proof -> (root hash of the database, entries 6..9, total_count 10)
prove_query(path [root], key docs, subquery: every position)
  -> verify_query -> items at keys 0..9 (big-endian positions), root hash of the database

Issue being fixed or feature implemented

Range reads and proofs for PrivateDocumentStore, which Dash Platform's query of a private document type's entries needs (store creation: dashpay/platform#5703; estimate fix: #1026). The V1 prover and verifier both had a placeholder refusing a store's lower layer ("planned at the BulkAppendTree layer").

What was done?

  • grovedb-version: GroveDBOperationsPrivateDocumentStoreVersions gains get_range and range_proof, 0 in GROVE_V1..GROVE_V3, 1 in GROVE_V4; the GROVE_V4 doc lists them.
  • grovedb-private-document-store: PrivateDocumentStore::get_range(start, limit), which reads through the bulk tree's new get_range_charging_chunk_validation and, like get_value, refuses an entry that breaks the committed entry size; RangePage re-exported.
  • grovedb-merkle-mountain-range: MmrStore::charging_leaf_validation(), an opt-in that charges one hash per stored standard leaf a read validates (off by default, so shipped paths report as before); MmrTreeProof::generate_with_cost.
  • GroveDb::private_document_store_get_range, gated on get_range like the store's other reads.
  • V1 prover: a subquery into a store, where range_proof is set, emits the store's bulk append tree layer (ProofBytes::BulkAppendTree), as for a BulkAppendTree; otherwise it still refuses. prove_bulk_position_range accepts a store under the same slot. A store's layer charges its proof generation's work (the proved chunk blobs, the hash validating each one read from storage, the MMR peak bagging, the buffer's dense proof) through the new BulkAppendTreeProof::generate_with_cost and MmrTreeProof::generate_with_cost, at the caller's grove version; the BulkAppendTree and CommitmentTree layers keep the charges they always had (each generate is now its generate_with_cost at GroveVersion::latest() with the cost dropped, and makes the same proof).
  • V1 verifier: before a store element's lower layer is dispatched, it must be ProofBytes::BulkAppendTree and range_proof must be exactly 1 (check_private_document_store_lower_layer), whatever envelope the layer arrives in; decode_bulk_append_lower_layer then returns pds_state(config_hash, bulk_root) as the root to bind to the parent. The CommitmentTree layer refuses a non-CommitmentTree element explicitly instead of failing on the hash. verify_bulk_position_range_proof reads the count of a store.
  • verify feature: builds grovedb-private-document-store without its storage feature (hash functions only).
  • CHANGELOG.md.

How Has This Been Tested?

In private_document_store_tests:

  • test_private_document_store_range_reads_and_proofs: over a store of 10 entries (chunk power 2), ranges inside a chunk, across chunks, across the last chunk and the buffer, inside the buffer, clamped at the end, past the end and of length 0. The unproved page, the proved page and the expected entries agree, the proof derives the database root, and the count is 10.
  • test_private_document_store_range_of_an_empty_store: an empty store's page reads and proves empty, against the empty store's committed root.
  • test_private_document_store_subquery_proofs_verify (replacing the test that expected the refusal): a V1 path query with a subquery into the store proves and verifies all 10 entries at their positions.
  • test_private_document_store_range_proof_refuses_a_changed_entry: changing an entry's bytes in the proof (one in a compacted chunk, one in the buffer) fails verification or derives another root.
  • test_private_document_store_subquery_proofs_refused_without_the_slot: with range_proof 0, proving into a store, verifying a store's lower layer and prove_bulk_position_range on a store all refuse.
  • test_private_document_store_layer_as_a_commitment_tree_layer_is_refused: a bulk layer re-encoded as a CommitmentTree layer (a made-up Sinsemilla root before the same bulk proof) is refused for the element it sits under, a store's and a BulkAppendTree's.
  • test_private_document_store_lower_layer_is_gated_before_dispatch: a Merk-tagged layer committing the store's true root, verified for a subset query stopping at the store, is refused with range_proof 0, 2 and 1.
  • test_private_document_store_range_proof_charges_its_reads_and_hashes: a store's range proof over two compacted chunks and a buffer charges at least the chunk blobs' bytes and more seeks than the same entries proved from a BulkAppendTree, and no fewer hash calls (the buffer's dense proof reads stored node hashes, computing none).
  • test_private_document_store_range_proof_charges_the_mmr_peak_bagging: proving the first of seven chunks bags two MMR peaks, one merge a store proof charges and the BulkAppendTree route does not.
  • In the bulk crate: the costed generator makes the same proof as generate and charges its reads; it charges exactly the one peak-bagging merge for the seven-chunk case; a single chunk committed and reopened charges exactly one validation hash when proved and when read with the charging range read, none with get_range; a buffer-only proof of one position costs exactly the dense proof's cost; and it refuses a subquery, missing chunks and a missing buffer. In the MMR crate: generate_with_cost keeps gen_proof's one merge for a 7-leaf MMR proving its first leaf.
  • In the store crate, test_range_reads_refuse_missing_chunks_and_wrong_widths: a range over a chunk whose storage is gone, and over entries of another width than the committed one (in a chunk and in the buffer), is refused.
  • The version pins, the V3 refusal test and the wrong-element test cover the new slots and get_range.
  • cargo test -p grovedb --lib -- private_document_store bulk_append commitment_tree and cargo test -p grovedb-private-document-store; cargo clippy on the touched crates with -D warnings.

Breaking Changes

GroveDBOperationsPrivateDocumentStoreVersions gains two public fields; code building it by hand must set them. No proof format, stored data or cost changes for any other element.

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 · 078ac1c

  • Bots — coderabbitai ✓ · thepastaclaw ✓
  • Self-review — post /self-reviewed
  • Build green
  • Approvals — you own every area touched; none needed

When every merge requirement is met, the PR Hygiene check passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.

Summary by CodeRabbit

  • New Features
    • Added paginated position-range reads for private document stores, with results limited to the requested range and available entries.
    • Added range proofs for private document store entries, including support for verifying proofs of store subqueries in GROVE_V4.
  • Compatibility
    • Range reads and proofs are available in GROVE_V4; they remain disabled in GROVE_V1–V3.

…sition range (GROVE_V4)

private_document_store_get_range reads [start, start + limit) of a
PrivateDocumentStore in append order, clamped to its count.
prove_bulk_position_range / verify_bulk_position_range_proof accept a store,
and a V1 proof's subquery into a store carries its bulk append tree's proof,
which the verifier binds through the store's committed config
(blake3("pds_state" || config_hash || bulk_state_root), from the
authenticated element). Before, V1 proofs refused subqueries into a store.

Gated by the new private_document_store.get_range and range_proof slots, 0
in GROVE_V1..V3 and 1 in GROVE_V4. The proof envelope gains no variant; the
verify feature now builds grovedb-private-document-store without storage.
V0 proofs are untouched.

BREAKING CHANGE: GroveDBOperationsPrivateDocumentStoreVersions gains the
public fields get_range and range_proof.

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

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3e464df3-c6c9-4c4f-a6b8-8617466ce7a7
Commits

Reviewing files that changed from the base of the PR and between c7186f6 and 078ac1c.

Files selected for processing: 8
  • grovedb-bulk-append-tree/src/proof/mod.rs
  • grovedb-bulk-append-tree/src/proof/tests.rs
  • grovedb-bulk-append-tree/src/tree/fetch.rs
  • grovedb-merkle-mountain-range/src/proof.rs
  • grovedb-merkle-mountain-range/src/storage_adapter.rs
  • grovedb-private-document-store/src/store.rs
  • grovedb/src/operations/proof/generate.rs
  • grovedb/src/tests/private_document_store_tests.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

Private document stores gain position-range reads and range proofs in GROVE_V4. GroveDB exposes range pages, and V1 proof generation supports store subqueries. Verification binds the bulk root through the store’s committed configuration.

Changes: Private document store ranges and proofs

Layer / File(s) Summary
Version-gated range reads
grovedb-version/src/version/*, grovedb-private-document-store/src/*, grovedb/src/operations/private_document_store.rs, grovedb/src/tests/private_document_store_tests.rs, CHANGELOG.md
Adds get_range and range_proof version slots, disabled in V1–V3 and enabled in V4. The store and GroveDB APIs return validated range pages. Tests cover bounds, empty stores, storage errors, and version gating. The changelog records range behavior and compatibility notes.
Cost-aware bulk proof generation
grovedb-merkle-mountain-range/src/*, grovedb-bulk-append-tree/src/proof/*, grovedb-bulk-append-tree/src/tree/fetch.rs
Adds cost-reporting MMR and bulk-append proof generation. MMR reads can report leaf-validation hashes. Tests check proof output, cost accounting, and error handling.
Store-aware proof generation
grovedb/src/operations/proof/generate.rs, grovedb/src/tests/private_document_store_tests.rs, grovedb/Cargo.toml
Enables gated bulk position-range proofs and V1 subquery proofs for private stores. Store proof generation reports read and hash costs. The verify feature enables the private document store crate.
Proof verification and validation
grovedb/src/operations/proof/verify.rs, grovedb/src/tests/private_document_store_tests.rs
Verifies private-store proofs using the committed configuration and bulk-state root. Tests cover proof-layer validation, disabled gates, and tampered entries.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant GroveDB
  participant PrivateDocumentStore
  participant BulkAppendTreeProof
  participant ProofVerifier
  Client->>GroveDB: Request a private-store range proof
  GroveDB->>PrivateDocumentStore: Read store count and chunk power
  GroveDB->>BulkAppendTreeProof: Generate lower-layer proof
  BulkAppendTreeProof-->>GroveDB: Return proof and generation cost
  GroveDB-->>Client: Return range proof
  Client->>ProofVerifier: Submit proof for verification
  ProofVerifier->>PrivateDocumentStore: Use committed store configuration
  ProofVerifier-->>Client: Return verification result
Loading

Suggested reviewers: thepastaclaw

Merge Risk: Minimal · up to 078ac

No actionable merge-blocking issue is established; the range-proof changes are mergeable after normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: adding position-range reads and proofs for PrivateDocumentStore entries in GROVE_V4.
Linked Issues check Passed Issue #1026 is closed and completed. It provides historical context only. No active directly linked issue remains, so no linked-issue coding requirements apply.
Out of Scope Changes check Passed The changes remain within the current PR scope. They implement PrivateDocumentStore range reads, GROVE_V4 gates, range proofs, store subquery verification, proof cost accounting, feature wiring, docum…
Docstring Coverage Passed Docstring coverage is 92.59% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentati…
Full details: Out of Scope Changes check

Explanation

The changes remain within the current PR scope. They implement PrivateDocumentStore range reads, GROVE_V4 gates, range proofs, store subquery verification, proof cost accounting, feature wiring, documentation, and related tests. No unrelated change is demonstrated.

Full details: Docstring Coverage

Explanation

Docstring coverage is 92.59% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 27 functions across 16 files.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · 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

@github-actions

github-actions Bot commented Nov 1, 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 Nov 1, 2026
@thepastaclaw

thepastaclaw commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

✅ Final review complete — no blockers (commit 078ac1c) · triage: critical · Phase 2 only (no Phase 1 for this repository)

@codecov

codecov Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.54369% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.24%. Comparing base (7b8a258) to head (078ac1c).

Files with missing lines Patch % Lines
grovedb-merkle-mountain-range/src/proof.rs 92.68% 6 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1027      +/-   ##
===========================================
+ Coverage    93.21%   93.24%   +0.03%     
===========================================
  Files          356      356              
  Lines       108970   109298     +328     
===========================================
+ Hits        101573   101912     +339     
+ Misses        7397     7386      -11     
Components Coverage Δ
grovedb-core 91.62% <100.00%> (+0.02%) ⬆️
merk 94.18% <ø> (ø)
storage 91.68% <ø> (ø)
commitment-tree 95.62% <ø> (ø)
mmr 95.24% <93.61%> (-0.20%) ⬇️
bulk-append-tree 94.48% <100.00%> (+0.75%) ⬆️
element 97.39% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…isguised store layer

The store's range read refuses a completed chunk it can no longer read and
entries of another width than the committed size, in a chunk or in the
buffer; GroveDb::private_document_store_get_range refuses an element that
is not a store; and a store's bulk layer dressed as a commitment tree layer
is refused for the element it sits under.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Waiting for bot review — coderabbitai not yet · thepastaclaw requested changes — dismiss the review or push a fix, 1 thread unresolved — resolve it. 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.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Final validation — Phase 2 only (no Phase 1 for this repository)

Static verification confirmed one blocking cost-accounting defect in the newly enabled store-proof path and one nonblocking gap in capability-gate enforcement. The range-read delegation and configuration-bound proof root otherwise match the existing store representation. Current CI shows all three Ubuntu test shards, linting, formatting, and security audit passing; PR Hygiene remains pending, and no local builds or tests were run.

🔴 1 blocking | 🟡 1 suggestion(s)

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: critical by gpt-6.1-sol (effort low) — The cross-layer range-proof implementation changes cryptographic proof acceptance and authenticated root binding in grovedb/src/operations/proof/verify.rs, notably decode_bulk_append_lower_layer, meeting both the intricacy and critical-surface criteria.
  • Phase 1 reviewers: not run (disabled for this repository)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `grovedb/src/operations/proof/generate.rs`:
- [BLOCKING] grovedb/src/operations/proof/generate.rs:2593-2603: Propagate bulk proof costs before enabling store proofs
  This new store descent reaches generate_bulk_append_layer_proof, which invokes BulkAppendTreeProof::generate through a plain Result. In grovedb-bulk-append-tree/src/proof/mod.rs, that generator discards the CostResult from every MMR element_at_position call with .unwrap(), and does the same to DenseTreeProof::generate. Those calls report storage seeks, loaded bytes, and dense-proof hash work, but none of those costs reach the enclosing GroveDB CostResult. For example, proving all entries of the tested 10-entry store reads both completed chunk blobs and generates the buffer proof while charging only the surrounding Merk/context work. The outer cost_return_on_error! cannot recover costs already discarded inside the dependency.

  Although existing bulk/commitment proofs share this defect, this PR newly exposes it for store proofs that previously refused descent. Add a cost-preserving proof-generation entry point in the owning bulk-tree crate and propagate its costs through the store-proof adapter, rather than estimating them in the store wrapper. Add regression assertions covering completed-chunk reads, buffer reads, and reported hash work; preserve historical charges through appropriate version dispatch if existing routes are changed.

In `grovedb/src/operations/proof/verify.rs`:
- [SUGGESTION] grovedb/src/operations/proof/verify.rs:2095-2099: Apply the store capability gate before lower-layer envelope dispatch
  Adding PrivateDocumentStore to this generic arm makes its capability check dependent on the supplied lower-layer envelope: only decode_bulk_append_lower_layer checks range_proof == 1. With a V4 version whose range_proof slot is changed to 0 or an unknown value such as 2, verify_subset_query can still accept a store lower layer tagged ProofBytes::Merk. When the subset query stops at the store element, merk_layer_root_hash accepts a single Op::Push(Node::Hash(store_state_root)); ParentCommitment::bind then authenticates that root and the original element bytes without reaching the store gate. The base implementation explicitly refused every store lower layer.

  Check the store's range_proof slot before dispatching its lower-layer envelope, and cover this Merk-tagged subset case with slot-0 and slot-2 tests. This does not forge entries or bypass the parent hash binding, so it is nonblocking, but disabled and unknown capability values currently fail to preserve the stated refusal behavior consistently.

Comment thread grovedb/src/operations/proof/verify.rs Resolved
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. and removed waiting-bots Waiting for the review bots to report on this head labels Nov 1, 2026
… store's layer before dispatch

BulkAppendTreeProof::generate_with_cost returns the proof with the cost of
the MMR node reads (the proved chunk blobs) and of the buffer's dense proof,
which generate dropped; generate is now generate_with_cost with the cost
dropped, so it makes the same proof. A store's V1 layer is generated through
it, while the BulkAppendTree and CommitmentTree layers keep the charges they
always had.

The verifier checks a store element's lower layer before dispatching it: it
must be ProofBytes::BulkAppendTree and private_document_store.range_proof
must be exactly 1, so a Merk-tagged layer can no longer bind a store's root
where the slot is off or unknown.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 1, 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 waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. labels Nov 1, 2026
QuantumExplorer added a commit to dashpay/platform that referenced this pull request Nov 1, 2026
The head charges a store range proof's reads and checks a store's proof layer
before dispatching it; the entries' reads and proofs are unchanged. Cargo.lock
changes only the GroveDB source lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)

Verified the Phase-2 findings against head c7186f6. The pre-dispatch capability gate is fixed, but store proofs still discard MMR peak-bagging hash costs, leaving one blocking finding. This was static verification only; current CI has linting and security audit passing, with all three Ubuntu test jobs and formatting still pending.

🔴 1 blocking

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: critical by gpt-6.1-sol (effort low) — The cross-layer implementation is intricate and directly changes cryptographic proof acceptance and authenticated root reconstruction in grovedb/src/operations/proof/verify.rs, particularly decode_bulk_append_lower_layer and the lower-layer dispatch checks.
  • Phase 1 reviewers: not run (disabled for this repository)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `grovedb-bulk-append-tree/src/proof/mod.rs`:
- [BLOCKING] grovedb-bulk-append-tree/src/proof/mod.rs:304-305: Propagate bulk proof costs before enabling store proofs
  The new accumulator preserves chunk-read costs and the buffer's dense-proof costs, but this call still discards the MMR proof's own hash charge. `MmrTreeProof::generate` calls `mmr.gen_proof(positions, GroveVersion::latest()).unwrap()` at `grovedb-merkle-mountain-range/src/proof.rs:464`, dropping its CostContext. `MMR::gen_proof` separately charges trailing-peak merges at `mmr.rs:304–305` and performs them at lines 309–312; these merges happen outside the node-read callback, so `read_cost` cannot capture them.

  A reachable example is a store with chunk power 2 and 28 entries, proving positions `[0, 4)`. Its seven completed chunks form peaks of 4 + 2 + 1 leaves. Proving chunk 0 leaves two trailing peaks to combine, requiring one Blake3 merge. With no buffer, the costed bulk generator reports zero hash calls despite that merge, and the newly enabled store route propagates the undercharge. The existing MMR test `gen_proof_peak_bagging_charge_is_versioned` explicitly asserts this one-merge charge under GROVE_V4. The new ten-entry store regression proves both completed chunks, so it performs no peak bagging; its no-fewer-hashes comparison cannot detect the omission.

  Add a cost-preserving typed MMR proof generator that accepts the caller's GroveVersion and retains `MMR::gen_proof` costs, then propagate those costs through the bulk generator and store adapter. Preserve historical cost-dropping wrappers for existing routes, and add an exact hash-cost regression for the seven-chunk partial-range case.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Nov 1, 2026
…roof, and cover the costed generator's refusals

MmrTreeProof::generate_with_cost takes the caller's grove version and keeps
what MMR::gen_proof charges (bagging the peaks right of the proved leaves),
which generate dropped; generate is now that at GroveVersion::latest() with
the cost dropped, as before. BulkAppendTreeProof::generate_with_cost takes
the grove version and charges it, and a store's V1 layer passes its own.
The BulkAppendTree and CommitmentTree layers keep their historical charges.

Tests: the one merge of a 7-leaf MMR proving its first leaf, the same merge
in a seven-chunk bulk proof of its first chunk (exact) and in a store proof
over it, and the costed bulk generator's three refusals.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Waiting for bot review — coderabbitai not yet · thepastaclaw requested changes — dismiss the review or push a fix, 1 thread unresolved — resolve it. 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 waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed labels Nov 1, 2026
QuantumExplorer added a commit to dashpay/platform that referenced this pull request Nov 1, 2026
The head also charges a store range proof's MMR peak bagging; the entries'
reads and proofs are unchanged. Cargo.lock changes only the GroveDB source
lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)

Verified the Phase-2 findings against head e1b0e90. All three prior findings are fixed, but the newly enabled store routes still omit persisted MMR leaf-validation hash costs; the dense-buffer cost regression also has a nonblocking coverage gap. This was static verification only: current CI shows Security Audit passing, with all three Ubuntu test shards, formatting, and linting still pending.

🔴 1 blocking | 🟡 1 suggestion(s)

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: critical by gpt-6.1-sol (effort low) — The large, cross-crate diff changes cryptographic proof generation and verification in grovedb/src/operations/proof/generate.rs and verify.rs, including binding a store's bulk proof root to its authenticated configuration and database root.
  • Phase 1 reviewers: not run (disabled for this repository)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `grovedb-bulk-append-tree/src/proof/mod.rs`:
- [BLOCKING] grovedb-bulk-append-tree/src/proof/mod.rs:298-304: Charge persisted MMR leaf-validation hashes on the new store routes
  This accumulator retains the reported node-read cost, but that cost omits hashing performed during deserialization. `MmrStore::element_at_position` calls `MmrNode::deserialize` and returns only `StorageContext::get`'s cost. For standard leaves, deserialization recomputes `leaf_hash(value)` to validate the stored hash. Completed chunks are standard leaves, constructed with `MmrNode::leaf(blob)` in `tree/append.rs`, so ordinary persisted chunk reads hash the entire blob without reporting that work.

  A minimal case is four persisted entries at chunk power 2, reopened and proved over `[0, 4)`. The bulk `generate_with_cost` reads and hashes the single chunk but returns zero `hash_node_calls`: the one-leaf MMR needs no peak bagging and there is no buffer. The newly added `PrivateDocumentStore::get_range` delegates to the same uncharged reader. The bulk cost regressions retain chunks in the MMR overlay, bypassing deserialization and therefore missing this case.

  Add cost-aware validation accounting at the owning MMR decoding/read boundary and propagate it through the new store routes, preserving historical charges for existing routes through explicit compatibility handling. Add an exact-cost regression that commits and reopens a single-chunk tree before reading and proving it. Accumulating higher-layer CostContexts cannot recover work the reader never reports.

In `grovedb-bulk-append-tree/src/proof/tests.rs`:
- [SUGGESTION] grovedb-bulk-append-tree/src/proof/tests.rs:71-75: Isolate dense-buffer costs in the costed-generator regression
  These assertions do not protect propagation of `dense_cost`. Every query in this loop generates a nonempty MMR proof: even the buffer-only range proves chunk 0 to anchor the MMR root. Those chunk reads already satisfy both positive-cost assertions, so deleting `cost += dense_cost` from the generator would leave this regression passing. The GroveDB integration regression likewise lower-bounds completed-chunk bytes rather than isolating buffer work.

  Add a fixture with no completed chunks and assert exact costs for a sparse buffer query. For example, three buffered entries at height 2 with only position 1 selected exercises buffer reads and ancestor-value hashing without MMR costs masking an omission.

…ds from storage, and isolate the buffer proof's cost in a test

Reading a stored MMR leaf recomputes blake3(0x00 || value) to validate it,
which MmrStore never reported. MmrStore::charging_leaf_validation opts a read
path into charging that one hash per standard leaf, the same one call an
append charges for hashing the leaf; it is off by default, so every shipped
path reports what it did. BulkAppendTreeProof::generate_with_cost opts in,
and so does the new BulkAppendTree::get_range_charging_chunk_validation,
which PrivateDocumentStore::get_range now reads with; get_range and the
BulkAppendTree and CommitmentTree routes keep their charges.

Tests: a single chunk committed and reopened charges exactly one hash when
proved and when read with the charging range read, none with get_range; a
buffer-only proof of one position costs exactly the dense proof's cost; a
reopened store's range read charges the chunk's validation; and in GroveDB
both store routes charge each chunk's validation over the BulkAppendTree's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 1, 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.

QuantumExplorer added a commit to dashpay/platform that referenced this pull request Nov 1, 2026
The head also charges validating each chunk a store reads from storage; the
entries' reads and proofs are unchanged. Cargo.lock changes only the GroveDB
source lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)

Independent static verification of the complete diff at 078ac1c found no remaining actionable in-scope defects, and all five prior findings are fixed. The store routes preserve lower-layer costs, enforce capability checks before dispatch, and authenticate the bulk root through the committed store configuration. No local builds or tests were run; current CI has formatting, linting, security audit, and Ubuntu test shards 1/3 and 2/3 passing, with shard 3/3 pending and the nonblocking codecov/patch coverage check failing.

🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)

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); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — The large, cross-crate change modifies cryptographic proof authentication in grovedb/src/operations/proof/verify.rs, including decode_bulk_append_lower_layer binding a store's bulk root to its authenticated configuration and accepting previously rejected proof layers.
  • Phase 1 reviewers: not run (disabled for this repository)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.

No unresolved findings remain from the prior review on this head.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

Bots are done — your move: post /self-reviewed.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Nov 1, 2026
@QuantumExplorer
QuantumExplorer merged commit 9b19035 into develop Nov 1, 2026
18 of 19 checks passed
@QuantumExplorer
QuantumExplorer deleted the feat/private-document-store-range-reads branch November 1, 2026 18:29
QuantumExplorer added a commit to dashpay/platform that referenced this pull request Nov 1, 2026
…9035f)

The same tree as the PR head this branch tested (078ac1c9), now on GroveDB's
develop. Cargo.lock changes only the GroveDB source lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
QuantumExplorer added a commit that referenced this pull request Nov 5, 2026
…tes on GROVE_V5, not V4

GroveDB 6.1.1 shipped GROVE_V4, and Dash Platform 5.0 runs it. #1027
(a store's position-range read and V1 range proofs) and #1026 (the insert
estimators pricing a store's creation as the apply does) landed after
6.1.1 and changed V4 in place. They move to GROVE_V5:

- private_document_store.get_range and range_proof are 0 in GROVE_V4, as
  6.1.1 had no such read or proof, and 1 in GROVE_V5. At V4 the range read
  fails closed and a V1 proof neither carries nor accepts a lower layer
  under a store, as 6.1.1 refused them.
- The average- and worst-case merk_insert_element v1 estimators are back to
  their 6.1.1 bytes. The store pricing is v2, selected by the new values
  average_case_merk_insert_element: 1 and worst_case_merk_insert_element: 1
  in GROVE_V5. Average v2 runs v1 and adds the existence check and the
  empty root's two hashes; worst v2 prices a store as a layered tree with
  those charges and hands every other element to v1.

Verifier hardening from #1027 that refuses a mistyped lower layer at every
version stays as it is.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
QuantumExplorer added a commit that referenced this pull request Nov 5, 2026
…tes on GROVE_V5, not V4 (#1029)

GroveDB 6.1.1 shipped GROVE_V4, and Dash Platform 5.0 runs it. #1027
(a store's position-range read and V1 range proofs) and #1026 (the insert
estimators pricing a store's creation as the apply does) landed after
6.1.1 and changed V4 in place. They move to GROVE_V5:

- private_document_store.get_range and range_proof are 0 in GROVE_V4, as
  6.1.1 had no such read or proof, and 1 in GROVE_V5. At V4 the range read
  fails closed and a V1 proof neither carries nor accepts a lower layer
  under a store, as 6.1.1 refused them.
- The average- and worst-case merk_insert_element v1 estimators are back to
  their 6.1.1 bytes. The store pricing is v2, selected by the new values
  average_case_merk_insert_element: 1 and worst_case_merk_insert_element: 1
  in GROVE_V5. Average v2 runs v1 and adds the existence check and the
  empty root's two hashes; worst v2 prices a store as a layered tree with
  those charges and hands every other element to v1.

Verifier hardening from #1027 that refuses a mistyped lower layer at every
version stays as it is.

Co-authored-by: Claude Opus 5.5 <[email protected]>
QuantumExplorer added a commit that referenced this pull request Nov 5, 2026
Brings in #1026, #1027 and #1028. #1028 added GROVE_V5 identical to
GROVE_V4, so this branch now builds on that shared version instead of
adding its own:

- v5.rs keeps this branch's three slots (element.path_query_push 2,
  path_query_methods.merge 2, path_query_methods.per_instance_query_offsets
  1) under #1028's doc block, which records why changes after 6.1.1 go in
  V5.
- grovedb-version tests keep local_offsets_only_change_the_v5_query_slots,
  which already compares V5 with V4 slot by slot, in place of #1028's
  v5_matches_v4_apart_from_protocol_version.
- CHANGELOG keeps both sides; this branch's latest() entry replaces
  #1028's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-self-review Waiting for the author to post /self-reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants