Skip to content

feat(drive)!: create the store of a private document type, and refuse document queries on one (PV15) - #5703

Merged
QuantumExplorer merged 7 commits into
v5.1-devfrom
feat/private-document-store
Nov 1, 2026
Merged

QuantumExplorer merged 7 commits into
v5.1-devfrom
feat/private-document-store

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Basic explanation

What this does: #5689 let a contract declare a document type private from protocol version 15: its documents will be fixed-size encrypted entries, appended by an anonymous transition paid from the shielded pool, that the chain never reads. Until now such a type was stored like any other, with an ordinary tree of documents at its key [0]. This gives it the storage its entries need: a grovedb private document store at [0], created with the contract, and it makes document queries refuse a private type, since what it holds are encrypted entries read by position, not documents. The transition that appends entries and the query that reads them come next.

Value: the store exists from the moment a private type is registered, on every path a contract takes into state (registration, an update adding the type, genesis, system contract upgrades), so the appending transition only has to append. Fixing the layout now matters: a type registered with the wrong storage could never be repaired, since private can not change on an update.

Risks: low. Only a private type is affected, and nothing is private before protocol version 15: every contract stored before it, and every public type at 15, lays out byte for byte as before (no root hash, fee or proof pin moves). At 15, registering a contract with a private type stores the store element at [0] instead of an empty tree, so its root hash and fees differ from what #5689 alone produced; no network runs protocol version 15.

