feat(platform)!: dashpay contact requests declare their checks (PV14) - #4933
QuantumExplorer wants to merge 2 commits into
Conversation
DashPay v2's contactRequest now states in its schema what consensus checks, using the PV14 keywords, instead of a hand-written data trigger: - toUserId: distinctFrom "$ownerId" (no request to oneself) and an identityPublicKey refersTo naming recipientKeyIndex (the recipient identity exists, holds that key, and the key is not disabled; the trigger only checked the identity). - encryptedPublicKey / encryptedAccountLabel: encryptedFor with the ecdh-secp256k1-aes256-cbc scheme, so wallets read the recipe from the contract and consensus refuses bytes that are not an IV plus whole AES blocks. senderKeyIndex / recipientKeyIndex gain maximum u32::MAX, which encryptedFor requires; DashPay keeps sizedIntegerTypes off, so both are still stored as i64. - Data trigger bindings 2 (PV14 only) drop the contact request trigger. The three new profile address fields lose their schema descriptions to keep the stored contract small; their formats move to a code comment. DashPay v2 replaces v1 in place at the PV14 upgrade without the contract update checks, so new tests pin that every v1 property keeps its stored encoding, run the registration checks system contracts skip, and read v1 contact documents back unchanged across the upgrade. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
📖 Book Preview built successfully. Download the preview from the workflow artifacts. Updated at 2026-09-23T03:19:23.557Z |
|
🕓 Review not started yet because this PR is a draft.
Commit 64fb59c. Normal review starts when eligible; priority review starts as soon as a slot is available. |
…ize account label Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Issue being fixed or feature implemented
DashPay v2 (protocol version 14) is the first DashPay contract that can use the schema keywords landed for PV14 (
refersTowithidentityPublicKey,distinctFrom,encryptedFor). The contact request still relied on a hand-written data trigger that checked two things: the recipient is not the sender, and the recipient identity exists. It never checked that the recipient holds the key the request names, and nothing in the contract told a wallet howencryptedPublicKeyandencryptedAccountLabelare encrypted.Separately, the three profile address fields added in 4.2 carried long
descriptionstrings that are stored and billed with the contract on chain.What was done?
contactRequestdeclares its checks (DashPay schema v2, edited in place: it is only loaded from protocol version 14)encryptedAccountLabelcarries the sameencryptedFor. Themaximumbounds are whatencryptedForrequires of key id properties. DashPay keepssizedIntegerTypesoff, so both key indexes are still stored as i64, exactly as v1 stored them.Data trigger bindings 2 (only selected from protocol version 14) drop the contact request create trigger, since the declarations make both of its checks.
create_contact_request_data_triggerstays at 1 in the v10 table, now unbound, with a comment.Behaviour at protocol version 14, before and after this PR:
All of these are paid consensus errors. Wallets and SDKs can now read the encryption recipe from the contract (
documentTypeEncryptedProperties("contactRequest")in JS,encrypted_properties()in Rust).Profile address descriptions removed
The
descriptionstrings oncorePaymentAddress,platformPaymentAddressandshieldedAddressare gone from the schema; the formats they described now live in a comment inpackages/dashpay-contract/src/v2/mod.rs. Net effect with the declarations above, creating the DashPay contract at protocol version 14 (check_tx test pin):Docs: v14 changelog item 33, the
SYSTEM_DATA_CONTRACT_VERSIONS_V3comment, and a "What consensus checks" table inbook/src/evo-sdk/dashpay-contact-requests.md.What was deliberately left out
keyRequirementson the recipient key. A census of all 368 testnet contact requests (docs/dashpay/SPEC.md, G15) found the mobile wallets (223 of them) use an unbound ENCRYPTION key, id 2, for both indexes, and mobile identities carry no DECRYPTION key. Requiringpurpose: "decryption"orboundTo: "contactRequest"would refuse Dash Wallet's requests, andkeyRequirementstakes one purpose, not "encryption or decryption".identityProperty: "$ownerId"onsenderKeyIndex, and a key id property with that reference is always stored as a u32. DashPay stores it as an i64, so every stored contact request would be misread after the upgrade (see below). Possible follow-up: storeKeyIdWithReferenceat the width the bare integer would get.contactInfo.encToUserIdis AES-256-ECB (two raw blocks, no IV) andprivateDatais AES-256-CBC under a BIP32-derived key, both self-encrypted; neither is the ECDH schemeencryptedForknows. Declaringecdh-secp256k1-aes256-cbconencToUserIdwould even pass the shape check (32 bytes) while giving wallets the wrong recipe.How Has This Been Tested?
DashPay v2 replaces v1 in place at the upgrade (
apply_contractintransition_to_version_14) without the contract update checks, and system contracts are never run through contract create validation. So the new tests cover what those checks would have:rs-dppshould_store_every_dashpay_v1_property_as_v1_did: every property v1 declares has the same stored encoding in v2. Mutation-checked: addingidentityPropertytosenderKeyIndexfails it (i64vsu32).rs-dppshould_declare_the_contact_request_checks_and_encryption: the parsed contract carries the reference,distinctFromand bothencryptedFordeclarations.drive-abcishould_accept_the_references_the_dashpay_system_contract_declares: the registration reference checks accept DashPay's declarations. Mutation-checked: akeyIdPropertynaming a missing property fails it.drive-abcibatch/tests/document/dashpay_contact_request.rs: a valid request, and the refusals above for oneself, a missing identity, a missing key and a 50-byte label, end to end throughprocess_raw_state_transitionson the system contract. The disabled key case is covered by the genericidentityPublicKeyreference tests, not a DashPay-specific one.drive-abcitest_protocol_change_v13_to_v14_upgrades_dashpay_and_keeps_v1_documents_readable(renamed from..._profiles_readable): also stores a v1contactRequest(with anaccountReferenceabove u32) and a v1contactInfoat protocol version 13 and asserts v2 reads both back unchanged. Mutation-checked: with the u32 re-encoding above, v2 silently readssenderKeyIndex1 as 0 andrecipientKeyIndex0 as 4294967296.deterministic_root_hash.rsand the DashPay-contract fees incheck_tx. Two deletion/replacement tests that build a random system contact request now set a valid 48-byteencryptedAccountLabel.Local runs on the rebased branch:
drive-abci --lib: 3385 passed; the only 2 failures were the deletion/replacement tests whose randomencryptedAccountLabellength now failsencryptedFor. With a fixed 48-byte label both pass, and the not-mutable replace fee pins moved by 200 (second commit).rs-dpp --lib: 4648 passed.dashpay-contractandplatform-versiontests pass.check_tx, the deletion/replacement tests anddrivedeterministic_root_hash.Breaking Changes
Consensus change at protocol version 14 (unreleased): contact requests that were accepted before (unknown or disabled recipient key, account label or public key that is not an IV plus whole blocks) are refused, and the errors for a request to oneself or to a missing identity change code, as listed above. Clients that match on the old
DataTriggerConditionErrormessages must match the new errors.In-place changes to shipped generations
None. The DashPay v2 schema and data trigger bindings 2 are only selected by protocol version 14, which has not shipped. The v14 changelog entry is item 33, after #4930 took 32.
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
Summary by CodeRabbit