feat(platform)!: identity public key references (refersTo identityPublicKey) - #4397
Conversation
…licKey) Extends refersTo with an identityPublicKey target: the property value holds the referenced identity's id and the declaration names a sibling integer property of the same document type (keyIdProperty) whose value carries the key id. Identity keys can be disabled but never removed, so an existing reference can never dangle; at write time the key must exist and must not be disabled (a key disabled later does not invalidate old documents). The billed existence check goes through fetch_identity_keys with a specific-key request, billed as one key lookup, matching how signature validation fetches keys. Contract registration (the create/update reference validation from the permanentDocument work) checks that the declared keyIdProperty exists in the same document type and is an integer. New state errors: ReferencedIdentityKeyNotFoundError (40123, also covers a missing identity), ReferencedIdentityKeyDisabledError (40124) and ReferencedKeyIdPropertyInvalidError (40125), discriminants pinned. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 9 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (20)
Comment |
|
ℹ️ Review superseded (commit f963dd8) |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## v4.2-dev #4397 +/- ##
============================================
- Coverage 87.68% 85.92% -1.76%
============================================
Files 2680 2680
Lines 341126 347366 +6240
============================================
- Hits 299109 298472 -637
- Misses 42017 48894 +6877
🚀 New features to boost your workflow:
|
Issue being fixed or feature implemented
Follows #2993 (refersTo for identities, contracts, tokens) and #4390 (permanent documents). This adds the next reference target that structurally cannot dangle: a specific public key of an identity — identity keys can be disabled but never removed.
What was done?
Extends
refersTowith anidentityPublicKeytarget. The reference property's value holds the identity id; the declaration names a sibling property of the same document type whose value carries the key id:This two-property shape matches how DashPay's
contactRequestalready pairstoUserIdwithrecipientKeyIndex, so per-document key selection works naturally.Semantics
keyIdPropertymust exist in the same document type and be an integer. The u32 key-id range is enforced at write time by the integer read.Changes
DocumentPropertyReferenceTargetgainsIdentityPublicKey { key_id_property }(appended — the enum is consensus-serialized inside errors and@append_only).refersTo.typeadmitsidentityPublicKey;keyIdProperty(dotted property-path shape, ≤256 chars) is required for it and rejected for every other target. The per-target conditionals are now anallOfofif/then/elseblocks.apply_property_reference_v0): new arm; missing/oversizedkeyIdPropertyis a hard parse error.document_reference_validationv0, amended in place — PV14 is unreleased): resolves the key id from document data (ReferencedKeyIdPropertyInvalidErrorwhen unset or out of range), billsRetrieveIdentityInfo::one_key(), fetches viafetch_identity_keys::<OptionalSingleIdentityPublicKeyOutcome>withIdentityKeysRequest::new_specific_key_query, then checksis_disabled().data_contract_reference_validationv0, amended in place — also PV14-new):keyIdPropertymust resolve to an integer property of the declaring document type.ReferencedIdentityKeyNotFoundError(40123 — a missing identity and a missing key are indistinguishable in the key tree and resolve to the same failure),ReferencedIdentityKeyDisabledError(40124),ReferencedKeyIdPropertyInvalidError(40125, shared by registration and write time).generic_consensus_error!.How Has This Been Tested?
keyIdProperty;keyIdPropertyon other targets; malformed values).setup_contract): key exists (success), key missing, identity missing, key disabled (the helper disables the test identity's master key in state), key-id property unset.keyIdPropertyand non-integerkeyIdPropertyare rejected at create.--all-targetschecks clean on dpp/drive/drive-abci/dash-sdk/wasm-dpp, clippy clean, fmt applied.Breaking Changes
Consensus-breaking for the in-development protocol version 14 only (extends the PV14 meta-schema v3 grammar and reference validation; pre-PV14 behavior is untouched).
Checklist:
For repository code-owners and collaborators only
🤖 Generated with Claude Code