Before (#5689 alone): registering a contract with a private secret type of 585-byte entries

[DataContractDocuments, <contract id>, 1, "secret", 0]  ->  Tree (empty)
select * from secret                                     ->  []

After:

[DataContractDocuments, <contract id>, 1, "secret", 0]  ->  PrivateDocumentStore(count: 0, entry_size: 601, chunk_power: 9)
select * from secret                                     ->  Unsupported: "secret" is a private document type: it holds encrypted entries, read by their position in its store, not documents a query can find

Issue being fixed or feature implemented

Private document types (#5689): the storage of a private type, and document queries kept off it.

What was done?

The store (drive/document/private_document_store.rs):

  • Each stored entry is the client's entry behind a 16-byte header Drive writes when it appends (block height and block time in milliseconds, u64 little endian), so the store's entry size is 16 + entrySize (PRIVATE_DOCUMENT_ENTRY_HEADER_SIZE).
  • Its chunk power is a platform rule, clamp(floor(log2(target / stored entry size)), min, max), so a compacted chunk stays near the target whatever the entry size: 9 for 585-byte entries, 6 for 4096-byte ones. It is committed into the store when the store is created.
  • The rule's numbers are system limits of the protocol version creating the store: private_document_store_target_chunk_bytes (512 KiB), private_document_store_min_chunk_power (4) and private_document_store_max_chunk_power (11), set in SYSTEM_LIMITS_V5 (protocol version 15) and None in every earlier table. Replaying a protocol version 15 block on a later binary sizes its stores as they were sized, and a later rule is a new table. A version-table test holds the method slot, the three limits and max_private_document_entry_size set exactly where parse_private_document is.
  • The empty store is inserted as an element: grovedb's empty-tree helpers take a TreeType, which can not carry the entry size. The element carries the contract's storage flags, like the type's other trees.
  • Creating it is a versioned Drive method, insert_empty_private_document_store_operation: a new OptionalFeatureVersion slot of the document methods, Some(0) in a new DRIVE_DOCUMENT_METHOD_VERSIONS_V5 that only drive version 10 (protocol version 15) selects, None in V1 to V4. Its v0 reads the limits below.

Where it is created: contract insert (insert_contract_operations_v0, which every insert_contract version runs) and the new-type branch of contract update (update_contract_operations_v0, which every update_contract version runs). Genesis registers system contracts through apply_contract, protocol upgrades through insert_contract, apply_contract and the rebuild migration, which recreates a type as an update adds one: all of them reach these two functions.

Fee estimation: nothing more is needed in Drive. grovedb prices the store element, and Drive's tree-type weights count it as the normal node it is in its parent. Tests estimate a registration and an update that create a store and hold the estimate at or above the applied processing and storage fees. At GroveDB 2128ea18 the insert estimators (v1, which GROVE_V4 selects) priced a store's creation below its apply: they missed the existence check a write-once store makes and the two hashes deriving its empty root (the worst case also priced the store as an item). dashpay/grovedb#1026 fixed them, and this PR moves the GroveDB pin to its merge, 7b8a258b, the only GroveDB commit since 2128ea18 (Cargo.lock changes only the GroveDB source lines). The store now adds 339,400 credits of processing to a registration's estimate (336,440 before the bump) against 259,600 to its applied fee; storage is unchanged.

Queries: drive::query::refuse_a_private_document_type refuses a read of a private type's documents. DriveDocumentQuery calls it in both its path-query builders, which the chained and composite queries also build through, and so does fetch_document_history_query, the history path query that fetch_document_history, prove_document_history and verify_document_history all build (it now takes the document type; prove_document_history takes the type in place of its name, and fetch_document_history drops the name it already had the type for). The history query handler refuses a private type first, so the answer is a query error, proved or not. Every other query kind already needs an index or a count, sum or average flag, none of which a private type can declare.

GroveDB structure and layout: drive/document/structure.rs lists the store among what the type's key [0] holds and describes it; grovedb-structure.json regenerated. The concrete layout (document_type_layout, which wasm-sdk's documentTypeLayout returns) lays out a private type as the store at [0], with its chunk power and a privateDocumentStore note, and nothing under it. The store's sizing (private_document_store_chunk_power, dispatched by the same method slot) is available under the verify feature for it.

In-place changes to shipped generations

Each new branch reads private_document(), which is Some only on a type parsed where parse_private_document is set, protocol version 15. Before it no type is private (registration refuses the key, and no stored contract carries it), so the branch never runs.

Generation Selected by Why consensus cannot change there
insert_contract_operations_v0 (run by insert_contract 0, 1 and 2) protocol versions 1 to 15 creates the store of a private type only; every other type takes the branch it took before
update_contract_operations_v0 (run by update_contract 0, 1 and 2) 1 to 15 the same, for a type the update adds
DriveDocumentQuery::construct_path_query and construct_path_query_operations (unversioned) 1 to 15 refuse a private type only
SYSTEM_LIMITS_V1 to SYSTEM_LIMITS_V4 protocol versions 1 to 14 gain the three store limits as None, which nothing reads before protocol version 15
DRIVE_DOCUMENT_METHOD_VERSIONS_V1 to V4 protocol versions 1 to 14 gain insert_empty_private_document_store_operation: None; nothing dispatches it before protocol version 15
drive-abci query_document_history_v0 and Drive's fetch_document_history_query_v0 (queries, not consensus) 1 to 15 refuse a private type only

How Has This Been Tested?

  • Drive (private_document_store tests): registering a contract creates an empty store of 16 + 585 byte entries at chunk power 9 while its public type keeps its tree; an update adding a private type creates the same store; the estimate of both covers their applied fees; a document query on the type is refused, by the path-query builder and by query_documents; the chunk power rule and its clamps; protocol version 14 creates no store (VersionNotActive).
  • platform-version: the store's method slot and limits are set exactly where private types parse.
  • drive-abci: should_refuse_the_history_of_a_document_of_a_private_type, proved and unproved.
  • Drive: should_refuse_the_document_history_of_a_private_type (fetch, prove and verify), and should_lay_out_the_store_of_a_private_type, which holds the layout to what Drive wrote.
  • drive-abci: should_register_a_private_type_and_create_its_store registers a contract with a private type through check_tx (whose fee estimate prices the store) and a block, and finds the store. The Batch refusal tests from feat(platform)!: private document types, declared with the private keyword (PV15) #5689 now check the store still holds no entry, read from the element (a query is refused).
  • Unchanged layout for every other type: drive's deterministic_root_hash, the drive contract suites (598 tests), drive-abci's check_tx suite and the protocol version 14 private-key tests.
  • UPDATE_GROVEDB_STRUCTURE=1 cargo test -p drive --lib structure::tests, then the structure tests without it.
  • cargo clippy --all-features --tests on drive and drive-abci.

Breaking Changes

Consensus, protocol version 15 only: a contract with a private type stores a private document store at the type's key [0], so the root hash and the fees of registering such a contract, or of an update adding such a type, differ from #5689 alone. GroveDB moves to 7b8a258b, which raises only the estimated fee of creating a private document store. Document queries and document history queries on a private type are refused. Drive API: fetch_document_history_query takes the document type in place of its name, prove_document_history too, and fetch_document_history no longer takes the name beside the type.

Checklist:

  • I have performed a self-review of my own code
  • My Rust, FFI, WASM, Swift or Kotlin changes follow the coding conventions
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed
  • If I added or changed GroveDB structure, I described it in the area's structure.rs, regenerated grovedb-structure.json, and checked the structure viewer link posted on this pull request
  • If I added or changed a system contract's document schemas, I checked the contract viewer link posted on this pull request

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

PR Hygiene · 20df1d0

  • Bots — thepastaclaw not yet — /skip-bots proceeds without the ones not yet reported
  • Self-review — post /self-reviewed
  • Build running
  • 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.

… document queries on one (PV15)

A private document type (protocol version 15) keeps its entries in a grovedb
`PrivateDocumentStore` at its key `[0]`, where every other type keeps its
primary-key tree, and has no index trees. Contract insert and the new-type
branch of contract update create the empty store, sized for the client's
entry plus Drive's 16-byte header (block height and time), with a chunk power
that keeps a compacted chunk near 512 KiB (`clamp(floor(log2(512 KiB /
stored entry)), 4, 11)`). Every insert and update version, genesis, system
contract upgrades and the rebuild migration run through those two shared
functions, edited in place: no type is private before protocol version 15.

`DriveDocumentQuery` refuses a private type in both path-query builders,
which chained and composite queries also use: the store holds encrypted
entries read by position, not documents.

Fee estimation needs nothing more: grovedb prices the store element. The
GroveDB structure description and grovedb-structure.json now show the store.

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

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 49 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 0a666ef and 20df1d0.

Files ignored due to path filters: 1
  • Cargo.lock is excluded by !**/*.lock
Files selected for processing: 1
  • Cargo.toml

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 3526962 and 0a666ef.

Files selected for processing: 13
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/yes_no_tests/decision_proposal_tests.rs
  • packages/rs-drive-abci/src/query/document_history/v0/mod.rs
  • packages/rs-drive/src/drive/document/get_fetch/fetch_document_history/mod.rs
  • packages/rs-drive/src/drive/document/get_fetch/fetch_document_history/v0/mod.rs
  • packages/rs-drive/src/drive/document/layout.rs
  • packages/rs-drive/src/drive/document/mod.rs
  • packages/rs-drive/src/drive/document/private_document_store/mod.rs
  • packages/rs-drive/src/drive/document/private_document_store/v0/mod.rs
  • packages/rs-drive/src/drive/document/prove/prove_document_history/mod.rs
  • packages/rs-drive/src/drive/document/prove/prove_document_history/v0/mod.rs
  • packages/rs-drive/src/drive/document/query/fetch_document_history_query/mod.rs
  • packages/rs-drive/src/drive/document/query/fetch_document_history_query/v0/mod.rs
  • packages/rs-drive/src/verify/document/verify_document_history/v0/mod.rs
Files with no reviewable changes: 1
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/yes_no_tests/decision_proposal_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 types now use dedicated GroveDB stores at key [0], with entry sizing and chunk-power limits configured by platform version. Contract registration and updates create these stores. Document and history queries reject private types.

Changes: Private document storage

Layer / File(s) Summary
Private-store platform limits
packages/rs-platform-version/src/version/system_limits/*, packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/*, packages/rs-platform-version/src/version/drive_versions/v10.rs, packages/rs-platform-version/src/version/dpp_versions/dpp_contract_versions/mod.rs, packages/rs-platform-version/src/version/v15.rs, packages/rs-platform-version/src/version/mocks/v2_test.rs
System limits and Drive method versions configure private-store sizing and creation for protocol version 15. Earlier versions leave the new limits and method unset. A test checks that the settings align with private-document parsing.
Private-store layout and sizing
packages/rs-drive/src/drive/document/private_document_store/*, packages/rs-drive/src/drive/document/mod.rs, packages/rs-drive/src/drive/document/layout.rs, packages/rs-drive/src/drive/document/structure.rs, packages/rs-drive/grovedb-structure.json
Helpers calculate stored-entry size and chunk power, and create an empty store. Document layout and GroveDB structure descriptions represent private stores and describe their entry layout.
Contract store creation
packages/rs-drive/src/drive/contract/insert/insert_contract/v0/mod.rs, packages/rs-drive/src/drive/contract/update/update_contract/v0/mod.rs, packages/rs-drive/src/drive/document/private_document_store/mod.rs, packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/private_type.rs, packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_create/mod.rs
Contract registration and updates create private stores instead of primary-key trees for private types. Tests inspect store contents, fees, and contract execution.
Private document query refusal
packages/rs-drive/src/query/mod.rs, packages/rs-drive/src/drive/document/query/*, packages/rs-drive/src/drive/document/get_fetch/fetch_document_history/*, packages/rs-drive/src/drive/document/prove/prove_document_history/*, packages/rs-drive/src/verify/document/verify_document_history/v0/mod.rs, packages/rs-drive-abci/src/query/document_history/v0/mod.rs, packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/yes_no_tests/decision_proposal_tests.rs
Document and history query paths reject private document types. History APIs pass a resolved document-type reference, and tests cover both proof and non-proof history requests.

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

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant ContractInsertion
  participant StoreOperation as insert_empty_private_document_store_operation
  participant GroveDB
  ContractInsertion->>StoreOperation: create empty store operation for private type
  StoreOperation-->>ContractInsertion: return insertion operation
  ContractInsertion->>GroveDB: queue store insertion at key [0]
Loading

Possibly related PRs

  • dashpay/platform#5689: Adds private document types and PrivateDocumentConfig, which this change uses to create private stores and refuse queries.

Suggested reviewers: thepastaclaw, shumkov

Merge Risk: Minimal · previous review 0a666

No actionable merge-blocking issue is established; merge 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 changes: creating private document stores and refusing document queries for protocol version 15.
Docstring Coverage Passed Docstring coverage is 81.48% 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…
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 81.48% 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 34 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 added this to the v5.1.0 milestone Oct 31, 2026
@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

🌳 GroveDB structure

This pull request changes the described GroveDB structure. Open it in the structure viewer: new nodes glow, removed ones stay as ghosts, and the tour walks through each change.

Changed (1 node)

  • contracts.contract.documents.document_type.primary_key

Compared c61384d0c7 with 20df1d059d. Updated at 2026-11-01T08:08:36.086Z

@QuantumExplorer
QuantumExplorer marked this pull request as ready for review October 31, 2026 06:25
@github-actions

Copy link
Copy Markdown
Contributor

Waiting for bot review — 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 31, 2026
@thepastaclaw

thepastaclaw commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

🕓 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 20df1d0. Normal review starts when eligible; priority review starts as soon as a slot is available.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Final validation — Phase 1 + Phase 2

The PR correctly routes PV15 private types to a PrivateDocumentStore and refuses document queries, but two in-scope correctness issues remain. The persisted store-configuration policy is not selected through PlatformVersion, and the pinned GroveDB estimator omits hashing work performed when creating the store, allowing check-time fees to be undercharged. The supplied CI snapshot shows Rust workspace tests still in progress and no failed code check.

🔴 2 blocking | 🟡 1 suggestion(s)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — The diff changes consensus-visible storage creation in insert_contract_operations_v0 and update_contract_operations_v0, but the production logic is bounded and straightforward rather than large or intricate, with much of the added code devoted to tests.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); 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 `packages/rs-drive/src/drive/document/private_document_store.rs`:
- [BLOCKING] packages/rs-drive/src/drive/document/private_document_store.rs:19-59: Version the consensus-visible private-store configuration policy
  `private_document_store_chunk_power` selects the chunk power committed into the GroveDB element, but it reads the 512 KiB target and power bounds from process-wide constants and has no `PlatformVersion` dispatch. The helper is called by both contract insertion and update paths, so changing these values later would not only affect newly created stores: replaying a historical PV15 contract registration on a newer binary would recreate its store with a different configuration, root hash, and fee. The comment that the rule affects only stores created after the change overlooks historical replay. Add an `OptionalFeatureVersion` method slot under the Drive document methods, select its initial generation only from the PV15 table, pass `platform_version` through the creation helpers as the final parameter, and move the tunable target and bounds into the appropriate `SystemLimits` table with PV15 values.
- [BLOCKING] packages/rs-drive/src/drive/document/private_document_store.rs:63-72: Account for private-store creation hashes in fee estimation
  This creates the store through `InsertOrReplaceDontCheckForBackwardsReferences`. At the pinned GroveDB revision, the apply path in `grovedb/src/batch/mod.rs:4264-4270` explicitly adds two `hash_node_calls` for the committed configuration hash and empty state-root hash. However, `grovedb/src/batch/estimated_costs/average_case_costs.rs:230-240` routes this element through the ordinary `average_case_merk_insert_element`, whose v1 implementation only prices the layered insertion and does not add those two hashes. Because Drive uses the estimated path for check-time fee validation, registering a private type can be accepted with a processing fee below the actual execution cost. Fix the estimator in GroveDB and update the pinned dependency, or otherwise ensure the creation operation's estimated and applied costs match; do not compensate with an unrelated Drive-side constant.
- [SUGGESTION] packages/rs-drive/src/drive/document/private_document_store.rs:228-262: Make the fee-estimation test compare estimation with execution
  The added test only asserts that registration estimation has a positive processing fee and that update estimation succeeds. It does not compare either estimate with an applied registration or update, and it does not assert that storage cost is covered. Consequently, the test passes despite the pinned GroveDB creation path charging two hash operations during application that the estimator omits. Use separate drive instances or otherwise capture both paths and assert that the estimated processing and storage fees are at least the applied fees.

@github-actions

Copy link
Copy Markdown
Contributor

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 Oct 31, 2026
… limits, and hold its estimate to the applied fees

The chunk rule's target (512 KiB) and bounds (4 and 11) were constants, so a later
change to them would have resized the stores of replayed protocol version 15 blocks.
They are now SystemLimits fields, set in SYSTEM_LIMITS_V5 and None before, read
through platform_version; a version-table test keeps them set exactly where private
types parse. The fee tests now compare an estimated registration and update creating
a store with the applied ones.

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

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw left review threads unresolved; resolve them.
Full checklist in the description.

@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

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.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

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 1 + Phase 2

The revised fee tests compare estimation with execution on independent Drives, and SystemLimits now pins the store-sizing parameters to the creating protocol version. One architectural blocker remains: the new shared sizing algorithm lacks the method-version dispatch explicitly required by the repository conventions; two non-blocking follow-ups concern GroveDB accounting and document-history query refusal. Current GitHub checks show Rust workspace tests, the JS build, and Swift/Kotlin checks passing; this verification was static, with no local builds or tests run.

🔴 1 blocking | 🟡 2 suggestion(s)

2 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.

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: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 7: muse-spark-1.3-contributor (agent: phase1-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) — This is a large change to consensus-critical persisted storage layout and protocol-versioned state-transition behavior, particularly in private document store creation and contract updates.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • 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 — security-auditor (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 `packages/rs-drive/src/query/mod.rs`:
- [SUGGESTION] packages/rs-drive/src/query/mod.rs:2696-2707: Reject private types in the document-history query path too
  This refusal only covers DriveDocumentQuery. GetDocumentHistory resolves an existing document type in drive-abci's query/document_history/v0/mod.rs and directly calls prove_document_history or fetch_document_history without checking is_private or documents_keep_history. Both Drive routes build a history path ending in [0, document_id], so a request naming the newly stored private type reaches GroveDB as a history-subtree lookup rather than receiving the intended private-type Unsupported error. Extend Drive-side eligibility validation to the history fetch/prove entry points and cover proved and unproved requests. This is an incomplete query-refusal surface, not evidence that encrypted entries can be read as documents.

In `packages/rs-drive/src/drive/document/private_document_store.rs`:
- [BLOCKING] packages/rs-drive/src/drive/document/private_document_store.rs:46-64: Version the consensus-visible private-store configuration policy
  (existing thread: https://github.com/dashpay/platform/pull/5703#discussion_r4430978195)
  Reading the target and bounds from SystemLimits fixes the numeric replay concern, but the sizing algorithm still has no method-version dispatcher. Both contract insertion and update generations reach this helper, and its division, logarithm, and clamping determine configuration committed into state. The book's “Shared helpers get a versioned method, not a capability flag” rule explicitly requires an initial method generation for this shape; “Numbers live in the version tables” governs subsequent parameter changes rather than exempting the algorithm from that requirement. Add an OptionalFeatureVersion slot under the Drive document methods, with None before PV15 and Some(0) in a PV15-only table, and dispatch to an initial v0 implementation that continues reading these SystemLimits. This is a missing required architectural boundary, not a claim that the current numeric tables already cause replay divergence.
- [SUGGESTION] packages/rs-drive/src/drive/document/private_document_store.rs:90-94: Account for private-store creation hashes in fee estimation
  (existing thread: https://github.com/dashpay/platform/pull/5703#discussion_r4430978197)
  The whole-registration and update comparisons address total fee coverage, so the omitted hashes alone do not establish Platform undercharging. The narrower upstream accounting omission is confirmed at pinned GroveDB 2128ea18, also the supplied default-branch tip: batch creation adds two hash_node_calls for the committed configuration and empty state root, while the average- and worst-case insertion estimators omit that derivation. Both estimator generations lack the addition, including v0 selected by GROVE_V4. Track the correction and an isolated creation-cost regression test in dashpay/grovedb, then link the issue or PR here before deferring the repair; the supplied discussion and inspected open-issue/PR searches contain no matching tracking reference. This is non-blocking and does not call for a compensating Drive constant or presume that estimates must equal applied fees exactly.

Comment thread packages/rs-drive/src/query/mod.rs Resolved
QuantumExplorer and others added 2 commits October 31, 2026 18:54
…d, and refuse private types in the document history query

insert_empty_private_document_store_operation is now dispatched from a new
OptionalFeatureVersion slot of the Drive document methods: Some(0) in
DRIVE_DOCUMENT_METHOD_VERSIONS_V5, which only drive version 10 (protocol
version 15) selects, None in V1 to V4. Its v0 sizes the store from the
SystemLimits as before. The version-table test now also holds the slot set
exactly where private types parse.

The document history query refuses a private type before it fetches or
proves, through drive::query::refuse_a_private_document_type, the check
DriveDocumentQuery already ran.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ument method version, and refuse private types in the document history query

The previous commit only moved private_document_store.rs to
private_document_store/mod.rs; this one holds the change it describes.

insert_empty_private_document_store_operation is dispatched from a new
OptionalFeatureVersion slot of the Drive document methods: Some(0) in
DRIVE_DOCUMENT_METHOD_VERSIONS_V5, which only drive version 10 (protocol
version 15) selects, None in V1 to V4. Its v0 sizes the store from the
SystemLimits as before. The version-table test now also holds the slot set
exactly where private types parse.

The document history query refuses a private type before it fetches or
proves, through drive::query::refuse_a_private_document_type, the check
DriveDocumentQuery already ran.

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

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw left review threads unresolved; resolve them.
Full checklist in the description.

@github-actions

Copy link
Copy Markdown
Contributor

Waiting for bot review — 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 labels Oct 31, 2026
@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — 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.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

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 1 + Phase 2

The PV15 store creation and versioning are sound, with two non-blocking gaps remaining: concrete layout introspection still describes an ordinary document tree, and direct Drive history queries bypass the private-type refusal. The pinned GroveDB estimator correction remains tracked in dashpay/grovedb#1026 rather than incorporated in this dependency revision. Static verification was performed against 573ffd0 without running builds or tests; current CI reports successful Rust workspace tests and applicable SDK checks, with PR Hygiene pending.

🟡 2 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); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 6: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 7: gpt-6-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 8: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 9: gpt-6-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 10: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); reviewer 11: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); reviewer 12: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 13: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 14: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 15: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 16: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 17: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — The intricate, cross-cutting change modifies consensus-persisted contract storage and its fee accounting in insert_contract/v0/mod.rs, update_contract/v0/mod.rs and private_document_store/v0/mod.rs, with protocol-version-specific activation and sizing rules.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • 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 — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — general (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — security-auditor (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, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
  • Model comparison: every Phase-2 reviewer also ran on gpt-6-astra; the verifier weighed both sets without knowing which model wrote which
🤖 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 `packages/rs-drive/src/drive/contract/insert/insert_contract/v0/mod.rs`:
- [SUGGESTION] packages/rs-drive/src/drive/contract/insert/insert_contract/v0/mod.rs:284-290: Keep Drive's concrete layout API aligned with the new store
  This branch changes the element at the document type's key [0] to a PrivateDocumentStore, but drive::document::layout::document_type_layout still passes every non-indexOnly type to primary_key_node. For a private type, that produces a NormalTree with document-ID Item descendants, neither of which describes the new storage. This concrete layout is exposed through wasm-sdk's documentTypeLayout; updating grovedb-structure.json does not update that output. Add a private-type branch to the Drive layout implementation that emits the store without document-ID descendants, and cover it in the layout-versus-storage test. Keep any shared configuration derivation in Drive and available under the required server/verify feature gates, rather than reconstructing it in the WASM wrapper.

In `packages/rs-drive-abci/src/query/document_history/v0/mod.rs`:
- [SUGGESTION] packages/rs-drive-abci/src/query/document_history/v0/mod.rs:97-103: Reject private types in the document-history query path too
  The new guard protects both RPC response modes, but direct Drive callers and client-side history verification still bypass it. Drive::fetch_document_history, prove_document_history, and verify_document_history all use fetch_document_history_query, whose builder receives only the type name and unconditionally constructs a history path beneath [0, document_id]. Exporting the predicate from Drive centralizes its definition, but does not enforce eligibility in this shared lowering path. Pass the resolved DocumentTypeRef into the shared builder and apply the existing refusal there, with fetch, prove, and verify using that checked builder; fetch and verify already receive the type, and this handler has it available for prove. This keeps storage-layout eligibility in Drive, as required by the book's query-lowering ownership rule, while ABCI translates the resulting error. Add direct Drive coverage; this remains non-blocking because the exposed RPC route is guarded and no encrypted-entry disclosure is established.

@github-actions

Copy link
Copy Markdown
Contributor

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 Oct 31, 2026
…in Drive's document history query

document_type_layout lays out a private type as its private document store
at [0], sized by private_document_store_chunk_power (the store's creation
generation, now available under verify for the layout and wasm-sdk), with a
privateDocumentStore note and nothing under it; the layout test holds it to
what Drive wrote. The store module is built under server or verify, and only
building the store's insert operation stays server-only.

fetch_document_history_query takes the document type and refuses a private
one, so fetch, prove and verify of a document's history all refuse it;
prove_document_history takes the type in place of its name, and
fetch_document_history drops the name it had the type for.

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

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — 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 labels Oct 31, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

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 1 + Phase 2

Static verification of head 0a666ef found no actionable in-scope findings: private-store creation is PV15-gated, and layout reporting and history-query refusal are enforced in Drive. Five prior findings are fixed; the isolated GroveDB creation-estimator omission remains at the dependency pin and is reasonably deferred to the verified upstream repair in dashpay/grovedb#1026. Current CI shows the JS build/tests, Kotlin tests, Swift schema check, formatting, Clippy and feature-cut checks passing; Rust workspace tests remain in progress, and no local builds or tests were run.

🔴 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: security-auditor); reviewer 6: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 7: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 11: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 12: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — The cross-cutting change alters consensus-visible persisted state and fees through insert_contract/v0, update_contract/v0, and private_document_store/v0, with protocol-versioned store sizing and activation across multiple contract insertion paths.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • 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 — security-auditor (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, gpt-6.1-sol — security-auditor (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

Copy link
Copy Markdown
Contributor

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 Oct 31, 2026
…re's creation as its apply

dashpay/grovedb#1026, the only GroveDB commit since 2128ea18: the v1 insert
estimators charge a store's existence check and the two hashes deriving its
empty root, and the worst case prices the store as a layered tree. Only the
estimate of creating a store moves (339,400 credits of processing for a
registration's store, 336,440 before); applied costs are unchanged.
Cargo.lock changes only the GroveDB source lines.

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

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — 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 labels Nov 1, 2026
@QuantumExplorer
QuantumExplorer merged commit f830a1c into v5.1-dev Nov 1, 2026
40 of 42 checks passed
@QuantumExplorer
QuantumExplorer deleted the feat/private-document-store branch November 1, 2026 09:31
QuantumExplorer added a commit that referenced this pull request Nov 1, 2026
v15.rs: the base extends note 13 (the private document store, #5703) where
this branch starts note 14; both are kept, note 13's text first.

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-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