From 71bbc2e826c6a47f440f987f1689ab5d51300d77 Mon Sep 17 00:00:00 2001 From: Rob Thijssen Date: Tue, 1 Sep 2026 04:50:01 +0300 Subject: [PATCH] fix: --rpc-external is refused on a validator The node crash-looped 7 times and was down ~100s, not mining: Error: --rpc-external option shouldn't be used if the node is running as a validator. Use `--unsafe-rpc-external` or `--rpc-methods=unsafe` if you understand the risks. Substrate rejects --rpc-external on a validator outright and exits, whatever --rpc-methods says. --unsafe-rpc-external binds identically ('Same as --rpc-external' per --help) and differs only in demanding an explicit acknowledgement. The safety still comes from --rpc-methods safe, which is unchanged. Restored on the host immediately; this makes CI converge on the same thing rather than reverting it. Also: validate opened with a bare , which exits 3 the moment a unit is 'activating' and under set -e aborted the step before printing anything. A crash-looping unit sits in activating/auto-restart forever, so a validator refusing its own flags surfaced as an opaque 'exit code 3'. It now waits for a terminal state and, on failure, reports NRestarts and the actual error lines from the journal. --- .gitea/workflows/deploy.yaml | 31 +++++++++++++++++++++++++++++-- CLAUDE.md | 5 ++++- readme.md | 10 +++++++++- 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index a6b3041..be9308f 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -163,7 +163,13 @@ jobs: # author_rotateKeys and friends off an exposed port. Loopback is # rate-limit-whitelisted so the arena exporter beside the node is not # throttled by its own polling. - rpc_expose: "--rpc-external --rpc-methods safe --rpc-cors all --rpc-rate-limit 300 --rpc-rate-limit-whitelisted-ips 127.0.0.1/32" + # --unsafe-rpc-external, NOT --rpc-external: Substrate REFUSES + # --rpc-external on a validator outright and exits, whatever + # --rpc-methods says. The two flags bind identically ("Same as + # `--rpc-external`" per --help); the unsafe- name is purely a + # forced acknowledgement. What actually keeps this safe is + # --rpc-methods safe, which stays. + rpc_expose: "--unsafe-rpc-external --rpc-methods safe --rpc-cors all --rpc-rate-limit 300 --rpc-rate-limit-whitelisted-ips 127.0.0.1/32" # Second site, for decentralisation. Uncomment when provisioned, and # give it its OWN inner_hash derived from its OWN wallet — sharing # bob's would publicly tie the two sites to one operator and defeat @@ -464,7 +470,28 @@ jobs: fail=0 echo "--- unit (${{ matrix.host }}) ---" - run systemctl is-active quantus-node.service + # NOT a bare `systemctl is-active`: that exits 3 the instant the unit + # is "activating", which under set -e aborts the whole step before any + # diagnostic runs. A crash-looping unit sits in activating/auto-restart + # indefinitely, so this waits, then reports WHY rather than an exit + # code — that is how a validator refusing its own flags looked like a + # bare "exit code 3". + state="" + for i in $(seq 1 30); do + state=$(run "systemctl show quantus-node.service -p ActiveState --value") + [ "$state" = "active" ] && break + [ "$state" = "failed" ] && break + sleep 4 + done + if [ "$state" = "active" ]; then + echo " active" + else + restarts=$(run "systemctl show quantus-node.service -p NRestarts --value") + echo " FAIL unit is '${state}' after 120s (NRestarts=${restarts}) — crash-looping" >&2 + jr=$(run "journalctl -u quantus-node.service --no-pager -n 40") + printf '%s\n' "$jr" | grep -iE "error|panic|refus" | tail -5 | sed 's/^/ /' >&2 + exit 1 + fi echo "--- version ---" got=$(run /usr/local/bin/quantus-node --version) diff --git a/CLAUDE.md b/CLAUDE.md index b978b82..ed75665 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -77,7 +77,10 @@ missing paths instead of making you read an rsync exit code. ## Exposing the JSON-RPC -`--rpc-methods safe` is mandatory whenever `--rpc-external` is set. Do not rely +Use `--unsafe-rpc-external`, never `--rpc-external`: Substrate **refuses the +latter on a validator** and exits immediately, regardless of `--rpc-methods`. +Both bind identically; the name is a forced acknowledgement. `--rpc-methods safe` +is what actually keeps it safe and is mandatory whenever the RPC is exposed. Do not rely on `auto` downgrading by itself, and never use `unsafe` on a validator. Access is bounded by a firewalld rich rule scoped to the node's own /16 — derived from the host's address at deploy time, never a literal in this repo. Whitelist diff --git a/readme.md b/readme.md index afd46fd..6d34d29 100644 --- a/readme.md +++ b/readme.md @@ -144,7 +144,7 @@ Loopback by default, which is the right posture for a validator. Opening it needs three things, and the flags are the part people forget: ``` ---rpc-external bind beyond loopback +--unsafe-rpc-external bind beyond loopback (see below) --rpc-methods safe NOT auto, NOT unsafe --rpc-cors all only if browsers will call it --rpc-rate-limit 300 @@ -156,6 +156,14 @@ on loopback. The deploy then opens `9944` with a firewalld rich rule scoped to **the node's own /16, derived from its own address at deploy time** — so no subnet literal lives in this repo and the rule follows the host between sites. +**`--rpc-external` does not work on a validator.** Substrate refuses it and +exits — whatever `--rpc-methods` says — demanding `--unsafe-rpc-external` or +`--rpc-methods=unsafe` as an explicit acknowledgement. The two binding flags are +identical ("Same as `--rpc-external`" per `--help`); only the name differs. So +the correct pairing is the alarming-looking `--unsafe-rpc-external` **with** +`--rpc-methods safe`, which binds externally while still refusing every unsafe +method. + `safe` is the load-bearing one. It still permits every state read and `author_submitExtrinsic` (signed, so no key exposure), while blocking `author_rotateKeys`, `system_addReservedPeer` and the rest of the unsafe set.