@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.
Files changed (147) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +84 -0
  3. package/config/ports.env +128 -0
  4. package/config/versions.env +120 -0
  5. package/dist/bin.d.ts +2 -0
  6. package/dist/bin.js +30 -0
  7. package/dist/bin.js.map +1 -0
  8. package/dist/cli.d.ts +3 -0
  9. package/dist/cli.js +471 -0
  10. package/dist/cli.js.map +1 -0
  11. package/dist/commands/bite.d.ts +27 -0
  12. package/dist/commands/bite.js +556 -0
  13. package/dist/commands/bite.js.map +1 -0
  14. package/dist/commands/dashboard.d.ts +2 -0
  15. package/dist/commands/dashboard.js +503 -0
  16. package/dist/commands/dashboard.js.map +1 -0
  17. package/dist/commands/dist.d.ts +7 -0
  18. package/dist/commands/dist.js +121 -0
  19. package/dist/commands/dist.js.map +1 -0
  20. package/dist/commands/fetch.d.ts +11 -0
  21. package/dist/commands/fetch.js +550 -0
  22. package/dist/commands/fetch.js.map +1 -0
  23. package/dist/commands/fork.d.ts +1 -0
  24. package/dist/commands/fork.js +164 -0
  25. package/dist/commands/fork.js.map +1 -0
  26. package/dist/commands/generate.d.ts +7 -0
  27. package/dist/commands/generate.js +201 -0
  28. package/dist/commands/generate.js.map +1 -0
  29. package/dist/commands/genesis-toml.d.ts +1 -0
  30. package/dist/commands/genesis-toml.js +26 -0
  31. package/dist/commands/genesis-toml.js.map +1 -0
  32. package/dist/commands/nginx-conf.d.ts +1 -0
  33. package/dist/commands/nginx-conf.js +32 -0
  34. package/dist/commands/nginx-conf.js.map +1 -0
  35. package/dist/commands/service-context.d.ts +13 -0
  36. package/dist/commands/service-context.js +5 -0
  37. package/dist/commands/service-context.js.map +1 -0
  38. package/dist/commands/service.d.ts +28 -0
  39. package/dist/commands/service.js +807 -0
  40. package/dist/commands/service.js.map +1 -0
  41. package/dist/commands/stamp-spawn.d.ts +7 -0
  42. package/dist/commands/stamp-spawn.js +43 -0
  43. package/dist/commands/stamp-spawn.js.map +1 -0
  44. package/dist/commands/start.d.ts +33 -0
  45. package/dist/commands/start.js +462 -0
  46. package/dist/commands/start.js.map +1 -0
  47. package/dist/commands/upgrade.d.ts +15 -0
  48. package/dist/commands/upgrade.js +101 -0
  49. package/dist/commands/upgrade.js.map +1 -0
  50. package/dist/fork/chains.d.ts +25 -0
  51. package/dist/fork/chains.js +36 -0
  52. package/dist/fork/chains.js.map +1 -0
  53. package/dist/fork/codec.d.ts +36 -0
  54. package/dist/fork/codec.js +122 -0
  55. package/dist/fork/codec.js.map +1 -0
  56. package/dist/fork/manifest.d.ts +13 -0
  57. package/dist/fork/manifest.js +77 -0
  58. package/dist/fork/manifest.js.map +1 -0
  59. package/dist/fork/overrides.d.ts +45 -0
  60. package/dist/fork/overrides.js +255 -0
  61. package/dist/fork/overrides.js.map +1 -0
  62. package/dist/fork/products.d.ts +68 -0
  63. package/dist/fork/products.js +265 -0
  64. package/dist/fork/products.js.map +1 -0
  65. package/dist/fork/rpc.d.ts +25 -0
  66. package/dist/fork/rpc.js +51 -0
  67. package/dist/fork/rpc.js.map +1 -0
  68. package/dist/fork/shared-relay.d.ts +99 -0
  69. package/dist/fork/shared-relay.js +162 -0
  70. package/dist/fork/shared-relay.js.map +1 -0
  71. package/dist/fork/sleep.d.ts +3 -0
  72. package/dist/fork/sleep.js +2 -0
  73. package/dist/fork/sleep.js.map +1 -0
  74. package/dist/fork/validators.d.ts +81 -0
  75. package/dist/fork/validators.js +170 -0
  76. package/dist/fork/validators.js.map +1 -0
  77. package/dist/fork/verify.d.ts +79 -0
  78. package/dist/fork/verify.js +192 -0
  79. package/dist/fork/verify.js.map +1 -0
  80. package/dist/lib/archive.d.ts +8 -0
  81. package/dist/lib/archive.js +40 -0
  82. package/dist/lib/archive.js.map +1 -0
  83. package/dist/lib/fork-bundle-name.d.ts +4 -0
  84. package/dist/lib/fork-bundle-name.js +20 -0
  85. package/dist/lib/fork-bundle-name.js.map +1 -0
  86. package/dist/lib/github.d.ts +48 -0
  87. package/dist/lib/github.js +192 -0
  88. package/dist/lib/github.js.map +1 -0
  89. package/dist/lib/provenance.d.ts +67 -0
  90. package/dist/lib/provenance.js +98 -0
  91. package/dist/lib/provenance.js.map +1 -0
  92. package/dist/lib/spawn-env.d.ts +33 -0
  93. package/dist/lib/spawn-env.js +71 -0
  94. package/dist/lib/spawn-env.js.map +1 -0
  95. package/dist/lib/spawn-stamp.d.ts +34 -0
  96. package/dist/lib/spawn-stamp.js +63 -0
  97. package/dist/lib/spawn-stamp.js.map +1 -0
  98. package/dist/upgrade/chains.d.ts +4 -0
  99. package/dist/upgrade/chains.js +17 -0
  100. package/dist/upgrade/chains.js.map +1 -0
  101. package/dist/upgrade/fund.d.ts +38 -0
  102. package/dist/upgrade/fund.js +119 -0
  103. package/dist/upgrade/fund.js.map +1 -0
  104. package/dist/upgrade/provider-node.d.ts +2 -0
  105. package/dist/upgrade/provider-node.js +7 -0
  106. package/dist/upgrade/provider-node.js.map +1 -0
  107. package/dist/upgrade/signer.d.ts +21 -0
  108. package/dist/upgrade/signer.js +48 -0
  109. package/dist/upgrade/signer.js.map +1 -0
  110. package/dist/upgrade/sudo.d.ts +2 -0
  111. package/dist/upgrade/sudo.js +26 -0
  112. package/dist/upgrade/sudo.js.map +1 -0
  113. package/dist/upgrade/upgrade.d.ts +128 -0
  114. package/dist/upgrade/upgrade.js +539 -0
  115. package/dist/upgrade/upgrade.js.map +1 -0
  116. package/networks/README.md +120 -0
  117. package/networks/devnet.json +113 -0
  118. package/networks/kusama.json +56 -0
  119. package/networks/paseo-next-v2.json +87 -0
  120. package/networks/polkadot.json +57 -0
  121. package/networks/previewnet.json +186 -0
  122. package/package.json +54 -0
  123. package/scripts/assign-cores.sh +12 -0
  124. package/scripts/dashboard.sh +11 -0
  125. package/scripts/docker-entrypoint.sh +52 -0
  126. package/scripts/dub/postgres.sh +116 -0
  127. package/scripts/dub/service.sh +202 -0
  128. package/scripts/ensure-dot-cli.sh +23 -0
  129. package/scripts/eth-rpc.sh +45 -0
  130. package/scripts/force-open-hrmp.sh +11 -0
  131. package/scripts/grant-invites.sh +11 -0
  132. package/scripts/increase-people-lite-attestation-allowance.sh +11 -0
  133. package/scripts/install.sh +12 -0
  134. package/scripts/ipfs-daemon.sh +48 -0
  135. package/scripts/ipfs-swarm.sh +48 -0
  136. package/scripts/kill-port.sh +11 -0
  137. package/scripts/lib/workspace.sh +47 -0
  138. package/scripts/omni-node.sh +112 -0
  139. package/scripts/patch-bootnodes.sh +11 -0
  140. package/scripts/pin-bulletin-products.sh +11 -0
  141. package/scripts/pin-design-families.sh +144 -0
  142. package/scripts/set-dispatcher-address.sh +11 -0
  143. package/scripts/storage-provider-node.sh +11 -0
  144. package/web/assets/index-BW4b1s2y.js +7 -0
  145. package/web/assets/index-X3pZpnYk.css +1 -0
  146. package/web/index.html +13 -0
  147. package/zombienet-configs/local-dev.toml +253 -0
