Repository navigation
Description
What's the problem
Found while testing PR #2634 (issue #2626) with 969@e5dfc192658b30ac6a88044e315417448e852c70 (tier4-e2e, phases=lifecycle).
Defect: wait_synced in tests/integration/e2e.sh can pass on the dashboard's restored snapshot instead of on a live reading. Readiness then refuses the destructive phases two seconds later, so lifecycle never runs.
After a deploy recreates dashboard, the new container seeds latest_data from the persisted snapshot (dashboard/mining_dashboard/service/data_setup.py). /api/state's sync block is built from that data (build_sync in web/views/infra_views.py). Until the dashboard's first poll cycle, sync.tari.state therefore reports the state from before the restart. wait_synced polls /api/state for done/done and returns on the first match, so it can accept that stale value. The one-shot readiness check in tests/integration/lib/run-scenario.sh (assert_release_readiness) then reads the first live poll, which sees a Tari that is still restarting.
what it impacts
Impact is not separately established in the existing report; confirm the affected users or behavior.
How I found it
Observed in job 969:
- The bench ran
minotari_nodev6.0.0 and the head pins v6.0.1-pre.0 (fix(tari): pin node and wallet to v6.0.1-pre.0 (#2604) #2625), so the deploy recreatedtari,monerodanddashboard. - 03:01:28
dashboardandtaristarted. - 03:01:37
✓ monero + tari re-confirmed synced (done/done):wait_syncedreturned 9 s after the dashboard started. - 03:01:39 readiness:
✗ Tari is synced — dashboard reports Tari is not done, and the destructive phases were refused. Passed 6, failed 1; no lifecycle row ran.
Every develop-based branch recreates tari on the benches until their baseline moves to the pinned Tari, so any tier4-e2e run that reaches readiness can hit this race.
Expected: wait_synced accepts only a reading that the recreated dashboard produced itself. Possible ways to get that:
- require the snapshot
timestampto be newer than the deploy; - require the reading to be stable across two polls, one poll interval apart;
- have readiness wait the same way instead of reading once.
Scope note: this is a harness defect, not a product one. /api/state serving the pre-restart sync state for one cycle is the same restored-derived-state pattern #664 addressed for update. Whether the dashboard should also drop monero_sync/tari_sync on restore is a separate product question.
how important is it
Importance has not been assessed explicitly; triage must state the priority and its reason.
acceptance criteria
Acceptance script
This issue has no acceptance section of its own. The script below operationalizes its Expected line: wait_synced accepts only a reading that the recreated dashboard produced itself.
Done means the script at the end of this section prints ACCEPTED and exits 0 on the PR head. Every check is a mechanical pass or fail, so no judgment call is needed. Paste the script's full output into the PR body.
# save the script below as /tmp/accept_2652.py (outside the repo), then, from the repo root:
python3 /tmp/accept_2652.py
Run it on Linux, as CI does. On macOS, run it inside the CI image: save it under the ignored tests/integration/results/ and run make test-container ARGS="python3 tests/integration/results/accept_2652.py". It takes under a minute. It changes tests/integration/e2e.sh once, for C3, and restores the file from its saved content afterwards.
A "#2652 selftest" is any file in tests/integration/selftest/ whose text contains #2652. A "#2652 row" is an assertion row (✓ or ✗) whose text contains #2652.
| Check | Passes when |
|---|---|
| C1 | tests/integration/e2e.sh and at least one file in tests/integration/selftest/ differ from develop. Nothing outside tests/integration/ and docs/ does. CHANGELOG.md is also allowed. |
| C2 | At least one #2652 selftest exists. Every one exits 0, and together they print at least 2 passing #2652 rows and no failing #2652 row. |
| C3 | With wait_synced in e2e.sh replaced by develop's version, which returns on the first done/done, the #2652 selftests print at least one failing #2652 row. |
| C4 | tests/integration/selftest/selftest-e2e-tari-settle.sh exits 0 and still passes the #2455 rows deploy_branch's wait_synced ceiling (...) and deploy_branch refuses destructive phases when the bounded settle expires. |
Rules:
- Do not change the script's test IDs, anchors or expected outcomes. If a check prints
error(anchor found 0x ...), production code has moved since this issue was filed. Stop and comment here with the output instead of editing the anchor. - A reviewer re-runs the same script on the head they review. A changed head needs a fresh run.
- The repo's normal gates still apply on top of this:
make test,make test-patch-coverage, and the adversarial review.e2e.shis the harness's deploy path, so the PR also carries the tier4-e2e job thatdocs/dev/testing-strategy.mdasks for.
Baseline, run 2026-10-03 on 3822294 (develop; the goal is derived from the Expected line): unmodified develop prints NOT ACCEPTED: 1/4 checks pass, failing C1, C2 and C3 because no #2652 selftest exists. Driving develop's wait_synced with a stub that answers a restored done/done first returns 0 on that first reading, which is the defect. A throwaway prototype, not committed, printed ACCEPTED: 4/4 checks pass on two runs. It changed wait_synced and added three #2652 rows to selftest-e2e-tari-settle.sh. All runs were made on a macOS host, and no check here depends on GNU tools.
Hint, not binding: the prototype had the bench print <sync> <snapshot age> <dashboard uptime>. The age came from pithead_snapshot_age_seconds on the dashboard's /metrics, and the uptime from the dashboard container's start time. It accepted done/done only when the age was smaller than the uptime. Two consecutive done/done polls 8 s apart do not prove a live reading: both can fall before the dashboard's first poll cycle ends, and until then it serves the restored snapshot. C3 shows only that the selftest tells the new wait_synced from develop's. The reviewer still checks that the #2652 rows model a restored snapshot.
Independent re-check, 2026-10-03: a second session re-ran this script in a fresh worktree at 3822294. Develop printed NOT ACCEPTED: 1/4 checks pass, and with the throwaway prototype applied it printed ACCEPTED: 4/4 checks pass. Files the script mutates were left unchanged after each run.
accept_2652.py
"""Acceptance check for p2pool-starter-stack/pithead#2652.
Save this file OUTSIDE the repo (for example /tmp/accept_2652.py) so it is never committed.
Run from the repo root on the PR head, on Linux as CI does (on macOS, inside `make test-container`):
python3 /tmp/accept_2652.py
Prints PASS/FAIL per check and exits 0 only when every check passes. tests/integration/e2e.sh is
mutated in place for one check and restored from its saved content in a finally block.
"""
import re
import subprocess
import sys
from pathlib import Path
E2E = Path("tests/integration/e2e.sh")
SELFTEST_DIR = Path("tests/integration/selftest")
SETTLE = SELFTEST_DIR / "selftest-e2e-tari-settle.sh"
TAG = "#2652"
# develop's wait_synced at 38222945: it returns on the first done/done, restored snapshot or not.
BASE_WAIT_SYNCED = r"""wait_synced() { # <timeout_s>
local deadline=$(($(date +%s) + ${1:-300})) st refusal="destructive phases"
[ "${2:-}" = restore ] && refusal="baseline proof"
while :; do
st="$(on_bench "curl -fsS --max-time 8 http://127.0.0.1:8000/api/state 2>/dev/null | jq -r '\"\(.sync.monero.state)/\(.sync.tari.state)\"' 2>/dev/null" || true)"
[ "$st" = "done/done" ] && {
ok "monero + tari re-confirmed synced ($st) — existing chains reused, no re-sync"
return 0
}
[ "$(date +%s)" -ge "$deadline" ] && {
warn "sync panels still '$st' after $((${1:-300}))s — $refusal refused"
return 1
}
sleep 8
done
}
"""
FUNC = re.compile(r"^wait_synced\(\) \{.*?^\}\n", re.S | re.M)
ROW = re.compile(r"^\s*(✓|✗) (.*)$")
results = []
def report(name, ok, detail=""):
results.append(ok)
print(f"{'PASS' if ok else 'FAIL'} {name}" + (f" [{detail}]" if detail else ""), flush=True)
def git(*args):
return subprocess.run(["git", *args], capture_output=True, text=True).stdout
def run_selftest(path):
"""-> (exit code, [(verdict, text)])"""
r = subprocess.run(["bash", str(path)], capture_output=True, text=True, timeout=600)
rows = []
for line in (r.stdout + r.stderr).splitlines():
m = ROW.match(re.sub(r"\x1b\[[0-9;]*m", "", line))
if m:
rows.append(("pass" if m[1] == "✓" else "fail", m[2].strip()))
return r.returncode, rows
def tagged(paths):
"""Run every #2652 selftest -> (all exited 0, passing #2652 rows, failing #2652 rows)."""
codes, passed, failed = [], 0, 0
for p in paths:
code, rows = run_selftest(p)
codes.append(code)
passed += sum(1 for v, t in rows if v == "pass" and TAG in t)
failed += sum(1 for v, t in rows if v == "fail" and TAG in t)
return all(c == 0 for c in codes), passed, failed
subprocess.run(["git", "fetch", "-q", "origin", "develop"], check=False)
base = git("merge-base", "origin/develop", "HEAD").strip()
changed = set(git("diff", "--name-only", base).split())
outside = sorted(f for f in changed
if not f.startswith(("tests/integration/", "docs/")) and f != "CHANGELOG.md")
report("C1 e2e.sh and a harness selftest changed; nothing outside tests/integration/ and docs/ (CHANGELOG.md allowed)",
str(E2E) in changed and any(f.startswith(f"{SELFTEST_DIR}/") for f in changed) and not outside,
f"changed: {sorted(changed)}")
suites = sorted(p for p in SELFTEST_DIR.glob("*.sh") if TAG in p.read_text())
all_ok, passed, failed = tagged(suites)
report("C2 the #2652 selftests exit 0 with >= 2 passing and 0 failing rows naming #2652",
bool(suites) and all_ok and passed >= 2 and failed == 0,
f"suites {[p.name for p in suites]}, pass rows {passed}, fail rows {failed}")
src = E2E.read_text()
found = FUNC.findall(src)
red = 0
if len(found) != 1:
got = f"error(anchor found {len(found)}x in {E2E})"
elif not suites:
got = "error(no #2652 selftest to run)"
else:
try:
E2E.write_text(src.replace(found[0], BASE_WAIT_SYNCED))
_, _, red = tagged(suites)
got = f"{red} failing #2652 rows"
finally:
E2E.write_text(src)
report("C3 with develop's wait_synced put back, at least one #2652 selftest row fails", red >= 1, f"got {got}")
code, rows = run_selftest(SETTLE)
ceiling = [t for v, t in rows if v == "pass" and t.startswith("deploy_branch's wait_synced ceiling (")]
refuse = [t for v, t in rows if v == "pass"
and t == "deploy_branch refuses destructive phases when the bounded settle expires"]
report("C4 the #2455 settle ceiling and refusal rows still pass in selftest-e2e-tari-settle.sh",
code == 0 and len(ceiling) == 1 and len(refuse) == 1,
f"exit {code}, ceiling rows {len(ceiling)}, refusal rows {len(refuse)}")
print(f"\n{'ACCEPTED' if all(results) else 'NOT ACCEPTED'}: {sum(results)}/{len(results)} checks pass")
sys.exit(0 if all(results) else 1)possible solutions
No distinct solution options are recorded; investigate the existing report before choosing an approach.
Activity
pithead-developer commentedon Oct 23, 2026
Parked in Icebox under the lean roadmap (owner, 2026-10-21: flaky tests are rerun, not fixed; harness forensics parked; no soaks): a harness readiness race, not a product bug. It comes back if it recurs and becomes a hard release blocker.
pithead-developer commentedon Nov 14, 2026
Questions before work continues (answer here, then remove the
questionlabel):Tiers 1-3 on PR #4105 were still running when this session ended, and I may not wait on background work. Should the runner resume this session once the checks at head 995a155 settle, so I can submit tier4-e2e (mode targeted, base develop-v2.1.0) through bench-submit? Default: yes, resume; I submit the job, then return waiting with its id@sha.
pithead-architect commentedon Nov 14, 2026
Ruling: Yes, take your default. A checkpoint is
waiting, so don't ask it as a question again. Tiers 1-3 at head 995a155 have already finished: 50 checks passed and 2 were skipped, none failed. When you resume, do these steps in order. (1) Check that the PR head is still 995a155. If it has moved, use the new head. (2) Submit onetier4-e2ejob through bench-submit, mode targeted, base develop-v2.1.0, on that head. The PR changestests/integration/e2e.shand the e2e sync sampling, which is harness code, so tier 1 alone is not enough. (3) Returnwaitingwith the job as id@sha inbench_jobs. Do not returndoneuntil the job has run. (4) When it has run, quote its conclusion in the PR body, together with thewait_syncedline and the readiness rows, so the record shows readiness ran on a live dashboard reading. If the bench doesn't recreatedashboardon that run, say so and do not claim the race was exercised. The self-testselftest-e2e-sync-freshness.shis the proof of the fix: in the PR body, show it red with the freshness check removed and green with it in place. List any further choices under "Decisions taken" and come back only for a product decision.testing: require live dashboard snapshots for e2e readiness (#2652) (#…
pithead-developer commentedon Nov 15, 2026
Merged in #4105.