Skip to content

[benchmark] Stability and mining impact of Tor-only egress #4155

Open

Description

@pithead-developer

What's the problem

The Tor-only egress work for v2.0.5 changes time, DNS, image pulls, rig stratum routing, the rig's Tor client and finally adds a default-drop outbound firewall (see #4144 (tracker)). Each change is tested on its own, but nobody has measured the whole at once for stability or for mining. The owner asked for exactly that ("we need to test and benchmark this to see how it impacts stability and mining"), inside their standing rule of no multi-day tests or soaks: every run here is bounded to hours per arm and at most 24 h of wall clock in total per run.

What it impacts

Every appliance and rig owner. A Tor-only box that boots slower, loses the clock, wedges Tor, drops pings or mines fewer accepted shares would be a regression, and some of these only show over hours and under injected faults. The result also gates #4154 (step 9: enforce the firewall): we do not enforce until the gate run below passes.

How I found it

By reading what exists. pithead already has an interleaved A/B harness and a recorded result (docs/benchmarks/tor-vs-clearnet.md, tests/integration/benchmarks/bench-orchestrate.sh, bench-collect.sh, bench-analyze.py; checked with git show origin/develop:...). That run took about 5 days, measured p2pool transport only, and found roughly a 10 % yield cost for p2pool over Tor (Tor stayed the default). It cannot be reused as is, because multi-day runs are ruled out. Its lesson is that sidechain shares are too rare to resolve small effects in hours: at about 155 own shares a day, a 6 h arm sees about 40, a Poisson spread of about 16 %. So the gating mining metrics here are stratum-level (hundreds of shares per hour), and sidechain yield is reported but does not gate. The runner side is in p2pool-starter-stack/bench-ci#2542 (bench-ci benchmark job); related work is p2pool-starter-stack/bench-ci#2458 (egress watchdog; recorders p2pool-starter-stack/bench-ci#2459, p2pool-starter-stack/bench-ci#2460 and p2pool-starter-stack/bench-ci#2461 not yet landed), #4135 (healthcheck over Tor), #4125 (Tor version pin) and the rig update tracker #4143.

How important is it

High for v2.0.5: it is the evidence that Tor-only costs nothing we cannot accept, and the condition for turning the firewall on. The runs are short, so the cost is bench time, not calendar time.