@@ -0,0 +1,51 @@
1
+ // Talking to a live previewnet chain, and indexing its storage so override values can be
2
+ // decode-verified against their real on-chain types before being written.
3
+ import { Metadata, TypeRegistry } from '@polkadot/types';
4
+ import { keyOf } from './codec.js';
5
+ export async function rpc(url, method, params = []) {
6
+ const r = await fetch(url, {
7
+ method: 'POST',
8
+ headers: { 'Content-Type': 'application/json' },
9
+ body: JSON.stringify({ jsonrpc: '2.0', id: 1, method, params }),
10
+ signal: AbortSignal.timeout(60_000),
11
+ });
12
+ const j = (await r.json());
13
+ if (j.error)
14
+ throw new Error(`${method}: ${JSON.stringify(j.error)}`);
15
+ return j.result;
16
+ }
17
+ export async function storageIndex(url) {
18
+ const reg = new TypeRegistry();
19
+ const meta = new Metadata(reg, await rpc(url, 'state_getMetadata'));
20
+ reg.setMetadata(meta);
21
+ const byKey = new Map();
22
+ const pallets = new Set();
23
+ for (const p of meta.asLatest.pallets) {
24
+ pallets.add(p.name.toString());
25
+ if (p.storage.isNone)
26
+ continue;
27
+ const storage = p.storage.unwrap();
28
+ for (const it of storage.items) {
29
+ byKey.set(keyOf(storage.prefix.toString(), it.name.toString()), {
30
+ label: `${p.name}::${it.name}`,
31
+ plain: it.type.isPlain ? it.type.asPlain.toNumber() : null,
32
+ mapValue: it.type.isMap ? it.type.asMap.value.toNumber() : null,
33
+ });
34
+ }
35
+ }
36
+ return { reg, meta, byKey, pallets };
37
+ }
38
+ /** Read a runtime constant, e.g. constantOf(index, 'Babe', 'EpochDuration'). */
39
+ export function constantOf({ meta, reg }, pallet, name) {
40
+ for (const p of meta.asLatest.pallets) {
41
+ if (p.name.toString() !== pallet)
42
+ continue;
43
+ for (const c of p.constants) {
44
+ if (c.name.toString() === name) {
45
+ return reg.createType(reg.createLookupType(c.type.toNumber()), c.value).toString();
46
+ }
47
+ }
48
+ }
49
+ return null;
50
+ }
51
+ //# sourceMappingURL=rpc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc.js","sourceRoot":"","sources":["../../src/fork/rpc.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,0EAA0E;AAE1E,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,MAAM,CAAC,KAAK,UAAU,GAAG,CAAU,GAAW,EAAE,MAAc,EAAE,SAAoB,EAAE;IACpF,MAAM,CAAC,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;QACzB,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QAC/D,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC;KACpC,CAAC,CAAC;IACH,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,E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AAE,CAAC,CAAC,CAAC,IAAI;gBAC1D,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI;aAChE,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AACvC,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,UAAU,CAAC,EAAE,IAAI,EAAE,GAAG,EAAgB,EAAE,MAAc,EAAE,IAAY;IAClF,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACtC,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,MAAM;YAAE,SAAS;QAC3C,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;YAC5B,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC;gBAC/B,OAAO,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC;YACrF,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,99 @@
1
+ /** One core, and the parachain that runs on it. */
2
+ export interface CoreAssignment {
3
+ core: number;
4
+ paraId: number;
5
+ }
6
+ /** A parachain as the descriptor describes it, narrowed to what core planning needs. */
7
+ export interface PlannedPara {
8
+ key: string;
9
+ paraId: number;
10
+ }
11
+ /**
12
+ * How many cores each parachain gets.
13
+ *
14
+ * Asset Hub keeps three: that is what gives it 2-second blocks through elastic scaling, and it
15
+ * is the one place where the number is a property of the network rather than a default. The
16
+ * rest get one each.
17
+ */
18
+ export declare function coresFor(key: string): number;
19
+ /**
20
+ * Lay the parachains out from core 0 upward.
21
+ *
22
+ * Upward from zero because those are the cores that end up with validator groups: the runtime
23
+ * fills groups in order, so with `num_cores` set to exactly what we plan here, every core in
24
+ * the plan is staffed and none of the plan depends on rotation luck.
25
+ */
26
+ export declare function planCores(paras: PlannedPara[]): CoreAssignment[];
27
+ /**
28
+ * `ParaScheduler::ValidatorGroups` — every planned core gets at least one validator.
29
+ *
30
+ * Round-robin rather than contiguous chunks: with 6 validators over 5 cores the remainder has
31
+ * to land somewhere, and spreading it means no group is empty. An empty group is the whole bug
32
+ * this file exists for.
33
+ */
34
+ export declare function validatorGroups(cores: number, validators: number): string;
35
+ /**
36
+ * The value each parachain's `Hrmp::HrmpIngressChannelsIndex` entry is replaced with: an empty
37
+ * list. No ingress channels means no MQC head for cumulus to disagree with.
38
+ */
39
+ export declare const HRMP_INGRESS_EMPTY = "00";
40
+ /** And `Dmp::DownwardMessageQueueHeads`: the zero hash, i.e. nothing received yet. */
41
+ export declare const DMP_HEAD_EMPTY: string;
42
+ /**
43
+ * Map entries to write per parachain. Injects rather than overrides — these are storage map
44
+ * entries, and `verify()` only decode-checks plain values.
45
+ */
46
+ export declare function messagingWipes(paraIds: number[]): Record<string, string>;
47
+ /**
48
+ * The parachain side of the same wipe: `ParachainSystem::LastDmqMqcHead`.
49
+ *
50
+ * Both halves or neither. The relay's `Dmp::DownwardMessageQueueHeads` and this value are two
51
+ * views of one number, and cumulus asserts they agree — so zeroing only the relay's simply
52
+ * turns the mismatch around, with the parachain's stale head on the left and a zero hash on the
53
+ * right. There is no HRMP counterpart to zero here: with the relay's ingress index emptied,
54
+ * cumulus iterates no channels and never looks at `LastHrmpMqcHeads` at all.
55
+ */
56
+ export declare function paraMessagingWipes(): Record<string, string>;
57
+ /**
58
+ * Transaction-storage chains need their proof schedule pushed out of reach.
59
+ *
60
+ * `pallet-transaction-storage` requires a proof of one historical transaction's data every
61
+ * `RetentionPeriod` blocks, and asserts in `on_finalize` that it happened:
62
+ *
63
+ * panicked at pallets/transaction-storage/src/lib.rs: Storage proof must be checked once in the block
64
+ * ERROR aura::cumulus: Unable to build block at slot
65
+ *
66
+ * A bite restores state but not the stored blobs, so the proof cannot be constructed and the chain
67
+ * cannot build any block at all. Bulletin on Paseo sits at ~1.49M with a period of 201,600, so it
68
+ * immediately wants a proof for a block whose data we do not have.
69
+ *
70
+ * Pushing the period past any plausible chain height means `now - RetentionPeriod` never reaches a
71
+ * block that has transactions, so no proof is ever due. 100M blocks is ~19 years at 6s and leaves
72
+ * `now + RetentionPeriod` far inside u32, which matters because the pallet also schedules cleanup
73
+ * that way. Nothing is lost: the data these proofs would attest to is already absent by
74
+ * construction.
75
+ *
76
+ * Applied on every bite of a chain that has the pallet, not just a shared relay: no bite carries
77
+ * the stored blobs, so the only thing that varies is whether the source chain has passed its first
78
+ * proof deadline yet. previewnet's bulletin passed it on 2026-08-19 and its published bundle
79
+ * wedged one block in, which is why the scoping in overrides.ts is by pallet alone.
80
+ */
81
+ export declare const FORK_RETENTION_PERIOD = 100000000;
82
+ export declare function transactionStorageWipes(): Record<string, string>;
83
+ /**
84
+ * `ParaScheduler::CoreDescriptors` as JSON for the live registry to encode.
85
+ *
86
+ * A **`BTreeMap<CoreIndex, CoreDescriptor>`**, so it is keyed by core index rather than a list
87
+ * of pairs. Worth stating because a list of pairs is what it looks like when read back, and
88
+ * encoding one gets you `Cannot decode value 1` from deep inside an Option — the core index of
89
+ * the second entry being read as the first entry's `queue`.
90
+ *
91
+ * Encoded through the chain's own metadata rather than by hand: nested options, an enum and a
92
+ * map, where the one bug this file's verification already caught in a sibling value was a
93
+ * missing compact length. The registry knows the shape; we should not restate it.
94
+ *
95
+ * `ratio`/`step` of 57600 is a whole core (the parts-per-core unit the relay uses), matching
96
+ * what `ppn service assign-cores` submits for Asset Hub's extra cores on a genesis network.
97
+ */
98
+ export declare const FULL_CORE = 57600;
99
+ export declare function coreDescriptorsValue(plan: CoreAssignment[]): Record<number, unknown>;
@@ -0,0 +1,162 @@
1
+ // Extra bite overrides for a fork of a *shared* relay — one carrying parachains we do not run.
2
+ //
3
+ // previewnet's relay is ours end to end: the only parachains registered on it are the five we
4
+ // spawn, so production's inherited state is exactly what we want and the bite leaves it alone
5
+ // (docs/FORK.md, "Deliberately not overridden"). paseo-next-v2, kusama and polkadot are forks of
6
+ // a relay shared with everybody else, and there two pieces of that state are actively wrong:
7
+ //
8
+ // cores Every registered parachain occupies a core, and the relay splits its validator set
9
+ // into one group per core. Paseo has 18 cores; a fork runs 6 dev validators, so the
10
+ // runtime deals 6 validators into 18 groups and 12 come out empty:
11
+ // `[[0],[1],[2],[3],[4],[5],[],[],…]`. Our parachains sit on cores 7-13, which no
12
+ // group is assigned to for two thirds of every rotation, and the foreign parachains
13
+ // hold the staffed cores 0-5 — with no collators to use them.
14
+ //
15
+ // HRMP Each parachain is snapshotted at its own height and the relay after them. Messages
16
+ // delivered in that window are pruned from the relay's channel contents but counted in
17
+ // its `mqc_head`, so a parachain can never reach the head the relay expects. cumulus
18
+ // asserts on it — `HRMP head mismatch` — and fails to build any block at all.
19
+ //
20
+ // zombie-bite handles both by shrinking the world to the bitten parachains: it rewrites
21
+ // `Paras::Parachains`, assigns cores from index 0, sizes the validator set to the cores
22
+ // (`(1 + req_cores).min(7)`), and empties `Hrmp::HrmpIngressChannelsIndex` and
23
+ // `Dmp::DownwardMessageQueueHeads` per parachain. This does the same, with one deliberate
24
+ // difference: it patches `scheduler_params.num_cores` inside the *decoded* HostConfiguration
25
+ // rather than substituting a hand-encoded blob, because that struct also carries
26
+ // `EnabledHostFunction(EccRfc163)` — without which the relay's validators reject People's PVFs.
27
+ //
28
+ // The channels are not lost: `ppn service force-open-hrmp` reopens them by sudo after the
29
+ // spawn, exactly as it does for a genesis previewnet, so the fork ends up with consistent
30
+ // working HRMP rather than none.
31
+ import { compactLen, keyOf, twox64Concat, u32le } from './codec.js';
32
+ /**
33
+ * How many cores each parachain gets.
34
+ *
35
+ * Asset Hub keeps three: that is what gives it 2-second blocks through elastic scaling, and it
36
+ * is the one place where the number is a property of the network rather than a default. The
37
+ * rest get one each.
38
+ */
39
+ export function coresFor(key) {
40
+ return key === 'asset-hub' ? 3 : 1;
41
+ }
42
+ /**
43
+ * Lay the parachains out from core 0 upward.
44
+ *
45
+ * Upward from zero because those are the cores that end up with validator groups: the runtime
46
+ * fills groups in order, so with `num_cores` set to exactly what we plan here, every core in
47
+ * the plan is staffed and none of the plan depends on rotation luck.
48
+ */
49
+ export function planCores(paras) {
50
+ const plan = [];
51
+ let core = 0;
52
+ for (const para of paras) {
53
+ for (let i = 0; i < coresFor(para.key); i++)
54
+ plan.push({ core: core++, paraId: para.paraId });
55
+ }
56
+ return plan;
57
+ }
58
+ /**
59
+ * `ParaScheduler::ValidatorGroups` — every planned core gets at least one validator.
60
+ *
61
+ * Round-robin rather than contiguous chunks: with 6 validators over 5 cores the remainder has
62
+ * to land somewhere, and spreading it means no group is empty. An empty group is the whole bug
63
+ * this file exists for.
64
+ */
65
+ export function validatorGroups(cores, validators) {
66
+ const groups = Array.from({ length: cores }, () => []);
67
+ for (let v = 0; v < validators; v++)
68
+ groups[v % cores].push(v);
69
+ return (compactLen(groups.length) +
70
+ groups.map((g) => compactLen(g.length) + g.map(u32le).join('')).join(''));
71
+ }
72
+ /**
73
+ * The value each parachain's `Hrmp::HrmpIngressChannelsIndex` entry is replaced with: an empty
74
+ * list. No ingress channels means no MQC head for cumulus to disagree with.
75
+ */
76
+ export const HRMP_INGRESS_EMPTY = '00';
77
+ /** And `Dmp::DownwardMessageQueueHeads`: the zero hash, i.e. nothing received yet. */
78
+ export const DMP_HEAD_EMPTY = '00'.repeat(32);
79
+ /**
80
+ * Map entries to write per parachain. Injects rather than overrides — these are storage map
81
+ * entries, and `verify()` only decode-checks plain values.
82
+ */
83
+ export function messagingWipes(paraIds) {
84
+ const wipes = {};
85
+ for (const id of paraIds) {
86
+ const suffix = twox64Concat(u32le(id));
87
+ wipes[keyOf('Hrmp', 'HrmpIngressChannelsIndex') + suffix] = HRMP_INGRESS_EMPTY;
88
+ wipes[keyOf('Dmp', 'DownwardMessageQueueHeads') + suffix] = DMP_HEAD_EMPTY;
89
+ }
90
+ return wipes;
91
+ }
92
+ /**
93
+ * The parachain side of the same wipe: `ParachainSystem::LastDmqMqcHead`.
94
+ *
95
+ * Both halves or neither. The relay's `Dmp::DownwardMessageQueueHeads` and this value are two
96
+ * views of one number, and cumulus asserts they agree — so zeroing only the relay's simply
97
+ * turns the mismatch around, with the parachain's stale head on the left and a zero hash on the
98
+ * right. There is no HRMP counterpart to zero here: with the relay's ingress index emptied,
99
+ * cumulus iterates no channels and never looks at `LastHrmpMqcHeads` at all.
100
+ */
101
+ export function paraMessagingWipes() {
102
+ return { [keyOf('ParachainSystem', 'LastDmqMqcHead')]: DMP_HEAD_EMPTY };
103
+ }
104
+ /**
105
+ * Transaction-storage chains need their proof schedule pushed out of reach.
106
+ *
107
+ * `pallet-transaction-storage` requires a proof of one historical transaction's data every
108
+ * `RetentionPeriod` blocks, and asserts in `on_finalize` that it happened:
109
+ *
110
+ * panicked at pallets/transaction-storage/src/lib.rs: Storage proof must be checked once in the block
111
+ * ERROR aura::cumulus: Unable to build block at slot
112
+ *
113
+ * A bite restores state but not the stored blobs, so the proof cannot be constructed and the chain
114
+ * cannot build any block at all. Bulletin on Paseo sits at ~1.49M with a period of 201,600, so it
115
+ * immediately wants a proof for a block whose data we do not have.
116
+ *
117
+ * Pushing the period past any plausible chain height means `now - RetentionPeriod` never reaches a
118
+ * block that has transactions, so no proof is ever due. 100M blocks is ~19 years at 6s and leaves
119
+ * `now + RetentionPeriod` far inside u32, which matters because the pallet also schedules cleanup
120
+ * that way. Nothing is lost: the data these proofs would attest to is already absent by
121
+ * construction.
122
+ *
123
+ * Applied on every bite of a chain that has the pallet, not just a shared relay: no bite carries
124
+ * the stored blobs, so the only thing that varies is whether the source chain has passed its first
125
+ * proof deadline yet. previewnet's bulletin passed it on 2026-08-19 and its published bundle
126
+ * wedged one block in, which is why the scoping in overrides.ts is by pallet alone.
127
+ */
128
+ export const FORK_RETENTION_PERIOD = 100_000_000;
129
+ export function transactionStorageWipes() {
130
+ return { [keyOf('TransactionStorage', 'RetentionPeriod')]: u32le(FORK_RETENTION_PERIOD) };
131
+ }
132
+ /**
133
+ * `ParaScheduler::CoreDescriptors` as JSON for the live registry to encode.
134
+ *
135
+ * A **`BTreeMap<CoreIndex, CoreDescriptor>`**, so it is keyed by core index rather than a list
136
+ * of pairs. Worth stating because a list of pairs is what it looks like when read back, and
137
+ * encoding one gets you `Cannot decode value 1` from deep inside an Option — the core index of
138
+ * the second entry being read as the first entry's `queue`.
139
+ *
140
+ * Encoded through the chain's own metadata rather than by hand: nested options, an enum and a
141
+ * map, where the one bug this file's verification already caught in a sibling value was a
142
+ * missing compact length. The registry knows the shape; we should not restate it.
143
+ *
144
+ * `ratio`/`step` of 57600 is a whole core (the parts-per-core unit the relay uses), matching
145
+ * what `ppn service assign-cores` submits for Asset Hub's extra cores on a genesis network.
146
+ */
147
+ export const FULL_CORE = 57600;
148
+ export function coreDescriptorsValue(plan) {
149
+ return Object.fromEntries(plan.map(({ core, paraId }) => [
150
+ core,
151
+ {
152
+ queue: null,
153
+ currentWork: {
154
+ assignments: [[{ Task: paraId }, { ratio: FULL_CORE, remaining: FULL_CORE }]],
155
+ endHint: null,
156
+ pos: 0,
157
+ step: FULL_CORE,
158
+ },
159
+ },
160
+ ]));
161
+ }
162
+ //# sourceMappingURL=shared-relay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-relay.js","sourceRoot":"","sources":["../../src/fork/shared-relay.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,EAAE;AACF,8FAA8F;AAC9F,8FAA8F;AAC9F,iGAAiG;AACjG,6FAA6F;AAC7F,EAAE;AACF,8FAA8F;AAC9F,6FAA6F;AAC7F,4EAA4E;AAC5E,2FAA2F;AAC3F,6FAA6F;AAC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AAC,oBAAoB,EAAE,iBAAiB,CAAC,CAAC,EAAE,KAAK,CAAC,qBAAqB,CAAC,EAAE,CAAC;AAC5F,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,CAAC;AAE/B,MAAM,UAAU,oBAAoB,CAAC,IAAsB;IACzD,OAAO,MAAM,CAAC,WAAW,CACvB,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;QAC7B,IAAI;QACJ;YACE,KAAK,EAAE,IAAI;YACX,WAAW,EAAE;gBACX,WAAW,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC;gBAC7E,OAAO,EAAE,IAAI;gBACb,GAAG,EAAE,CAAC;gBACN,IAAI,EAAE,SAAS;aAChB;SACF;KACF,CAAC,CACH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** Promise-returning `setTimeout`, injectable so tests never wait in real time. */
2
+ export type Sleep = (ms: number) => Promise<void>;
3
+ export declare const sleep: Sleep;
@@ -0,0 +1,2 @@
1
+ export const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
2
+ //# sourceMappingURL=sleep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sleep.js","sourceRoot":"","sources":["../../src/fork/sleep.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,KAAK,GAAU,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC"}
@@ -0,0 +1,81 @@
1
+ import type { AuraScheme } from '@parity/ppn-network-config';
2
+ export declare const ALICE_SR = "d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d";
3
+ export interface DevValidator {
4
+ stash: string;
5
+ babe: string;
6
+ grandpa: string;
7
+ beefy: string;
8
+ paraValidator: string;
9
+ paraAssignment: string;
10
+ authorityDiscovery: string;
11
+ }
12
+ /**
13
+ * Well-known dev keys, verbatim from zombie-bite src/utils.rs.
14
+ *
15
+ * Order matters: it must match get_validator_keys() — ALICE, BOB, CHARLIE, DAVE, FERDIE,
16
+ * EVE (note FERDIE before EVE) — because ActiveValidatorIndices and ValidatorGroups index
17
+ * into it positionally.
18
+ */
19
+ export declare const VALIDATORS: DevValidator[];
20
+ export declare const sessionKeys: (v: DevValidator) => string;
21
+ /**
22
+ * Relay storage values that install the dev authority set.
23
+ *
24
+ * Deliberately NOT included, unlike zombie-bite's defaults. These are all relay pallets —
25
+ * production's values are the ones we want, and each has teeth:
26
+ * Configuration::ActiveConfig the relay's host configuration for every parachain. Its
27
+ * scheduler_params holds numCores, of which the relay hands
28
+ * Asset Hub three — that is what gives Asset Hub 2s blocks.
29
+ * Its executor_params holds EnabledHostFunction(EccRfc163),
30
+ * without which the relay's validators reject People's PVFs.
31
+ * One key, two things depending on it.
32
+ * Hrmp::* / Dmp::* keeps the four HRMP channels
33
+ * Paras::Parachains keeps all four parachains registered
34
+ */
35
+ export declare function relayCandidates(): Record<string, string>;
36
+ /** Session::NextKeys is a map, so our validators' entries are injects, not overrides. */
37
+ export declare function relayInjects(): Record<string, string>;
38
+ /**
39
+ * Endow the fork's sudo (//Alice) by writing its System::Account entry at import.
40
+ *
41
+ * Shared-relay networks only: their chains are live public networks where no dev
42
+ * account holds funds, so sudo's first transaction (a runtime upgrade's fees) is
43
+ * unpayable — observed live on paseo-next-v2's people chain. Injecting the entry is
44
+ * safe: verified byte-for-byte on-chain and A/B'd against clean bites on previewnet.
45
+ * Networks with their own relay are left alone — their genesis endows the dev
46
+ * accounts, and overwriting a live account would reset its nonce and consumers.
47
+ */
48
+ export declare function sudoEndowInjects(): Record<string, string>;
49
+ /**
50
+ * The collator key for a parachain.
51
+ *
52
+ * zombie-bite derives it from the seed "//Collator-<paraId>" and names the collator
53
+ * Collator-<paraId>; zombienet derives non-well-known node keys the same way, so the two
54
+ * agree. Verified byte-identical against a real `bite -r paseo` run.
55
+ *
56
+ * The curve is the chain's, not ours: see auraScheme(). The same seed on the other curve
57
+ * is a different key, and zombienet already writes it — under `gran`, not `aura`.
58
+ */
59
+ export declare function collatorKey(paraId: number, scheme?: AuraScheme): Promise<string>;
60
+ /**
61
+ * Authorize a runtime upgrade in storage, so a fork with no sudo can still enact one.
62
+ *
63
+ * `authorize_upgrade` is a root call, and Kusama and Polkadot have no Sudo pallet — there is
64
+ * no origin on a fork that can make it. Writing the authorization at import instead leaves the
65
+ * chain in the state that call would have produced, and `apply_authorized_upgrade` is callable
66
+ * unsigned by anyone, so the second half needs no privilege either.
67
+ *
68
+ * This is the state the real upgrade path passes through, not a shortcut around it: the blob
69
+ * is still hashed, still checked against this authorization, and on a parachain still goes
70
+ * through the relay's PVF pre-check and go-ahead. What it skips is only the governance
71
+ * dispatch that would have authorized it.
72
+ *
73
+ * `checkVersion` false is what applying a runtime whose spec_version is not bumped needs —
74
+ * an e2e run replaying production's own runtime against a fork of production's state.
75
+ *
76
+ * Mirrors zombie-bite's `--rc-upgrade`/`--para-upgrade` (paritytech/zombie-bite#127), which is
77
+ * where this belongs once PPN calls zombie-bite instead of driving doppelganger itself.
78
+ */
79
+ export declare function authorizedUpgradeCandidate(codeHash: string, checkVersion: boolean): Record<string, string>;
80
+ export declare function paraCandidates(collator: string): Record<string, string>;
81
+ export declare function paraInjects(collator: string): Record<string, string>;
@@ -0,0 +1,170 @@
1
+ // The authority set a bite installs, and the storage values that install it.
2
+ //
3
+ // Doppelganger replaces the on-chain authority set while the warp-synced state is imported,
4
+ // so the forked network can be driven with keys we hold. Production's validators use
5
+ // generated keys, which is why a fork is undrivable without this.
6
+ //
7
+ // Everything in this file is pure — given a para id it produces the same bytes every time —
8
+ // so the encodings are unit-testable. relayOverrides()/paraOverrides() in ./overrides.ts
9
+ // additionally decode-verify each value against the live runtime before writing it.
10
+ import { Keyring } from '@polkadot/keyring';
11
+ import { cryptoWaitReady } from '@polkadot/util-crypto';
12
+ import { blake2128Concat, compactLen, keyOf, twox64Concat, u128le, u32le } from './codec.js';
13
+ export const ALICE_SR = 'd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d';
14
+ const mk = (stash, babe, grandpa, beefy) => ({
15
+ stash, babe, grandpa, beefy,
16
+ paraValidator: babe, paraAssignment: babe, authorityDiscovery: babe,
17
+ });
18
+ /**
19
+ * Well-known dev keys, verbatim from zombie-bite src/utils.rs.
20
+ *
21
+ * Order matters: it must match get_validator_keys() — ALICE, BOB, CHARLIE, DAVE, FERDIE,
22
+ * EVE (note FERDIE before EVE) — because ActiveValidatorIndices and ValidatorGroups index
23
+ * into it positionally.
24
+ */
25
+ export const VALIDATORS = [
26
+ mk('be5ddb1579b72e84524fc29e78609e3caf42e85aa118ebfe0b0ad404b5bdd25f', ALICE_SR, '88dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0ee', '020a1091341fe5664bfa1782d5e04779689068c916b04cb365ec3153755684d9a1'),
27
+ mk('fe65717dad0447d715f660a0a58411de509b42e6efb8375f562f58a554d5860e', '8eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48', 'd17c2d7823ebf260fd138f2d7e27d114c0145d968b5ff5006125f2414fadae69', '0390084fdbf27d2b79d26a4f13f0ccd982cb755a661969143c37cbc49ef5b91f27'),
28
+ mk('1e07379407fecc4b89eb7dbd287c2c781cfb1907a96947a3eb18e4f8e7198625', '90b5ab205c6974c9ea841be688864633dc9ca8a357843eeacf2314649965fe22', '439660b36c6c03afafca027b910b4fecf99801834c62a5e6006f27d978de234f', '020e7446f3910e15fed2b2db1e71a01c57f3dd85cc2e65f30680220e09f8bbbc79'),
29
+ mk('e860f1b1c7227f7c22602f53f15af80747814dffd839719731ee3bba6edc126c', '306721211d5404bd9da88e0204360a1a9ab8b87c66c1bc2fcdd37f3c2222cc20', '5e639b43e0052c47447dac87d6fd2b6ec50bdd4d0f614e4299c665249bbd09d9', '0227e2b139697b04eb01f4eef7e8f3724431b795c45ce6ef7b8e23a4e93f4abd26'),
30
+ mk('101191192fc877c24d725b337120fa3edc63d227bbc92705db1e2cb65f56981a', '1cbd2d43530a44705ad088af313e18f80b53ef16b36177cd4b77b846f2a5f07c', '568cb4a574c6d178feb39c27dfc8b3f789e5f5423e19c71633c748b9acf086b5', '0291f1217d5a04cb83312ee3d88a6e6b33284e053e6ccfc3a90339a0299d12967c'),
31
+ mk('8ac59e11963af19174d0b94d5d78041c233f55d2e19324665bafdfb62925af2d', 'e659a7a1628cdd93febc04a4e0646ea20e9f5f0ce097d9a05290d4a9e054df4e', '1dfe3e22cc0d45c70779c1095f7489a8ef3cf52d62fbd8c2fa38c9f1723502b5', '031d10105e323c4afce225208f71a6441ee327a65b9e646e772500c74d31f669aa'),
32
+ ];
33
+ export const sessionKeys = (v) => v.grandpa + v.babe + v.paraValidator + v.paraAssignment + v.authorityDiscovery + v.beefy;
34
+ /**
35
+ * Relay storage values that install the dev authority set.
36
+ *
37
+ * Deliberately NOT included, unlike zombie-bite's defaults. These are all relay pallets —
38
+ * production's values are the ones we want, and each has teeth:
39
+ * Configuration::ActiveConfig the relay's host configuration for every parachain. Its
40
+ * scheduler_params holds numCores, of which the relay hands
41
+ * Asset Hub three — that is what gives Asset Hub 2s blocks.
42
+ * Its executor_params holds EnabledHostFunction(EccRfc163),
43
+ * without which the relay's validators reject People's PVFs.
44
+ * One key, two things depending on it.
45
+ * Hrmp::* / Dmp::* keeps the four HRMP channels
46
+ * Paras::Parachains keeps all four parachains registered
47
+ */
48
+ export function relayCandidates() {
49
+ const len = compactLen(VALIDATORS.length);
50
+ const each = (f) => VALIDATORS.map(f).join('');
51
+ return {
52
+ [keyOf('Session', 'Validators')]: len + each((v) => v.stash),
53
+ [keyOf('Session', 'QueuedKeys')]: len + each((v) => v.stash + sessionKeys(v)),
54
+ [keyOf('Babe', 'Authorities')]: len + each((v) => v.babe + '0100000000000000'),
55
+ [keyOf('Babe', 'NextAuthorities')]: len + each((v) => v.babe + '0100000000000000'),
56
+ [keyOf('Grandpa', 'Authorities')]: len + each((v) => v.grandpa + '0100000000000000'),
57
+ [keyOf('Staking', 'Invulnerables')]: len + each((v) => v.stash),
58
+ [keyOf('ParasShared', 'ActiveValidatorIndices')]: len + VALIDATORS.map((_, i) => u32le(i)).join(''),
59
+ [keyOf('ParasShared', 'ActiveValidatorKeys')]: len + each((v) => v.paraValidator),
60
+ [keyOf('AuthorityDiscovery', 'Keys')]: len + each((v) => v.authorityDiscovery),
61
+ [keyOf('AuthorityDiscovery', 'NextKeys')]: len + each((v) => v.authorityDiscovery),
62
+ [keyOf('Sudo', 'Key')]: ALICE_SR,
63
+ // Each group carries its own compact length. Verified against production, whose real
64
+ // value is `18` + 6x(`04` + u32) = [[0],[1],[2],[3],[4],[5]].
65
+ [keyOf('ParaScheduler', 'ValidatorGroups')]: len + VALIDATORS.map((_, i) => compactLen(1) + u32le(i)).join(''),
66
+ // previewnet's relay runs the paseo runtime, which has no `:UsePreviousValidators:`
67
+ // hook, so doppelganger's inject for it is inert. Without ForceNone the first session
68
+ // rotation re-elects production's validators — whose Session::NextKeys doppelganger has
69
+ // just wiped — leaving Babe::NextAuthorities empty and halting authoring after one epoch.
70
+ [keyOf('Staking', 'ForceEra')]: '02', // Forcing::ForceNone
71
+ };
72
+ }
73
+ /** Session::NextKeys is a map, so our validators' entries are injects, not overrides. */
74
+ export function relayInjects() {
75
+ // twox128(":UsePreviousValidators:")
76
+ const injects = { c57d82d01f0fc18afc048ca20ac460dd: '01' };
77
+ const nextKeys = keyOf('Session', 'NextKeys');
78
+ for (const v of VALIDATORS) {
79
+ injects[nextKeys + twox64Concat(v.stash)] = sessionKeys(v);
80
+ }
81
+ return injects;
82
+ }
83
+ /**
84
+ * Endow the fork's sudo (//Alice) by writing its System::Account entry at import.
85
+ *
86
+ * Shared-relay networks only: their chains are live public networks where no dev
87
+ * account holds funds, so sudo's first transaction (a runtime upgrade's fees) is
88
+ * unpayable — observed live on paseo-next-v2's people chain. Injecting the entry is
89
+ * safe: verified byte-for-byte on-chain and A/B'd against clean bites on previewnet.
90
+ * Networks with their own relay are left alone — their genesis endows the dev
91
+ * accounts, and overwriting a live account would reset its nonce and consumers.
92
+ */
93
+ export function sudoEndowInjects() {
94
+ // //Alice, sr25519 public key.
95
+ const alice = 'd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d';
96
+ const info = '00000000' + // nonce
97
+ '00000000' + // consumers
98
+ '01000000' + // providers: the balance provides for the account
99
+ '00000000' + // sufficients
100
+ u128le(10n ** 16n) + // free: 1M units at 10 decimals — clears any fee on these chains
101
+ u128le(0n) + // reserved
102
+ u128le(0n) + // frozen
103
+ u128le(1n << 127n); // flags: the new-logic marker every current account carries
104
+ return { [keyOf('System', 'Account') + blake2128Concat(alice)]: info };
105
+ }
106
+ /**
107
+ * The collator key for a parachain.
108
+ *
109
+ * zombie-bite derives it from the seed "//Collator-<paraId>" and names the collator
110
+ * Collator-<paraId>; zombienet derives non-well-known node keys the same way, so the two
111
+ * agree. Verified byte-identical against a real `bite -r paseo` run.
112
+ *
113
+ * The curve is the chain's, not ours: see auraScheme(). The same seed on the other curve
114
+ * is a different key, and zombienet already writes it — under `gran`, not `aura`.
115
+ */
116
+ export async function collatorKey(paraId, scheme = 'sr25519') {
117
+ await cryptoWaitReady();
118
+ const pair = new Keyring({ type: scheme }).addFromUri(`//Collator-${paraId}`);
119
+ return Buffer.from(pair.publicKey).toString('hex');
120
+ }
121
+ /**
122
+ * Authorize a runtime upgrade in storage, so a fork with no sudo can still enact one.
123
+ *
124
+ * `authorize_upgrade` is a root call, and Kusama and Polkadot have no Sudo pallet — there is
125
+ * no origin on a fork that can make it. Writing the authorization at import instead leaves the
126
+ * chain in the state that call would have produced, and `apply_authorized_upgrade` is callable
127
+ * unsigned by anyone, so the second half needs no privilege either.
128
+ *
129
+ * This is the state the real upgrade path passes through, not a shortcut around it: the blob
130
+ * is still hashed, still checked against this authorization, and on a parachain still goes
131
+ * through the relay's PVF pre-check and go-ahead. What it skips is only the governance
132
+ * dispatch that would have authorized it.
133
+ *
134
+ * `checkVersion` false is what applying a runtime whose spec_version is not bumped needs —
135
+ * an e2e run replaying production's own runtime against a fork of production's state.
136
+ *
137
+ * Mirrors zombie-bite's `--rc-upgrade`/`--para-upgrade` (paritytech/zombie-bite#127), which is
138
+ * where this belongs once PPN calls zombie-bite instead of driving doppelganger itself.
139
+ */
140
+ export function authorizedUpgradeCandidate(codeHash, checkVersion) {
141
+ // Case-insensitive, then lowercased: `0xAB…` is the same hash, and every tool that prints
142
+ // one has its own opinion about case. Rejecting it here would fail *after* the bite ran.
143
+ const hash = codeHash.replace(/^0x/, '').toLowerCase();
144
+ if (!/^[0-9a-f]{64}$/.test(hash))
145
+ throw new Error(`code hash must be 32 bytes of hex, got "${codeHash}"`);
146
+ return { [keyOf('System', 'AuthorizedUpgrade')]: hash + (checkVersion ? '01' : '00') };
147
+ }
148
+ export function paraCandidates(collator) {
149
+ const one = compactLen(1);
150
+ return {
151
+ [keyOf('CollatorSelection', 'DesiredCandidates')]: '01000000',
152
+ [keyOf('CollatorSelection', 'Invulnerables')]: one + collator,
153
+ [keyOf('AuraExt', 'Authorities')]: one + collator,
154
+ [keyOf('Aura', 'Authorities')]: one + collator,
155
+ [keyOf('Session', 'Validators')]: one + collator,
156
+ [keyOf('Session', 'QueuedKeys')]: one + collator + collator,
157
+ [keyOf('Sudo', 'Key')]: ALICE_SR,
158
+ // ParachainSystem::LastDmqMqcHead is left alone: zeroing it (as zombie-bite does)
159
+ // desyncs the parachain from the relay's preserved Dmp state.
160
+ };
161
+ }
162
+ export function paraInjects(collator) {
163
+ return {
164
+ [keyOf('Session', 'NextKeys') + twox64Concat(collator)]: collator,
165
+ // Session::KeyOwner(("aura", collatorKey))
166
+ ['cec5070d609dd3497f72bde07fc96ba0726380404683fc89e8233450c8aa1950eab3d4a1675d3d746175726180' +
167
+ collator]: collator,
168
+ };
169
+ }
170
+ //# sourceMappingURL=validators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.js","sourceRoot":"","sources":["../../src/fork/validators.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,EAAE;AACF,4FAA4F;AAC5F,qFAAqF;AACrF,kEAAkE;AAClE,EAAE;AACF,4FAA4F;AAC5F,yFAAyF;AACzF,oFAAoF;AAEpF,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAG7F,MAAM,CAAC,MAAM,QAAQ,GAAG,kEAAkE,CAAC;AAY3F,MAAM,EAAE,GAAG,CAAC,KAAa,EAAE,IAAY,EAAE,OAAe,EAAE,KAAa,EAAgB,EAAE,CAAC,CAAC;IACzF,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK;IAC3B,aAAa,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI;CACpE,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAmB;IACxC,EAAE,CAAC,kEAAkE,EAAE,QAAQ,EAAE,kEAAkE,EAAE,oEAAoE,CAAC;IAC1N,EAAE,CAAC,kEAAkE,EAAE,kEAAkE,EAAE,kEAAkE,EAAE,oEAAoE,CAAC;IACpR,EAAE,CAAC,kEAAkE,EAAE,kEAAkE,EAAE,kEAAkE,EAAE,oEAAoE,CAAC;IACpR,EAAE,CAAC,kEAAkE,EAAE,kEAAkE,EAAE,kEAAkE,EAAE,oEAAoE,CAAC;IACpR,EAAE,CAAC,kEAAkE,EAAE,kEAAkE,EAAE,kEAAkE,EA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