@parity/ppn 0.3.0 → 0.4.0

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/config/ports.env CHANGED
@@ -106,6 +106,14 @@ DASHBOARD_HOST=
106
106
  # Empty means the dashboard is read-only there.
107
107
  DASHBOARD_ACTIONS_TOKEN=
108
108
 
109
+ # The file holding this deployment's secrets: PPN_PROFILE, the sudo, faucet, allowance and
110
+ # attester keys. Empty means the local profile and the dev keys.
111
+ #
112
+ # It lives here rather than only in the environment because every service that needs those
113
+ # keys runs as a zombienet custom process, and those are handed no environment at all. Setting
114
+ # it for the supervisor reaches the supervisor and stops; a deployment patches this file.
115
+ PPN_SECRETS_FILE=
116
+
109
117
  # Where this run's chain state and per-process logs live. Empty locally: `ppn start`
110
118
  # resolves it per mode (data/ vs data-fork/) and writes the answer to
111
119
  # config/ports.local.env, which is sourced after this file. A deployment that spawns
@@ -1,13 +1,18 @@
1
1
  /**
2
- * Deployment secrets, from the file named by PPN_SECRETS_FILE.
2
+ * Where the operator keeps deployment secrets, named by PPN_SECRETS_FILE.
3
3
  *
4
4
  * The engine ships no default path on purpose. A default is a guess about somebody else's
5
5
  * host, and a wrong guess is indistinguishable from "there are no secrets" — which resolves
6
6
  * to the local profile and the well-known dev keys, so a deployed server runs Alice as sudo
7
7
  * and nothing says so.
8
8
  *
9
+ * Read from the environment *or* from config/ports.env, because zombienet hands custom
10
+ * processes no environment at all: every service that needs the deployable keys runs as one,
11
+ * so an environment-only lookup is unset exactly where it matters most. ports.env is the
12
+ * channel those facts already travel on, and a deployment patches it per deploy.
13
+ *
9
14
  * Unset means local. Set-but-missing is fatal: that is a deployment that believes it
10
- * configured secrets, and it is exactly the case a silent fallback gets wrong.
15
+ * configured secrets, and it is the case a silent fallback gets wrong.
11
16
  */
12
17
  export declare function secretsFile(): string | null;
13
18
  /** secretsFile(), merged into process.env without overwriting what is already set. */
@@ -1,18 +1,24 @@
1
1
  import fs from 'node:fs';
2
- import { readEnvFile } from '@parity/ppn-network-config';
2
+ import path from 'node:path';
3
+ import { readEnvFile, repoRoot, workspaceRoot } from '@parity/ppn-network-config';
3
4
  /**
4
- * Deployment secrets, from the file named by PPN_SECRETS_FILE.
5
+ * Where the operator keeps deployment secrets, named by PPN_SECRETS_FILE.
5
6
  *
6
7
  * The engine ships no default path on purpose. A default is a guess about somebody else's
7
8
  * host, and a wrong guess is indistinguishable from "there are no secrets" — which resolves
8
9
  * to the local profile and the well-known dev keys, so a deployed server runs Alice as sudo
9
10
  * and nothing says so.
10
11
  *
12
+ * Read from the environment *or* from config/ports.env, because zombienet hands custom
13
+ * processes no environment at all: every service that needs the deployable keys runs as one,
14
+ * so an environment-only lookup is unset exactly where it matters most. ports.env is the
15
+ * channel those facts already travel on, and a deployment patches it per deploy.
16
+ *
11
17
  * Unset means local. Set-but-missing is fatal: that is a deployment that believes it
12
- * configured secrets, and it is exactly the case a silent fallback gets wrong.
18
+ * configured secrets, and it is the case a silent fallback gets wrong.
13
19
  */
14
20
  export function secretsFile() {
15
- const file = process.env.PPN_SECRETS_FILE;
21
+ const file = process.env.PPN_SECRETS_FILE || fromPorts();
16
22
  if (!file)
17
23
  return null;
18
24
  if (!fs.existsSync(file)) {
@@ -22,6 +28,20 @@ export function secretsFile() {
22
28
  }
23
29
  return file;
24
30
  }
31
+ /** ports.local.env wins over ports.env, the same precedence every other fact uses. */
32
+ function fromPorts() {
33
+ for (const p of [
34
+ path.join(workspaceRoot(), 'config', 'ports.local.env'),
35
+ path.join(repoRoot(), 'config', 'ports.env'),
36
+ ]) {
37
+ if (!fs.existsSync(p))
38
+ continue;
39
+ const v = readEnvFile(p).PPN_SECRETS_FILE;
40
+ if (v)
41
+ return v;
42
+ }
43
+ return undefined;
44
+ }
25
45
  /** secretsFile(), merged into process.env without overwriting what is already set. */
26
46
  export function loadSecrets() {
27
47
  const file = secretsFile();
@@ -1 +1 @@
1
- {"version":3,"file":"secrets.js","sourceRoot":"","sources":["../../src/l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AAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CACb,8BAA8B,IAAI,2BAA2B;YAC3D,wFAAwF;YACxF,iFAAiF,CACpF,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,sFAAsF;AACtF,SAAS,SAAS;IAChB,KAAK,MAAM,CAAC,IAAI;QACd,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,QAAQ,EAAE,iBAAiB,CAAC;QACvD,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,WAAW,CAAC;KAC7C,EAAE,CAAC;QACF,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;YAAE,SAAS;QAChC,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC;QAC1C,IAAI,CAAC;YAAE,OAAO,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,WAAW;IACzB,MAAM,IAAI,GAAG,WAAW,EAAE,CAAC;IAC3B,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC7E,OAAO,IAAI,CAAC;AACd,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parity/ppn",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "description": "Spin up a local Polkadot ecosystem: fetch, generate, fork and run a network",
6
6
  "bin": {
@@ -20,7 +20,7 @@
20
20
  "commander": "^15.0.0",
21
21
  "polkadot-api": "^1.23.3",
22
22
  "toml": "^3.0.0",
23
- "@parity/ppn-network-config": "0.3.0"
23
+ "@parity/ppn-network-config": "0.4.0"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/node": "^22.10.5",
@@ -51,6 +51,17 @@ fi
51
51
  # generated TOML on purpose: the deployable profile holds private keys at runtime only
52
52
  # (see docs/PROFILES.md). No default path — that would be a guess about someone's host,
53
53
  # and guessing wrong looks exactly like "no secrets", which is the dev keys.
54
+ #
55
+ # Read from ports.env when the environment does not carry it, because zombienet hands this
56
+ # process no environment: an env-only lookup is empty on exactly the deployed servers that
57
+ # need the keys. Same resolution as lib/secrets.ts, local override first.
58
+ if [[ -z "${PPN_SECRETS_FILE:-}" ]]; then
59
+ for f in "$PPN_WS/config/ports.local.env" "$PROJECT_DIR/config/ports.env"; do
60
+ [[ -f "$f" ]] || continue
61
+ v=$(grep -m1 '^PPN_SECRETS_FILE=' "$f" | cut -d= -f2- | tr -d '"'"'"'')
62
+ [[ -n "$v" ]] && { PPN_SECRETS_FILE="$v"; break; }
63
+ done
64
+ fi
54
65
  if [[ -n "${PPN_SECRETS_FILE:-}" ]]; then
55
66
  if [[ ! -f "$PPN_SECRETS_FILE" ]]; then
56
67
  echo "[$ROLE] PPN_SECRETS_FILE points at $PPN_SECRETS_FILE, which does not exist." >&2
@@ -93,7 +93,7 @@ name = "bulletin-collator1"
93
93
  rpc_port = 10030
94
94
  p2p_port = 30333
95
95
  command = "{{SCRIPTS}}/omni-node.sh"
96
- args = ["-lparachain=debug,xcm=trace", "--rpc-max-connections=500", "--force-authoring", "--ipfs-server", "--authoring=slot-based", "--unsafe-rpc-external", "--rpc-max-response-size=50", "--experimental-webrtc", "--listen-addr=/ip4/127.0.0.1/udp/30333/webrtc-direct", "--enable-hop", "--hop-retention-secs=3600", "--hop-check-interval=60"]
96
+ args = ["-lparachain=debug,xcm=trace", "--rpc-max-connections=500", "--force-authoring", "--ipfs-server", "--unsafe-rpc-external", "--rpc-max-response-size=50", "--experimental-webrtc", "--listen-addr=/ip4/127.0.0.1/udp/30333/webrtc-direct", "--enable-hop", "--hop-retention-secs=3600", "--hop-promotion-buffer-secs=1800", "--hop-check-interval=60"]
97
97
 
98
98
  ## Web3 Storage Chain (Parachain 1600)
99
99
  [[parachains]]