Skip to content

Every Tor start re-dials monerod; a peerless monerod is restarted within bounds #4076

Closed

Description

@pithead-architect

What's the problem

Part of #4045. A Tor restart kills monerod's SOCKS peer sockets and monerod does not recover on its own: confirmed 2026-11-12 (issue comment) — a manual ./pithead restart tor left monerod "disconnected from the network" 3 s later and it stayed disconnected 14 minutes until a manual ./pithead restart monerod, while its chain froze at one height and it kept serving work to 6 rigs.

In dashboard/mining_dashboard/service/health/tor_heal.py, monerod is cycled only when the healer itself restarted Tor; _observe_tor_start() treats any external Tor restart merely as a fresh outage window and never re-dials monerod. Separately, dashboard/mining_dashboard/service/health/monero_health.py detects peerless (zero peers_out) and stalled nodes but "detects and alerts; it restarts nothing".

What it impacts

Every appliance whose Tor restarts (healer, ./pithead, Docker, an update): the node sits peerless for tens of minutes or longer, rigs hash a stale tip (until #4046 sheds it), and revenue is lost until a human acts.

How I found it

Owner report on #4045 (2026-11-12 comment: restart tor → monerod stranded 14 min) and the production event of 2026-11-11, where monerod froze at 09:27Z and never re-dialled; verified against the code above.

How important is it

Release-blocker for v2.0.4 by owner direction (2026-11-12): the acceptance addition says every Tor restart, manual or automatic, must be followed by a monerod re-dial once Tor reports a circuit.

Acceptance criteria

  • After ANY Tor container start (healer's, ./pithead restart tor, Docker), once Tor reports a circuit, a monerod that is still peerless is restarted — bounded to one re-dial per Tor start, with a cooldown and a per-day cap, logged and audited.
  • A bounded peerless-monerod watchdog: monerod peerless beyond the existing PEERLESS_SEC verdict restarts it, with cooldown, per-day cap, audit and a one-off owner-visible log; after the cap it stops and says so.
  • Keep existing guards: only a running monerod is cycled (LAN guard on the *_lan_access ports is not restored at boot: DIY Docker hosts publish them to every source until ./pithead up #2749, LAN-source DIY rule), a remote monero.mode: remote node is never restarted by this box.
  • Unit tests for the re-dial-after-external-restart and the peerless watchdog, both red without the fix; e2e fault scenarios: frozen monerod peers → synced unattended; external Tor start → monerod re-dialled within the window; a KVM leg for the stranded-monerod mode.
  • Added from the 2026-11-14/15 incident: a height-stall trigger for a monerod whose target height is above its height while the height stays unchanged for 10 min (a named constant), covering a node that has live outgoing peers but stores no block (06:21-06:39, 18 min). It restarts monerod alone. Unit tests: brief peer readings do not defeat it, and a sequence modelled on the incident (height frozen, target 32-38 blocks above it) fires once.
  • Added from the 2026-11-14/15 incident: the trigger runs only while Tor is proven: bootstrap 100% and a completed-circuit reading for 5 consecutive minutes (a named constant). The stall clock starts when Tor becomes proven, not when the height last moved, so a Tor outage is never counted as a stall. Unit test: height frozen through a Tor outage does not fire at the moment Tor recovers.
  • Added from the 2026-11-14/15 incident: when the node is in initial sync, or the gap between target height and height exceeds a named number of blocks, the threshold is a longer named constant, and the trigger never fires while the height is advancing. Unit tests for each branch.
  • Added from the 2026-11-14/15 incident: a peer gap shorter than a named number of seconds (the 3-6 s gaps at 06:43:28 and 06:44:58 were normal) pauses the stall clock without resetting it and never fires the trigger. Unit test: repeated brief gaps during a frozen height still reach the threshold.
  • Added from the 2026-11-14/15 incident: one shared cooldown and daily counter covers this trigger, the re-dial watchdog and the healer's own monerod restart after a Tor restart (monerod loses all peers when the tor container is recreated, and nothing notices #972, tor_heal.py), so they cannot restart monerod back to back. Unit test: after one of the three fires, the other two are held by the same cooldown and counter.
  • Added from the 2026-11-14/15 incident: the trigger never restarts P2Pool and never touches chain data. Before acting it records height, target height and peer counts, as the dashboard already reads them and without peer addresses, in the audit row or log. Unit test on the recorded fields.

Possible solutions

  • Reuse the healer's existing _observe_tor_start/_monerod_running machinery with a pending-redial flag cleared once monerod shows peers.
  • A small sibling of tor_heal.py consuming MoneroChainHealth.verdict and the docker stop/start control API with the same bounded-budget pattern.

Parent: #4045

Worker brief: Test tier: tier4-e2e. Two behaviours in the dashboard service, one objective: monerod always recovers after Tor moves. (1) After any Tor container start the healer detects (its own or external), once Tor reports a circuit, if monerod is still peerless restart it — once per Tor start, cooldown + per-day cap, audit + one-off log. (2) A peerless-monerod watchdog consuming MoneroChainHealth.verdict (peerless beyond PEERLESS_SEC) that restarts monerod within the same bounds and stops-and-says-so at the cap. Keep the #2749 guard (only a running monerod is cycled; remote-mode nodes untouched). Start at dashboard/mining_dashboard/service/health/tor_heal.py (_observe_tor_start, _monerod_running, the #972 monerod restart path), monero_health.py, and the docker control API they use. Tests: new dashboard/tests/service/health cases (external-Tor-start → monerod re-dialled; peerless streak → restart; cap → stop and warn) red before the fix; e2e scenarios via tests/integration/lib/run-monero-stranded.sh and selftest-monero-peer-wait.sh extended to assert unattended resync; a KVM leg modelled on tests/os legs the RC gate runs. Do NOT touch the NEWNYM/tor-recover ladder, P2Pool, config templates or alert UI — sibling chunks. No comments in code; update docs describing #972 restart behaviour.

Activity

  1. added this to the v2.0.4 milestone on Nov 13, 2026
  2. added
    needs-triage
    size:M
    on Nov 13, 2026
  3. added
    bug
    P1-user-facing
    on Nov 13, 2026
  4. 9 remaining items

  5. added this to the v2.0.5 milestone on Nov 16, 2026
  6. pithead-developer commented on Nov 20, 2026

    @pithead-developer
    Contributor

    Blocked on #4291. Blocked on #4291. PR #4200's base is now develop-v2.0.5, and job 4295 was cancelled as conflicting with it. I merged develop-v2.0.5 and resolved the file-budget conflict, then pushed head da79f3f. Local lints and pytest tests/service tests/collector pass. The tier-4 submit is held because the 'Build + scan the appliance rootfs' check fails on CVE-2026-95839 (HIGH, the bundled Compose's containerd). This PR does not touch that and #4291 owns it, with PR #4279 targeting develop. I commented the blocker on the PR. Done so far: both reviewer returns fixed, and job 1002 on the earlier head passed the two live Tor circuit rows and both exact-once log rows. It failed only an unrelated P2P probe row. Still needed once #4291 reaches develop-v2.0.5: a green rootfs scan and one tier4-e2e monero-stranded job on the new head. The branch also carries two develop commits (#4169, #4001) from an earlier merge, made before the base changed, so the reviewer should check them. The KVM leg from the issue is not built.

    The runner resumes this issue when that one closes.

  7. added
    blocked
    on Nov 20, 2026
  8. removed
    blocked
    on Nov 20, 2026
  9. pithead-developer commented on Nov 20, 2026

    @pithead-developer
    Contributor

    Waiting on a transient bench_outage condition, not on another issue. tier4-e2e submit for 130f836 (phase monero-stranded, base develop-v2.0.5) lost attempts 2 and 3 of 5 to connection timeouts. A follow-up bench-ci list read also timed out twice, so the fleet could not be read. Whether a job was created is unknown. When the bench is readable, look up the job by commit before resubmitting. If none exists, resubmit the identical request. The runner re-checks it (first at 2026-11-20T19:17Z, at most 5 times).

  10. added a commit that references this issue on Nov 21, 2026
    d8de0ad
  11. pithead-developer commented on Nov 21, 2026

    @pithead-developer
    Contributor

    Merged in #4200.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1-user-facingappliancebugneeds-triagesize:M

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions