Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/bite-network.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
required: true
default: kusama
type: choice
options: [kusama, polkadot, devnet, paseo-next-v2, previewnet]
options: [kusama, polkadot, westend, devnet, paseo-next-v2, previewnet]
upgrade:
description: 'Authorize a runtime at import: <chain>=<url to wasm>, comma-separated'
required: false
Expand Down
1 change: 1 addition & 0 deletions networks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,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=<wasm>` — 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=<wasm> people=<wasm>"` 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=<wasm>"`). The Individuality processes are off, since Westend runs none of those pallets |
76 changes: 76 additions & 0 deletions networks/westend.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"name": "westend",
"displayName": "Westend",
"description": "Fork-only, bitten on the fly. Relay, Asset Hub and People: the system chains polkadot-sdk's Westend runtimes are released for, without the Individuality pallets. The relay and Asset Hub have sudo; People does not, so a People runtime under test is authorized at bite time (`--upgrade people=<wasm>`).",
"genesis": false,
"sudo": true,
"bite": {
"prebaked": false,
"source": "wss://westend-rpc.polkadot.io",
"doppelganger": {
"repo": "paritytech/doppelganger-wrapper",
"tag": "v0.2.3"
},
"sharedRelay": true
},
"releases": {
"polkadot-sdk": {
"repo": "paritytech/release-automation",
"tag": "latest"
}
},
"relay": {
"chain": "westend",
"spec": "westend",
"rpc": "wss://westend-rpc.polkadot.io",
"specSource": "builtin",
"validators": 6,
"binary": {
"name": "polkadot",
"release": "polkadot-sdk"
}
},
"parachains": [
{
"key": "asset-hub",
"paraId": 1000,
"spec": "asset-hub",
"rpc": "wss://westend-asset-hub-rpc.polkadot.io",
"specSource": "builtin:asset-hub-westend",
"binary": {
"name": "polkadot-parachain",
"release": "polkadot-sdk"
}
},
{
"key": "people",
"paraId": 1004,
"spec": "people",
"rpc": "wss://westend-people-rpc.polkadot.io",
"specSource": "builtin:people-westend",
"binary": {
"name": "polkadot-parachain",
"release": "polkadot-sdk"
}
}
],
"services": {
"eth-rpc": {
"binary": {
"name": "eth-rpc",
"release": "polkadot-sdk"
}
},
"pin-design-families": false,
"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."
},
"stack": {
"tld": "westend",
"pointer": {
"url": "https://stack-westend.parity-testnet.parity.io/.well-known/trinity-stack.json"
}
}
}
4 changes: 4 additions & 0 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ about what is running. An unknown binary or release name is refused rather than
`ppn show --json` marks every overridden slot, so a gate can report what actually executed instead
of what it asked for.

A local `polkadot` (`--binary polkadot=file:/path/to/target/release/polkadot`) is copied together with
`polkadot-execute-worker` and `polkadot-prepare-worker` from the same directory, and the fetch fails if
either is missing.

## Authentication

