Skip to content

feat(platform): adopt 4.2.0-beta.3 nonce-committed document ids - #562

Merged
PastaPastaPasta merged 7 commits into
stagingfrom
beta3/sdk-and-ids
Sep 21, 2026
Merged

PastaPastaPasta merged 7 commits into
stagingfrom
beta3/sdk-and-ids

Conversation

@PastaPastaPasta

Copy link
Copy Markdown
Owner

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:

dsha256("dash:document-id:v1" || contractId || ownerId || typeName || entropy || nonce as u64 BE)

Consensus recomputes it and refuses a mismatch with InvalidDocumentTransitionIdError (10405). The shipped wasm-dpp2 Document constructor and Document.generateId still produce the entropy-only v0 id, and new DocumentCreateTransition({ document }) copies document.id verbatim — 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

  • Pin @dashevo/evo-sdk and @dashevo/wasm-sdk to exactly 4.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.ts pins 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 → build Document and DocumentCreateTransition from that one nonce → sign → broadcast. buildDocumentForCreate requires { entropy, identityContractNonce }; generateDocumentIdentity/getDocumentId and the documentId/entropy options are gone, so a create document without a nonce-derived id can no longer be built. documentData may be a function of the id, called once with the id the transition will carry.
  • Auth vault encrypts its bundle against the id createDocument hands it (AEAD associated data), so the AAD id is the stored $id by construction.
  • Scripts (seed-lib, verify-lib, battery-lib, feature-seed-lib, pipeline, run-seeder, provision-seed-identities, verify-refersto, verify-poll-interop): buildDocument returns id: null for a create unless a nonce (hand-built transitions) or an id (replace/delete) is given; create paths read the real id from the Document documents.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 by findRecentByValues, time-bounded in the batteries. seed-lib mirrors the derivation for Node and the seeder self-test pins the same vector. verify-v4/verify-v5 untouched.
  • 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 from retryPostCreation.
  • 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

  • The pre-create "already exists on Platform" probe by id is removed: a fresh call always derives a fresh id, so it could only ever have matched the cached-bytes branch, which runs first.
  • The ST-byte replay cache is still keyed by the id but is unreachable from a fresh call — as it already was before protocol 14, when the id was a function of fresh entropy alone. The comments in createDocument and retryPostCreation that claimed otherwise are corrected; the double-write guard on a timed-out wait is the optimistic confirmed: false return. Making the cache reachable needs a caller-supplied idempotency key (separate change).
  • Seeders: a post/reply whose create threw after landing is recognised by value; two identical documents by one author cannot be told apart (documented duplicate risk), a DM's fresh AES-GCM IV is recognisable only within the call that built it, and a retried post may adopt an older identical post by the same author.

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-validator and code-simplifier passes applied (time-bounded value readbacks, sameValue guards, honest cache comments, dedup).
  • Not verified — belongs to PR C: that a beta.3 node accepts a create signed by the reordered createDocument. Moutai answered getStatus during this work with drive/dapi 4.2.0-beta.3, protocol 14, height 237 (fresh wipe); nothing was broadcast from this PR.

🤖 Generated with Claude Code

PastaPastaPasta and others added 7 commits September 20, 2026 17:15
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>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Deploying yappr-v2 with  Cloudflare Pages  Cloudflare Pages

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

View logs

@coderabbitai

coderabbitai Bot commented Sep 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 4a1d6101-2daf-4c82-af0d-eafcd715b361

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying yappr with  Cloudflare Pages  Cloudflare Pages

Latest commit: cd64bc9
Status: ✅  Deploy successful!
Preview URL: https://1b20fcce.yappr.pages.dev
Branch Preview URL: https://beta3-sdk-and-ids.yappr.pages.dev

View logs

@thepastaclaw

thepastaclaw commented Sep 20, 2026 •

Copy link
Copy Markdown
Collaborator

⚠️ DEGRADED — Review in progress — actively reviewing now (commit cd64bc9) · triage: normal · stand-in models (primary models out of quota)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants