@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
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@parity/ppn",
3
+ "version": "0.2.0-rc.1",
4
+ "type": "module",
5
+ "description": "Spin up a local Polkadot ecosystem: fetch, generate, fork and run a network",
6
+ "bin": {
7
+ "ppn": "./dist/bin.js"
8
+ },
9
+ "exports": {
10
+ ".": "./dist/cli.js",
11
+ "./spawn-env": "./dist/lib/spawn-env.js"
12
+ },
13
+ "dependencies": {
14
+ "@polkadot-labs/hdkd-helpers": "^0.0.11",
15
+ "@polkadot/api": "^15.8.1",
16
+ "@polkadot/keyring": "13.5.9",
17
+ "@polkadot/types": "^15.10.2",
18
+ "@polkadot/util": "13.5.9",
19
+ "@polkadot/util-crypto": "^13.5.9",
20
+ "commander": "^15.0.0",
21
+ "polkadot-api": "^1.23.3",
22
+ "toml": "^3.0.0",
23
+ "@parity/ppn-network-config": "0.2.0-rc.1"
24
+ },
25
+ "devDependencies": {
26
+ "@types/node": "^22.10.5",
27
+ "tsx": "^4.19",
28
+ "typescript": "^5.7"
29
+ },
30
+ "license": "Apache-2.0",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/paritytech/previewnet-engine.git",
34
+ "directory": "packages/cli"
35
+ },
36
+ "files": [
37
+ "dist",
38
+ "scripts",
39
+ "config",
40
+ "zombienet-configs",
41
+ "networks",
42
+ "web"
43
+ ],
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
47
+ "engines": {
48
+ "node": ">=22"
49
+ },
50
+ "scripts": {
51
+ "build": "tsc -b",
52
+ "test": "tsx --test tests/*.test.ts"
53
+ }
54
+ }
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env bash
2
+ # zombienet's custom_processes spawns a command path, so this launcher has to exist.
3
+ # Everything it used to decide — which para id gets the extra elastic-scaling cores, which
4
+ # key signs for it — now lives in `ppn service assign-cores`.
5
+ # In a checkout the entry point is bin/ppn.mjs; installed from npm it is dist/bin.js —
6
+ # the tarball ships no bin/. Every service launcher had the checkout path hardcoded, which
7
+ # broke every custom_process on an npm install, silently: zombienet does not gate a spawn
8
+ # on its custom processes, so the network came up with cores unassigned and no services.
9
+ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
10
+ ENTRY="$ROOT/bin/ppn.mjs"
11
+ [[ -f "$ENTRY" ]] || ENTRY="$ROOT/dist/bin.js"
12
+ exec node "$ENTRY" service assign-cores
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env bash
2
+ # zombienet's custom_processes exec a command path, so this launcher has to exist.
3
+ # The logic lives in `ppn service dashboard` — see docs/DASHBOARD.md.
4
+ # In a checkout the entry point is bin/ppn.mjs; installed from npm it is dist/bin.js —
5
+ # the tarball ships no bin/. Every service launcher had the checkout path hardcoded, which
6
+ # broke every custom_process on an npm install, silently: zombienet does not gate a spawn
7
+ # on its custom processes, so the network came up with cores unassigned and no services.
8
+ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
9
+ ENTRY="$ROOT/bin/ppn.mjs"
10
+ [[ -f "$ENTRY" ]] || ENTRY="$ROOT/dist/bin.js"
11
+ exec node "$ENTRY" service dashboard
@@ -0,0 +1,52 @@
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ if [ "$(uname -m)" != "x86_64" ]; then
5
+ echo "ERROR: PPN Docker mode only supports Linux x86_64."
6
+ echo "macOS Apple Silicon is not supported — p2p networking fails under x86_64 emulation."
7
+ echo "Use native mode instead: make start"
8
+ exit 1
9
+ fi
10
+
11
+ echo "========================================"
12
+ echo " PPN - Product Preview Network"
13
+ echo "========================================"
14
+ echo ""
15
+
16
+ # Clean data directory if requested
17
+ if [ "$CLEAN" = "1" ]; then
18
+ echo "Cleaning data directory..."
19
+ make clean-data
20
+ echo ""
21
+ fi
22
+
23
+ # Regenerate chainspecs if requested (for custom runtime overrides)
24
+ if [ "$REGENERATE" = "1" ]; then
25
+ echo "Regenerating chain specs..."
26
+ make generate
27
+ echo ""
28
+ fi
29
+
30
+ # Show persistence mode
31
+ if [ "$EPHEMERAL" = "1" ]; then
32
+ echo "Mode: Ephemeral (data lost on stop)"
33
+ else
34
+ echo "Mode: Persistent (DATA_DIR=${DATA_DIR:-./data})"
35
+ fi
36
+ echo ""
37
+
38
+ echo "Starting network... (this may take a few minutes)"
39
+ echo ""
40
+ echo "Endpoints will be available at:"
41
+ echo " Relay Alice: ws://localhost:10000"
42
+ echo " Relay Bob: ws://localhost:10001"
43
+ echo " Relay Charlie: ws://localhost:10002"
44
+ echo " Asset Hub: ws://localhost:10020 (2s blocks)"
45
+ echo " People Chain: ws://localhost:10010"
46
+ echo " Bulletin: ws://localhost:10030"
47
+ echo " Eth RPC: http://localhost:8545"
48
+ echo ""
49
+ echo "========================================"
50
+ echo ""
51
+
52
+ exec make start
@@ -0,0 +1,116 @@
1
+ #!/usr/bin/env bash
2
+ # Postgres cluster backing the device-uniqueness-backend services.
3
+ #
4
+ # One cluster with a database per service. Upstream's compose file runs a
5
+ # separate cluster per service so each can deploy independently; that buys
6
+ # nothing here and costs three extra processes.
7
+ set -euo pipefail
8
+
9
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
10
+ PROJECT_DIR="$SCRIPT_DIR/../.."
11
+ source "$SCRIPT_DIR/../lib/workspace.sh"
12
+ BIN_DIR="$PPN_WS_BIN"
13
+ PG_DIST="$BIN_DIR/postgres-dist"
14
+
15
+ source "$PROJECT_DIR/config/ports.env"
16
+ [[ -f "$PPN_WS/config/ports.local.env" ]] && source "$PPN_WS/config/ports.local.env"
17
+
18
+ # DATA_DIR does not survive zombie-cli into a custom_process, so fall back to
19
+ # the project-local default the same way storage-provider-node.sh does.
20
+ #
21
+ # Deliberately NOT $DATA_DIR/dub-postgres: zombienet creates a directory
22
+ # named after each custom_process for its log and writes dub-postgres.log
23
+ # there before this script runs, and initdb refuses a non-empty directory.
24
+ PGDATA="${DUB_POSTGRES_DATA_DIR:-${DATA_DIR:-$PPN_WS/data}/identity-pgdata}"
25
+
26
+ # Databases to create on first init. `identity` is shared by device-attestation-api, its chain
27
+ # writer and registration-queue; username-indexer owns its own.
28
+ # One database per service that owns state. v0.2.0 split a bare DATABASE_URL, which eight
29
+ # call sites had been reading while naming four different Postgres instances, into namespaced
30
+ # keys — so each exists here even when only device-attestation and the indexer are busy.
31
+ #
32
+ # `identity` keeps its physical name: the config key that carries it became
33
+ # DEVICE_ATTESTATION_DATABASE_URL in v0.3.0, but nothing upstream reads the database's name, and
34
+ # renaming it would strand every cluster already initialised under the old one. `dim_tickets` is
35
+ # gone with the service that owned it — an existing cluster keeps the database, unread.
36
+ DATABASES=(identity username_indexer invite_tickets)
37
+
38
+ PG_USER=identity
39
+
40
+ if [[ ! -x "$PG_DIST/bin/postgres" ]]; then
41
+ echo "Error: postgres not found at $PG_DIST/bin/postgres" >&2
42
+ echo " Run 'make fetch' to download it (see docs/DEVICE-UNIQUENESS-BACKEND.md)." >&2
43
+ exit 1
44
+ fi
45
+
46
+ "$SCRIPT_DIR/../kill-port.sh" "$DUB_POSTGRES_PORT"
47
+
48
+ # initdb once; on restart the existing cluster is reused.
49
+ if [[ ! -f "$PGDATA/PG_VERSION" ]]; then
50
+ echo "Initialising Postgres cluster at $PGDATA"
51
+ mkdir -p "$PGDATA"
52
+ # --auth=trust: the cluster listens on loopback only (see -c below) and
53
+ # holds nothing but local dev state, so there is no password to manage.
54
+ "$PG_DIST/bin/initdb" -D "$PGDATA" -U "$PG_USER" --auth=trust --encoding=UTF8 >/dev/null
55
+ INITIALISED=1
56
+ else
57
+ echo "Reusing Postgres cluster at $PGDATA"
58
+ INITIALISED=0
59
+ fi
60
+
61
+ # Unix sockets are disabled outright. The socket path has a hard 103-byte limit
62
+ # and PGDATA is user-controlled via DATA_DIR, so a deep path makes postgres fail
63
+ # to start with "could not create any Unix-domain sockets". Every client here
64
+ # connects over TCP anyway.
65
+ PG_OPTS=(
66
+ -D "$PGDATA"
67
+ -p "$DUB_POSTGRES_PORT"
68
+ -c listen_addresses=127.0.0.1
69
+ -c unix_socket_directories=
70
+ )
71
+
72
+ PG_PID=""
73
+ cleanup() {
74
+ if [[ -n "$PG_PID" ]]; then
75
+ # Fast shutdown: roll back live transactions rather than waiting for
76
+ # clients, which never disconnect on their own here.
77
+ kill -INT "$PG_PID" 2>/dev/null || true
78
+ wait "$PG_PID" 2>/dev/null || true
79
+ fi
80
+ exit 0
81
+ }
82
+ trap cleanup INT TERM EXIT
83
+
84
+ "$PG_DIST/bin/postgres" "${PG_OPTS[@]}" &
85
+ PG_PID=$!
86
+
87
+ echo "Waiting for Postgres on 127.0.0.1:$DUB_POSTGRES_PORT..."
88
+ for _ in $(seq 1 60); do
89
+ if "$PG_DIST/bin/pg_isready" -h 127.0.0.1 -p "$DUB_POSTGRES_PORT" -U "$PG_USER" -d postgres >/dev/null 2>&1; then
90
+ break
91
+ fi
92
+ sleep 1
93
+ done
94
+
95
+ if ! "$PG_DIST/bin/pg_isready" -h 127.0.0.1 -p "$DUB_POSTGRES_PORT" -U "$PG_USER" -d postgres >/dev/null 2>&1; then
96
+ echo "Error: Postgres did not become ready within 60s" >&2
97
+ exit 1
98
+ fi
99
+
100
+ # Create databases on every boot, not just after initdb: a cluster left over
101
+ # from an older revision may predate a database added since.
102
+ for db in "${DATABASES[@]}"; do
103
+ if "$PG_DIST/bin/psql" -h 127.0.0.1 -p "$DUB_POSTGRES_PORT" -U "$PG_USER" \
104
+ -d postgres -tAc "SELECT 1 FROM pg_database WHERE datname='$db'" | grep -q 1; then
105
+ echo " = $db"
106
+ else
107
+ "$PG_DIST/bin/createdb" -h 127.0.0.1 -p "$DUB_POSTGRES_PORT" -U "$PG_USER" "$db"
108
+ echo " + $db"
109
+ fi
110
+ done
111
+
112
+ [[ "$INITIALISED" == "1" ]] && echo "Postgres ready (fresh cluster)" || echo "Postgres ready"
113
+
114
+ # Migrations are applied by the services themselves on boot, under a Postgres
115
+ # advisory lock, so nothing else is needed here.
116
+ wait "$PG_PID"
@@ -0,0 +1,202 @@
1
+ #!/usr/bin/env bash
2
+ # Runs one device-uniqueness-backend service.
3
+ #
4
+ # service.sh --role=<role> --wait-for=<host:port>
5
+ #
6
+ # Flag form rather than positionals because zombienet validates custom_process
7
+ # args as CLI arguments and rejects anything that is not a flag or --key=value.
8
+ #
9
+ # Config does not live here: the non-secret environment is emitted into the
10
+ # generated zombienet TOML by packages/network-config/src/dub.ts, so what a service runs
11
+ # with is visible in the config rather than in a shell default. This script only
12
+ # does the three things a declaration cannot.
13
+ set -uo pipefail
14
+
15
+ # Both spellings are accepted because zombienet does not pass args through
16
+ # verbatim: `--role=all-in-one` in the TOML arrives as `--role all-in-one`,
17
+ # two separate argv entries.
18
+ ROLE=""
19
+ # device-uniqueness-backend v0.2.0 ships one binary; the service is chosen with --role.
20
+ # Named `ibv2` until v0.3.0 renamed it, along with the release assets `ppn fetch` reads.
21
+ BINARY="dub"
22
+ WAIT_TARGET=""
23
+ while [[ $# -gt 0 ]]; do
24
+ case "$1" in
25
+ --role=*) ROLE="${1#*=}"; shift ;;
26
+ --role) ROLE="${2:-}"; shift 2 ;;
27
+ --wait-for=*) WAIT_TARGET="${1#*=}"; shift ;;
28
+ --wait-for) WAIT_TARGET="${2:-}"; shift 2 ;;
29
+ *) echo "service.sh: unknown argument '$1'" >&2; exit 1 ;;
30
+ esac
31
+ done
32
+
33
+ if [[ -z "$ROLE" || -z "$WAIT_TARGET" ]]; then
34
+ echo "usage: service.sh --role=<role> --wait-for=<host:port>" >&2
35
+ exit 1
36
+ fi
37
+
38
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
39
+ PROJECT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
40
+ # Binaries live in the workspace, not beside this script — see scripts/lib/workspace.sh.
41
+ source "$SCRIPT_DIR/../lib/workspace.sh"
42
+ BIN_DIR="$PPN_WS_BIN"
43
+
44
+ if [[ ! -x "$BIN_DIR/$BINARY" ]]; then
45
+ echo "Error: $BINARY not found at $BIN_DIR/$BINARY (run \`ppn fetch\`)" >&2
46
+ echo " Run 'make fetch' (see docs/DEVICE-UNIQUENESS-BACKEND.md)." >&2
47
+ exit 1
48
+ fi
49
+
50
+ # 1. Secrets. Kept out of the generated TOML on purpose — the deployable profile
51
+ # keeps private keys at runtime only and never writes them to a generated
52
+ # file (see docs/PROFILES.md). Absent file means local profile, and the dev
53
+ # defaults below apply. Exported unconditionally; services that do not read
54
+ # a given variable simply ignore it.
55
+ [[ -f /etc/ppn/secrets.env ]] && set -a && source /etc/ppn/secrets.env && set +a
56
+
57
+ # The attester, under the deployable profile.
58
+ #
59
+ # increase-people-lite-attestation-allowance.sh grants the allowance to
60
+ # PPN_ALLOWANCE_SS58, so the writer has to attest as that same account — the
61
+ # generated TOML carries Alice, who holds no allowance on a deployed server.
62
+ # Overridden here rather than at generate time because redeploy.sh does not
63
+ # regenerate the TOML; it deploys the committed one.
64
+ #
65
+ # Refuse to start when the key for that account is missing, rather than falling
66
+ # back to //Alice: the writer would sign, the API would keep returning 202, and
67
+ # every registration would sit in the outbox failing NoAttestationAllowance.
68
+ # Same reasoning as the allowance script's own hard-fail.
69
+ if [[ -n "${PPN_ALLOWANCE_SS58:-}" ]]; then
70
+ if [[ -z "${PPN_DUB_ATTESTER_URI:-${PPN_IDENTITY_ATTESTER_URI:-}}" ]]; then
71
+ echo "Error: PPN_ALLOWANCE_SS58 is set but no attester key is set." >&2
72
+ echo " The attestation allowance is granted to $PPN_ALLOWANCE_SS58, so the" >&2
73
+ echo " chain writer must hold that account's key. Add it to" >&2
74
+ echo " /etc/ppn/secrets.env — see docs/DEVICE-UNIQUENESS-BACKEND.md." >&2
75
+ exit 1
76
+ fi
77
+ export ATTESTER_ACCOUNT="$PPN_ALLOWANCE_SS58"
78
+ fi
79
+
80
+ # Writer's signing key. Must resolve to ATTESTER_ACCOUNT above, or the writer
81
+ # derives a proxy target from the difference and People Chain needs a matching
82
+ # proxy registration.
83
+ # The attester key. PPN_DUB_ATTESTER_URI is the current name; PPN_IDENTITY_ATTESTER_URI is
84
+ # still read because it is already set as a GitHub Actions secret on deployed environments, and
85
+ # a rename here would break those deploys until someone re-entered a value only they hold.
86
+ export CHAIN_WRITER_SIGNER_SURI="${PPN_DUB_ATTESTER_URI:-${PPN_IDENTITY_ATTESTER_URI:-//Alice}}"
87
+ # The ticket services sign their own batches. v0.2.0 removed INVITER_PROXY_FOR: proxying is now
88
+ # derived from whether this key's account differs from INVITER_ADDRESS, so keeping them equal
89
+ # means direct signing and no proxy registration on chain — the same arrangement the chain
90
+ # writer already used.
91
+ #
92
+ # Bob, not Alice: two independent writers on one account share a nonce lane, and
93
+ # invite-tickets-pool submits every ~30s, which starves the chain writer until its
94
+ # registration fails terminally. It must stay in step with INVITER_ADDRESS in the generated
95
+ # TOML (see BOB_SS58 in packages/network-config/src/dub.ts) — a mismatch turns direct
96
+ # signing into a proxy call that People Chain has no registration for.
97
+ export INVITER_SIGNER_SURI="${PPN_INVITER_SURI:-//Bob}"
98
+
99
+ # turn-api signs short-lived TURN credentials. Base64, not hex — it rejects hex with "invalid
100
+ # base64 encoding". Local-only: nothing outside this machine can use a credential minted here.
101
+ export TURN_SECRET="${TURN_SECRET:-AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=}"
102
+
103
+ # Where all-in-one serves /docs from. A ServeDir, so it needs a directory rather than the two
104
+ # loose files the old gateway mapped by hand; `ppn fetch` fills it from the backend's tree at
105
+ # the pinned tag. Set here and not in the TOML because it is a path on this machine.
106
+ export GATEWAY_DOCS_ROOT="${GATEWAY_DOCS_ROOT:-$BIN_DIR/identity-docs}"
107
+
108
+ # Dev-only JWT signing seed. A deployed server must override it.
109
+ export JWT_ED25519_SECRET="${JWT_ED25519_SECRET:-0x0101010101010101010101010101010101010101010101010101010101010101}"
110
+
111
+ # device-attestation mints JWTs with the secret above; the ticket APIs verify them, and v0.2.0 requires
112
+ # the verification key explicitly (JWT_JWKS_JSON or JWT_ED25519_PUBLIC_KEY). Derived from the
113
+ # secret rather than written out beside it: two hardcoded halves drift, and a mismatch would
114
+ # look like every ticket request being unauthorised for no visible reason.
115
+ if [[ -z "${JWT_ED25519_PUBLIC_KEY:-}" && -z "${JWT_JWKS_JSON:-}" ]]; then
116
+ JWT_ED25519_PUBLIC_KEY=$(node -e '
117
+ const crypto = require("crypto");
118
+ const seed = Buffer.from(process.env.JWT_ED25519_SECRET.replace(/^0x/, ""), "hex");
119
+ const pkcs8 = Buffer.concat([Buffer.from("302e020100300506032b657004220420", "hex"), seed]);
120
+ const pub = crypto
121
+ .createPublicKey(crypto.createPrivateKey({ key: pkcs8, format: "der", type: "pkcs8" }))
122
+ .export({ format: "der", type: "spki" })
123
+ .subarray(-32);
124
+ process.stdout.write("0x" + pub.toString("hex"));
125
+ ') || { echo "[$ROLE] could not derive JWT_ED25519_PUBLIC_KEY from JWT_ED25519_SECRET" >&2; exit 1; }
126
+ export JWT_ED25519_PUBLIC_KEY
127
+ fi
128
+
129
+ # 2. Free our own port. A leftover process from a previous run holds it, and the
130
+ # supervision loop below would otherwise respawn against "Address already in
131
+ # use (os error 48)" forever. BIND_ADDR comes from the TOML env and is only
132
+ # set for the services that listen, so this is a no-op for the workers.
133
+ if [[ -n "${BIND_ADDR:-}" ]]; then
134
+ "$PROJECT_DIR/scripts/kill-port.sh" "${BIND_ADDR##*:}" >/dev/null 2>&1 || true
135
+ fi
136
+
137
+ # 3. Wait for Postgres. Every service connects and applies migrations before
138
+ # anything else, and exits rather than retrying when it is unreachable
139
+ # ("pool timed out while waiting for an open connection"). custom_processes
140
+ # have no ordering, so waiting here is the only sequencing available.
141
+ #
142
+ # No equivalent wait for the chain: the services block on the People Chain
143
+ # connect indefinitely and pick it up whenever it appears. They do not bind
144
+ # their HTTP port until that succeeds, so /livez and /readyz being
145
+ # unreachable while the parachain starts is expected, not a fault.
146
+ WAIT_HOST="${WAIT_TARGET%:*}"
147
+ WAIT_PORT="${WAIT_TARGET##*:}"
148
+
149
+ echo "[$ROLE] waiting for $WAIT_TARGET..."
150
+ for _ in $(seq 1 120); do
151
+ if "$BIN_DIR/postgres-dist/bin/pg_isready" -h "$WAIT_HOST" -p "$WAIT_PORT" \
152
+ -U identity -d postgres >/dev/null 2>&1; then
153
+ break
154
+ fi
155
+ sleep 1
156
+ done
157
+
158
+ # The port is not the thing to wait for. postgres.sh has to open it *before* it can create
159
+ # the databases, and pg_isready above asks about `postgres`, which always exists — so a
160
+ # service that wins the race connects into the gap, dies with `database "identity" does not
161
+ # exist`, and then sits out a restart backoff. That cost five minutes on CI, long enough for
162
+ # the registration test to give up while the chain half had already succeeded.
163
+ for _ in $(seq 1 120); do
164
+ missing=""
165
+ for db in identity username_indexer invite_tickets; do
166
+ "$BIN_DIR/postgres-dist/bin/psql" -h "$WAIT_HOST" -p "$WAIT_PORT" -U identity \
167
+ -d "$db" -tAc 'select 1' >/dev/null 2>&1 || missing="$missing $db"
168
+ done
169
+ [[ -z "$missing" ]] && break
170
+ sleep 1
171
+ done
172
+ [[ -n "$missing" ]] && echo "[$ROLE] warning: databases still missing:$missing" >&2
173
+ echo "[$ROLE] databases ready"
174
+
175
+ # 4. Supervise. zombienet has no restart policy for custom_processes — the
176
+ # schema is name/command/image/args/env — so a service that dies stays dead
177
+ # until the whole network restarts. Same reason ipfs-daemon.sh loops.
178
+ CHILD_PID=""
179
+ cleanup() {
180
+ if [[ -n "$CHILD_PID" ]]; then
181
+ kill "$CHILD_PID" 2>/dev/null
182
+ wait "$CHILD_PID" 2>/dev/null
183
+ fi
184
+ exit 0
185
+ }
186
+ trap cleanup INT TERM EXIT
187
+
188
+ while true; do
189
+ "$BIN_DIR/$BINARY" --role "$ROLE" &
190
+ CHILD_PID=$!
191
+ wait "$CHILD_PID"
192
+ EXIT_CODE=$?
193
+ CHILD_PID=""
194
+
195
+ # Killed by signal (128+n) means the network is going down with us.
196
+ if [[ $EXIT_CODE -gt 128 ]]; then
197
+ exit 0
198
+ fi
199
+
200
+ echo "[$ROLE] exited (code $EXIT_CODE), restarting in 5s..."
201
+ sleep 5
202
+ done
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ if command -v dot >/dev/null 2>&1; then
5
+ echo "✓ dot CLI present"
6
+ exit 0
7
+ fi
8
+
9
+ if ! command -v npm >/dev/null 2>&1; then
10
+ echo "Error: npm is required to install dot CLI (polkadot-cli)."
11
+ echo "Install Node.js first, then rerun: make ensure-dot-cli"
12
+ exit 1
13
+ fi
14
+
15
+ echo "Installing dot CLI globally (polkadot-cli@1.1.1)..."
16
+ if npm install -g polkadot-cli@1.1.1; then
17
+ echo "✓ dot CLI installed"
18
+ else
19
+ echo "✗ Failed to install dot CLI"
20
+ echo "Try running manually:"
21
+ echo " npm install -g polkadot-cli@1.1.1"
22
+ exit 1
23
+ fi
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env bash
2
+ # eth-rpc wrapper - connects to Asset Hub
3
+
4
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
+ # The package: shipped, read-only — this script and the default ports.env travel together.
6
+ PROJECT_DIR="$SCRIPT_DIR/.."
7
+
8
+ # The workspace: where `ppn fetch` puts binaries and `ppn start` writes ports.local.env. In a
9
+ # checkout it is the same directory as the package; installed from npm it is not, and reading
10
+ # either from $SCRIPT_DIR/.. would look inside node_modules for a bin/ that does not exist.
11
+ source "$(dirname "${BASH_SOURCE[0]}")/lib/workspace.sh"
12
+ WS="$PPN_WS"
13
+ BIN_DIR="$WS/bin"
14
+
15
+ # Source port configuration — the package's own default.
16
+ source "$PROJECT_DIR/config/ports.env"
17
+
18
+ # eth-rpc is network-versioned (its build must match the Asset Hub runtime's revive
19
+ # pallet), so non-previewnet networks keep it in bin/<network>. zombie-cli does not
20
+ # forward env to custom_processes; the network selector comes from the gitignored
21
+ # override file `ppn start` writes into the workspace.
22
+ [[ -f "$WS/config/ports.local.env" ]] && source "$WS/config/ports.local.env"
23
+ if [[ -n "${PPN_NETWORK:-}" && "$PPN_NETWORK" != "previewnet" ]]; then
24
+ BIN_DIR="$WS/bin/$PPN_NETWORK"
25
+ fi
26
+
27
+ export RUST_LOG="${RUST_LOG:-info}"
28
+
29
+ # eth-rpc caches receipts and block index in a SQLite db. Its default home is
30
+ # ~/.local/share/eth-rpc, which outlives the chain: wipe the chain data, start a
31
+ # network with a different genesis, and eth-rpc finds a db from the old chain,
32
+ # fails the essential `block-subscription` task with ChainMismatch and exits —
33
+ # leaving nothing behind port 8545 until someone deletes the db by hand
34
+ # (previewnet spent 2026-08-19 to 08-20 that way). Keeping it under the chain
35
+ # data directory ties the cache's lifetime to the state it describes, so
36
+ # `make clean-data` and a clean redeploy take it with them.
37
+ # Per-mode data dir (data/ vs data-fork/), written by `ppn start` into ports.local.env —
38
+ # zombienet strips DATA_DIR from custom processes. A genesis cache read by a fork (or the
39
+ # reverse) is a different chain: eth-rpc exits with ChainMismatch on its first block.
40
+ ETH_RPC_BASE_PATH="${ETH_RPC_DATA_DIR:-${DATA_DIR:-${PPN_DATA_DIR:-$WS/data}}/eth-rpc-db}"
41
+ mkdir -p "$ETH_RPC_BASE_PATH"
42
+
43
+ exec "$BIN_DIR/eth-rpc" \
44
+ --node-rpc-url "ws://127.0.0.1:$ASSET_HUB_PORT" \
45
+ --base-path "$ETH_RPC_BASE_PATH"
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env bash
2
+ # zombienet's custom_processes spawns a command path, so this launcher has to exist.
3
+ # What it used to decide now lives in `ppn service force-open-hrmp` — see docs/ARCHITECTURE.md.
4
+ # In a checkout the entry point is bin/ppn.mjs; installed from npm it is dist/bin.js —
5
+ # the tarball ships no bin/. Every service launcher had the checkout path hardcoded, which
6
+ # broke every custom_process on an npm install, silently: zombienet does not gate a spawn
7
+ # on its custom processes, so the network came up with cores unassigned and no services.
8
+ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
9
+ ENTRY="$ROOT/bin/ppn.mjs"
10
+ [[ -f "$ENTRY" ]] || ENTRY="$ROOT/dist/bin.js"
11
+ exec node "$ENTRY" service force-open-hrmp
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env bash
2
+ # zombienet's custom_processes spawns a command path, so this launcher has to exist.
3
+ # What it used to decide now lives in `ppn service grant-invites` — see docs/ARCHITECTURE.md.
4
+ # In a checkout the entry point is bin/ppn.mjs; installed from npm it is dist/bin.js —
5
+ # the tarball ships no bin/. Every service launcher had the checkout path hardcoded, which
6
+ # broke every custom_process on an npm install, silently: zombienet does not gate a spawn
7
+ # on its custom processes, so the network came up with cores unassigned and no services.
8
+ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
9
+ ENTRY="$ROOT/bin/ppn.mjs"
10
+ [[ -f "$ENTRY" ]] || ENTRY="$ROOT/dist/bin.js"
11
+ exec node "$ENTRY" service grant-invites
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env bash
2
+ # zombienet's custom_processes spawns a command path, so this launcher has to exist.
3
+ # What it used to decide now lives in `ppn service increase-people-lite-attestation-allowance` — see docs/ARCHITECTURE.md.
4
+ # In a checkout the entry point is bin/ppn.mjs; installed from npm it is dist/bin.js —
5
+ # the tarball ships no bin/. Every service launcher had the checkout path hardcoded, which
6
+ # broke every custom_process on an npm install, silently: zombienet does not gate a spawn
7
+ # on its custom processes, so the network came up with cores unassigned and no services.
8
+ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
9
+ ENTRY="$ROOT/bin/ppn.mjs"
10
+ [[ -f "$ENTRY" ]] || ENTRY="$ROOT/dist/bin.js"
11
+ exec node "$ENTRY" service increase-people-lite-attestation-allowance
@@ -0,0 +1,12 @@
1
+ # install.sh - Install system dependencies for PPN
2
+ #
3
+
4
+ # Check for protoc (only needed if building from source)
5
+ if ! command -v protoc &> /dev/null; then
6
+ if [[ "$OSTYPE" == "darwin"* ]]; then
7
+ brew install protobuf
8
+ else
9
+ sudo apt install -y protobuf-compiler
10
+ fi
11
+ fi
12
+
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env bash
2
+ # IPFS daemon wrapper — restarts on crash, cleans up on signal
3
+
4
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
+ PROJECT_DIR="$SCRIPT_DIR/.."
6
+ source "$SCRIPT_DIR/lib/workspace.sh"
7
+ BIN_DIR="$PPN_WS_BIN"
8
+
9
+ # Source port configuration
10
+ source "$PROJECT_DIR/config/ports.env"
11
+
12
+ export IPFS_PATH="$BIN_DIR/.ipfs"
13
+ LOCK_FILE="$IPFS_PATH/repo.lock"
14
+
15
+ # Kill any process already on IPFS ports (prevents stale daemons from blocking startup)
16
+ "$SCRIPT_DIR/kill-port.sh" "$IPFS_GATEWAY_PORT" "$IPFS_API_PORT" "$IPFS_SWARM_PORT"
17
+
18
+ IPFS_PID=""
19
+ cleanup() {
20
+ if [ -n "$IPFS_PID" ]; then
21
+ kill "$IPFS_PID" 2>/dev/null
22
+ wait "$IPFS_PID" 2>/dev/null
23
+ fi
24
+ exit 0
25
+ }
26
+ trap cleanup INT TERM EXIT
27
+
28
+ while true; do
29
+ # Remove stale lock if no ipfs daemon process is running
30
+ if [ -f "$LOCK_FILE" ] && ! pgrep -f "$BIN_DIR/ipfs daemon" >/dev/null; then
31
+ echo "Removing stale repo.lock (no running ipfs daemon found)"
32
+ rm -f "$LOCK_FILE"
33
+ fi
34
+
35
+ "$BIN_DIR/ipfs" daemon &
36
+ IPFS_PID=$!
37
+ wait "$IPFS_PID"
38
+ EXIT_CODE=$?
39
+ IPFS_PID=""
40
+
41
+ # Exit cleanly if killed by signal (128+signal)
42
+ if [ $EXIT_CODE -gt 128 ]; then
43
+ exit 0
44
+ fi
45
+
46
+ echo "IPFS daemon exited (code $EXIT_CODE), restarting in 5s..."
47
+ sleep 5
48
+ done