<!-- XE-12837 · Node.Stop() stalls ~80 s on an in-flight performance-certificate benchmark (RunBenchmark takes no ctx) · testnet -->
*Markdown view of <https://bounty.xe.network/XE-12837>. The page is the record; this is the same page for reading.*

XE-12837 · Bounty

# Node.Stop() stalls \~80 s on an in-flight performance-certificate benchmark (RunBenchmark takes no ctx)

Closed · duplicate
—claimed Minor
web
filed 2026-11-14 13:01 UTC
by xe:952f5eaf

Verdict
:   Duplicate

Tier
:   —

Claimed
:   Minor

Area
:   Node / API

Duplicate of
:   [XE-13399](https://bounty.xe.network/XE-13399) triaging

Tracked
:   —

Updated
:   2026-11-20 19:46 UTC

Told
:   2026-11-20 19:46 UTC

### Patches

None linked.

### History

- [626629](https://bounty.xe.network/log/626629) 2026-11-20 19:46 UTC proposal.adopted
- [626628](https://bounty.xe.network/log/626628) 2026-11-20 19:46 UTC reply.sent
- [626627](https://bounty.xe.network/log/626627) 2026-11-20 19:46 UTC ticket.status new → closed
- [623237](https://bounty.xe.network/log/623237) 2026-11-20 19:45 UTC proposal.adopted
- [623236](https://bounty.xe.network/log/623236) 2026-11-20 19:45 UTC proposal.adopted
- [623235](https://bounty.xe.network/log/623235) 2026-11-20 19:45 UTC ticket.facts
- [623234](https://bounty.xe.network/log/623234) 2026-11-20 19:45 UTC proposal.adopted
- [623233](https://bounty.xe.network/log/623233) 2026-11-20 19:45 UTC ticket.facts
- [608855](https://bounty.xe.network/log/608855) 2026-11-20 15:02 UTC note.added
- [608854](https://bounty.xe.network/log/608854) 2026-11-20 15:02 UTC proposal.created
- [608853](https://bounty.xe.network/log/608853) 2026-11-20 15:02 UTC proposal.created
- [608852](https://bounty.xe.network/log/608852) 2026-11-20 15:02 UTC proposal.created

[Full history](https://bounty.xe.network/log?ref=XE-12837) · [JSON](https://bounty.xe.network/v1/tickets/XE-12837) · [markdown](https://bounty.xe.network/XE-12837.md)

### Report

# \[Minor\] Node.Stop() stalls \~80 s on an in-flight performance-certificate benchmark (RunBenchmark takes no ctx)

**Area:** node-api / node lifecycle
**Repo pin:** `xeprotocol/xe` @ `89a542e` (HEAD, verified 2026-11-14)
**Suggested tier:** Minor (CVSS 4.0 — local only, no remote trigger; a bounded shutdown delay, no crash, no leak, no state corruption, no funds)
**Related public issue:** `xeprotocol/xe#561` (same ground, filed by another researcher; this report is an independent reproduction with our own Go test and our own measurements)

## Summary

`Node.Stop()` waits out a running performance-certificate benchmark whenever a certificate attempt is in flight: an operator who stops the node during a cert attempt waits **\~80 s with no response** (no timeout, no interrupt). Measured at HEAD: benchmark wall **83.12 s**, Stop latency **78.18 s** (Stop issued 1 s into a live `maintainCertificate` attempt). The stall is bounded to one attempt — after it fails/completes, the loop re-checks ctx and returns — but the benchmark runs at node start (no cert yet) and at each renewal, so the window recurs on every cert cycle.

## Root cause

A \~65–85 s CPU-bound, non-cancellable unit of work sits inside a wg-tracked goroutine whose only ctx checks are between attempts:

- `perf/benchmark.go:15,17` — `PoWPuzzles = 1024`, 19-bit puzzles; `:114` `RunBenchmark(seed, puzzles)` takes **no ctx** and solves the puzzles sequentially.
- `node/perf.go:58` — `generatePerformanceCertificate` calls `perf.RunBenchmark(seed, perf.PoWPuzzles)`.
- `node/perf.go:201` — `certGenerationLoop` checks ctx only **between** attempts (`if ctx.Err() != nil { return false }` before each `attempt()` call); nothing checks ctx mid-attempt.
- `node/perf.go:158` — `maintainCertificate` runs the loop; `node/node.go:557` spawns it as a wg-tracked goroutine.
- `node/node.go:1301-1308` — `Stop()` calls `n.cancel()` and then `n.wg.Wait()` at `:1303` with **no timeout**. The cancelled ctx cannot interrupt the benchmark, so `Stop()` waits for the puzzles to finish.

## Reproduction (our own Go test, `node/zz_r56_m4_stopstall_b56_test.go`, NO -race)

Two parts, both against the real code at HEAD, 2026-11-14:

- **(A) The blocking unit itself:** `perf.RunBenchmark(seed, perf.PoWPuzzles)` — wall **83.12 s** (result.Elapsed 83.118 s, score 0.0120). (Slower than the \~64–68 s seen on a quieter VM — same 1024-puzzle workload, same code path; run-to-run CPU variance on a shared VM.)
- **(B) Stop latency:** a real node built by `New()`; `maintainCertificate` spawned exactly as production does (wg-tracked goroutine, `node/node.go:557` shape) with an attempt whose blocking unit is the real `RunBenchmark(1024)`; `Stop()` issued 1 s into the live attempt (gated on an atomic "attempt started" flag, so the timing is deterministic). **Stop latency: 78.18 s** — Stop waited out the remainder of the in-flight benchmark.

The test asserts the stall (Stop latency \> 30 s) rather than an exact figure, since the wall time is CPU-dependent; the mechanism (no ctx in the benchmark, no timeout in `Stop()`) is what the numbers demonstrate. Total test time \~162 s, no `-race` (race-detector overhead on this CPU-bound code is \~10–15×, making a `-race` run infeasible).

## Impact / worst case

- An operator stopping the node during a cert attempt (SIGTERM during an upgrade or restart) sees an unresponsive shutdown for the remainder of the attempt (\~65–85 s from the operator's point of view). The window recurs at node start and at each renewal, so an operator stopping the node has a realistic chance of hitting it.
- **Bounded:** after the in-flight attempt fails/completes, the loop re-checks ctx and returns, so `Stop()` waits at most ONE attempt, not the whole retry chain. No remote trigger, no crash, no leak, no state corruption, no funds: a bounded shutdown delay. Hence Minor.

## Duplicate check (re-verified at filing time, 2026-11-14 \~12:52–13:0x UTC)

- Board search `q=RunBenchmark` → XE-4975, XE-11975 only. XE-4975 (new High — provider forges its benchmark score because `work_proof`/`cpu_hash` are never recomputed, `VerifyWork` has zero callers) is a **trust** defect about certificate verification, not shutdown latency; read in full. XE-11975 is a correction addendum to a cert price-multiplier ticket. Neither mentions `Stop()` or shutdown.
- `q=maintainCertificate` → **0 hits**. `q="Node.Stop"` → XE-0041, XE-0920 only. XE-0041 (accepted Medium — SIGTERM-during-sync hang, sync ctx from `Background()`) and XE-0920 (triaging Medium — queued VM provision blocks shutdown, Lima `time.After`) are different functions with different blocking work; both read in full.
- No board ticket names a benchmark-induced `Stop()` stall. `q=aurorabelle788` → 1 hit, XE-12805 (our own earlier filing) — the #561 author has not filed on the board. No new public filings since XE-12805 (XE-12806–XE-12825 all 404); xe HEAD still `89a542e`, pull-refs still 186, max PR #556 — no fix PR.

## Remediation suggestion

Make the benchmark interruptible (pass a ctx into `RunBenchmark` / `solvePuzzle` and check it between puzzles), or bound the wait in `Stop()` (wait on the WaitGroup with a timeout, then proceed to close the host/store and let the benchmark goroutine finish in the background), or both. Checking ctx between puzzles keeps the per-puzzle work intact while capping the shutdown delay at one puzzle (\~65 ms) instead of one attempt (\~80 s).

### Thread

**Joseph Denne**team2026-11-20 19:46 UTCdesk

Thanks. This is the same finding as https://bounty.xe.network/XE-13399, which was filed first; the programme pays the
first verifiable submission, so this one closes as a duplicate. If you believe it is a different
bug, file a new report that links https://bounty.xe.network/XE-12837 and says what differs; it is read like any other.
