From 1b75743f65267866d38663529676dcbafb093d57 Mon Sep 17 00:00:00 2001 From: Maksym H Date: Fri, 13 Nov 2026 23:11:08 +0000 Subject: [PATCH 1/8] Start each bite node log empty --- packages/cli/src/commands/bite.ts | 44 ++++++++++++---------------- packages/cli/tests/bite.test.ts | 48 +++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 26 deletions(-) diff --git a/packages/cli/src/commands/bite.ts b/packages/cli/src/commands/bite.ts index 5cef8ff..a824ace 100644 --- a/packages/cli/src/commands/bite.ts +++ b/packages/cli/src/commands/bite.ts @@ -125,9 +125,9 @@ function biteLogDir(out: string): string { * * Resolves whatever the exit code is: doppelganger deliberately ends an essential task to stop * the node once it has captured the state, so a non-zero exit is the normal path. Success is - * judged by readBiteBlock. + * judged by readBiteBlock, from this run's log alone: the file starts empty. */ -function runBiteNode( +export function runBiteNode( cmd: string, args: string[], env: NodeJS.ProcessEnv, @@ -135,7 +135,7 @@ function runBiteNode( label = path.basename(logFile, '.log') ): Promise { fs.mkdirSync(path.dirname(logFile), { recursive: true }); - const fd = fs.openSync(logFile, 'a'); + const fd = fs.openSync(logFile, 'w'); fs.writeSync(fd, `=== ${cmd} ${args.join(' ')}\n`); return new Promise((resolve) => { const child = spawn(cmd, args, { env, stdio: ['ignore', fd, fd] }); @@ -204,14 +204,15 @@ function logTail(logFile: string, lines: number, filter?: RegExp): string[] { } /** - * The block a bite node captured, or null when it captured none. doppelganger writes the info - * file whether or not importing that block succeeded, so the import result in its log decides. + * The block a bite node captured. Fails with the end of its log when the import didn't + * succeed: doppelganger writes the info file either way. */ -function readBiteBlock(infoFile: string, logFile: string): number | null { - const log = fs.existsSync(logFile) ? fs.readFileSync(logFile, 'utf-8') : ''; - if (!log.includes('Block import done! : Ok(') || !fs.existsSync(infoFile)) return null; - const block = fs.readFileSync(infoFile, 'utf-8').trim(); - return block ? Number(block) : null; +export function readBiteBlock(label: string, infoFile: string, logFile: string): number { + const isImportOk = fs.existsSync(logFile) && fs.readFileSync(logFile, 'utf-8').includes('Block import done! : Ok('); + const block = isImportOk && fs.existsSync(infoFile) ? fs.readFileSync(infoFile, 'utf-8').trim() : ''; + if (block) return Number(block); + const hint = logTail(logFile, 5, /Block import done|not present on the host|error|panic/i); + throw new Error(`${label}: bite FAILED (log: ${logFile})\n${hint.map((line) => ' ' + line).join('\n')}`); } export interface BiteOptions { @@ -602,16 +603,12 @@ export async function run(args: string[], opts: BiteOptions = {}): Promise const biteBlocks: Record = {}; for (const para of parachains) { const id = String(para.paraId); - const log = path.join(biteLogDir(out), `${id}.log`); - const block = readBiteBlock(path.join(out, 'work', id, 'info.txt'), log); - if (block === null) { - const hint = logTail(log, 3, /Block import done|not present on the host|error|panic/i); - throw new Error( - `para ${id}: bite FAILED (log: ${log})\n${hint.map((l) => ' ' + l).join('\n')}` - ); - } - biteBlocks[id] = block; - console.log(` para ${id} bitten at block ${block}`); + biteBlocks[id] = readBiteBlock( + `para ${id}`, + path.join(out, 'work', id, 'info.txt'), + path.join(biteLogDir(out), `${id}.log`) + ); + console.log(` para ${id} bitten at block ${biteBlocks[id]}`); } console.log('=== 5/6 biting relay with parachain heads injected ==='); @@ -654,12 +651,7 @@ export async function run(args: string[], opts: BiteOptions = {}): Promise `relay (${net.relay.chain})` ); - const relayBlock = readBiteBlock(path.join(relayWork, 'info.txt'), relayLog); - if (relayBlock === null) { - const tail = logTail(relayLog, 5, /Block import done|error|panic/i); - throw new Error(`relay bite FAILED (log: ${relayLog})\n${tail.map((l) => ' ' + l).join('\n')}`); - } - biteBlocks.relay = relayBlock; + biteBlocks.relay = readBiteBlock('relay', path.join(relayWork, 'info.txt'), relayLog); console.log('=== 6/6 packing snapshots ==='); const snapshotBytes: Record = {}; diff --git a/packages/cli/tests/bite.test.ts b/packages/cli/tests/bite.test.ts index 75d01c9..9a280a1 100644 --- a/packages/cli/tests/bite.test.ts +++ b/packages/cli/tests/bite.test.ts @@ -5,6 +5,8 @@ import os from 'node:os'; import path from 'node:path'; import { compressor, + readBiteBlock, + runBiteNode, SYNC_SOURCE_PREFIX, syncSourceArgs, syncSourceWarnings, @@ -127,3 +129,49 @@ describe('sync sources that will do nothing', () => { assert.deepEqual(withEnv({ PPN_BITE_LOG_DIR: '/tmp/logs' }, () => syncSourceWarnings(['1000'])), []); }); }); + +// doppelganger writes the info file even when the block import fails, and a bundle shipped at +// a failed block spawns a network that never produces. The import line in the log decides, +// and a bite into a directory an earlier bite used is judged by its own log. +describe('the block a bite captured', () => { + const OK = 'Block import done! : Ok(Imported(..))'; + const ERR = 'Block import done! : Err(Other("state root mismatch"))'; + const writeBiteFiles = (log: string, info: string | null) => { + const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'ppn-bite-')); + const logFile = path.join(dir, 'relay.log'); + const infoFile = path.join(dir, 'info.txt'); + fs.writeFileSync(logFile, log); + if (info !== null) fs.writeFileSync(infoFile, info); + return { infoFile, logFile }; + }; + const readBlock = ({ infoFile, logFile }: { infoFile: string; logFile: string }) => + readBiteBlock('relay', infoFile, logFile); + // The line comes through the environment, so the header runBiteNode writes doesn't contain it. + const runNodePrinting = (line: string, logFile: string) => + runBiteNode('sh', ['-c', 'echo "$IMPORT_LINE"'], { ...process.env, IMPORT_LINE: line }, logFile); + + it('is the info file number when the import succeeded', () => { + assert.equal(readBlock(writeBiteFiles(`=== polkadot\n${OK}\n`, '4356800\n')), 4356800); + }); + + it('fails when the import failed, with the import line in the message', () => { + assert.throws(() => readBlock(writeBiteFiles(`=== polkadot\n${ERR}\n`, '4356800\n')), /relay: bite FAILED[\s\S]*state root mismatch/); + }); + + it("fails when the node didn't write a block number", () => { + assert.throws(() => readBlock(writeBiteFiles(`=== polkadot\n${OK}\n`, null)), /bite FAILED/); + assert.throws(() => readBlock(writeBiteFiles(`=== polkadot\n${OK}\n`, '')), /bite FAILED/); + }); + + it('fails when the last bite into a reused log directory failed after an earlier success', async () => { + const { infoFile, logFile } = writeBiteFiles(`=== polkadot\n${OK}\n`, '4356800\n'); + await runNodePrinting(ERR, logFile); + assert.throws(() => readBlock({ infoFile, logFile }), /bite FAILED[\s\S]*state root mismatch/); + }); + + it('returns the block when the last bite into a reused log directory succeeded after a failure', async () => { + const { infoFile, logFile } = writeBiteFiles(`=== polkadot\n${ERR}\n`, '4356800\n'); + await runNodePrinting(OK, logFile); + assert.equal(readBlock({ infoFile, logFile }), 4356800); + }); +}); From e4c11ca28cab1d13070f0829b3a9c927c94cfdfd Mon Sep 17 00:00:00 2001 From: Maksym H Date: Fri, 13 Nov 2026 23:11:44 +0000 Subject: [PATCH 2/8] Turn off the identity backend on the Westend fork --- networks/westend.json | 3 ++- .../network-config/tests/fork-toml.test.ts | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/networks/westend.json b/networks/westend.json index 46e6cfd..7839712 100644 --- a/networks/westend.json +++ b/networks/westend.json @@ -65,7 +65,8 @@ "increase-people-lite-attestation-allowance": false, "increase-dotns-attestation-allowance": false, "grant-invites": false, - "_note": "Westend runs none of the Individuality pallets these processes grant from." + "dub": false, + "_note": "Westend doesn't run the Individuality pallets these processes and the identity backend use." }, "stack": { "tld": "westend", diff --git a/packages/network-config/tests/fork-toml.test.ts b/packages/network-config/tests/fork-toml.test.ts index 1efa8b6..6a90a5c 100644 --- a/packages/network-config/tests/fork-toml.test.ts +++ b/packages/network-config/tests/fork-toml.test.ts @@ -496,6 +496,24 @@ describe('generateForkToml — non-previewnet bundles', () => { assert.ok(devnetToml().includes('name = "grant-invites"')); }); + // Westend doesn't run any of the Individuality pallets, so the identity backend and the grants + // that feed it would only fail on a Westend fork. eth-rpc serves Asset Hub there as anywhere. + it("doesn't run the identity backend or the Individuality grants on a Westend fork", () => { + const toml = generateForkToml({ + repoDir: REPO, + bundleDir: makeNetBundle('westend', { + relay: { paraId: null, spec: 'westend', specId: 'westend2' }, + 'asset-hub': { paraId: 1000, spec: 'asset-hub', specId: 'asset-hub-westend' }, + people: { paraId: 1004, spec: 'people', specId: 'people-westend' }, + }), + }); + for (const name of ['dub-postgres', 'dub-api', 'registration-queue', 'invite-tickets-pool', 'turn', + 'grant-invites', 'pin-design-families', 'increase-people-lite-attestation-allowance']) { + assert.ok(!toml.includes(`name = "${name}"`), `${name} runs on westend`); + } + assert.ok(toml.includes('name = "eth-rpc"')); + }); + // A bite that authorized runtimes leaves the apply half to the spawn: the fork should come // up running the release under test, not merely permitted to. A bundle that seeded nothing // gets no such process. From 0f246c5e3c52dc1bc259b176ca3aa66c12c07407 Mon Sep 17 00:00:00 2001 From: Maksym H Date: Fri, 13 Nov 2026 23:13:15 +0000 Subject: [PATCH 3/8] Copy file: pins even when fetch --if-needed finds the files present --- packages/cli/src/cli.ts | 2 +- packages/cli/src/commands/fetch.ts | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index e8c1bd6..ccd280c 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -466,7 +466,7 @@ export function buildProgram(): Command { 'Download the binaries, runtimes and tooling the selected network declares.\n' + 'What gets fetched comes from networks/.json — see `ppn show`.' ) - .option('--if-needed', 'do nothing when everything the descriptor declares is present') + .option('--if-needed', 'skip the downloads when everything the descriptor declares is present (file: pins are still copied)') .option('--force', 're-download every artifact, even ones the last stamp proves current') ).action( async ( diff --git a/packages/cli/src/commands/fetch.ts b/packages/cli/src/commands/fetch.ts index c9f4b4b..d45071d 100644 --- a/packages/cli/src/commands/fetch.ts +++ b/packages/cli/src/commands/fetch.ts @@ -58,10 +58,14 @@ function localPin(repo: string): string | null { return repo.startsWith('file:') ? repo.slice('file:'.length) : null; } +// Through a temporary file and a rename: a node still running the old copy continues on the +// old inode, and the write doesn't fail with ETXTBSY. function copyLocal(src: string, dest: string, what: string): void { if (!fs.existsSync(src)) throw new Error(`${what}: no file at ${src}`); fs.mkdirSync(path.dirname(dest), { recursive: true }); - fs.copyFileSync(src, dest); + const partial = `${dest}.partial`; + fs.copyFileSync(src, partial); + fs.renameSync(partial, dest); } const PVF_WORKERS = ['polkadot-execute-worker', 'polkadot-prepare-worker']; @@ -183,6 +187,13 @@ export async function run(args: string[], opts: FetchOptions = {}): Promise Date: Fri, 13 Nov 2026 23:14:29 +0000 Subject: [PATCH 4/8] List westend in the docs --- CLAUDE.md | 8 +++++--- Makefile | 2 +- README.md | 11 +++++++---- docs/FORK.md | 4 +++- networks/README.md | 8 ++++---- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 08d318e..5038699 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -75,10 +75,11 @@ registrations and balances are already present. A fork that is started again res stopped, as long as the data came from the bundle being spawned. See `docs/FORK.md`. Only previewnet can start from genesis. Every other network (paseo-next-v2, devnet, kusama, -polkadot) is fork-only, defined by a descriptor in `networks/.json` — +polkadot, westend) is fork-only, defined by a descriptor in `networks/.json` — see `networks/README.md` for the schema and per-network status. Polkadot forks relay, Asset Hub, People and Bulletin with the fellowship's runtimes authorized at bite time; `docs/POLKADOT-FORK.md` -is the runbook for a dedicated machine. +is the runbook for a dedicated machine. Westend forks relay, Asset Hub and People: the relay and +Asset Hub have sudo and People doesn't, so a People runtime under test is authorized at bite time. A descriptor states, explicitly, which binary each chain runs and from which release, which runtime it starts from (genesis networks), its services, tools and bite tool. @@ -120,7 +121,8 @@ networks/ # Network descriptors (see networks/README.md) ├── paseo-next-v2.json # Fork-only: paseo relay, previewnet para-id band ├── devnet.json # Fork-only: paseo relay, system-chain para ids (1000+) ├── kusama.json # Fork-only, no sudo, on-the-fly bite: relay + Asset Hub -└── polkadot.json # Fork-only, no sudo, on-the-fly bite: relay + Asset Hub + People + Bulletin +├── polkadot.json # Fork-only, no sudo, on-the-fly bite: relay + Asset Hub + People + Bulletin +└── westend.json # Fork-only, on-the-fly bite: relay + Asset Hub (sudo) + People (no sudo) config/ ├── ports.env # Port configuration for all services diff --git a/Makefile b/Makefile index 20f6f77..d241ff2 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ # FRESH_BITE=1 # With FORK=1: bite the live network now instead of # # downloading the latest published bundle # UPGRADES="= ..." # With a bite: runtimes to authorize at import, for a -# # network without sudo (kusama, polkadot). See docs/FORK.md. +# # chain without sudo (kusama, polkadot, westend's people). See docs/FORK.md. # # Examples: # make start # Native, persistent, from genesis diff --git a/README.md b/README.md index 1915971..f935b3a 100644 --- a/README.md +++ b/README.md @@ -62,10 +62,13 @@ what you can do with it afterwards: | `devnet` | the Polkadot Products Devnet on public Paseo, system-chain para ids | yes | a bite of the live network | | `kusama` | Kusama relay and Asset Hub | no | a bite, with the runtime under test authorized at import | | `polkadot` | Polkadot relay, Asset Hub, People and Bulletin | no | a bite, with the runtime under test authorized at import | +| `westend` | Westend relay, Asset Hub and People | relay and Asset Hub; People doesn't | a bite of the live network, with People's runtime under test authorized at import | -**Forking a testnet with sudo.** The bundle is bitten for you every night, so a start is a -download. Once the fork runs, sudo is `//Alice`, and anything that needs root works as it -does on genesis: runtime upgrades, HRMP, core assignment, the People grants. +**Forking a testnet with sudo.** Previewnet's and paseo-next-v2's bundles are bitten for you +every night, so a start is a download; devnet and westend are bitten on the fly. Once the fork +runs, sudo is `//Alice`, and anything that needs root works as it does on genesis: runtime +upgrades, HRMP, core assignment, the People grants (off on westend). Westend's People doesn't have a Sudo pallet, so a +People runtime under test is authorized at bite: `make bite NETWORK=westend UPGRADES="people="`. ```bash ppn start --fork # previewnet, from last night's bundle @@ -141,7 +144,7 @@ ppn upgrade people --ws wss://my-host/people ./people_runtime.wasm # a remote ``` Sudo dispatches the authorization, so this is for genesis and for forks of a sudo network. On -a fork of Kusama or Polkadot the authorization comes from the bite, as described under +a fork of Kusama, Polkadot or Westend's People the authorization comes from the bite, as described under "Forking a mainnet without sudo" above. See [docs/RUNTIME-UPGRADE.md](docs/RUNTIME-UPGRADE.md). diff --git a/docs/FORK.md b/docs/FORK.md index 0e835a9..b641319 100644 --- a/docs/FORK.md +++ b/docs/FORK.md @@ -25,7 +25,9 @@ bundle, not the environment. Networks without sudo (Kusama, Polkadot) are not pre-bitten by CI — their bundles would be stale by the time anyone used one, and biting a public chain nightly is load nobody asked for. -They are bitten on demand instead, and their system-chain specs come from the parachain binary +Westend is not pre-bitten either: its bundle is 3.3 GB, and its People doesn't have a Sudo pallet, so a +People runtime under test is authorized at bite like on Kusama and Polkadot. These are bitten on +demand instead, and their system-chain specs come from the parachain binary (`builtin:asset-hub-kusama`, `builtin:people-polkadot`), so nothing has to publish one — except Polkadot's Bulletin, which is not built in and runs from the spec Parity's own RPC nodes use. Non-previewnet networks keep their own binaries (`bin//`, release pinned by the diff --git a/networks/README.md b/networks/README.md index e18ced3..b796386 100644 --- a/networks/README.md +++ b/networks/README.md @@ -27,7 +27,7 @@ or `PPN_NETWORK=` in the environment of the scripts. | --- | --- | | `name` | Network id; must match the filename. | | `genesis` | May be spawned from genesis. Previewnet only — the genesis machinery (runtimes, chain-spec presets, DotNS genesis) is previewnet's. | -| `sudo` | The live network has sudo. Networks without it (Kusama, Polkadot) cannot be upgraded after the fork, so a runtime under test must be injected at bite time — which is why they cannot be pre-bitten by CI. | +| `sudo` | The live relay has sudo. Networks without it (Kusama, Polkadot) cannot be upgraded after the fork, so a runtime under test must be injected at bite time — which is why they cannot be pre-bitten by CI. It also gates the processes that dispatch People's `Sudo.sudo` (the attestation allowances and invites), so a network whose People doesn't have a Sudo pallet (Westend) turns those off in `services`, and a People runtime under test there still needs `--upgrade` at bite. | | `bite.prebaked` | CI bites this network on release and publishes `fork-bundle-.tar.gz` (`fork-bundle-previewnet.tar.gz` for previewnet). Only meaningful for sudo networks with a real `bite.source`. | | `bite.source` | Base URL of the live network to bite. Per-chain `rpc` values that are paths resolve against it. When every `rpc` is an absolute URL (public networks like devnet), it serves as provenance (`manifest.source`) and as the origin `pin-bulletin-products` fetches product bytes from (`/ipfs/`), so point it at the network's IPFS gateway. | | `releases` | The version table: `{ "": { "repo": "...", "tag": "..." } }`. Every binary and runtime reference names one of these, so a version is written once per network. Names are yours — there are no reserved or special-cased names, and nothing resolves against `config/versions.env`. An unused entry is an error. | @@ -44,7 +44,7 @@ or `PPN_NETWORK=` in the environment of the scripts. | `tools` | Local tools this network needs that are neither a chain nor a service — previewnet's `chain-spec-builder`, for instance, which only a genesis network uses. | | `bite.doppelganger` | `{repo, tag}` of the bite tool. Per network, because the build has to be able to execute the runtimes of the network being bitten. | | *(bin layout)* | Only node binaries are network-versioned: previewnet's live in `bin/`, every other network's in `bin//` (plus `dg/` for bites). Shared tooling with no per-network dimension — zombie-cli, ipfs, postgres, identity, design families — lives in plain `bin/` and is pinned in `config/versions.env`. Collators run through `scripts/omni-node.sh` regardless of binary; it carries the libp2p fix and picks binary/dir from `PPN_COLLATOR_BINARY`/`PPN_BIN_DIR`. | -| `relay.chain` | Built-in chain name doppelganger runs with (`ZOMBIE_CHAIN`), e.g. `paseo`, `kusama`. | +| `relay.chain` | Built-in chain name doppelganger runs with (`ZOMBIE_CHAIN`), e.g. `paseo`, `kusama`. `westend` also sets `ZOMBIE_IS_WESTEND=1`, which makes the relay bite skip GRANDPA justification checks: Westend's GRANDPA history has a forced authority change at block 4356716. | | `relay.spec` | Basename of the relay spec inside the bundle (`specs/.json`). | | `relay.rpc`, `parachains[].rpc` | RPC endpoint: an absolute `ws(s)://`/`http(s)://` URL, or a path resolved against `bite.source`. | | `rpcAlternates` | Informational: other public providers for the same chain, for when the primary is re-homed. Not consumed by tooling (yet). | @@ -85,7 +85,7 @@ One thing to know: ## Forking a shared relay `bite.sharedRelay` marks a network whose live relay carries parachains we do not run — Paseo, -Kusama, Polkadot. Previewnet's relay is ours end to end, so it inherits state that is already +Kusama, Polkadot, Westend. Previewnet's relay is ours end to end, so it inherits state that is already correct and the bite leaves it alone. A shared relay inherits three things that are wrong for six dev validators, and all three are silent: @@ -113,4 +113,4 @@ dial collators, a resolved address is the only way that substream ever opens. | devnet | no | yes | once its `_todo` clears | sources filled from docs.polkadotcommunity.foundation; one open question — whether doppelganger can warp-sync Asset Hub from the published smol (stateRootHash) spec. Verify with `make bite NETWORK=devnet`, then drop the `_todo`. It shares a relay with other parachains, so it needs `bite.sharedRelay` too — already set | | kusama | no | on-the-fly only | no (no sudo) | wired. Asset Hub's spec comes from the parachain binary (`builtin:asset-hub-kusama`). A runtime under test is authorized at bite time — `ppn bite --upgrade asset-hub=` — since nothing can dispatch root after the fork; see docs/FORK.md. Upstream equivalent: [zombie-bite#127](https://github.com/paritytech/zombie-bite/issues/127) | | polkadot | no | on-the-fly only | no (no sudo) | relay + Asset Hub 1000 + People 1004 + Bulletin 1010, all live at runtimes 2.4; the fellowship's 2.5 (Individuality on People and Asset Hub) is what a fork of it is for — `make bite NETWORK=polkadot UPGRADES="asset-hub= people="` authorizes the blobs at import. All six HRMP channels between the three exist live and survive the bite (reset, not cleared). ~50 registered parachains makes the core remapping above load-bearing rather than a nicety. Runbook: docs/POLKADOT-FORK.md | -| westend | no | on-the-fly only | no | relay + Asset Hub 1000 + People 1004, the chains polkadot-sdk releases Westend runtimes for. The relay and Asset Hub have sudo and upgrade after the fork; People has none, so its runtime is authorized at bite time (`UPGRADES="people="`). The Individuality processes are off, since Westend runs none of those pallets | +| westend | no | on-the-fly only | no | relay + Asset Hub 1000 + People 1004, the chains polkadot-sdk releases Westend runtimes for. The relay and Asset Hub have sudo and upgrade after the fork; People doesn't, so its runtime is authorized at bite time (`UPGRADES="people="`). The Individuality processes and the identity backend are off, since Westend doesn't run any of those pallets | From f0a8ba7586e3f3a7c4a37d11a4411654a061b528 Mon Sep 17 00:00:00 2001 From: Maksym H Date: Fri, 13 Nov 2026 23:18:29 +0000 Subject: [PATCH 5/8] Simplify the parachain session key derivation --- packages/cli/src/fork/overrides.ts | 12 ++-- packages/cli/src/fork/validators.ts | 70 ++++++++++++---------- packages/cli/tests/fork-validators.test.ts | 58 +++++++++--------- 3 files changed, 73 insertions(+), 67 deletions(-) diff --git a/packages/cli/src/fork/overrides.ts b/packages/cli/src/fork/overrides.ts index ed15a0c..43f2961 100644 --- a/packages/cli/src/fork/overrides.ts +++ b/packages/cli/src/fork/overrides.ts @@ -27,14 +27,14 @@ import { import { devValidators, paraCandidates, - paraCollators, + deriveParaCollators, paraInjects, relayCandidates, relayInjects, - sessionKeyFields, + resolveSessionKeyFields, sudoEndowInjects, authorizedUpgradeCandidate, - type SessionKeyFieldType, + type SessionKeyMetadataField, } from './validators.js'; import type { AuraScheme } from '@parity/ppn-network-config'; @@ -434,7 +434,7 @@ function seededUpgradeInject(index: StorageIndex, upgrade?: SeededUpgrade): Reco } /** The fields of the runtime's SessionKeys, from the value type of Session::NextKeys. */ -function sessionKeysType(index: StorageIndex): SessionKeyFieldType[] { +function readSessionKeyMetadataFields(index: StorageIndex): SessionKeyMetadataField[] { const nextKeys = index.byKey.get(keyOf('Session', 'NextKeys')); if (nextKeys?.mapValue == null) throw new Error('Session::NextKeys is not a map in this runtime'); const { lookup } = index.reg; @@ -456,8 +456,8 @@ export async function paraOverrides( const index = await storageIndex(paraUrl); // A parachain without a Session pallet manages authorities through Aura alone. const hasSession = index.pallets.has('Session'); - const fields = hasSession ? sessionKeyFields(sessionKeysType(index), scheme) : []; - const collators = await paraCollators(paraId, collatorCount, scheme, fields); + const fields = hasSession ? resolveSessionKeyFields(readSessionKeyMetadataFields(index), scheme) : []; + const collators = await deriveParaCollators(paraId, collatorCount, scheme, fields); // The inherited messaging state is reset on every bite, matching the relay half in // messagingResets() — see ./shared-relay.ts. The channels stay open, so XCM keeps working. // The transaction-storage wipe applies on EVERY bite of a chain with that pallet, not diff --git a/packages/cli/src/fork/validators.ts b/packages/cli/src/fork/validators.ts index c76bc8c..8b14128 100644 --- a/packages/cli/src/fork/validators.ts +++ b/packages/cli/src/fork/validators.ts @@ -215,23 +215,26 @@ export function authorizedUpgradeCandidate(codeHash: string, checkVersion: boole /** A SessionKeys field: the KeyTypeId its key is registered under, and the key's curve. */ export interface SessionKeyField { keyTypeId: string; - scheme: AuraScheme; + curve: AuraScheme; } /** A parachain SessionKeys field as metadata describes it: its name and its type's path. */ -export interface SessionKeyFieldType { +export interface SessionKeyMetadataField { name: string; typePath: string[]; } -// Metadata carries the SessionKeys field names but not their KeyTypeIds. -const PARA_KEY_TYPE_IDS: Record = { aura: 'aura', authority_discovery: 'audi' }; +// Metadata has the SessionKeys field names but not their KeyTypeIds. A field whose type path +// doesn't contain its curve takes the one listed here. +const SESSION_KEY_FIELDS_BY_NAME: Record = { + aura: { keyTypeId: 'aura' }, + // `sp_authority_discovery::app::Public` is sr25519 app crypto. + authority_discovery: { keyTypeId: 'audi', curve: 'sr25519' }, +}; -function keyScheme(typePath: string[]): AuraScheme | undefined { +function detectKeyCurve(typePath: string[]): AuraScheme | undefined { if (typePath.some((segment) => segment.includes('sr25519'))) return 'sr25519'; if (typePath.some((segment) => segment.includes('ed25519'))) return 'ed25519'; - // `sp_authority_discovery::app::Public` is sr25519 app crypto; its path does not say so. - if (typePath[0] === 'sp_authority_discovery') return 'sr25519'; return undefined; } @@ -239,17 +242,17 @@ function keyScheme(typePath: string[]): AuraScheme | undefined { * The KeyTypeId and curve of each SessionKeys field, in field order. Fails on a field whose * KeyTypeId or curve is unknown, and on an Aura curve other than the one the descriptor declares. */ -export function sessionKeyFields(fields: SessionKeyFieldType[], auraScheme: AuraScheme): SessionKeyField[] { +export function resolveSessionKeyFields(fields: SessionKeyMetadataField[], auraScheme: AuraScheme): SessionKeyField[] { return fields.map(({ name, typePath }) => { - const keyTypeId = PARA_KEY_TYPE_IDS[name]; - const scheme = keyScheme(typePath); - if (!keyTypeId || !scheme) { - throw new Error(`SessionKeys field "${name}" (${typePath.join('::')}) has no known KeyTypeId and curve`); + const fieldEntry = SESSION_KEY_FIELDS_BY_NAME[name]; + const curve = detectKeyCurve(typePath) ?? fieldEntry?.curve; + if (!fieldEntry || !curve) { + throw new Error(`SessionKeys field "${name}" (${typePath.join('::')}) doesn't have a known KeyTypeId and curve`); } - if (name === 'aura' && scheme !== auraScheme) { - throw new Error(`the descriptor declares ${auraScheme} Aura keys, but the runtime's SessionKeys has ${scheme}`); + if (name === 'aura' && curve !== auraScheme) { + throw new Error(`the descriptor declares ${auraScheme} Aura keys, but the runtime's SessionKeys has ${curve}`); } - return { keyTypeId, scheme }; + return { keyTypeId: fieldEntry.keyTypeId, curve }; }); } @@ -259,30 +262,33 @@ export interface ParaCollator { sessionKeys: { keyTypeId: string; publicKey: string }[]; } -/** The collators collatorKeys() derives, each with a key for every field of the runtime's SessionKeys. */ -export async function paraCollators( +/** + * The collators collatorKeys() derives, each with a key for every field of the runtime's + * SessionKeys. A collator's account is its Aura public key, on the chain's Aura curve. + */ +export async function deriveParaCollators( paraId: number, count: number, scheme: AuraScheme, fields: SessionKeyField[] ): Promise { - const keysByScheme = new Map([[scheme, await collatorKeys(paraId, count, scheme)]]); - for (const field of fields) { - if (!keysByScheme.has(field.scheme)) keysByScheme.set(field.scheme, await collatorKeys(paraId, count, field.scheme)); - } - return keysByScheme.get(scheme)!.map((account, position) => ({ + const accounts = await collatorKeys(paraId, count, scheme); + const fieldKeys = await Promise.all(fields.map((field) => collatorKeys(paraId, count, field.curve))); + return accounts.map((account, position) => ({ account, - sessionKeys: fields.map((field) => ({ + sessionKeys: fields.map((field, fieldPosition) => ({ keyTypeId: field.keyTypeId, - publicKey: keysByScheme.get(field.scheme)![position], + publicKey: fieldKeys[fieldPosition][position], })), })); } +const encodeParaSessionKeys = (collator: ParaCollator): string => + collator.sessionKeys.map((key) => key.publicKey).join(''); + /** - * Parachain storage values that install the collators as its authority set. One key serves as - * both the account and the Aura key: the seed is the same and the account is the sr25519 public - * key, which is what CollatorSelection and Session hold. + * Parachain storage values that install the collators as its authority set: the account goes + * into CollatorSelection, Aura and Session. */ export function paraCandidates(collators: ParaCollator[]): Record { const len = compactLen(collators.length); @@ -294,8 +300,7 @@ export function paraCandidates(collators: ParaCollator[]): Record collator.account + collator.sessionKeys.map((key) => key.publicKey).join('')).join(''), + len + collators.map((collator) => collator.account + encodeParaSessionKeys(collator)).join(''), [keyOf('Sudo', 'Key')]: ALICE_SR, // ParachainSystem::LastDmqMqcHead is left alone: zeroing it (as zombie-bite does) // desyncs the parachain from the relay's preserved Dmp state. @@ -305,12 +310,11 @@ export function paraCandidates(collators: ParaCollator[]): Record { const injects: Record = {}; for (const collator of collators) { - injects[keyOf('Session', 'NextKeys') + twox64Concat(collator.account)] = - collator.sessionKeys.map((key) => key.publicKey).join(''); + injects[keyOf('Session', 'NextKeys') + twox64Concat(collator.account)] = encodeParaSessionKeys(collator); for (const { keyTypeId, publicKey } of collator.sessionKeys) { // Session::KeyOwner((KeyTypeId, Vec)) - const owned = Buffer.from(keyTypeId).toString('hex') + compactLen(publicKey.length / 2) + publicKey; - injects[keyOf('Session', 'KeyOwner') + twox64Concat(owned)] = collator.account; + const keyOwnerTuple = Buffer.from(keyTypeId).toString('hex') + compactLen(publicKey.length / 2) + publicKey; + injects[keyOf('Session', 'KeyOwner') + twox64Concat(keyOwnerTuple)] = collator.account; } } return injects; diff --git a/packages/cli/tests/fork-validators.test.ts b/packages/cli/tests/fork-validators.test.ts index bb2e780..cdd3d63 100644 --- a/packages/cli/tests/fork-validators.test.ts +++ b/packages/cli/tests/fork-validators.test.ts @@ -12,12 +12,12 @@ import { collatorKeys, devValidators, paraCandidates, - paraCollators, + deriveParaCollators, paraInjects, relayCandidates, relayInjects, sessionKeys, - sessionKeyFields, + resolveSessionKeyFields, authorizedUpgradeCandidate, type DevValidator, } from '../src/fork/validators.js'; @@ -27,8 +27,9 @@ import { TypeRegistry } from '@polkadot/types'; import { PARACHAINS } from '../src/fork/chains.js'; // Captured from the override files of a bite that produced a verified working fork, before -// this logic was ported from scripts/fork/*.mjs to TypeScript. Any change to an encoding -// here changes the authority set a fork boots with. +// this logic was ported from scripts/fork/*.mjs to TypeScript, except the Session::KeyOwner +// entries, which are this code's own output. Any change to an encoding here changes the +// authority set a fork boots with. const GOLDEN = JSON.parse( fs.readFileSync(path.join(import.meta.dirname, 'fixtures/overrides.golden.json'), 'utf-8') ) as Record; injects: Record }>; @@ -194,12 +195,12 @@ describe('para overrides', () => { assert.notEqual(a, await collatorKey(1500), 'para id must change the key'); }); - // Every parachain bitten before authority_discovery joined SessionKeys had Aura alone. - const AURA_ONLY = [{ keyTypeId: 'aura', scheme: 'sr25519' as const }]; + // A parachain whose SessionKeys has only Aura. + const AURA_ONLY = [{ keyTypeId: 'aura', curve: 'sr25519' as const }]; it('matches the values a verified bite produced, for every parachain', async () => { for (const { paraId } of PARACHAINS) { - const collators = await paraCollators(paraId, 1, 'sr25519', AURA_ONLY); + const collators = await deriveParaCollators(paraId, 1, 'sr25519', AURA_ONLY); const candidates = paraCandidates(collators); const injects = paraInjects(collators); for (const [key, value] of Object.entries(GOLDEN[paraId].overrides)) { @@ -213,7 +214,7 @@ describe('para overrides', () => { it('installs exactly one collator as the authority by default', async () => { const collator = await collatorKey(1500); - const candidates = paraCandidates(await paraCollators(1500, 1, 'sr25519', AURA_ONLY)); + const candidates = paraCandidates(await deriveParaCollators(1500, 1, 'sr25519', AURA_ONLY)); assert.equal(candidates[keyOf('CollatorSelection', 'DesiredCandidates')], '01000000'); for (const [pallet, item] of [['Aura', 'Authorities'], ['AuraExt', 'Authorities'], ['Session', 'Validators']]) { assert.equal(candidates[keyOf(pallet, item)], compactLen(1) + collator, `${pallet}::${item}`); @@ -237,7 +238,7 @@ describe('para overrides', () => { it('installs every collator it is given as an authority', async () => { const five = await collatorKeys(1502, 5); - const collators = await paraCollators(1502, 5, 'sr25519', AURA_ONLY); + const collators = await deriveParaCollators(1502, 5, 'sr25519', AURA_ONLY); const candidates = paraCandidates(collators); assert.equal(candidates[keyOf('CollatorSelection', 'DesiredCandidates')], u32le(5)); for (const [pallet, item] of [['Aura', 'Authorities'], ['AuraExt', 'Authorities'], ['Session', 'Validators'], ['CollatorSelection', 'Invulnerables']]) { @@ -250,14 +251,15 @@ describe('para overrides', () => { // Zeroing it, as zombie-bite does, desyncs the parachain from the relay's preserved Dmp. it('leaves ParachainSystem::LastDmqMqcHead alone', async () => { - const candidates = paraCandidates(await paraCollators(1500, 1, 'sr25519', AURA_ONLY)); + const candidates = paraCandidates(await deriveParaCollators(1500, 1, 'sr25519', AURA_ONLY)); assert.equal(candidates[keyOf('ParachainSystem', 'LastDmqMqcHead')], undefined); }); }); -// polkadot-sdk parachains carry `SessionKeys { aura, authority_discovery }` (Westend's Asset Hub -// and People already do). Session::QueuedKeys and NextKeys decode as that struct, so a value -// carrying only the Aura key fails the runtime's round-trip and the bite stops there. +// polkadot-sdk parachains, Westend's Asset Hub and People among them, have +// `SessionKeys { aura, authority_discovery }`. Session::QueuedKeys and NextKeys decode as that +// struct, so a value that contains only the Aura key fails the runtime's round-trip and the +// bite stops there. describe('para session keys', () => { const WESTEND_ASSET_HUB = [ { name: 'aura', typePath: ['sp_consensus_aura', 'sr25519', 'app_sr25519', 'Public'] }, @@ -269,20 +271,20 @@ describe('para session keys', () => { const roundTrips = (type: string, hex: string) => registry.createType(type, '0x' + hex).toHex() === '0x' + hex; it('reads the KeyTypeId and curve of every SessionKeys field', () => { - assert.deepEqual(sessionKeyFields(WESTEND_ASSET_HUB, 'sr25519'), [ - { keyTypeId: 'aura', scheme: 'sr25519' }, - { keyTypeId: 'audi', scheme: 'sr25519' }, + assert.deepEqual(resolveSessionKeyFields(WESTEND_ASSET_HUB, 'sr25519'), [ + { keyTypeId: 'aura', curve: 'sr25519' }, + { keyTypeId: 'audi', curve: 'sr25519' }, ]); }); it('writes a key for every field, each round-tripping through the runtime type', async () => { - const collators = await paraCollators(1000, 2, 'sr25519', sessionKeyFields(WESTEND_ASSET_HUB, 'sr25519')); + const collators = await deriveParaCollators(1000, 2, 'sr25519', resolveSessionKeyFields(WESTEND_ASSET_HUB, 'sr25519')); const account = await collatorKey(1000); assert.deepEqual(collators[0].sessionKeys.map((key) => key.publicKey), [account, account]); - const queued = paraCandidates(collators)[keyOf('Session', 'QueuedKeys')]; - assert.ok(roundTrips('Vec<(AccountId32, TwoKeySessionKeys)>', queued)); - const [[, firstKeys]] = registry.createType('Vec<(AccountId32, TwoKeySessionKeys)>', '0x' + queued).toJSON() as [string, unknown][]; + const queuedKeysValue = paraCandidates(collators)[keyOf('Session', 'QueuedKeys')]; + assert.ok(roundTrips('Vec<(AccountId32, TwoKeySessionKeys)>', queuedKeysValue)); + const [[, firstKeys]] = registry.createType('Vec<(AccountId32, TwoKeySessionKeys)>', '0x' + queuedKeysValue).toJSON() as [string, unknown][]; assert.deepEqual(firstKeys, { aura: '0x' + account, authority_discovery: '0x' + account }); const injects = paraInjects(collators); @@ -291,26 +293,26 @@ describe('para session keys', () => { }); // `KeyOwner::get((KeyTypeId, key))` is how the runtime finds the account behind a key, so each - // entry has to sit at the Twox64Concat key of that tuple, one per key. + // entry is stored under the Twox64Concat key of that tuple, one per key. it('records the owner of every key under its own KeyTypeId', async () => { - const collators = await paraCollators(1000, 1, 'sr25519', sessionKeyFields(WESTEND_ASSET_HUB, 'sr25519')); + const collators = await deriveParaCollators(1000, 1, 'sr25519', resolveSessionKeyFields(WESTEND_ASSET_HUB, 'sr25519')); const account = collators[0].account; const injects = paraInjects(collators); for (const keyTypeId of ['aura', 'audi']) { - const owned = registry.createType('([u8;4], Bytes)', [Buffer.from(keyTypeId), '0x' + account]).toHex().slice(2); - assert.equal(injects[keyOf('Session', 'KeyOwner') + twox64Concat(owned)], account); + const keyOwnerTuple = registry.createType('([u8;4], Bytes)', [Buffer.from(keyTypeId), '0x' + account]).toHex().slice(2); + assert.equal(injects[keyOf('Session', 'KeyOwner') + twox64Concat(keyOwnerTuple)], account); } }); it('derives a field on another curve from the same seed', async () => { - const fields = sessionKeyFields( + const fields = resolveSessionKeyFields( [ { name: 'aura', typePath: ['sp_consensus_aura', 'ed25519', 'app_ed25519', 'Public'] }, { name: 'authority_discovery', typePath: ['sp_authority_discovery', 'app', 'Public'] }, ], 'ed25519' ); - const [collator] = await paraCollators(1000, 1, 'ed25519', fields); + const [collator] = await deriveParaCollators(1000, 1, 'ed25519', fields); assert.equal(collator.account, await collatorKey(1000, 'ed25519')); assert.deepEqual(collator.sessionKeys.map((key) => key.publicKey), [ await collatorKey(1000, 'ed25519'), @@ -320,10 +322,10 @@ describe('para session keys', () => { it('rejects a field it cannot key, and an Aura curve the descriptor disagrees with', () => { assert.throws( - () => sessionKeyFields([{ name: 'beefy', typePath: ['sp_consensus_beefy', 'ecdsa_crypto', 'Public'] }], 'sr25519'), + () => resolveSessionKeyFields([{ name: 'beefy', typePath: ['sp_consensus_beefy', 'ecdsa_crypto', 'Public'] }], 'sr25519'), /SessionKeys field "beefy"/ ); - assert.throws(() => sessionKeyFields(WESTEND_ASSET_HUB, 'ed25519'), /declares ed25519 Aura keys/); + assert.throws(() => resolveSessionKeyFields(WESTEND_ASSET_HUB, 'ed25519'), /declares ed25519 Aura keys/); }); }); From a483f4af6fe1885fdf4c194a6703761c4c2179cc Mon Sep 17 00:00:00 2001 From: Maksym H Date: Fri, 13 Nov 2026 23:18:29 +0000 Subject: [PATCH 6/8] Fail a bite when Session::NextKeys or KeyOwner isn't Twox64Concat --- packages/cli/src/fork/overrides.ts | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/packages/cli/src/fork/overrides.ts b/packages/cli/src/fork/overrides.ts index 43f2961..ae00450 100644 --- a/packages/cli/src/fork/overrides.ts +++ b/packages/cli/src/fork/overrides.ts @@ -306,19 +306,12 @@ async function messagingResets( * byte-for-byte as production has it; the pending contents and the recipient's digests are * emptied to match. The parachain half is paraMessagingWipes(). * - * The hashers are checked against the metadata because the keys are assembled by hand: an - * inject on a mis-hashed key is a write nothing reads, and the fork would fail later with - * `HRMP head mismatch` pointing nowhere near here. + * A mis-hashed key shows up later as `HRMP head mismatch`, which doesn't mention this reset. */ async function hrmpResets(index: StorageIndex, relayUrl: string, paraIds: number[]): Promise> { if (!index.pallets.has('Hrmp')) return {}; - for (const item of ['HrmpChannels', 'HrmpChannelContents', 'HrmpChannelDigests', 'HrmpIngressChannelsIndex', 'HrmpEgressChannelsIndex']) { - const entry = index.byKey.get(keyOf('Hrmp', item)); - if (!entry) throw new Error(`this relay runtime has no Hrmp::${item}`); - if (entry.hashers.join(',') !== 'Twox64Concat') { - throw new Error(`Hrmp::${item} is hashed with ${entry.hashers.join(',')}, not Twox64Concat as the reset assumes`); - } - } + const channelItems = ['HrmpChannels', 'HrmpChannelContents', 'HrmpChannelDigests', 'HrmpIngressChannelsIndex', 'HrmpEgressChannelsIndex']; + assertTwox64Concat(index, 'Hrmp', channelItems); const read = (key: string) => rpc<`0x${string}` | null>(relayUrl, 'state_getStorage', ['0x' + key]); const paraList = (hex: `0x${string}` | null): number[] => @@ -433,6 +426,20 @@ function seededUpgradeInject(index: StorageIndex, upgrade?: SeededUpgrade): Reco return report('seeded upgrade authorization', verify(index, candidate), candidate); } +/** + * Fails unless each item exists and is a map hashed with Twox64Concat. The bite assembles their + * keys by hand, and an inject on a mis-hashed key is a write the runtime doesn't read. + */ +function assertTwox64Concat(index: StorageIndex, pallet: string, items: string[]): void { + for (const item of items) { + const entry = index.byKey.get(keyOf(pallet, item)); + if (!entry) throw new Error(`this runtime doesn't have ${pallet}::${item}`); + if (entry.hashers.join(',') !== 'Twox64Concat') { + throw new Error(`${pallet}::${item} is hashed with ${entry.hashers.join(',')}, not Twox64Concat as the bite assumes`); + } + } +} + /** The fields of the runtime's SessionKeys, from the value type of Session::NextKeys. */ function readSessionKeyMetadataFields(index: StorageIndex): SessionKeyMetadataField[] { const nextKeys = index.byKey.get(keyOf('Session', 'NextKeys')); @@ -456,6 +463,7 @@ export async function paraOverrides( const index = await storageIndex(paraUrl); // A parachain without a Session pallet manages authorities through Aura alone. const hasSession = index.pallets.has('Session'); + if (hasSession) assertTwox64Concat(index, 'Session', ['NextKeys', 'KeyOwner']); const fields = hasSession ? resolveSessionKeyFields(readSessionKeyMetadataFields(index), scheme) : []; const collators = await deriveParaCollators(paraId, collatorCount, scheme, fields); // The inherited messaging state is reset on every bite, matching the relay half in From 4b1d0370b5929abf6393c4d6f376c36f2f9c8aa8 Mon Sep 17 00:00:00 2001 From: Maksym H Date: Fri, 13 Nov 2026 23:18:29 +0000 Subject: [PATCH 7/8] Keep the PVF companion rule in one place --- packages/cli/src/commands/fetch.ts | 80 +++++++++++------------------- 1 file changed, 28 insertions(+), 52 deletions(-) diff --git a/packages/cli/src/commands/fetch.ts b/packages/cli/src/commands/fetch.ts index d45071d..e59b0a7 100644 --- a/packages/cli/src/commands/fetch.ts +++ b/packages/cli/src/commands/fetch.ts @@ -68,7 +68,13 @@ function copyLocal(src: string, dest: string, what: string): void { fs.renameSync(partial, dest); } -const PVF_WORKERS = ['polkadot-execute-worker', 'polkadot-prepare-worker']; +/** + * The binaries that must come from the same build as `name`: polkadot validates PVFs only + * with its two workers, and rejects a worker from another build at spawn. + */ +function companionBinaries(name: string): string[] { + return name === 'polkadot' ? ['polkadot-execute-worker', 'polkadot-prepare-worker'] : []; +} export interface LocalBinaryCopy { name: string; @@ -77,20 +83,18 @@ export interface LocalBinaryCopy { } /** - * Copy a `file:` pinned binary into `nodeDest`. A local polkadot also brings its PVF workers from - * its own directory, and fails without copying anything when either is not there. + * Copy a `file:` pinned binary into `nodeDest`. For a local polkadot, also copies the PVF + * workers from the same directory, and fails without copying anything when either is not there. */ export function copyLocalBinary(name: string, src: string, nodeDest: string): LocalBinaryCopy[] { const copies = [{ name, src, dest: path.join(nodeDest, name) }]; - if (name === 'polkadot') { - for (const worker of PVF_WORKERS) { - const workerSrc = path.join(path.dirname(src), worker); - if (!fs.existsSync(workerSrc)) { - throw new Error(`--binary polkadot=file:${src}: no ${worker} next to it at ${workerSrc}; ` + - 'a local polkadot needs both PVF workers from its own build'); - } - copies.push({ name: worker, src: workerSrc, dest: path.join(nodeDest, worker) }); + for (const companion of companionBinaries(name)) { + const companionSrc = path.join(path.dirname(src), companion); + if (!fs.existsSync(companionSrc)) { + throw new Error(`--binary ${name}=file:${src}: no ${companion} next to it at ${companionSrc}; ` + + `${name} runs only with ${companion} from its own build`); } + copies.push({ name: companion, src: companionSrc, dest: path.join(nodeDest, companion) }); } for (const copy of copies) { copyLocal(copy.src, copy.dest, `--binary ${copy.name}`); @@ -271,41 +275,17 @@ export async function run(args: string[], opts: FetchOptions = {}): Promise b.name === 'polkadot')) { - for (const w of PVF_WORKERS) { - if (gone(nodeDest, w)) out.push(w); - } + for (const b of networkBinaries(net)) { + for (const file of [b.name, ...companionBinaries(b.name)]) if (gone(nodeDest, file)) out.push(file); } for (const r of networkRuntimes(net)) if (gone(nodeDest, r.file)) out.push(r.file); if (gone(sharedDest, 'zombie-cli')) out.push('zombie-cli'); From 858782abfacb5cd58a6739a2aa56e59e2e948723 Mon Sep 17 00:00:00 2001 From: Maksym H Date: Fri, 13 Nov 2026 23:18:29 +0000 Subject: [PATCH 8/8] Reword fork comments --- packages/cli/src/commands/bite.ts | 6 +++--- packages/cli/tests/fetch-local.test.ts | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/cli/src/commands/bite.ts b/packages/cli/src/commands/bite.ts index a824ace..d0eb133 100644 --- a/packages/cli/src/commands/bite.ts +++ b/packages/cli/src/commands/bite.ts @@ -642,9 +642,9 @@ export async function run(args: string[], opts: BiteOptions = {}): Promise ZOMBIE_CHAIN: net.relay.chain, ZOMBIE_RC_EPOCH_DURATION: String(manifest.epochDuration), RUST_LOG: 'doppelganger=info', - // Westend's GRANDPA history carries a forced authority change (#4356716), so no warp - // proof from genesis verifies up to the live head. doppelganger skips the justification - // checks under this variable, as zombie-bite does for Westend. + // Westend's GRANDPA history has a forced authority change at block 4356716, so a warp + // proof from genesis doesn't verify up to the live head. doppelganger skips the + // justification checks under this variable, as zombie-bite does for Westend. ...(net.relay.chain === 'westend' ? { ZOMBIE_IS_WESTEND: '1' } : {}), }, relayLog, diff --git a/packages/cli/tests/fetch-local.test.ts b/packages/cli/tests/fetch-local.test.ts index 6deede5..b791dc5 100644 --- a/packages/cli/tests/fetch-local.test.ts +++ b/packages/cli/tests/fetch-local.test.ts @@ -1,9 +1,8 @@ // Tests for copyLocalBinary in packages/cli/src/commands/fetch.ts // Run with: tsx --test tests/fetch-local.test.ts // -// A `file:` pinned polkadot is a local build, and polkadot validates PVFs with the two workers -// built alongside it. Copying only polkadot left a node that spawns and then fails every -// candidate it is asked to validate. +// A `file:` pinned polkadot is a local build, and polkadot validates PVFs only with the two +// workers from its own build. import { describe, it, beforeEach, afterEach } from 'node:test'; import assert from 'node:assert/strict'; @@ -41,7 +40,7 @@ describe('copyLocalBinary', () => { } }); - it('fails, copying nothing, when a worker is missing next to polkadot', () => { + it('fails without copying anything when a worker is missing next to polkadot', () => { writeBuild('polkadot', 'polkadot-execute-worker'); assert.throws( () => copyLocalBinary('polkadot', path.join(buildDir, 'polkadot'), nodeDest),