@parity/ppn 0.2.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +84 -0
- package/config/ports.env +128 -0
- package/config/versions.env +120 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +30 -0
- package/dist/bin.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +471 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/bite.d.ts +27 -0
- package/dist/commands/bite.js +556 -0
- package/dist/commands/bite.js.map +1 -0
- package/dist/commands/dashboard.d.ts +2 -0
- package/dist/commands/dashboard.js +503 -0
- package/dist/commands/dashboard.js.map +1 -0
- package/dist/commands/dist.d.ts +7 -0
- package/dist/commands/dist.js +121 -0
- package/dist/commands/dist.js.map +1 -0
- package/dist/commands/fetch.d.ts +11 -0
- package/dist/commands/fetch.js +550 -0
- package/dist/commands/fetch.js.map +1 -0
- package/dist/commands/fork.d.ts +1 -0
- package/dist/commands/fork.js +164 -0
- package/dist/commands/fork.js.map +1 -0
- package/dist/commands/generate.d.ts +7 -0
- package/dist/commands/generate.js +201 -0
- package/dist/commands/generate.js.map +1 -0
- package/dist/commands/genesis-toml.d.ts +1 -0
- package/dist/commands/genesis-toml.js +26 -0
- package/dist/commands/genesis-toml.js.map +1 -0
- package/dist/commands/nginx-conf.d.ts +1 -0
- package/dist/commands/nginx-conf.js +32 -0
- package/dist/commands/nginx-conf.js.map +1 -0
- package/dist/commands/service-context.d.ts +13 -0
- package/dist/commands/service-context.js +5 -0
- package/dist/commands/service-context.js.map +1 -0
- package/dist/commands/service.d.ts +28 -0
- package/dist/commands/service.js +807 -0
- package/dist/commands/service.js.map +1 -0
- package/dist/commands/stamp-spawn.d.ts +7 -0
- package/dist/commands/stamp-spawn.js +43 -0
- package/dist/commands/stamp-spawn.js.map +1 -0
- package/dist/commands/start.d.ts +33 -0
- package/dist/commands/start.js +462 -0
- package/dist/commands/start.js.map +1 -0
- package/dist/commands/upgrade.d.ts +15 -0
- package/dist/commands/upgrade.js +101 -0
- package/dist/commands/upgrade.js.map +1 -0
- package/dist/fork/chains.d.ts +25 -0
- package/dist/fork/chains.js +36 -0
- package/dist/fork/chains.js.map +1 -0
- package/dist/fork/codec.d.ts +36 -0
- package/dist/fork/codec.js +122 -0
- package/dist/fork/codec.js.map +1 -0
- package/dist/fork/manifest.d.ts +13 -0
- package/dist/fork/manifest.js +77 -0
- package/dist/fork/manifest.js.map +1 -0
- package/dist/fork/overrides.d.ts +45 -0
- package/dist/fork/overrides.js +255 -0
- package/dist/fork/overrides.js.map +1 -0
- package/dist/fork/products.d.ts +68 -0
- package/dist/fork/products.js +265 -0
- package/dist/fork/products.js.map +1 -0
- package/dist/fork/rpc.d.ts +25 -0
- package/dist/fork/rpc.js +51 -0
- package/dist/fork/rpc.js.map +1 -0
- package/dist/fork/shared-relay.d.ts +99 -0
- package/dist/fork/shared-relay.js +162 -0
- package/dist/fork/shared-relay.js.map +1 -0
- package/dist/fork/sleep.d.ts +3 -0
- package/dist/fork/sleep.js +2 -0
- package/dist/fork/sleep.js.map +1 -0
- package/dist/fork/validators.d.ts +81 -0
- package/dist/fork/validators.js +170 -0
- package/dist/fork/validators.js.map +1 -0
- package/dist/fork/verify.d.ts +79 -0
- package/dist/fork/verify.js +192 -0
- package/dist/fork/verify.js.map +1 -0
- package/dist/lib/archive.d.ts +8 -0
- package/dist/lib/archive.js +40 -0
- package/dist/lib/archive.js.map +1 -0
- package/dist/lib/fork-bundle-name.d.ts +4 -0
- package/dist/lib/fork-bundle-name.js +20 -0
- package/dist/lib/fork-bundle-name.js.map +1 -0
- package/dist/lib/github.d.ts +48 -0
- package/dist/lib/github.js +192 -0
- package/dist/lib/github.js.map +1 -0
- package/dist/lib/provenance.d.ts +67 -0
- package/dist/lib/provenance.js +98 -0
- package/dist/lib/provenance.js.map +1 -0
- package/dist/lib/spawn-env.d.ts +33 -0
- package/dist/lib/spawn-env.js +71 -0
- package/dist/lib/spawn-env.js.map +1 -0
- package/dist/lib/spawn-stamp.d.ts +34 -0
- package/dist/lib/spawn-stamp.js +63 -0
- package/dist/lib/spawn-stamp.js.map +1 -0
- package/dist/upgrade/chains.d.ts +4 -0
- package/dist/upgrade/chains.js +17 -0
- package/dist/upgrade/chains.js.map +1 -0
- package/dist/upgrade/fund.d.ts +38 -0
- package/dist/upgrade/fund.js +119 -0
- package/dist/upgrade/fund.js.map +1 -0
- package/dist/upgrade/provider-node.d.ts +2 -0
- package/dist/upgrade/provider-node.js +7 -0
- package/dist/upgrade/provider-node.js.map +1 -0
- package/dist/upgrade/signer.d.ts +21 -0
- package/dist/upgrade/signer.js +48 -0
- package/dist/upgrade/signer.js.map +1 -0
- package/dist/upgrade/sudo.d.ts +2 -0
- package/dist/upgrade/sudo.js +26 -0
- package/dist/upgrade/sudo.js.map +1 -0
- package/dist/upgrade/upgrade.d.ts +128 -0
- package/dist/upgrade/upgrade.js +539 -0
- package/dist/upgrade/upgrade.js.map +1 -0
- package/networks/README.md +120 -0
- package/networks/devnet.json +113 -0
- package/networks/kusama.json +56 -0
- package/networks/paseo-next-v2.json +87 -0
- package/networks/polkadot.json +57 -0
- package/networks/previewnet.json +186 -0
- package/package.json +54 -0
- package/scripts/assign-cores.sh +12 -0
- package/scripts/dashboard.sh +11 -0
- package/scripts/docker-entrypoint.sh +52 -0
- package/scripts/dub/postgres.sh +116 -0
- package/scripts/dub/service.sh +202 -0
- package/scripts/ensure-dot-cli.sh +23 -0
- package/scripts/eth-rpc.sh +45 -0
- package/scripts/force-open-hrmp.sh +11 -0
- package/scripts/grant-invites.sh +11 -0
- package/scripts/increase-people-lite-attestation-allowance.sh +11 -0
- package/scripts/install.sh +12 -0
- package/scripts/ipfs-daemon.sh +48 -0
- package/scripts/ipfs-swarm.sh +48 -0
- package/scripts/kill-port.sh +11 -0
- package/scripts/lib/workspace.sh +47 -0
- package/scripts/omni-node.sh +112 -0
- package/scripts/patch-bootnodes.sh +11 -0
- package/scripts/pin-bulletin-products.sh +11 -0
- package/scripts/pin-design-families.sh +144 -0
- package/scripts/set-dispatcher-address.sh +11 -0
- package/scripts/storage-provider-node.sh +11 -0
- package/web/assets/index-BW4b1s2y.js +7 -0
- package/web/assets/index-X3pZpnYk.css +1 -0
- package/web/index.html +13 -0
- package/zombienet-configs/local-dev.toml +253 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
// `ppn fork <command>` — the bite/fork tooling.
|
|
2
|
+
//
|
|
3
|
+
// All the logic lives in TypeScript under ./../fork/ and is unit-tested; this
|
|
4
|
+
// file only parses arguments and prints. The descriptor queries a bite also needs
|
|
5
|
+
// (chains, spec-sources, network fields) are in bin/ppn.mjs instead, because those
|
|
6
|
+
// need no compiled code and `make bite` should not have to build first to read them.
|
|
7
|
+
//
|
|
8
|
+
// ppn fork manifest <baseUrl> <outFile>
|
|
9
|
+
// ppn fork overrides <outDir> <baseUrl>
|
|
10
|
+
// ppn fork head-env <workDir>
|
|
11
|
+
// ppn fork toml <bundleDir> <outFile>
|
|
12
|
+
// ppn fork products <assetHubRpc> <bulletinRpc> <resolverAddr>
|
|
13
|
+
// ppn fork wait <bundleDir> [timeoutSeconds] block until all chains finalize
|
|
14
|
+
// ppn fork verify <bundleDir> [sampleSeconds] is the fork working?
|
|
15
|
+
//
|
|
16
|
+
// Environment: ENABLE_HOP toml: --enable-hop on the bulletin collator (default true)
|
|
17
|
+
import fs from 'node:fs';
|
|
18
|
+
import path from 'node:path';
|
|
19
|
+
import { PARACHAINS, CHAINS, NETWORK, endpointOf } from '../fork/chains.js';
|
|
20
|
+
import { PORTS, RELAY_BASE_PORT, repoRoot, workspaceRoot } from '@parity/ppn-network-config';
|
|
21
|
+
import { writeManifest, headEnvLines } from '../fork/manifest.js';
|
|
22
|
+
import { relayOverrides, paraOverrides } from '../fork/overrides.js';
|
|
23
|
+
import { generateForkToml } from '@parity/ppn-network-config';
|
|
24
|
+
import { scanProducts } from '../fork/products.js';
|
|
25
|
+
import { targetsFromManifest, waitForChains, checkChains, checkDistinctChains, checkDiverged, } from '../fork/verify.js';
|
|
26
|
+
// Roots come from repoRoot()/workspaceRoot(), never from counting directory levels.
|
|
27
|
+
const REPO = repoRoot();
|
|
28
|
+
/** Mutable state — binaries, chain data, bundles — lives in the workspace, not the package. */
|
|
29
|
+
const WS = workspaceRoot();
|
|
30
|
+
const usage = (msg) => {
|
|
31
|
+
console.error(`${msg}\n\nsee the header of lib/commands/fork.mjs for usage`);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
};
|
|
34
|
+
const need = (value, what) => value ?? usage(`missing ${what}`);
|
|
35
|
+
const readManifest = (bundleDir) => JSON.parse(fs.readFileSync(`${need(bundleDir, 'bundleDir')}/manifest.json`, 'utf8'));
|
|
36
|
+
export async function run(args) {
|
|
37
|
+
const [command, ...rest] = args;
|
|
38
|
+
// Ports come from the same table the fork TOML is generated from, so a chain can never
|
|
39
|
+
// be probed on a port nothing was told to listen on.
|
|
40
|
+
const bundleTargets = (manifest) => targetsFromManifest(manifest, (k) => k === 'relay' ? RELAY_BASE_PORT : PORTS[k]);
|
|
41
|
+
switch (command) {
|
|
42
|
+
case 'manifest': {
|
|
43
|
+
const [baseUrl, outFile] = rest;
|
|
44
|
+
return writeManifest(need(baseUrl, 'baseUrl'), need(outFile, 'outFile'), new Date().toISOString());
|
|
45
|
+
}
|
|
46
|
+
case 'overrides': {
|
|
47
|
+
const [outDir, baseUrl] = rest;
|
|
48
|
+
need(outDir, 'outDir');
|
|
49
|
+
need(baseUrl, 'baseUrl');
|
|
50
|
+
// Runtimes `ppn bite --upgrade` staged, keyed by chain. Passed as JSON rather than
|
|
51
|
+
// read off disk so this subcommand stays a pure function of its arguments.
|
|
52
|
+
const flag = rest.indexOf('--upgrades');
|
|
53
|
+
const seeded = flag === -1 ? {} : JSON.parse(need(rest[flag + 1], '--upgrades'));
|
|
54
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
55
|
+
const relay = CHAINS.find((c) => c.key === 'relay');
|
|
56
|
+
// A shared relay carries parachains this network does not run, and its inherited core
|
|
57
|
+
// layout and messaging state are then wrong for us — see fork/shared-relay.ts.
|
|
58
|
+
const shared = NETWORK.bite.sharedRelay
|
|
59
|
+
? {
|
|
60
|
+
paras: PARACHAINS.map((p) => ({ key: p.key, paraId: p.paraId })),
|
|
61
|
+
validators: NETWORK.relay.validators,
|
|
62
|
+
}
|
|
63
|
+
: undefined;
|
|
64
|
+
await relayOverrides(endpointOf(relay, NETWORK, baseUrl), `${outDir}/rc_overrides.json`, shared, seeded.relay);
|
|
65
|
+
for (const p of PARACHAINS) {
|
|
66
|
+
await paraOverrides(p.paraId, endpointOf(p, NETWORK, baseUrl), `${outDir}/${p.paraId}_overrides.json`, NETWORK.bite.sharedRelay, seeded[p.key], p.aura);
|
|
67
|
+
}
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
case 'head-env': {
|
|
71
|
+
return console.log(headEnvLines(need(rest[0], 'workDir')).join('\n'));
|
|
72
|
+
}
|
|
73
|
+
case 'toml': {
|
|
74
|
+
const [bundleDir, outFile] = rest;
|
|
75
|
+
need(bundleDir, 'bundleDir');
|
|
76
|
+
need(outFile, 'outFile');
|
|
77
|
+
// Binaries follow the bundle's network, not the environment: previewnet's live in
|
|
78
|
+
// bin/, every other network's in bin/<network>.
|
|
79
|
+
const bundleNet = readManifest(bundleDir).network || 'previewnet';
|
|
80
|
+
const toml = generateForkToml({
|
|
81
|
+
repoDir: WS,
|
|
82
|
+
// The launchers ship in the package; the workspace has no scripts/ unless it *is* a
|
|
83
|
+
// checkout. In a checkout REPO === WS, so this changes nothing there.
|
|
84
|
+
scriptsDir: path.join(REPO, 'scripts'),
|
|
85
|
+
bundleDir: path.resolve(bundleDir),
|
|
86
|
+
enableHop: (process.env.ENABLE_HOP || 'true').toLowerCase() !== 'false',
|
|
87
|
+
binDir: bundleNet === 'previewnet' ? undefined : path.join(WS, 'bin', bundleNet),
|
|
88
|
+
});
|
|
89
|
+
fs.writeFileSync(outFile, toml);
|
|
90
|
+
const rpcPorts = [...toml.matchAll(/^rpc_port = (\d+)$/gm)].map((m) => m[1]);
|
|
91
|
+
const processes = [...toml.matchAll(/^\[\[custom_processes\]\]\nname = "([^"]+)"/gm)].map((m) => m[1]);
|
|
92
|
+
console.log(`wrote ${outFile}`);
|
|
93
|
+
console.log(` nodes: ${rpcPorts.length} on ports ${rpcPorts.join(', ')}`);
|
|
94
|
+
console.log(` custom_processes: ${processes.join(', ')}`);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
// Print the CIDs a forked network needs in order to serve its DotNS products.
|
|
98
|
+
// Resolved from the fork's own state, so it works with no access to the source.
|
|
99
|
+
case 'products': {
|
|
100
|
+
const [assetHubRpc, bulletinRpc, resolverAddr] = rest;
|
|
101
|
+
const r = await scanProducts(need(assetHubRpc, 'assetHubRpc'), need(bulletinRpc, 'bulletinRpc'), need(resolverAddr, 'resolverAddr'));
|
|
102
|
+
if (r.resolver.toLowerCase() !== resolverAddr.toLowerCase()) {
|
|
103
|
+
console.error(` ${resolverAddr} held nothing; using ${r.resolver} found on chain`);
|
|
104
|
+
}
|
|
105
|
+
console.error(` ${r.records} contenthash records, ${r.bulletinEntries} bulletin entries -> ` +
|
|
106
|
+
`${r.cids.length} products (${r.unmatched} records no longer retained)`);
|
|
107
|
+
// A live contract with no records is nearly always a stale address: each release
|
|
108
|
+
// redeploys DotNS, and the previous resolver stays on chain holding nothing.
|
|
109
|
+
if (r.records === 0) {
|
|
110
|
+
console.error(' No contenthash records on any contract — this network has no registered products.');
|
|
111
|
+
}
|
|
112
|
+
if (r.cids.length)
|
|
113
|
+
console.log(r.cids.join('\n'));
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
// Block until every chain in the bundle is producing *and* finalizing. Collators
|
|
117
|
+
// restore their DB snapshots long after the relay, and parachain finality only starts
|
|
118
|
+
// once the relay finalizes a block carrying their candidates.
|
|
119
|
+
case 'wait': {
|
|
120
|
+
const [bundleDir, timeoutSeconds] = rest;
|
|
121
|
+
const targets = bundleTargets(readManifest(bundleDir));
|
|
122
|
+
const timeoutMs = Number(timeoutSeconds || 600) * 1000;
|
|
123
|
+
console.log(`waiting up to ${timeoutMs / 1000}s for ${targets.length} chains to finalize`);
|
|
124
|
+
const r = await waitForChains(targets, timeoutMs, { requireFinality: true });
|
|
125
|
+
const secs = Math.round(r.waitedMs / 1000);
|
|
126
|
+
if (!r.ok) {
|
|
127
|
+
console.error(`not finalizing after ${secs}s: ${r.missing.join(', ')}`);
|
|
128
|
+
process.exit(1);
|
|
129
|
+
}
|
|
130
|
+
return console.log(`all ${targets.length} chains producing and finalizing after ${secs}s`);
|
|
131
|
+
}
|
|
132
|
+
// Assert a running fork is actually working: every chain continuing from its bite
|
|
133
|
+
// block, producing and finalizing, on its own chain, and diverged from its source.
|
|
134
|
+
case 'verify': {
|
|
135
|
+
const [bundleDir, sampleSeconds] = rest;
|
|
136
|
+
const manifest = readManifest(bundleDir);
|
|
137
|
+
const targets = bundleTargets(manifest);
|
|
138
|
+
const waitMs = Number(sampleSeconds || 30) * 1000;
|
|
139
|
+
console.log(`checking ${targets.length} chains over ${waitMs / 1000}s`);
|
|
140
|
+
const results = await checkChains(targets, waitMs);
|
|
141
|
+
for (const r of results) {
|
|
142
|
+
console.log(` ${r.ok ? 'ok ' : 'FAIL'} ${r.key.padEnd(13)} best=${r.best} finalized=${r.finalized} ` +
|
|
143
|
+
`(+${r.produced} blocks)${r.problems.length ? ' ' + r.problems.join('; ') : ''}`);
|
|
144
|
+
}
|
|
145
|
+
const distinct = await checkDistinctChains(targets);
|
|
146
|
+
console.log(` ${distinct.ok ? 'ok ' : 'FAIL'} chains are distinct` +
|
|
147
|
+
(distinct.problems.length ? ' ' + distinct.problems.join('; ') : ''));
|
|
148
|
+
const relay = targets.find((t) => t.key === 'relay');
|
|
149
|
+
// Manifests record each chain's resolved endpoint; older bundles predate that.
|
|
150
|
+
const sourceRelay = manifest.chains.relay.endpoint || `${manifest.source}/relay/alice`;
|
|
151
|
+
const diverged = await checkDiverged(relay.url, sourceRelay, relay.biteBlock);
|
|
152
|
+
console.log(` ${diverged.ok ? 'ok ' : 'FAIL'} diverged from source — ${diverged.detail}`);
|
|
153
|
+
const failed = results.filter((r) => !r.ok).length + (distinct.ok ? 0 : 1) + (diverged.ok ? 0 : 1);
|
|
154
|
+
if (failed) {
|
|
155
|
+
console.error(`\n${failed} check(s) failed`);
|
|
156
|
+
process.exit(1);
|
|
157
|
+
}
|
|
158
|
+
return console.log('\nfork is healthy');
|
|
159
|
+
}
|
|
160
|
+
default:
|
|
161
|
+
usage(`fork: unknown command "${command ?? ''}"`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=fork.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fork.js","sourceRoot":"","sources":["../../src/commands/fork.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,EAAE;AACF,8EAA8E;AAC9E,kFAAkF;AAClF,mFAAmF;AACnF,qFAAqF;AACrF,EAAE;AACF,0CAA0C;AAC1C,0CAA0C;AAC1C,gCAAgC;AAChC,wCAAwC;AACxC,iEAAiE;AACjE,kFAAkF;AAClF,uEAAuE;AACvE,EAAE;AACF,sFAAsF;AAEtF,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,QAAQ,EACvC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAqB,MAAM,4BAA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IAAI,MAAM,EAAE,CAAC;gBACX,OAAO,CAAC,KAAK,CAAC,KAAK,MAAM,kBAAkB,CAAC,CAAC;gBAC7C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC;YACD,OAAO,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QAC1C,CAAC;QAED;YACE,KAAK,CAAC,0BAA0B,OAAO,IAAI,EAAE,GAAG,CAAC,CAAC;IACtD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface GenerateOptions {
|
|
2
|
+
/** Do nothing when every spec this would build is already there. */
|
|
3
|
+
ifNeeded?: boolean;
|
|
4
|
+
/** Delete the specs this builds, and stop. */
|
|
5
|
+
clean?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function run(args: string[], opts?: GenerateOptions): Promise<void>;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
// `ppn generate` — build the genesis chain specs.
|
|
2
|
+
//
|
|
3
|
+
// Only a genesis network has these (previewnet; see networks/README.md). Every value —
|
|
4
|
+
// para ids, chain ids, display names, presets, output filenames, which runtime each chain
|
|
5
|
+
// builds from — comes from the descriptor, the same file `ppn fetch` reads to download
|
|
6
|
+
// those runtimes, so the two cannot disagree.
|
|
7
|
+
//
|
|
8
|
+
// Usage: ppn generate [binDir] (default: ./bin)
|
|
9
|
+
//
|
|
10
|
+
// Environment:
|
|
11
|
+
// PPN_PROFILE local (default) | deployable — see docs/PROFILES.md
|
|
12
|
+
// PPN_SUDO_URI deployable: the sudo signing key
|
|
13
|
+
// PPN_SUDO_SS58 deployable: the same key's address, cross-checked below
|
|
14
|
+
// PPN_FAUCET_SS58 deployable: pre-funded faucet account
|
|
15
|
+
import fs from 'node:fs';
|
|
16
|
+
import path from 'node:path';
|
|
17
|
+
import { execFileSync } from 'node:child_process';
|
|
18
|
+
import { loadCurrentNetwork, networkChains, repoRoot, workspaceRoot } from '@parity/ppn-network-config';
|
|
19
|
+
import { patchSpec, applyProfile, enableEccRfc163, injectDotns, readSpec, setNetworkSuffix, createPeopleCollections } from '@parity/ppn-network-config';
|
|
20
|
+
// Roots come from repoRoot()/workspaceRoot(), never from counting directory levels.
|
|
21
|
+
const REPO = repoRoot();
|
|
22
|
+
/** Mutable state — binaries, chain data, bundles — lives in the workspace, not the package. */
|
|
23
|
+
const WS = workspaceRoot();
|
|
24
|
+
const SECRETS_FILE = '/etc/ppn/secrets.env';
|
|
25
|
+
/**
|
|
26
|
+
* Deployable-profile secrets. server/redeploy.sh exports them before calling us; a direct
|
|
27
|
+
* `make generate` does not, so read the file when it is there.
|
|
28
|
+
*/
|
|
29
|
+
function loadSecrets() {
|
|
30
|
+
if (!fs.existsSync(SECRETS_FILE))
|
|
31
|
+
return;
|
|
32
|
+
for (const line of fs.readFileSync(SECRETS_FILE, 'utf8').split('\n')) {
|
|
33
|
+
const m = line.match(/^\s*(?:export\s+)?([A-Z_][A-Z0-9_]*)=(.*)$/);
|
|
34
|
+
if (!m)
|
|
35
|
+
continue;
|
|
36
|
+
const value = m[2].trim().replace(/^["']|["']$/g, '');
|
|
37
|
+
process.env[m[1]] ??= value;
|
|
38
|
+
}
|
|
39
|
+
console.log(`Loaded ${SECRETS_FILE} (PPN_PROFILE=${process.env.PPN_PROFILE ?? 'unset'})`);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Confirm PPN_SUDO_URI and PPN_SUDO_SS58 are the same keypair before any spec is built.
|
|
43
|
+
* A mismatch silently bricks sudo at runtime — every sudo call returns BadOrigin, with a
|
|
44
|
+
* misleading error — so it is much better to fail here.
|
|
45
|
+
*/
|
|
46
|
+
function checkDeployableSudo() {
|
|
47
|
+
const uri = process.env.PPN_SUDO_URI;
|
|
48
|
+
const ss58 = process.env.PPN_SUDO_SS58;
|
|
49
|
+
if (!uri || !ss58)
|
|
50
|
+
throw new Error('deployable profile requires PPN_SUDO_URI and PPN_SUDO_SS58');
|
|
51
|
+
const dot = (args) => execFileSync('dot', args, { encoding: 'utf8', stdio: ['pipe', 'pipe', 'ignore'] });
|
|
52
|
+
try {
|
|
53
|
+
dot(['--version']);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
throw new Error('deployable profile requires the `dot` CLI (make ensure-dot-cli)');
|
|
57
|
+
}
|
|
58
|
+
const account = '_ppn_sudo_check';
|
|
59
|
+
const remove = () => {
|
|
60
|
+
try {
|
|
61
|
+
dot(['account', 'remove', account]);
|
|
62
|
+
}
|
|
63
|
+
catch { /* not present */ }
|
|
64
|
+
};
|
|
65
|
+
remove();
|
|
66
|
+
dot(['account', 'add', account, '--env', 'PPN_SUDO_URI']);
|
|
67
|
+
let derived;
|
|
68
|
+
try {
|
|
69
|
+
derived = JSON.parse(dot(['account', 'inspect', account, '--json'])).ss58;
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
remove();
|
|
73
|
+
}
|
|
74
|
+
if (derived !== ss58) {
|
|
75
|
+
throw new Error(`PPN_SUDO_URI derives to ${derived} but PPN_SUDO_SS58 is ${ss58}\n` +
|
|
76
|
+
' The chain spec sudo.key and the operational signing key must match.');
|
|
77
|
+
}
|
|
78
|
+
console.log('Verified PPN_SUDO_URI derives to PPN_SUDO_SS58');
|
|
79
|
+
}
|
|
80
|
+
export async function run(args, opts = {}) {
|
|
81
|
+
const binDir = path.resolve(args[0] || path.join(WS, 'bin'));
|
|
82
|
+
const netForFiles = loadCurrentNetwork();
|
|
83
|
+
const specFiles = netForFiles.genesis
|
|
84
|
+
? networkChains(netForFiles).map((c) => c.genesisSpec.file)
|
|
85
|
+
: [];
|
|
86
|
+
if (opts.clean) {
|
|
87
|
+
for (const f of specFiles)
|
|
88
|
+
fs.rmSync(path.join(binDir, f), { force: true });
|
|
89
|
+
console.log(`removed ${specFiles.length} chain spec(s) from ${binDir}`);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (opts.ifNeeded && specFiles.length > 0 && specFiles.every((f) => fs.existsSync(path.join(binDir, f)))) {
|
|
93
|
+
console.log(`✓ chain specs present in ${binDir}`);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
loadSecrets();
|
|
97
|
+
const profile = process.env.PPN_PROFILE || 'local';
|
|
98
|
+
if (profile === 'deployable')
|
|
99
|
+
checkDeployableSudo();
|
|
100
|
+
const net = loadCurrentNetwork();
|
|
101
|
+
if (!net.genesis) {
|
|
102
|
+
throw new Error(`${net.name} is fork-only — it has no genesis to build (see networks/README.md)`);
|
|
103
|
+
}
|
|
104
|
+
const { chainType, properties } = net.genesisConfig;
|
|
105
|
+
const relayChainId = net.relay.genesisSpec.chainId;
|
|
106
|
+
const builder = path.join(binDir, 'chain-spec-builder');
|
|
107
|
+
if (!fs.existsSync(builder)) {
|
|
108
|
+
throw new Error(`no chain-spec-builder in ${binDir} — run \`make fetch\` first`);
|
|
109
|
+
}
|
|
110
|
+
console.log(`Generating chain specs (profile: ${profile}, network: ${net.name})...`);
|
|
111
|
+
const log = (msg) => console.log(msg);
|
|
112
|
+
// Which chains actually took the network suffix — only the runtimes carrying the pallet
|
|
113
|
+
// can, and a network that names one and finds none has runtime pins older than it.
|
|
114
|
+
const networkSuffix = net.genesisConfig.networkSuffix;
|
|
115
|
+
const suffixed = [];
|
|
116
|
+
for (const chain of networkChains(net)) {
|
|
117
|
+
const { chainId, name, preset, file } = chain.genesisSpec;
|
|
118
|
+
const isRelay = chain.key === 'relay';
|
|
119
|
+
console.log(isRelay ? `Relay Chain (${chainId}):` : `${name} (parachain ${chain.paraId}):`);
|
|
120
|
+
// The relay has no built-in preset for this chain id, so its spec is built from the
|
|
121
|
+
// runtime WASM like every parachain's — the only difference is that it takes no
|
|
122
|
+
// para id and is not told which relay it belongs to.
|
|
123
|
+
execFileSync(builder, [
|
|
124
|
+
'create',
|
|
125
|
+
...(isRelay ? [] : ['-p', String(chain.paraId), '-c', relayChainId]),
|
|
126
|
+
'-i', chainId,
|
|
127
|
+
'-n', name,
|
|
128
|
+
'-t', chainType,
|
|
129
|
+
'--properties', properties,
|
|
130
|
+
'-r', chain.runtime.file,
|
|
131
|
+
'named-preset', preset,
|
|
132
|
+
], { cwd: binDir, stdio: 'inherit' });
|
|
133
|
+
fs.renameSync(path.join(binDir, 'chain_spec.json'), path.join(binDir, file));
|
|
134
|
+
// Per-chain genesis edits, then the profile's account rules. One read-modify-write:
|
|
135
|
+
// a spec that needs no change is left byte-for-byte as chain-spec-builder wrote it.
|
|
136
|
+
const specPath = path.join(binDir, file);
|
|
137
|
+
const mutators = [];
|
|
138
|
+
if (isRelay) {
|
|
139
|
+
// The People runtime uses RFC-163 ECC host calls during PVF validation when the ZK
|
|
140
|
+
// chunk payloads are decoded. Without this the relay's validators reject those
|
|
141
|
+
// candidates for missing ext_host_calls_* functions.
|
|
142
|
+
mutators.push(enableEccRfc163);
|
|
143
|
+
}
|
|
144
|
+
let fundEvmDev = false;
|
|
145
|
+
if (chain.key === 'asset-hub') {
|
|
146
|
+
// Only Asset Hub runs pallet-revive, so only it gets the EVM-mapped dev accounts
|
|
147
|
+
// and the pre-deployed DotNS contracts.
|
|
148
|
+
fundEvmDev = true;
|
|
149
|
+
// The descriptor's networkSuffix doubles as the DotNS TLD (one knob, no drift):
|
|
150
|
+
// it names the fetched asset, and injectDotns asserts the artifact's own stamp
|
|
151
|
+
// against it, so a registry baked for a different namespace cannot land here.
|
|
152
|
+
if (networkSuffix) {
|
|
153
|
+
const dotnsPath = path.join(binDir, `dotns-genesis-${networkSuffix}.json`);
|
|
154
|
+
if (!fs.existsSync(dotnsPath)) {
|
|
155
|
+
// A namespaced genesis network without its registry is a broken product, not a
|
|
156
|
+
// reduced one — 05-dotns-contracts and the gateway would fail hours later.
|
|
157
|
+
throw new Error(`${path.basename(dotnsPath)} is missing from ${binDir} — run: make fetch`);
|
|
158
|
+
}
|
|
159
|
+
const dotns = readSpec(dotnsPath);
|
|
160
|
+
mutators.push((spec) => {
|
|
161
|
+
injectDotns(spec, dotns, networkSuffix);
|
|
162
|
+
console.log(` Injected ${Object.keys(dotns.accounts ?? {}).length} DotNS contracts into Asset Hub genesis`);
|
|
163
|
+
return true;
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
console.log(' Note: no networkSuffix in the descriptor — no namespace, skipping DotNS');
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (chain.key === 'people') {
|
|
171
|
+
mutators.push((spec) => {
|
|
172
|
+
const created = createPeopleCollections(spec);
|
|
173
|
+
console.log(created.length > 0
|
|
174
|
+
? ` Created the People collections at genesis (${created.join(', ')})`
|
|
175
|
+
: ' Note: this People runtime has no collection flag in genesis — skipping\n' +
|
|
176
|
+
' (a runtime older than the flag; re-run `ppn fetch` if registrations do not land)');
|
|
177
|
+
return created.length > 0;
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
if (networkSuffix) {
|
|
181
|
+
mutators.push((spec) => {
|
|
182
|
+
const outcome = setNetworkSuffix(spec, networkSuffix);
|
|
183
|
+
if (outcome !== 'absent') {
|
|
184
|
+
suffixed.push(chain.key);
|
|
185
|
+
console.log(` Set network suffix to "${networkSuffix}"`);
|
|
186
|
+
}
|
|
187
|
+
return outcome === 'set';
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
mutators.push((spec) => applyProfile(spec, { profile, fundEvmDev, log }));
|
|
191
|
+
patchSpec(specPath, mutators);
|
|
192
|
+
console.log(` Done: ${file}`);
|
|
193
|
+
}
|
|
194
|
+
if (networkSuffix && suffixed.length === 0) {
|
|
195
|
+
console.log(`\nWarning: ${net.name} asks for network suffix "${networkSuffix}", but no runtime it\n` +
|
|
196
|
+
' builds from carries the pallet that holds it — those specs keep the suffix\n' +
|
|
197
|
+
" their preset ships. Re-run `ppn fetch` for runtimes new enough to take it.");
|
|
198
|
+
}
|
|
199
|
+
console.log(`\nGenerated chain specs in ${binDir}`);
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=generate.js.map
|
|
@@ -0,0 +1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
|
1
|
+
export declare function run(_args?: string[]): Promise<void>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// `ppn genesis-toml` — the checked-in zombienet config for a genesis network.
|
|
2
|
+
//
|
|
3
|
+
// packages/network-config/src/toml-generator.ts is the single source of truth for ports, per-chain args
|
|
4
|
+
// and which custom processes run; this prints what it generates. Regenerate the
|
|
5
|
+
// checked-in copy with `make generate-toml` after editing that file.
|
|
6
|
+
//
|
|
7
|
+
// Environment:
|
|
8
|
+
// PPN_PARACHAINS comma-separated subset (default: every parachain the network has)
|
|
9
|
+
// ENABLE_HOP --enable-hop on the bulletin collator (default true)
|
|
10
|
+
import { loadCurrentNetwork } from '@parity/ppn-network-config';
|
|
11
|
+
import { generateToml } from '@parity/ppn-network-config';
|
|
12
|
+
export async function run(_args) {
|
|
13
|
+
const net = loadCurrentNetwork();
|
|
14
|
+
if (!net.genesis) {
|
|
15
|
+
console.error(`ppn genesis-toml: ${net.name} is fork-only — it has no genesis config`);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
const parachains = (process.env.PPN_PARACHAINS || net.parachains.map((p) => p.key).join(','))
|
|
19
|
+
.split(',')
|
|
20
|
+
.map((s) => s.trim())
|
|
21
|
+
.filter(Boolean);
|
|
22
|
+
const enableHop = (process.env.ENABLE_HOP || 'true').toLowerCase() !== 'false';
|
|
23
|
+
const header = '# DO NOT EDIT — regenerate with: make generate-toml\n# Source: packages/network-config/src/toml-generator.ts\n\n';
|
|
24
|
+
process.stdout.write(header + generateToml(parachains, { enableHop }));
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=genesis-toml.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genesis-toml.js","sourceRoot":"","sources":["../../src/commands/genesis-toml.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,EAAE;AACF,wGAAwG;AACxG,gFAAgF;AAChF,qEAAqE;AACrE,EAAE;AACF,eAAe;AACf,sFAAsF;AACtF,yEAAyE;AAEzE,OAAO,EAAE,kBAAkB,EAAkB,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,KAAgB;IACxC,MAAM,GAAG,GAAG,kBAAkB,EAAE,CAAC;IACjC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QACjB,OAAO,CAAC,KAAK,CAAC,qBAAqB,GAAG,CAAC,IAAI,0CAA0C,CAAC,CAAC;QACvF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,UAAU,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SAC1F,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SAC5B,MAAM,CAAC,OAAO,CAAgB,CAAC;IAClC,MAAM,SAAS,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,MAAM,CAAC,CAAC,WAAW,EAAE,KAAK,OAAO,CAAC;IAE/E,MAAM,MAAM,GACV,kHAAkH,CAAC;IACrH,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,YAAY,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;AACzE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function run(args: string[]): void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// `ppn nginx-conf <template> <out>` — render the server's nginx config.
|
|
2
|
+
//
|
|
3
|
+
// The chain and service routes are generated from the dashboard model (the same table the
|
|
4
|
+
// dashboard proxies locally); everything else in the template — TLS, certbot, p2p streams,
|
|
5
|
+
// logs — passes through untouched, including its ${VARS}, which the caller still envsubsts.
|
|
6
|
+
// Two markers say where the generated halves go, so a template that loses them fails loudly
|
|
7
|
+
// instead of silently shipping no routes.
|
|
8
|
+
import fs from 'node:fs';
|
|
9
|
+
import { loadCurrentNetwork, dashboardModel, nginxRoutes } from '@parity/ppn-network-config';
|
|
10
|
+
const UPSTREAMS = '# {{GENERATED_UPSTREAMS}}';
|
|
11
|
+
const LOCATIONS = ' # {{GENERATED_LOCATIONS}}';
|
|
12
|
+
export function run(args) {
|
|
13
|
+
const [template, out] = args;
|
|
14
|
+
if (!template || !out)
|
|
15
|
+
throw new Error('usage: ppn nginx-conf <template> <out>');
|
|
16
|
+
const domain = process.env.PPN_DOMAIN;
|
|
17
|
+
if (!domain)
|
|
18
|
+
throw new Error('PPN_DOMAIN is not set — the routes advertise it');
|
|
19
|
+
const net = loadCurrentNetwork();
|
|
20
|
+
const model = dashboardModel(net, `https://${domain}`);
|
|
21
|
+
const { upstreams, locations } = nginxRoutes(model);
|
|
22
|
+
let text = fs.readFileSync(template, 'utf-8');
|
|
23
|
+
for (const [marker, block] of [[UPSTREAMS, upstreams], [LOCATIONS, locations]]) {
|
|
24
|
+
if (!text.includes(marker)) {
|
|
25
|
+
throw new Error(`template has no "${marker.trim()}" marker — refusing to emit a config without routes`);
|
|
26
|
+
}
|
|
27
|
+
text = text.replace(marker, block);
|
|
28
|
+
}
|
|
29
|
+
fs.writeFileSync(out, text);
|
|
30
|
+
console.log(`wrote ${out}: ${model.chains.length} chain routes generated`);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=nginx-conf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nginx-conf.js","sourceRoot":"","sources":["../../src/commands/nginx-conf.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,EAAE;AACF,0FAA0F;AAC1F,2FAA2F;AAC3F,4FAA4F;AAC5F,4FAA4F;A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AAa,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC5B,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,KAAK,KAAK,CAAC,MAAM,CAAC,MAAM,yBAAyB,CAAC,CAAC;AAC7E,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { NetworkDef } from '@parity/ppn-network-config';
|
|
2
|
+
export interface ServiceContext {
|
|
3
|
+
net: NetworkDef;
|
|
4
|
+
/** config/ports.env merged with the gitignored ports.local.env `make start` writes. */
|
|
5
|
+
ports: Record<string, string>;
|
|
6
|
+
/** Node binaries: $BIN when `make start` set it, else bin/ or bin/<network>. */
|
|
7
|
+
binDir: string;
|
|
8
|
+
/** Shared tooling (ipfs, postgres) always lives in plain bin/, one level up. */
|
|
9
|
+
sharedBinDir: string;
|
|
10
|
+
relayWs: string;
|
|
11
|
+
/** Sudo signing URI: the deployable profile's operator key, else //Alice. */
|
|
12
|
+
sudoUri: string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// What every `ppn service` handler receives. Its own module so a handler can import the
|
|
2
|
+
// type without importing the dispatch table — which dynamically imports the handlers back,
|
|
3
|
+
// and a type-only import still counts as a cycle to the boundary rules.
|
|
4
|
+
export {};
|
|
5
|
+
//# sourceMappingURL=service-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-context.js","sourceRoot":"","sources":["../../src/commands/service-context.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,2FAA2F;AAC3F,wEAAwE"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ServiceContext } from './service-context.js';
|
|
2
|
+
export type { ServiceContext } from './service-context.js';
|
|
3
|
+
/** Injected in tests; in production these are the real implementations. */
|
|
4
|
+
export interface ServiceDeps {
|
|
5
|
+
scanProducts?: (assetHubRpc: string, bulletinRpc: string, resolver: string) => Promise<{
|
|
6
|
+
resolver: string;
|
|
7
|
+
records: number;
|
|
8
|
+
bulletinEntries: number;
|
|
9
|
+
unmatched: number;
|
|
10
|
+
cids: string[];
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
export { pinBulletinProducts };
|
|
14
|
+
export declare function serviceNames(): string[];
|
|
15
|
+
export declare function run(args: string[], deps?: ServiceDeps): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Import the DotNS products a forked bulletin cannot serve on its own.
|
|
18
|
+
*
|
|
19
|
+
* A fork carries chain state but not bulletin's stored bytes — those live in block bodies
|
|
20
|
+
* and the bite is a warp sync. So a forked bulletin lists content it does not hold. Copying
|
|
21
|
+
* all of bulletin is not viable (35 GiB on paseo-next-v2), so this copies only what DotNS
|
|
22
|
+
* points at, and only the versions still within bulletin's retention window.
|
|
23
|
+
*
|
|
24
|
+
* Which CIDs are needed is resolved from the fork's own state, so it never guesses; only
|
|
25
|
+
* the bytes come from the source, over HTTP. Best effort by design — it must never block a
|
|
26
|
+
* spawn, so every failure path returns rather than throwing.
|
|
27
|
+
*/
|
|
28
|
+
declare function pinBulletinProducts(ctx: ServiceContext, deps?: ServiceDeps): Promise<void>;
|