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

XE-13399 · Bounty

# Node.Stop() stalls \~65–70 s on an in-flight performance-certificate benchmark

Triaging
claimed Minor
[xe#561](https://github.com/xeprotocol/xe/issues/561)
filed 2026-11-14 11:50 UTC
by Aurora Belle

Verdict
:   published when the fix ships

Tier
:   published when the fix ships

Claimed
:   Minor

Area
:   Node / API

Duplicate of
:   —

Tracked
:   internally

Updated
:   2026-11-20 19:47 UTC

Told
:   2026-11-20 19:46 UTC

### Patches

None linked.

### History

- [627232](https://bounty.xe.network/log/627232) 2026-11-20 19:46 UTC proposal.adopted
- [627231](https://bounty.xe.network/log/627231) 2026-11-20 19:46 UTC ticket.award
- [627186](https://bounty.xe.network/log/627186) 2026-11-20 19:46 UTC reply.mirrored
- [627043](https://bounty.xe.network/log/627043) 2026-11-20 19:46 UTC github.labels
- [625868](https://bounty.xe.network/log/625868) 2026-11-20 19:45 UTC proposal.adopted
- [625867](https://bounty.xe.network/log/625867) 2026-11-20 19:45 UTC reply.sent
- [625510](https://bounty.xe.network/log/625510) 2026-11-20 19:45 UTC proposal.adopted
- [625509](https://bounty.xe.network/log/625509) 2026-11-20 19:45 UTC ticket.status new → triaging
- [624231](https://bounty.xe.network/log/624231) 2026-11-20 19:45 UTC proposal.adopted
- [624230](https://bounty.xe.network/log/624230) 2026-11-20 19:45 UTC ticket.facts area
- [624227](https://bounty.xe.network/log/624227) 2026-11-20 19:45 UTC proposal.adopted
- [624226](https://bounty.xe.network/log/624226) 2026-11-20 19:45 UTC ticket.facts

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

### Report

**Severity: Minor** (XE tier ceiling 650 XE). **CVSS 3.1: 4.0 (AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L)** — CVSS Medium at the boundary; XE tier Minor per the bounty tier table (see §7).

**Target:** `github.com/xeprotocol/xe` @ `89a542ea51d38375299aee54c6c99102e9bfa666` ("release: testnet-0005 quorum withhold fix", 2026-11-10). Go 1.25.0.

## 1\. Impact (read this first)

`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 **\~65–70 s with no response** (no timeout, no interrupt). Measured at HEAD: benchmark wall **68.17 s**, Stop latency **70.20 s** — Stop issued 1 s into a live `maintainCertificate` attempt waited out the in-flight benchmark.

The stall is bounded: after a failed attempt the loop re-checks ctx and returns, so `Stop()` waits at most ONE attempt (\~64–68 s), not the whole retry chain. The benchmark runs at node start (no cert yet) and at each renewal (`certRenewalDelay`), so the window recurs on every cert cycle, not just once. No remote trigger, no crash, no leak, no state corruption, no funds: a bounded shutdown delay. That is why this is Minor.

## 2\. Root cause

A \~64–68 s CPU-bound, non-cancellable unit of work sits inside a wg-tracked goroutine whose only ctx checks are between attempts. `generatePerformanceCertificate` (`node/perf.go:34`) calls `perf.RunBenchmark(seed, perf.PoWPuzzles)` (`node/perf.go:58`; `perf/benchmark.go:114-130`, `PoWPuzzles = 1024` (`perf/benchmark.go:15`), 19-bit puzzles (`PoWDifficultyBits = 19`, `:17`), `solvePuzzle` workers with no ctx). It is called from `certGenerationLoop` (`node/perf.go:201`, ctx checked only BETWEEN attempts) inside `maintainCertificate` (`node/perf.go:158`), spawned as a wg-tracked goroutine at `node/node.go:557`. `Stop()` (`node/node.go:1301-1308`) `wg.Wait()`s it with no timeout. Neither the benchmark nor the cert loop checks ctx mid-attempt, so there is nothing for `Stop()` to interrupt — it waits for the puzzles to finish.

## 3\. Scenario (how it happens)

1. A node starts (no certificate yet) or reaches a certificate renewal: `maintainCertificate` begins a `generatePerformanceCertificate` attempt — 1024 sequential 19-bit puzzles, \~64–68 s of CPU work.
2. The operator stops the node (`Node.Stop()`, e.g. SIGTERM during an upgrade or restart) while the attempt is in flight.
3. `Stop()` calls `n.cancel()` and then `n.wg.Wait()` — and waits. The benchmark does not observe the cancelled ctx. Shutdown is unresponsive for the remainder of the attempt (\~65–70 s from the operator's point of view). After the attempt fails/completes, the loop re-checks ctx and returns, and `Stop()` proceeds — at most one attempt's worth of delay.

## 4\. Proof of concept (local, deterministic)

PoC: `hunt-v3/stage3/tests/` — `TestT38_BenchmarkWallTime` (`node/`, **NO `-race`**, 139.40 s), re-run byte-identical at HEAD in an isolated worktree copy with temp data dirs. The `-race` run was infeasible in V3 (\>13 min, killed by a runtime restart — race-detector overhead \~10–15× on this CPU-bound code), so the no-race run is authoritative, exactly as in V3.

Re-run result at HEAD (2026-11-14), same magnitude as V3 (2026-11-11):

| Observation | V3 | Re-run at HEAD |
| --- | --- | --- |
| `RunBenchmark(seed, 1024)` wall | 64.24 s (score 0.0156) | **68.17 s** (result.Elapsed 68.167 s, score 0.0147) |
| Stop latency (issued 1 s into a live attempt) | 65.48 s | **70.20 s** |
| Mechanism | `H-D MECHANISM CONFIRMED` | `H-D MECHANISM CONFIRMED` |
| Race detector | 0 `DATA RACE` | 0 `DATA RACE` |

The \~4 s / \~5 s increases vs V3 are run-to-run CPU variance on the shared VM (same 1024-puzzle workload, same code path); magnitude and mechanism are unchanged.

Log: `hunt-v4-followup/stage3-minors/logs/t38-reverify-norace.log`. The test files were copied byte-identical (`cmp` clean; sha256 `6c42779aeb57a66bada81445b9174de806f025a8d9196a7761eeb17f894888a7` for `node/stage3_lifecycle_test.go`).

## 5\. Attacker prerequisites

- **None — local only, no attacker.** The trigger is a local operator stopping the node during a cert attempt. No remote step, no privilege on the victim. The window recurs at node start and at each renewal, so an operator stopping the node has a realistic chance of hitting it — but hitting it costs only time.

## 6\. Independent validation and false-positive assessment

- **Deterministic reproduction, twice:** V3 (2026-11-11) and the HEAD re-run (2026-11-14) give the same magnitude (64.24 s → 68.17 s wall, 65.48 s → 70.20 s Stop). The stall is measured wall time, not a pattern match.
- **Disproof attempted:** (a) checked whether the benchmark or the cert loop checks ctx mid-attempt — neither does; (b) checked whether the stall could be the whole retry chain — disproved, bounded to one attempt by the ctx re-check after a failed attempt; (c) checked whether `waitForAttestationPeers` could extend it — it is ctx-guarded, so no.
- **Duplicate check (fresh, DB 2,421 entries as of 2026-11-14 \~17:00 WIB):** all 7 benchmark/certificate hits are *trust* reports (forged benchmark scores, unverified work proofs, expired-cert acceptance — XE-4975, xe#354, XE-5677, xe#392, XE-0001/xe#6), not shutdown latency. The closest same-class report is XE-0920 (queued VM provision blocks shutdown — different function, unbounded, stand-in-sleep PoC). XE-0041/xe#60 is a SIGTERM sync hang (different function, no benchmark). xe#348/PR #349 is a wg-*registration* race on a running node; PR #349 (full body \+ files list read this run) never mentions `perf/`, `RunBenchmark`, `generatePerformanceCertificate`, `maintainCertificate`, or `certGenerationLoop`, and adds no `Stop()` timeout — it does not fix this. Classification: **NOVEL on public data** (private Critical/Severe reports may exist; uniqueness is not guaranteed). Full analysis: `duplicate-intel/reports/v4f-hd-benchmark-duplicate-analysis.md`.

## 7\. Severity justification (Minor, ceiling 650 XE)

CVSS 3.1: **4.0 (AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L)**. Attack vector is local (a local operator stopping the node); complexity is Low (stop during a cert attempt — a window that recurs at start and at each renewal); no privileges or user interaction; availability impact is Low (a bounded \~65–70 s unresponsive shutdown; the node stops cleanly afterwards, no crash, no state impact, no funds). The CVSS score sits exactly on the Low/Medium boundary (4.0); the XE tier is Minor because the bounty tier table prices this class — a bounded shutdown delay with no remote trigger and no lasting effect — as Minor, and the CVSS number is informational here.

Why not higher: the delay is bounded to one attempt, the node always stops cleanly afterwards, and nothing is lost or corrupted.

## 8\. Fix suggestion

Make the benchmark ctx-aware: chunk the 1024 puzzles with ctx checks between chunks (or pass the ctx into `RunBenchmark`/`runCPUChain`), so `Stop()`'s cancel interrupts the attempt — or run the cert attempt outside `n.wg` with a timeout so `Stop()` does not wait it out. Either fix must keep the certificate issuance semantics (a cancelled attempt simply retries on the next cycle, as the existing between-attempt re-check already does).

## 9\. Caveats (kept in the report)

1. The `-race` run is infeasible (\>13 min, killed in V3); the no-race numbers are the production-relevant ones.
2. The \~4–5 s increases vs V3 are run-to-run CPU variance on the shared VM, not a code change.
3. The stall is bounded to ONE attempt by the ctx re-check after a failed attempt; it is not the whole retry chain.
4. NOVEL means no matching *public* finding as of the 2026-11-14 \~17:00 WIB check (DB 2,421 entries); private reports may exist.

## 10\. Reproduction (for the committee)

Local only, worktree copy at `89a542e`, isolated temp data dirs:

```
export PATH=~/workspace/go/go/bin:$PATH
export TMPDIR=~/workspace/xe-bounty/.tmp
cd <worktree>/node
go test -count=1 -timeout 20m -run 'TestT38_BenchmarkWallTime$' -v ./...
# Expected: PASS (exit 0), ~140 s — read the numbers from the log:
# RunBenchmark wall ~68 s, Stop latency ~70 s, H-D MECHANISM CONFIRMED.
# Do NOT add -race (infeasible on this CPU-bound code, >13 min).
```

PoC: `hunt-v3/stage3/tests/` (`node/stage3_lifecycle_test.go`). Log: `hunt-v4-followup/stage3-minors/logs/t38-reverify-norace.log`. Full analysis: `hunt-v3/stage3/STAGE3_VERDICT.md` §H-D; duplicate analysis: `duplicate-intel/reports/v4f-hd-benchmark-duplicate-analysis.md`.

### Thread

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

Thanks for the report. We have read it against the code and confirmed the behaviour you describe. It is being handled, and this ticket will be updated when there is a change to check.
