Repository navigation
fix(dpp)!: refuse a document type schema naming a key twice (PV15) - #5702
Conversation
…ot (PV15) The document type parser reads the first entry of a repeated top-level schema key, where the registration check and the document validator read the schema as JSON and keep the last. #5689 refuses a repeated key for private document types; from protocol version 15 registration refuses it for every type, before the schema is converted to JSON, with the same InvalidContractStructure error. Loading a stored contract runs no schema check, so contracts already stored keep loading. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Detect and reject repeated keys packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/common/mod.rs, packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/native_schema/mod.rs, packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/mod.rs, packages/rs-platform-version/src/version/v15.rs |
Full validation checks the submitted schema and each supplied $defs value before shorthand expansion. Schema-check version 0 skips the check; version 1 recursively checks map and array values and returns InvalidContractStructure for duplicate text keys. |
Track schema reads and test parsing packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/mod.rs, packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/repeated_doctype_key_tests.rs, packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/index_only_tests.rs, packages/rs-drive-abci/src/execution/check_tx/v0/mod.rs |
Generation 3 records the walk’s read count for schema-size billing. Tests cover repeated keys in schemas and $defs, protocol-version behavior, validation-disabled parsing, decoding, billing, and repeated skipIfAbsent declarations. Fee tests update expected amounts for protocol version 15. |
Validate repeated-key contract updates packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/* |
A block-execution test checks that an update with repeated properties keys fails and leaves the stored contract version and document values unchanged. |
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix
Sequence Diagram(s)
sequenceDiagram
participant Generation3Parser
participant CommonSchemaCheck
participant NativeSchemaWalker
Generation3Parser->>CommonSchemaCheck: schema and definitions with platform version
CommonSchemaCheck->>NativeSchemaWalker: run repeated-key check when enabled
NativeSchemaWalker-->>Generation3Parser: read count and result
Possibly related PRs
- dashpay/platform#5689: Its document-schema parser also handles repeated doctype declarations.
Suggested reviewers: thepastaclaw, shumkov
Merge Risk: 
Minimal · up to 30c38
-
PV15 is intended to reject repeated schema keys. No concrete merge-blocking risk has been established.
Pre-merge checks: 
5
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 80.00% 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 15 functions across 9 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.
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
|
✅ Final review complete — no blockers (commit 30c389a) · triage: critical |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
The production change is correctly scoped to protocol version 15 and preserves earlier registration and stored-contract loading behavior. I found only non-blocking test-quality and maintainability issues; no consensus, layering, or security defects are present. Build-related CI checks were still queued at the evidence snapshot, with no failed code check.
🟡 3 suggestion(s) | 💬 2 nitpick(s)
Review provenance
Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: glm-5.3-flash (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); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
lowbygpt-6.1-sol(effort low) — The production change is a small, straightforward duplicate-key check in refuse_a_repeated_doctype_key with a single protocol-gated call site, while most of the diff adds tests rather than intricate consensus logic. - Phase 1 reviewers:
glm-5.3-flash— general (completed, effort high); agentphase1-reviewer,glm-5.3-flash— rust-quality (completed, effort high); agentphase1-reviewer - Phase 1 model:
glm-5.3-flash— zai quota: 5h 93% left, weekly 77% left; passed overgemini-3.8-flash-high(antigravity quota lookup failed) - Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort medium); 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-dpp/src/data_contract/methods/validate_update/mod.rs`:
- [SUGGESTION] packages/rs-dpp/src/data_contract/methods/validate_update/mod.rs:6-7: Gate the update refusal test on the validation feature
`repeated_properties_tests` is enabled for every test build, but its expected refusal is produced by `check_document_type_schema` and `native_schema`, which are compiled only with the `validation` feature. With the package's default features, `full_validation = true` does not execute this check, so `expect_err` can panic instead of testing the intended behavior. The sibling schema test modules already use the feature-aware gate.
In `packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/repeated_doctype_key_tests.rs`:
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/repeated_doctype_key_tests.rs:72-79: Assert the consensus error class in the new refusal tests
The new DPP-level refusal assertions in this file and `methods/validate_update/repeated_properties_tests.rs` check only a debug-string fragment. The implementation deliberately maps `InvalidContractStructure` to `ConsensusError::BasicError(BasicError::ContractError(...))` when validation is enabled; that classification determines whether the block path treats the refusal as a paid consensus error. A regression that returned `ProtocolError::DataContractError` could still satisfy the current assertions. Match the exact nested variant as the existing private-document tests do, then separately assert the message fragment.
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/repeated_doctype_key_tests.rs:54-80: Pin the unchanged repeated-key behavior for protocol version 14
The new test exercises only `PlatformVersion::latest()`, so it verifies the new version-1 dispatch but does not pin the claim that version 14 and earlier still accept a repeated root key. A future refactor could move the refusal outside the version-1 arm and all current tests would remain green while changing shipped-version behavior. Add a case using the existing `latest_with_the_meta_schema_check` pattern, or an equivalent platform-version copy with `check_document_type_schema = 0`, and assert that the repeated schema remains accepted under the meta-schema path.
In `packages/rs-dpp/src/data_contract/methods/validate_update/repeated_properties_tests.rs`:
- [NITPICK] packages/rs-dpp/src/data_contract/methods/validate_update/repeated_properties_tests.rs:53-58: Reuse the platform serialization configuration in the wire fixture
The fixture is intended to reproduce the bytes carried by a state transition, but it duplicates `PLATFORM_BINCODE_CONFIG` with an inline bincode configuration. Reusing the exported platform constant keeps the test tied to the same encoding invariant as the production decoder and avoids drift if that configuration changes.
- [NITPICK] packages/rs-dpp/src/data_contract/methods/validate_update/repeated_properties_tests.rs:62-90: Name the test after the deserialization behavior it exercises
This test is located under `methods/validate_update` and is named as an update validation test, but it directly calls `DataContract::versioned_deserialize_untrusted` and never invokes `validate_update`. The comment explains that the refusal occurs before `validate_update` can compare versions, so a name such as `repeated_properties_decode_tests` or placement with contract serialization tests would more accurately describe the coverage. The block-level update path is covered separately by the drive-abci test.
Out-of-scope follow-up suggestions (1)
These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.
- Book still describes protocol-version-14 meta-schema validation as universal —
book/src/contract-keywords.mdstates that every document type schema is validated against the protocol-version-14 meta-schema when registered or updated, while protocol version 15 now uses the native schema checker. This documentation gap predates this PR and is not a production defect introduced here, but it should be corrected separately.- Follow-up: Open a documentation issue or follow-up PR covering the protocol-version-15 native registration checks.
|
Bots are done — your move: post |
… gate Address review on the PV15 repeated-key refusal tests: - match ProtocolError::ConsensusError(BasicError::ContractError( InvalidContractStructure)) exactly, then the message - pin that check_document_type_schema 0 (the PV14 registration check) still admits the repeat - move the wire-bytes contract test next to the parser tests, under the validation-gated module, encoded with PLATFORM_BINCODE_CONFIG 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 root-level duplicate-key refusal is correctly placed and version-gated, and all five prior findings are fixed. However, the new root-only scan leaves a real nested duplicate-key divergence: parser metadata can use the first nested properties entry while the native validation schema uses the last, allowing a registered schema whose required-field behavior differs between parsing and validation. The Rust workspace tests and JS build were still in progress in the supplied CI snapshot.
🔴 1 blocking
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); 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); 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 diff changes protocol-version-gated document schema validation on the consensus-critical contract registration path, specificallycheck_document_type_schemaandnative_schema::refuse_a_repeated_doctype_key, and therefore changes consensus rules despite being relatively contained. - 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 each finding against the current code and only fix it if needed.
In `packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/native_schema/mod.rs`:
- [BLOCKING] packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/native_schema/mod.rs:100-106: Nested duplicate properties can still diverge from the native validator
This helper scans only the document schema root, but the claim that all readers below the root already use last-entry semantics is not true. `parse_document_properties` builds `required_fields` through `Value::inner_recursive_optional_array_of_strings`, whose recursive map lookups use the first matching entry. For a nested object whose schema repeats `properties`, the first value can define `child` with `required: ["leaf"]` and the second value can define the same `child` without `required`. The parser therefore marks `child.leaf` as required, while `insert_values_nested` and `validation_schema::build_node` use last-entry maps and build a validator that does not require it. The existing repeated-entry helper covers repeated property names and the root `properties` keyword, but not a repeated `properties` keyword inside a nested object schema; the existing `shadowed_keyword` fixture demonstrates that such nested repeats are admitted. This leaves PV15 able to register a schema whose parser-owned required metadata disagrees with the native validator, allowing documents to be accepted by one representation and rejected by the other. Extend the PV15 reconciliation to nested parser-read schema keywords, or introduce matching versioned reader semantics, with a regression test.
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them. |
…ot only at its root Below the root the parser's `required` and `transient` walk reads the first `properties` of a nested object, where its property walk and every schema check read the last, so the root-only check still registered a type whose required metadata disagreed with its validator. `refuse_a_repeated_doctype_key` now walks every object of the schema and of the contract's `$defs` (a property's schema, an index, a `$defs` entry), naming where the repeat is. It runs on the schema and `$defs` as sent, from the generation-3 parser before it expands property type shorthands: expansion keeps the last of a repeated `type` or `size` and drops the rest, which hid such a repeat from the enriched root the check read before while the contract stored both entries. The version gate stays `check_document_type_schema` (`common`). Tests: a nested object naming `properties` twice, an index naming `unique` twice, a shorthand property naming `type` or `size` twice, a `$defs` entry naming `maxLength` twice; the PV14 check still admits the nested repeat; parsed without validation the nested repeat shows the two walks reading different entries. `should_keep_the_last_of_repeated_skip_if_absent_keys` keeps its last-wins read for a stored contract and expects the refusal at registration. Co-Authored-By: Claude Mythos 5.1 <[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
At head 5a37552, the recursive pre-expansion check closes the nested duplicate-key ambiguity, and all six prior findings are fixed. One blocking issue remains: repeated-key rejection bypasses the schema-validation charge despite performing a potentially whole-schema traversal. This was a static verification with no local builds or tests; current CI reports Rust workspace tests and Kotlin tests passing, with the JavaScript build and Swift build/tests still pending.
🔴 1 blocking
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); 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); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The recursive duplicate-key rejection in native_schema::refuse_a_repeated_doctype_key and its integration into the generation-3 parser change consensus acceptance rules with intricate interactions among nested schemas, $defs, shorthand expansion, protocol gating, and stored-contract loading. - 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,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 - 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-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/mod.rs`:
- [BLOCKING] packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/mod.rs:417-420: Account for schema traversal on duplicate-key rejection
This `?` returns before `parse_document_type_core` records `DocumentTypeSchemaValidationForSize` through `validate_schema_depth_and_account_for_size`. A schema can put a repeated root key after a large `properties` subtree, or a repeat in a late `$defs` entry: the new walker traverses the preceding objects and constructs their `BTreeSet`s, then rejects without recording a schema-validation operation for that document type. For a single-type contract, the transformation's DPP-operation accumulator remains empty; both create and update transformers forward that accumulator even on consensus errors, so `PaidConsensusError` does not restore the omitted charge. Unlike the existing early name check, this rejection performs work proportional to attacker-controlled schema contents. Keep the check before shorthand expansion, but account for the work on rejection through the PV15 DPP validation-cost path without double-charging successful parses. Add a regression that places a duplicate after a substantial subtree and asserts the accumulated validation operation or resulting processing fee.
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them. |
The PV15 repeated-key walk runs before the parse records its DocumentTypeSchemaValidationForSize operation, so a refusal returned with the walk unbilled. A refusal now records that operation for the size the parse bills on success (the schema with the base schema and $defs added, as sent); a walk that passes records nothing, so a registered type is billed once. A root deeper than the maximum depth, or one the base schema can not be added to, is left to the stages that follow, so the walk never descends past the depth limit. 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 |
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them. |
…alk reads The walk skipped an entry whose key is not text without counting it, so a wide map of such entries before a repeat added work the refusal charge did not cover. Each such entry now counts as read; it is still not walked into (the checks that follow refuse non-text keys). 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
Verified the combined reviewer evidence against head 8564557. All 11 prior findings are fixed, but one blocking accounting gap remains: a successfully parsed document type can discard its raw traversal count before a later type rejects the contract. Validation was static only; current Rust workspace tests and the JS build remain pending.
🔴 1 blocking
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 7: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 8: gpt-6-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 9: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 10: gpt-6-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 11: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); reviewer 12: gpt-6-astra (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 recursive duplicate-key validation and deferred schema-read fee accounting in try_from_schema/native_schema/mod.rs and try_from_schema/v3/mod.rs introduce intricate changes to consensus acceptance and billing 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 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 - 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-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/mod.rs`:
- [BLOCKING] packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/mod.rs:386: Preserve the raw traversal floor when an individual type parses successfully
The raw walk can inspect substantially more values than the successful type's depth measurement covers. An otherwise valid type can contain a root `required` array with N copies of `$createdAt`: the new walk visits every element, but `enrich_with_base_schema_v1` removes all of those system-generated requirements before depth measurement and native validation. Parsing succeeds, and this arm discards the larger raw count, leaving the schema-size charge independent of N.
This also affects rejected contracts, not just successful registration. Submit that schema as type `a`, followed by type `z` containing a repeated root key. `create_document_types_from_document_schemas_v0` processes the BTreeMap in name order, retaining `a`'s undersized operation before `z` returns a consensus error. Both node transformers forward those operations, but construction stops before compiled-size validation or storage can account for the omitted work. Increasing N therefore increases this PR's validator traversal without increasing its schema-validation charge. Apply the raw-read floor to successful per-type parses too, preserving the existing version gate and single size operation, and add a regression covering normalization followed by another type's rejection.
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them. |
…alk's read A type that registers was billed the depth check's size alone, which can be less than the walk read: the depth check measures the schema after the base schema drops the system fields of `required`. The walk's count is now a floor on every path, registered or refused. Registration fees at protocol version 15 rise by the difference (20 to 60 credits for the check_tx test contracts, whose expected fees are updated); protocol version 14 runs no walk and is unchanged. 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 review of the complete diff at 6f4afa9 found no remaining blocking defects, and all 12 prior findings are fixed. One nonblocking suggestion remains: directly pin PV14 validation-operation forwarding through the new billing adapter. No builds or tests were run in this lane; current CI shows Kotlin tests passing, but changed-package detection and PR Hygiene remain pending, and completed Rust validation is not yet established.
🟡 1 suggestion(s)
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); 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); 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 recursive duplicate-key validation in native_schema::refuse_a_repeated_doctype_key and the generation-3 parser's SchemaReadBilling introduce intricate consensus-visible contract acceptance and fee-accounting changes gated to PV15. - 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 each finding against the current code and only fix it if needed.
In `packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/repeated_doctype_key_tests.rs`:
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/repeated_doctype_key_tests.rs:265-269: Pin historical operation forwarding as well as schema acceptance
This historical-path test verifies acceptance, but `parse_on` discards the validation-operation accumulator. The new `SchemaReadBilling` adapter also handles PV14, where preserving the original operations is a separate consensus-sensitive guarantee. Removing the `if walked` guard from its `Extend` implementation would swallow PV14's schema-size operation without changing acceptance, so this test would remain green. Add a regression using `PlatformVersion::get(14)` that asserts the pre-change operation sequence for a successful schema and an early rejection such as malformed `immutable`, which must not acquire the PV15 traversal charge. The current forwarding logic is correct; this would protect its historical-fee guarantee directly.
|
Bots are done — your move: post |
The generation-3 parser forwards its operations through the repeated-key billing adapter at protocol version 14 too, where no walk runs. Pin that a type registering there records the depth check's size alone and one refused before the depth check (a malformed `immutable`) records none. 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
Verified the complete diff at 30c389a: repeated-key rejection runs before normalization only under PV15 validation, traversal billing survives successful and rejected parses, and PV14 operation forwarding remains unchanged. All 13 prior findings are fixed, with no remaining actionable findings. This was a static review; current CI reports no failed checks, but the Rust workspace test runner-selection job and JS build remain pending.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); 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); 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 recursive duplicate-key validation and fee accounting in try_from_schema/native_schema/mod.rs and try_from_schema/v3/mod.rs introduce intricate consensus-visible changes to contract acceptance and processing charges at protocol version 15. - 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 |
Both sides moved the check_tx DashPay contract fee pins: the base bills a document type's schema size at least the values its repeated-key walk read (#5702), this branch adds the DashPay v3 declarations. The comments keep both reasons; the values are re-pinned in the next commit. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Basic explanation
What this does: A document type's schema is a map of keys (
properties,indices,documentsMutable, ...). Written as JSON a key can only appear once, but the binary form a state transition carries can hold the same key twice. From protocol version 15, registering a contract (creating it or updating it) is refused when any object of a document type's schema, its root or one below it, names the same key twice. #5689 already refuses a repeat at the root of a private document type's schema; this applies the rule to every type and every object of the schema.Value: The parser and the schema checks no longer have to agree on which of two entries counts: the parser reads the first entry of many a repeated key (every top-level keyword,
requiredandtransientdown a nestedproperties, an index's keys), while the schema checks and the document validator read the last, and below the root the parser's own walks disagree (itsrequiredwalk reads the firstpropertiesof a nested object, its property walk the last). With the repeat refused, the document type the chain parses is always the one its schema shows.Risks: Low. It is a consensus rule, but only at protocol version 15, which has not shipped. A schema written as JSON can never repeat a key, so no contract built the usual way is affected. Contracts already stored keep loading: loading a contract runs no schema check, and earlier protocol versions keep their registration check unchanged. Registering a contract at protocol version 15 costs slightly more processing fee where the schema holds values the depth check does not measure (20 to 60 credits for the test contracts), since its schema size is billed at least the values the walk read.
Issue being fixed or feature implemented
The document type parser reads a top-level schema key with
get_optional_from_map, which returns the first entry, andinner_recursive_optional_array_of_strings(therequiredandtransientwalk) reads the firstpropertiesof each nested object the same way, whereinsert_values_nestedreads the last through aBTreeMap. The registration check (document meta-schema through PV14, the native check from PV15) and the document validator read the schema as JSON, where the last entry wins. #5689 closed that gap for the root of private types (declares_private_document); public types still accepted a repeated top-level key, and every type a repeat below the root.What was done?
native_schema::refuse_a_repeated_doctype_key(try_from_schema/native_schema/mod.rs): refuses a key any object of the document type schema or of the contract's$defsnames more than once, at the schema's root, in a property's schema, in an index, or in a$defsentry, naming where (at its root,at properties.note,at indices[0],at $defs.word), with the error feat(platform)!: private document types, declared with theprivatekeyword (PV15) #5689 uses for private types (InvalidContractStructure), so there is no new error code. The walk is linear in the schema's size and recurses no deeper than decoding it did.common::refuse_a_repeated_doctype_key(try_from_schema/common/mod.rs) gates it oncheck_document_type_schema(0 refuses nothing, 1 runs the walk), and the generation-3 parser (try_from_schema/v3/mod.rs) runs it under full validation on the schema and$defsas sent, before it expands property type shorthands: expansion keeps the last of a repeatedtypeorsizeand drops the rest, which would hide the repeat from every later check while the contract stores both entries, and every later check reads the schema as JSON, which keeps only the last entry. Registration only: loading a stored contract runs no full validation.requiredwalk does not (thepastaclaw's blocking finding). The validation schema builder's own repeated-entry rules (refuse_repeated_entries_the_parser_reads_otherwise,refuse_a_required_repeated_differently) stay: they still guard contracts stored before protocol version 15, whose documents the native validator checks.DocumentTypeSchemaValidationForSizeoperation, so it counts the values it reads, andtry_from_schema_generation_3holds the depth check's size until the parse is judged, then records one size: the larger of the depth check's size and the walk's count, or the count alone when the type was refused before the depth check (a repeat, or a later stage such as a malformedimmutable). The count is a floor whether the type registers or not: the depth check measures the schema after the base schema drops the system fields ofrequired, and may stop early at an unresolvable$ref. The walk always reads the whole schema and$defsas sent, whatever a$refor annotation in them says.native_schemamodule doc lists it among protocol version 15's own rules, and note 7 ofv15.rsmentions it.Example, a document type schema whose root names
propertiestwice:{ "type": "object", "properties": { "a": { "type": "string", "maxLength": 10, "position": 0 } }, "properties": { "a": { "type": "integer", "minimum": 0, "maximum": 100, "position": 0 } }, "additionalProperties": false }Before (protocol version 15): registered; the parser reads
aas a string, the schema checks and the document validator read it as an integer.After (protocol version 15): refused at registration:
The same holds for any other key, at the root (
documentsMutablewritten twice) or below it: a nested object's schema namingpropertiestwice (at properties.note), an index naminguniquetwice (at indices[0]), a$defsentry namingmaxLengthtwice (at $defs.word). Protocol version 14 and earlier: unchanged.How Has This Been Tested?
New tests, at the latest protocol version:
try_from_schema/v3/repeated_doctype_key_tests.rs: full validation refuses a repeatedpropertiesand a repeateddocumentsMutableat the root, a nested object namingpropertiestwice (first with achildrequiringleaf, then without: the reviewer's case), an index naminguniquetwice, a shorthand property namingtypetwice and one namingsizetwice (which expansion would have erased), and a$defsentry namingmaxLengthtwice, each withConsensusError::BasicError(BasicError::ContractError(InvalidContractStructure))and the place named; a contract decoded from transition bytes (PLATFORM_BINCODE_CONFIG) with the repeat is refused the same way; the PV14 registration check (check_document_type_schema0) still admits the root and the nested repeat; parsed without validation (a stored contract) the root repeat still loads reading the first entry, and the nested one loads with the parser requiringnote.child.leafof the first entry while holding theextraproperty of the last, which is what the rule keeps out; without the repeat the schemas register.index_only_tests::should_keep_the_last_of_repeated_skip_if_absent_keyskeeps its last-wins read for a stored contract and expects the refusal at registration.batch/tests/document/repeated_properties_update.rs: the update goes throughprocess_raw_state_transitionsand is refused as a paid consensus error (BasicError::ContractError(InvalidContractStructure)); the contract stays at version 1 and its stored documents read as they were written.Ran locally:
cargo test -p dpp --lib --features all_features -- repeated private_document_tests native_schemacargo test -p drive-abci --lib -- repeated_properties_update private_document data_contract_update byte_array_encoding_flip_chain_haltcargo clippy -p dpp --features all_features --tests,cargo check -p dpp --tests(default features)Breaking Changes
Protocol version 15 only: creating or updating a contract whose document type schema names a key twice in any object it holds, at its root or below it, is refused with
InvalidContractStructure. Earlier protocol versions and contracts already stored are unaffected.In-place changes to shipped generations
try_from_schema/v3/mod.rs,try_from_schema_generation_3andparse_generation_3), selected by protocol versions 14 and 15: it now callscommon::refuse_a_repeated_doctype_keyand forwards its operations throughSchemaReadBilling. Inert at protocol version 14: the call dispatches oncheck_document_type_schema, which is 0 there and walks nothing, so the walk's count staysNone, the adapter holds no operation and forwards every one unchanged, and no size is added. The new rule itself (check_document_type_schema1) is selected only byCONTRACT_VERSIONS_V7, which only protocol version 15 uses, and protocol version 15 has not shipped.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 ·
30c389a/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.Summary by CodeRabbit
$defs, including in nested objects and arrays, and identifies the repeated key and its location.