Repository navigation
fix(dpp): read a refersTo as dynamic only where protocol version 14 cannot read it - #5887
Conversation
…annot read it Version 1 of apply_property_reference (protocol version 15) read a refersTo as naming its target through the referring document whenever its contractId or documentType was a "$self." string, whatever its type. Version 0 (protocol version 14) never reads those keys on an identity, contract, token or identityPublicKey reference, and reads a document reference's documentType as a type name. A contract stored before protocol version 15 with these keys on such a declaration therefore loaded at 14 and was refused at 15. declares_dynamic_target now holds only for a declaration version 0 cannot read at all: a reference to a document whose contractId is a "$self." string, or a type that lists kinds. Every other declaration is read as version 0 read it, so such a contract loads as it did. Registration at 15 is unchanged: before the parser runs, the native schema check refuses "$self." keys on a non-document reference, and a documentType read from the document beside a contractId that is not. Follow-up to #5849. Test would have caught this in CI: ✖ before fix, ✔ after: - should_load_a_stored_non_document_reference_with_self_target_keys_as_it_did before: "identity refersTo reads no contractId or documentType from the referring document ..." - should_load_a_stored_document_reference_whose_document_type_alone_is_written_self_as_it_did before: "... reads both contractId and documentType from it: contractId must be ..." - should_load_judge_and_expire_documents_of_a_contract_registered_at_protocol_version_14_with_self_keys_on_identity_references before: loading the contract at protocol version 15 failed with the identity refersTo error 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 39 minutes. View limit details
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 1fcc98d) · triage: normal |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
Static verification of head 1fcc98d found no actionable defects. The duplicate-key fixture exercises historical binary-schema behavior intentionally, and the predicate change remains isolated to protocol version 15 while registration restrictions remain unchanged. Current CI shows all executed code checks passing, including the previously queued JavaScript suites; only review and hygiene checks remain pending.
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); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); 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:
normalbygpt-6.1-sol(effort low) — The production change is a small, contained adjustment to declares_dynamic_target in dynamic_reference.rs, with extensive compatibility tests, rather than a large or intricate modification qualifying as critical. - 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) - Second Phase-2 pass: on this first full review every Phase-2 reviewer also ran a second, independent time, and the verifier weighed both sets
- 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,gpt-6.1-sol— security-auditor (completed, effort high); agentphase2-reviewer,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,gpt-6.1-sol— security-auditor (completed, effort high); agentphase2-reviewer
|
Bots are done — your move: post |
…roposal-contract-1db678 Brings in v5.1-dev at 97fb5f9: a refersTo is read as dynamic only where protocol version 14 cannot read it (#5887). The merge is clean and no root pin, fee pin or stored contract fixture line changes. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ecision-proposal-description-reference Brings in v5.1-dev at 97fb5f9: a refersTo is read as dynamic only where protocol version 14 cannot read it (#5887). The one conflict is protocol version 15 note 33, where both sides added a sentence: it keeps this branch's use of the reference by the decision proposals contract and the base's statement of which declarations version 1 reads as dynamic. The parser and its tests merge cleanly: the description reference is a `moderatedDocument` whose `contractId` is written `$self.`, which stays dynamic. No root pin, fee pin or stored contract fixture line changes. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Issue being fixed or feature implemented
Follow-up to #5849, document references whose target the document names (protocol version 15).
Version 1 of
apply_property_referenceread arefersToas naming its target through the referring document whenever itscontractIdordocumentTypewas a"$self."string, whatever itstype. Version 0, which protocol version 14 runs, never readscontractIdordocumentTypeon anidentity,contract,tokenoridentityPublicKeyreference. On a document reference it readsdocumentTypeas a plain document type name. So a contract stored before protocol version 15 with these keys on such a declaration loaded at 14 and was refused at 15. With this change it loads as it did.What was done?
Detection (
declares_dynamic_target). A declaration now gets the dynamic reading only when version 0 cannot read it at all:permanentDocument,moderatedDocumentordeletableDocument) whosecontractIdis a"$self."string. That is never an identifier, so version 0 refuses it.typethat is a list. Version 0 readstypeonly as a string.Every declaration version 0 can read is read exactly as version 0 reads it. The same predicate drives the refusal of a dynamic target in an expression operand, on a string or byte array property, on typed-array elements, and in
ownerRefersTo/creatorRefersTo, so those narrow the same way.Registration is unchanged. At protocol version 15 the native schema check already refuses these declarations before the parser runs:
"$self."keys on a non-document reference: itstypemust then bepermanentDocumentormoderatedDocument.documentTyperead from the document next to acontractIdthat is not read from it:contractIdis then required and must be"$self."too.I kept the refusal in that registration check rather than ignoring the keys there, because a new contract then cannot carry them. Meanwhile the parser itself never refuses them, so loading a stored contract never does.
deletableDocumentwith a"$self."contractIdstill reaches the dynamic parser, which refuses it with its explicit message. Version 0 refuses it too.Doc comments updated to match:
declares_dynamic_target,apply_property_reference_v1,parse_doctype_reference, and note 33 ofv15.rs.How Has This Been Tested?
New tests, red on
v5.1-devand green with the fix:should_load_a_stored_non_document_reference_with_self_target_keys_as_it_did.identity,contractandtokenreferences on a property, and an identity reference in ananyOfoperand and inownerRefersTo.type.invalid contract structure: identity refersTo reads no contractId or documentType from the referring document and takes no documentTypeRequirements: …should_load_a_stored_document_reference_whose_document_type_alone_is_written_self_as_it_did.permanentDocumentandmoderatedDocumentwithdocumentType: "$self.…"and acontractIdleft out or given as an id, and the same in ananyOfoperand.contractId.invalid contract structure: permanentDocument refersTo naming its target through the referring document reads both contractId and documentType from it: contractId must be "$self.<a top-level property>"should_load_judge_and_expire_documents_of_a_contract_registered_at_protocol_version_14_with_self_keys_on_identity_references.DataContractCreate, then writes an expiring note and refuses a note naming a missing identity.the contract should load at the latest protocol version: Protocol(ConsensusError(BasicError(ContractError(InvalidContractStructure("identity refersTo reads no contractId or documentType from the referring document …")))))should_refuse_what_cannot_sit_beside_a_dynamic_target. AcontractIdgiven in the schema, or left out, next to a"$self."documentTypeis now refused by registration rather than by the parser, which reads it as version 0 does. ThedocumentTypecases still go through the parser's own refusal.dynamic_reference_tests,native_schema) and drive-abci (dynamic_document_reference) pass unchanged.Commands run:
cargo test -p dpp --all-features --lib --tests: 6,096 lib and 44 integration tests passed, the contract corpus loads included.RUST_MIN_STACK=4194304 cargo test -p drive-abci --lib: 4,631 passed.cargo clippy -p dpp -p drive-abci -p platform-version --all-features --all-targets -- -D warningsandcargo fmt --all -- --check: clean.78d691dd4e: thetry_from_schematests and the related drive-abci tests again.Breaking Changes
None. Only protocol version 15 behaviour changes, and protocol version 15 is unreleased and not activated on testnet or mainnet, which both run 14. At 15 no registration verdict changes. A contract stored before 15 with these keys on a declaration version 0 reads now loads, where it was refused.
In-place changes to shipped generations
None. The edited code is reached only through
apply_property_reference1 and theSome(1)arms beside it, which only protocol version 15 selects (CONTRACT_VERSIONS_V7). Protocol version 14 and earlier keepapply_property_reference0 and never calldeclares_dynamic_target.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 ·
1fcc98d/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.