`ppn fetch` reads GitHub releases. The packaged networks name only public ones, so a token is
Expand Down
45 changes: 29 additions & 16 deletions packages/cli/src/commands/bite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ 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 the info file the node writes, as before.
* judged by readBiteBlock.
*/
function runBiteNode(
cmd: string,
Expand Down Expand Up @@ -203,6 +203,17 @@ function logTail(logFile: string, lines: number, filter?: RegExp): string[] {
return (picked.length ? picked : all).slice(-lines);
}

/**
* 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.
*/
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 interface BiteOptions {
/** Override the network's own bite.source, to bite another instance of it. */
source?: string;
Expand Down Expand Up @@ -554,7 +565,7 @@ export async function run(args: string[], opts: BiteOptions = {}): Promise<void>
console.log(` ${para.key}: syncing state from ${SYNC_SOURCE_PREFIX}${id}, no other peer`);
}
// The bite node always exits non-zero: doppelganger ends an essential task to stop
// the node once the state import is captured. Success is judged by the info file.
// the node once the state import is captured. Success is judged by readBiteBlock.
await runBiteNode(
'doppelganger-parachain',
[
Expand Down Expand Up @@ -591,16 +602,15 @@ export async function run(args: string[], opts: BiteOptions = {}): Promise<void>
const biteBlocks: Record<string, number> = {};
for (const para of parachains) {
const id = String(para.paraId);
const info = path.join(out, 'work', id, 'info.txt');
const block = fs.existsSync(info) ? fs.readFileSync(info, 'utf-8').trim() : '';
if (!block) {
const log = path.join(biteLogDir(out), `${id}.log`);
const hint = logTail(log, 3, /not present on the host|error|panic/i);
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] = Number(block);
biteBlocks[id] = block;
console.log(` para ${id} bitten at block ${block}`);
}

Expand All @@ -621,6 +631,7 @@ export async function run(args: string[], opts: BiteOptions = {}): Promise<void>
console.log(` injecting ${Object.keys(headEnv).length} parachain heads over Paras::Heads`);

const relayWork = path.join(out, 'work', 'relay');
const relayLog = path.join(biteLogDir(out), 'relay.log');
fs.mkdirSync(relayWork, { recursive: true });
await runBiteNode(
'doppelganger',
Expand All @@ -634,19 +645,21 @@ export async function run(args: string[], opts: BiteOptions = {}): Promise<void>
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.
...(net.relay.chain === 'westend' ? { ZOMBIE_IS_WESTEND: '1' } : {}),
},
path.join(biteLogDir(out), 'relay.log'),
relayLog,
`relay (${net.relay.chain})`
);

const relayInfo = path.join(relayWork, 'info.txt');
const relayBlock = fs.existsSync(relayInfo) ? fs.readFileSync(relayInfo, 'utf-8').trim() : '';
if (!relayBlock) {
const log = path.join(biteLogDir(out), 'relay.log');
const tail = logTail(log, 5);
throw new Error(`relay bite FAILED (log: ${log})\n${tail.map((l) => ' ' + l).join('\n')}`);
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 = Number(relayBlock);
biteBlocks.relay = relayBlock;

console.log('=== 6/6 packing snapshots ===');
const snapshotBytes: Record<string, number> = {};
Expand Down
44 changes: 37 additions & 7 deletions packages/cli/src/commands/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,37 @@ function copyLocal(src: string, dest: string, what: string): void {
fs.copyFileSync(src, dest);
}

const PVF_WORKERS = ['polkadot-execute-worker', 'polkadot-prepare-worker'];

export interface LocalBinaryCopy {
name: string;
src: string;
dest: string;
}

/**
* 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.
*/
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 copy of copies) {
copyLocal(copy.src, copy.dest, `--binary ${copy.name}`);
makeExecutable(copy.dest);
}
return copies;
}

const REPO = repoRoot();
/** Mutable state — binaries, chain data, bundles — lives in the workspace, not the package. */
const WS = workspaceRoot();
Expand Down Expand Up @@ -219,11 +250,10 @@ export async function run(args: string[], opts: FetchOptions = {}): Promise<void
const local = localPin(repo);
if (local) {
for (const b of bins) {
const dest = path.join(nodeDest, b.name);
copyLocal(local, dest, `--binary ${b.name}`);
makeExecutable(dest);
stamps.push({ kind: 'binary', name: b.name, repo, pinned: tag, resolved: 'local', file: dest });
ok(`${b.name} (from ${local})`);
for (const copy of copyLocalBinary(b.name, local, nodeDest)) {
stamps.push({ kind: 'binary', name: copy.name, repo, pinned: tag, resolved: 'local', file: copy.dest });
ok(`${copy.name} (from ${copy.src})`);
}
}
continue;
}
Expand Down Expand Up @@ -256,7 +286,7 @@ export async function run(args: string[], opts: FetchOptions = {}): Promise<void
// polkadot cannot validate a PVF without its two workers, and they must come from
// the same build — a mismatched worker is rejected at spawn.
if (b.name === 'polkadot') {
for (const worker of ['polkadot-execute-worker', 'polkadot-prepare-worker']) {
for (const worker of PVF_WORKERS) {
if (stamp({ kind: 'binary', name: worker, repo, pinned: tag, resolved: rel.tag,
file: path.join(nodeDest, worker) })) { current(worker); continue; }
const wDest = path.join(nodeDest, worker);
Expand Down Expand Up @@ -586,7 +616,7 @@ function whatIsMissing(
for (const b of networkBinaries(net)) if (gone(nodeDest, b.name)) out.push(b.name);
// polkadot is useless without the two workers it validates PVFs with.
if (networkBinaries(net).some((b) => b.name === 'polkadot')) {
for (const w of ['polkadot-execute-worker', 'polkadot-prepare-worker']) {
for (const w of PVF_WORKERS) {
if (gone(nodeDest, w)) out.push(w);
}
}
Expand Down
25 changes: 20 additions & 5 deletions packages/cli/src/fork/overrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ import {
type PlannedPara,
} from './shared-relay.js';
import {
collatorKeys,
devValidators,
paraCandidates,
paraCollators,
paraInjects,
relayCandidates,
relayInjects,
sessionKeyFields,
sudoEndowInjects,
authorizedUpgradeCandidate,
type SessionKeyFieldType,
} from './validators.js';
import type { AuraScheme } from '@parity/ppn-network-config';

Expand Down Expand Up @@ -431,6 +433,17 @@ function seededUpgradeInject(index: StorageIndex, upgrade?: SeededUpgrade): Reco
return report('seeded upgrade authorization', verify(index, candidate), candidate);
}

/** The fields of the runtime's SessionKeys, from the value type of Session::NextKeys. */
function sessionKeysType(index: StorageIndex): SessionKeyFieldType[] {
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;
return lookup.getSiType(nextKeys.mapValue).def.asComposite.fields.map((field) => ({
name: field.name.toString(),
typePath: lookup.getSiType(field.type).path.map(String),
}));
}

export async function paraOverrides(
paraId: number,
paraUrl: string,
Expand All @@ -441,7 +454,10 @@ export async function paraOverrides(
collatorCount = 1
): Promise<void> {
const index = await storageIndex(paraUrl);
const collators = await collatorKeys(paraId, collatorCount, scheme);
// 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);
// 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
Expand All @@ -457,13 +473,12 @@ export async function paraOverrides(

console.log(
`para ${paraId} (${collators.length} collator${collators.length === 1 ? '' : 's'} from //Collator-${paraId} ` +
`${scheme} = ${collators.map((c) => c.slice(0, 16) + '…').join(', ')}):`
`${scheme} = ${collators.map((collator) => collator.account.slice(0, 16) + '…').join(', ')}):`
);
const overrides = report(`para ${paraId} overrides`, verify(index, candidates), candidates);

// A parachain without a Session pallet manages authorities through Aura alone.
const injects = {
...(index.pallets.has('Session') ? paraInjects(collators) : {}),
...(hasSession ? paraInjects(collators) : {}),
// Parachains of a shared relay are live public chains: no dev account holds
// funds there, so sudo is endowed at import (see sudoEndowInjects).
...(sharedRelay ? sudoEndowInjects() : {}),
Expand Down
Loading
Loading