Acceptance criteria

  1. Pre-registration. The method, metrics, margins and pass rules below are fixed in this issue before the baseline run. Later changes need a comment with the owner's approval. The baseline run may tighten a margin from measured noise, never loosen it.
  2. Three runs happen, each at most 24 h of wall clock, each with its verdict and the retained evidence linked here by job id (no hostnames or addresses):
  3. Method. A/B on two comparable benches at the same time: current develop is the control, the Tor-only build the treatment. Same sidechain, same owner wallets (the payout-verified settings the benches already use), same rig count at fixed hashrate, XvB disabled in both arms so the donation optimizer does not react to the transport (the lesson of the earlier run). A separate XvB-over-Tor check is optional and reported on its own. Each run has two legs with the arms swapped between benches, so bench-specific bias cancels. Each leg is 1 h settle (discarded) plus 6 h measured; the two legs take 14 h. The benches' own follow-develop refresh is paused for the run and restored after.
  4. Statistics. The unit is a 1 h block, giving 12 paired blocks per run (6 per leg). For each rate metric compute log(treatment / control) per block, take the mean, and form a 90 % CI with a moving-block bootstrap (block length 2 h, 10,000 resamples) to respect autocorrelation. Pass is equivalence: the whole CI lies inside the margin (TOST). With an assumed block spread of 5 %, 12 blocks give a half-width of about 2.4 %, enough to resolve 5 %; Run 0 measures the real spread. Counts of rare events (rejects, stale shares, reconnects, wedges, restarts) use an exact conditional binomial test on the two counts given equal exposure. Blocks with an injected fault, a rig-count change or bench maintenance are dropped from both arms.
  5. Mining gates (treatment against control).
    • Accepted-share rate per kH/s at the stratum: CI inside +/-5 %.
    • Rig-reported effective hashrate (15 min) and pool-side 1 h hashrate: CI inside +/-3 %.
    • Rejected plus stale share rate: upper 95 % bound of the difference at most +0.5 percentage points, and not above 1.5 times control.
    • Time from a new Monero block to the new job reaching the rigs (block template freshness over Tor P2P, measured on the stack host's single clock, p2pool's block-seen to job-sent): p95 at most control p95 plus 2 s or 25 %, whichever is larger. The bound is fixed after Run 0 from its spread.
    • monerod outgoing peers: median not more than 1 below control. Height lag behind the network tip (monerod and Tari): p95 at most control plus 1 block, and never more than 2 blocks for over 5 min.
    • Reported, not gated: P2Pool uncles, orphans and reward share (too sparse over hours; the earlier multi-day result stands for p2pool transport, which develop already routes over Tor).
  6. Stability gates.
    • Time from boot to first accepted share (KVM share leg and the mining legs): median at most control plus 5 min.
    • First-boot and update success: 100 % of 5 repeats per arm and per role; duration median at most control plus 20 %, worst at most plus 50 %. The repeats run in parallel on benches outside the A/B pair, inside the same 24 h window.
    • Tor bootstrap time: p95 at most control p95 plus 30 s.
    • Time sync: at least 95 % of attempts succeed, absolute offset after a step at most 60 s (Tari refuses blocks 540 s ahead), staleness never above 2 times the check interval.
    • DNS: at most 2 % lookup failures once Tor is ready, and zero lookups on any port 53 off the box.
    • Unexpected flows: zero in every window, faults included, using the netwatch classifier and the log-only firewall counters. Only the declared Tor-cut fault class and an owner-configured stratum pool are allowed.
    • Tor wedges: none in a clean window; an injected wedge recovers within 10 min (the runner's own wedge threshold).
    • Healthcheck pings (already sent over Tor today, so this is a regression gate, not a leak fix): no gap above 2 times the ping interval outside an injected fault.
    • Unplanned container, dashboard or service restarts in a clean window: zero, and not above control.
  7. Fault injection, at most 1 h each, in KVM guests (both roles where it applies), run in parallel with the mining legs on benches that are not in the A/B pair, so total wall clock stays within 24 h. Each ends with zero unexpected flows and the stated recovery:
    • Tor wedge: healthy within 10 min, first accepted share within 15 min after.
    • 3 min network drop: circuits rebuilt within 5 min of the link returning, first accepted share within 10 min.
    • RTC 2 h ahead and RTC 3 days behind: the box boots, the time client brings the clock within 60 s within 15 min of Tor being ready, no clearnet fallback, no chain rejection. A clock far ahead must fail safe with the manual time prompt, not stall silently.
    • Tor down at boot: no service dials out directly, the stack reaches healthy within 10 min of Tor starting.
    • Registry block during an update: the update fails closed with a plain message, the old slot keeps running and mining, and a retry after the block lifts succeeds.
  8. Rig on an external pool (stratum over per-pool Tor socks5 against direct with TLS and a fingerprint pin): latency (from XMRig's per-share round trip), stale rate and reconnects, in 30 min alternating blocks for 2 h per mode. Runs only if the owner names the pool and wallet for it; otherwise it is marked not run (see Possible solutions). It informs the docs and does not gate a step.
  9. Report. One comment per run with the table of every gate, its CI or count, the verdict and job ids. A skipped, unavailable or interrupted leg is stated, never counted as a pass. Any gate failure becomes its own issue against the step that caused it.
  10. No benchmark run exceeds 24 h of wall clock; a run that would is aborted and reported.

Possible solutions

  • Metric sources (existing): the rig's mining sampler (jobs, accepts, rejects, connection errors, hashrate), p2pool's /stats/* and the collector in bench-collect.sh, monerod and Tari RPC for peers and height, Tor logs for bootstrap and wedges, the healthcheck ping log, container restart counts, netwatch and the log-only firewall counters. Needs from other steps: the time client must expose offset and last-success stamp (Get the clock through Tor onion services and remove NTP and the clearnet htpdate fallback #4149 (step 5: time through Tor)); the DNS resolver must count failures (Resolve all names through Tor DNSPort and stop using LAN or ISP DNS #4148 (step 4: DNS through Tor)).
  • Runner: a bounded paired job on the benches (p2pool-starter-stack/bench-ci#2542 (bench-ci benchmark job)). Run 0 can be done by hand with the existing pithead harness trimmed to the 14 h schedule if the runner is not ready, with no change to the gates.
  • Where the arms run: two e2e-capable benches with the same rig count, kept off any bench whose deploy takes the exclusive node lease, which would starve the KVM fault runs.
  • Fault injection: reuse the existing tor-heal and fault phases of tests/os/run.sh and add the RTC, network-drop, Tor-down-at-boot and registry-block legs there.
  • Open for the owner: the external-pool leg conflicts with the standing rule to test only against Pithead pools, so it needs an explicit pool and wallet; skipping it leaves the rig stratum choice (socks5 or direct) decided on design alone. Unknown: the real block-to-block spread (Run 0 will show it), whether p2pool's log timestamps both events needed for block-to-job latency (to check before Run 0), and whether the first leg can hold the benches' follow-develop refresh without side effects.

Activity

  1. added this to the v2.0.5 milestone on Nov 16, 2026
  2. added
    testing
    appliance
    operator-action
    on Nov 16, 2026
  3. added
    blocked
    on Nov 16, 2026
  4. pithead-developer commented on Nov 16, 2026

    @pithead-developer
    ContributorAuthor

    Blocked on #4145.
    Blocked on p2pool-starter-stack/bench-ci#2542.

    Run 0 of the benchmark starts when step 1 and the bench-ci benchmark job exist (rollout order in #4144). Run 1 comes before step 9 and Run 2 on the release candidate, each at most 24 h.

  5. removed
    operator-action
    on Nov 16, 2026
  6. pithead-architect commented on Dec 1, 2026

    @pithead-architect

    Owner decision 2026-12-01: this issue now also carries #4146's last acceptance item, the benchmark run of up to 24 hours per arm showing hashrate and share acceptance unchanged with fail-closed outbound clients. #4146 is closed.

    Models: claude-opus-5-5 (architect)

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

    applianceblockedtesting

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions