Repository navigation
feat(drive)!: create the store of a private document type, and refuse document queries on one (PV15) - #5703
Conversation
… 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]>
|
Warning Review limit reachedYou'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. View limit details
No actionable comments were generated in the recent review.
|
| 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]
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: 
5
-
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.
|
🌳 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)
Compared |
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
|
🕓 Review not started yet because the new head is waiting for the 30-minute push debounce.
Commit 20df1d0. Normal review starts when eligible; priority review starts as soon as a slot is available. |
thepastaclaw
left a comment
There was a problem hiding this comment.
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:
normalbygpt-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); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort high); agentphase2-reviewer
🤖 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.
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them. |
… 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]>
|
Your move: thepastaclaw left review threads unresolved; resolve them. |
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them. |
thepastaclaw
left a comment
There was a problem hiding this comment.
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:
criticalbygpt-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); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-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.
…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]>
|
Your move: thepastaclaw left review threads unresolved; resolve them. |
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
…t does Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
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:
criticalbygpt-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); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer,gpt-6-astra— general (completed, effort xhigh); agentphase2-reviewer,gpt-6-astra— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6-astra— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6-astra— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6-astra— security-auditor (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-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.
|
Bots are done — your move: post |
…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]>
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
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:
criticalbygpt-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); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-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.
|
Bots are done — your move: post |
…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]>
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
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]>
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
privatecan 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
secrettype of 585-byte entriesAfter:
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):16 + entrySize(PRIVATE_DOCUMENT_ENTRY_HEADER_SIZE).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.private_document_store_target_chunk_bytes(512 KiB),private_document_store_min_chunk_power(4) andprivate_document_store_max_chunk_power(11), set inSYSTEM_LIMITS_V5(protocol version 15) andNonein 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 andmax_private_document_entry_sizeset exactly whereparse_private_documentis.TreeType, which can not carry the entry size. The element carries the contract's storage flags, like the type's other trees.insert_empty_private_document_store_operation: a newOptionalFeatureVersionslot of the document methods,Some(0)in a newDRIVE_DOCUMENT_METHOD_VERSIONS_V5that only drive version 10 (protocol version 15) selects,Nonein V1 to V4. Its v0 reads the limits below.Where it is created: contract insert (
insert_contract_operations_v0, which everyinsert_contractversion runs) and the new-type branch of contract update (update_contract_operations_v0, which everyupdate_contractversion runs). Genesis registers system contracts throughapply_contract, protocol upgrades throughinsert_contract,apply_contractand 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_V4selects) 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.lockchanges 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_typerefuses a read of a private type's documents.DriveDocumentQuerycalls it in both its path-query builders, which the chained and composite queries also build through, and so doesfetch_document_history_query, the history path query thatfetch_document_history,prove_document_historyandverify_document_historyall build (it now takes the document type;prove_document_historytakes the type in place of its name, andfetch_document_historydrops 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.rslists the store among what the type's key[0]holds and describes it;grovedb-structure.jsonregenerated. The concrete layout (document_type_layout, which wasm-sdk'sdocumentTypeLayoutreturns) lays out a private type as the store at[0], with its chunk power and aprivateDocumentStorenote, and nothing under it. The store's sizing (private_document_store_chunk_power, dispatched by the same method slot) is available under theverifyfeature for it.In-place changes to shipped generations
Each new branch reads
private_document(), which isSomeonly on a type parsed whereparse_private_documentis 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.insert_contract_operations_v0(run byinsert_contract0, 1 and 2)update_contract_operations_v0(run byupdate_contract0, 1 and 2)DriveDocumentQuery::construct_path_queryandconstruct_path_query_operations(unversioned)SYSTEM_LIMITS_V1toSYSTEM_LIMITS_V4None, which nothing reads before protocol version 15DRIVE_DOCUMENT_METHOD_VERSIONS_V1toV4insert_empty_private_document_store_operation: None; nothing dispatches it before protocol version 15query_document_history_v0and Drive'sfetch_document_history_query_v0(queries, not consensus)How Has This Been Tested?
private_document_storetests): registering a contract creates an empty store of16 + 585byte 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 byquery_documents; the chunk power rule and its clamps; protocol version 14 creates no store (VersionNotActive).should_refuse_the_history_of_a_document_of_a_private_type, proved and unproved.should_refuse_the_document_history_of_a_private_type(fetch, prove and verify), andshould_lay_out_the_store_of_a_private_type, which holds the layout to what Drive wrote.should_register_a_private_type_and_create_its_storeregisters 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 theprivatekeyword (PV15) #5689 now check the store still holds no entry, read from the element (a query is refused).deterministic_root_hash, the drive contract suites (598 tests), drive-abci'scheck_txsuite 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 --testson 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_querytakes the document type in place of its name,prove_document_historytoo, andfetch_document_historyno longer takes the name beside the type.Checklist:
structure.rs, regeneratedgrovedb-structure.json, and checked the structure viewer link posted on this pull requestFor repository code-owners and collaborators only
🤖 Generated with Claude Code
PR Hygiene ·
20df1d0/skip-botsproceeds without the ones not yet reported/self-reviewedWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.