Repository navigation
refactor(network): the route snapshot schema has one home, in a leaf entry - #2033
Merged
Merged
Conversation
…entry `RouteSnapshotSchema` lived twice, in `pxe/schemas.ts` and in the network spec, each value list tied to its type by a `satisfies` that accepts a narrower list. Widening `EndpointState` or `TransportFailure` compiled while both copies refused the new value. The schema now lives in `@nulo/aztec-runtime/pxe/route-snapshot`, an entry that imports only zod and types, so the popup's network spec reads it without the `pxe` barrel. It is unannotated, and a type test pins its output to `RouteSnapshot | null`, so a value only one side lists no longer compiles. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Extension preview build —
|
This was referenced Nov 26, 2026
alejoamiras
added a commit
that referenced
this pull request
Nov 27, 2026
…rt accepts (#2035) The owner's pick of 2026-11-26: > The export never writes a contract part that its own import would refuse. Past the limit it leaves out contract code, the largest app contract first, until the part fits. It never leaves out a saved sender or a contract's entry, and code the wallet itself ships goes last. After a restore, a contract whose code was left out is listed in View errors with the existing "Contract artifact not found", and its app adds it again when it next registers it. … Nothing shows when the backup is made. ## Owner sign-off The owner's word in chat, 2026-11-27: "land 2035". On the restore commit: "Yes, keep the fix in this PR please." On the transaction history, which the fit leaves whole: "ok known issue", filed as #2036 (a full backup with tens of thousands of transactions is too large to create). Match: head `e054777df` builds the pick quoted above. Its second commit makes a contract of a class the wallet ships, left without code, restore from the wallet's own copy, which the pick's restore sentence needs. No screen, word or layout changes. ## The rule - **Budget.** A written contract part passes three checks. First, the import's cap, measured as the import measures it (`JSON.stringify(part).length` on the file's form of the part, after the import rewrites each network id to its seeded one). Second, the sealed file's limit. Third, the pretty file's limit. The page fetches the contract part after every other part and passes it what the rest of the file takes, so both file checks see the whole file. - **Order.** When the part is over budget, whole class-table entries go one at a time until it fits: classes an app registered first, then the classes the wallet itself ships (its catalog and its account class). Within each group the largest in the file goes first, and ties go by class id. The kept entries keep their order. - **What stays.** Every contract entry and every saved sender. A part already under budget is written as it is, byte for byte. - **Where.** One function beside the class-table encoder (`fitAccountStatePart` in `account-state/normalize.ts`), called once by the export. It sizes each class once and measures the final part once with the import's own measure. If the two disagree, or if the entries alone are over the import's cap, the export stops with an error. If the file still fails a file check with every class out, the page's existing "Backup is too large to create" refuses it. - **Log.** When code is left out, one warn line gives the count, the sizes and up to eight class names (Noir identifiers only), never an address. - **Restore.** A contract of a class the wallet ships, whose code the file leaves out, restores from the wallet's own copy: the restore takes that copy in the wire form a file's artifacts have, so its class-id check reads it. A contract of an app's class whose code was left out reads "Contract artifact not found" in View errors, and registers again when its app next registers it. A registration without a key spends none of the app's registration allowance. No stored shape changes. UI impact: none. No screen, word or layout changes. ## Tests - Unit (`normalize-fit.test.ts`): a part under budget is returned as the same object; at the budget and one code unit over; the order (app before wallet, largest first, ties by class id, kept entries in table order); entries and senders untouched; the file's form of the code (real `Buffer` bytecode, real `Fr` class ids, the production sanitizer); the UTF-8 and pretty budgets; the network-id rewrite; every class must go; idempotent; a bound on the serializations over 2,000 classes; the refusals. - Unit: the page passes the contract part's client what the rest of the file takes, and the messaging client forwards it; the file-size helpers. - Restore tests: the wallet's own copy of a class, as the PXE client returns it, registers; the artifact schema stand-in refuses a value already parsed, as the real one does. - Composition (`backup-fit.composition.test.ts`): the real export, file assembly, network rewrite and chain-sync tail, then a fresh profile's restore. The largest app code is left out, every entry and sender restores, and the left-out contracts read the existing error. With every class out, the wallet's own contracts restore from its catalog. - e2e, proverless, retry 0, the affected specs plus the evidence spec: - Chrome: 11 network specs and the evidence spec, 40 of 40 passed (27 min). 7 smoke specs, 29 passed and 7 skipped (`toolbar-panel` runs on Firefox only). - Firefox: 37 passed and 3 skipped (`backup-restore-sw-restart` runs on Chrome only) (34 min). Smoke, 36 of 36 passed. - Network specs: `backup-restore-integrity`, `restore-again`, `backup-migration-roundtrip`, `backup-import-stalled-network`, `backup-edited-local-network`, `import-handshake-note`, `import-handshake-note-matrix`, `account-balance-orphans`, `same-token-concurrent-sends`, `backup-restore-sw-restart`, `profile-reimport-matrix`. - Smoke specs: `backup-roundtrip`, `backup-imported-account`, `security-backup`, `passkey-backup`, `passkey-retry`, `legal-acceptance`, `toolbar-panel`. - No e2e scenario is added. ## Evidence (scratch spec, not committed; proverless, retry 0) The base build is dev at `8a90f146f` with the same e2e flags. The e2e and evidence ran on these two commits on top of `8a90f146f`. The rebase onto `6d722c105` adds only #2033 (where the PXE route snapshot schema lives), and every local gate (`lint`, `typecheck:all`, `test`, `audit:vue`, `test:ci-gating`, Storybook) passed after it. In E2 this build's export runs right after an in-place update and an unlock, so its time includes that cold start. Fitting a 6.36M part that already fits takes 0.35 to 0.6 s in a unit run. | Row | What it shows | Chrome | Firefox | |---|---|---|---| | E1 | A build with the import's cap lowered to 5,500,000 code units. Its export leaves out the app's Crowdfunding code, then the wallet's 3.6M Token code, and writes a 2.54M part. A fresh profile on that build imports the file. Every sender comes back, and every entry but the Crowdfunding contract registers again. The wallet's Token contract restores from its own copy. The Crowdfunding contract reads "Contract artifact not found", the playground registers it again, and its delegated `sendTx` returns a tx hash. | pass. Export 4.2 s, import 13.9 s, call 13.2 s | pass. Export 7.6 s, import 21.8 s, call 20.7 s | | E2 | One profile, the base build then this build swapped in place: both write the same contract part, byte for byte (6,364,903 code units). | pass. Base export 4.6 s, this build 7.7 s | pass. Base export 7.1 s, this build 15.0 s | | E3 | The base build's file imports on this build with no errors and every registration back. | pass. 14.5 s | pass. 21.1 s | 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
The route snapshot half of #1976; the proving-backend half shipped in #1989.
RouteSnapshotSchemaexisted twice, inpackages/aztec-runtime/src/pxe/schemas.ts(the PXE client's parse) and inapps/extension/src/wallet/services/network/spec.ts(the network service's RPC result). Each value list was tied to its type byas const satisfies readonly T[], which accepts a narrower list, so wideningEndpointStateorTransportFailurecompiled while both copies refused the new value. #1989 could not import the schema from the@nulo/aztec-runtime/pxebarrel: the popup reachesnetwork/spec.ts, and that import put the PXE and its kernel artifacts in the popup's graph.packages/aztec-runtime/src/pxe/route-snapshot.ts, exported as@nulo/aztec-runtime/pxe/route-snapshot, holds the lists and the schema and imports only zod and types.pxe/schemas.tsre-exports it, so the client and its test keep their import.network/spec.tsimports it from the leaf, and its copy goes. Nothing imported the schema fromnetwork/spec.ts.route-snapshot.test.tspinsz.output<typeof RouteSnapshotSchema>toRouteSnapshot | nullwithexpectTypeOf. A state or failure that only one side lists is now a compile error inbun run typecheck:all.network/spec.ts's type-only barrel import now says why values come from leaf entries.packages/aztec-runtime/README.mdnames the entry.Proofs
Premise, at base
93394e1e7. WithEndpointStatewidened by"stale",tsc --noEmitinpackages/aztec-runtimeandvue-tsc --noEmitinapps/extensionboth exit 0, and both schemas refusestate: "stale"while accepting"ready".Fix, at this head. Widening
EndpointState("stale") orTransportFailure("throttled") makes aztec-runtime'stsc --noEmitfail atroute-snapshot.test.ts(TS2344). Unwidened, it passes. At run time,pxe/schemas.ts's export andNetworkMethodSchemas.getRouteSnapshot.resultare the leaf's schema object.The popup's graph does not grow. Measured on the Chrome build: the module scripts in
dist/chrome/src/popup/index.html, and the bytes of their files.93394e1e7The chunk names are the same, content hashes aside, except for one shared chunk, now named
route-snapshotinstead ofrpc-url.Stored shapes. The route snapshot is not a stored shape.
stored-shapes/snapshot.test.tspasses with no new stamp.Layering. Extension → aztec-runtime is allowed by
biome.json'snoRestrictedImports. The leaf imports nothing from another workspace.Review. One Codex pass (
gpt-6.1-sol, high, read-only) over the diff. It was asked whether the popup's graph grows, whether a schema accepts or refuses anything new, whether a layer is crossed and whether the type test can pass vacuously. Verdict: approve, no findings. It compared both base schemas with the head schema on 27 boundary cases, and they agreed on every one.Validation
At this head,
81556e22a(rebased ondevafter #2032), retry 0, one at a time:bun run lint,bun run typecheck:all,bun run test(1067 files passed),bun run test:ci-gating(784 pass). Before the rebase, at the same change: both Chrome builds above andbun run --cwd apps/extension build-storybook, all exit 0. No local e2e, since no behaviour changes. The e2e lanes in CI are the gate of record.No visible change.
Closes #1976
🤖 Generated with Claude Code