Repository navigation
feat(platform): adopt 4.2.0-beta.3 nonce-committed document ids - #562
Conversation
Platform 4.2.0-beta.3 (protocol 14) derives document ids from the identity contract nonce; the JS SDK ships the matching rs-sdk put path. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Protocol 14 (platform#4859) makes a new document's id dsha256("dash:document-id:v1" || contractId || ownerId || typeName || entropy || nonce BE), recomputed by consensus and refused on mismatch (InvalidDocumentTransitionIdError). The shipped wasm-dpp2 Document constructor and Document.generateId still produce the entropy-only v0 id and DocumentCreateTransition copies document.id verbatim, so the manual create path now fetches the nonce first, derives the id in lib/document-id.ts (pinned to rs-dpp's test vector), and builds the Document and the transition from that one nonce. The ST-byte replay cache stays keyed by the derived id; the pre-create exists-by-id probe is gone because a fresh call always derives a fresh id. buildDocumentForCreate requires the nonce; generateDocumentIdentity and getDocumentId are removed. The auth vault encrypts against the id createDocument hands it via a data callback, so the AEAD-bound id is the one Platform stores.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Under protocol 14 the seeders' precomputed Document.generateId id is a placeholder: documents.create() assigns the nonce, derives the real id and returns the confirmed Document. buildDocument now returns id=null unless a nonce (pipeline.mjs, verify-poll-interop.mjs, dry runs) or an existing id (replace/delete) is given; create paths take the id from the returned Document (createdId) and, when the call threw after broadcasting, recover it by a value readback of the owner's recent documents (findRecentByValues) or by the caller's existing value probe (indexOnly types, profile by owner). Ids are recorded in the checkpoint files under the logical key as before, so resumability survives; a stored doctype without a distinctive value set carries a documented duplicate risk after such a throw. seed-lib carries the derivation for Node and the seeder self-test pins it to rs-dpp's vector. verify-v4/verify-v5 are untouched historical records. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Adds matchers for the beta.3 codes the app can hit on the current v7 contract: 10405 InvalidDocumentTransitionId, 41107/41108/41114 moderation ban/suspension/counterparty barred, 40129/40130/40222 gas payer, 40132/40133/40134 action fee agreement, 40131 referenced type not deletable, 40722 once-per-identity grant already claimed. Each is pinned to rs-dpp's rendered message and labelled-code form, given a permanent user-facing message in categorizeError (never the buy-YAPP or network ones), and excluded from retryPostCreation via isPermanentProtocol14Error. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…e's real reach Review follow-ups: findRecentByValues takes a since floor (batteries pass the write start so an identical fixture from an earlier run cannot score a refused write as accepted; seeders leave the pre-write probe unbounded on purpose), returns null for empty data and undefined rows, guards sameValue against uncoercible values, only falls back to an unordered page on an index-shape refusal, and scans 100 rows. feature-seed-lib wraps the pre-write probe in readback. The seed-lib derivation is renamed deriveDocumentIdBytes to match lib/document-id.ts. The createDocument and retryPostCreation comments and the upgrade doc now say plainly that the ST replay cache is unreachable from a fresh call (as it was before protocol 14) and that the optimistic confirmed:false return is the double-write guard; the DM IV and older-post adoption risks are documented. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
buildDocumentForCreate returns the Document alone (its caller already holds the derived id); the auth vault builds its seven stored fields once for create and replace; createdId reuses asBase58; the preimage is assembled from a parts array; the seeder self-test derives the pinned id once. Restores the updateDocument docstring dropped while moving createDocument's. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Deploying yappr-v2 with
|
| Latest commit: |
cd64bc9
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://edf9a5ea.yappr-v2.pages.dev |
| Branch Preview URL: | https://beta3-sdk-and-ids.yappr-v2.pages.dev |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
Deploying yappr with
|
| Latest commit: |
cd64bc9
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://1b20fcce.yappr.pages.dev |
| Branch Preview URL: | https://beta3-sdk-and-ids.yappr.pages.dev |
|
|
Why
Platform 4.2.0-beta.3 (protocol 14, dashpay/platform#4859) derives a new document's id from the identity contract nonce of its create transition:
Consensus recomputes it and refuses a mismatch with
InvalidDocumentTransitionIdError(10405). The shipped wasm-dpp2Documentconstructor andDocument.generateIdstill produce the entropy-only v0 id, andnew DocumentCreateTransition({ document })copiesdocument.idverbatim — so every create Yappr signed by hand was refused on beta.3. This is PR A of the beta.3 upgrade: keep the current v7 contract working. The contract re-cuts adopting moderation,deletableDocument, optional token costs, gas sponsorship, the once-per-identity grant and action fees are PR B (beta3/social-v8); the moutai deployment is PR C.What
@dashevo/evo-sdkand@dashevo/wasm-sdkto exactly4.2.0-beta.3(one WASM runtime resolved).lib/document-id.ts— the derivation in JS (@noble/hashes), plus DIP-30 nonce masking.lib/document-id.test.tspins rs-dpp's consensus vector (e574ae73…c50f15f) and asserts it is not the v0 id.createDocument(state-transition-service.ts) is now nonce-first: fetch nonce → derive id → buildDocumentandDocumentCreateTransitionfrom that one nonce → sign → broadcast.buildDocumentForCreaterequires{ entropy, identityContractNonce };generateDocumentIdentity/getDocumentIdand thedocumentId/entropyoptions are gone, so a create document without a nonce-derived id can no longer be built.documentDatamay be a function of the id, called once with the id the transition will carry.createDocumenthands it (AEAD associated data), so the AAD id is the stored$idby construction.seed-lib,verify-lib,battery-lib,feature-seed-lib,pipeline,run-seeder,provision-seed-identities,verify-refersto,verify-poll-interop):buildDocumentreturnsid: nullfor a create unless anonce(hand-built transitions) or anid(replace/delete) is given; create paths read the real id from theDocumentdocuments.create()returns and checkpoint it under the logical key as before. A create that threw after broadcasting is reconciled by the existing value probes (unique index / indexOnly) or byfindRecentByValues, time-bounded in the batteries.seed-libmirrors the derivation for Node and the seeder self-test pins the same vector.verify-v4/verify-v5untouched.lib/error-utils.ts— matchers for 10405, 41107/41108/41114, 40129/40130/40222, 40132/40133/40134, 40131, 40722, each pinned to rs-dpp's rendered message and labelled-code form, given a permanent user-facing message, and excluded fromretryPostCreation.docs/PLATFORM_BETA3_UPGRADE.md— all 33 beta.2→beta.3 commits with their effect on Yappr, the derivation section, what is/isn't verified, PR B summary, deployment-evidence stub.Behaviour changes a reviewer should know
createDocumentandretryPostCreationthat claimed otherwise are corrected; the double-write guard on a timed-out wait is the optimisticconfirmed: falsereturn. Making the cache reachable needs a caller-supplied idempotency key (separate change).Verification
npx tsc --noEmit,npm run lint,npm run lint:dead,npx vitest run(60 files / 531 tests),npm run build:devnet— clean against beta.3.run-seeder --self-test(incl. 4 new document-id checks),verify-v7 --self-test,verify-refersto --dry-run,verify-{blog,dm,storefront,tips,pollr} --self-test,seed-non-social --which * --self-test/--dry-run,provision-seed-identities --self-test— pass.code-review-validatorandcode-simplifierpasses applied (time-bounded value readbacks,sameValueguards, honest cache comments, dedup).createDocument. Moutai answeredgetStatusduring this work with drive/dapi4.2.0-beta.3, protocol 14, height 237 (fresh wipe); nothing was broadcast from this PR.🤖 Generated with Claude Code