Skip to content

fix(monitoring): one shared body validator so HTTP 200 alone never means up (#17180) - #8652

Open
DSP-AID wants to merge 2 commits into
Scottcjn:mainfrom
DSP-AID:fix/node-liveness-body-validation-17180
Open

DSP-AID wants to merge 2 commits into
Scottcjn:mainfrom
DSP-AID:fix/node-liveness-body-validation-17180

Conversation

@DSP-AID

@DSP-AID DSP-AID commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Problem (Scottcjn/rustchain-bounties#17180)

An attestation node's IP was repurposed for an unrelated single-page app. The SPA answers HTTP 200 with HTML on every path, and all five monitors decided health from the status code alone — so a host that is not a RustChain node anymore kept reporting up forever (fleet believed at 4 nodes when it was 2).

Fix

One shared body validator, monitoring/node_probe.py (stdlib-only, py3.9+), becomes the only place a monitor decides what "up" means:

state meaning
up HTTP 200 and JSON body carries RustChain node identity keys (ok/version/uptime_s, or epoch keys on /epoch)
degraded genuine node reporting ok:false, db_rw:false, or stale tip
impostor HTTP 200 but HTML SPA / parking page / keyless JSON — never counted up
down non-200 status
unreachable timeout / refused / DNS / TLS

All five monitors now route through it (single shared copy, imported via a small sys.path bootstrap — no vendored drift):

  • status/status_server.py — per-node state + error, impostor incident type
  • health-dashboard/server.py — NodeStatus.status carries the probe state incl. impostor
  • monitoring/rustchain-exporter.py — rustchain_node_health=0 on any failed scrape (incl. crashed cycles), new rustchain_last_successful_scrape_timestamp gauge
  • tools/node_health_monitor.py — loud IMPOSTOR alert, ⚑ impostor table marker, state field in JSON output
  • tools/node-health-cli/node_health.py — HealthStatus.state from the shared probe

Status page and dashboard visibly distinguish impostor from up (badge override + CSS + summary card; the existing asserted template line is preserved verbatim).

Tests

New tests/test_node_liveness_body_validation.py (31 tests, runs in CI via existing pytest tests/ job — no workflow changes) with recorded fixtures: genuine node body, HTML-200 SPA, keyless JSON, ok:false, HTTP 500, socket timeout. HTML-200 → impostor is asserted per monitor.

Existing suites re-verified green: tests/ full run 1314 passed (only pre-existing missing-dependency failures locally), plus health-dashboard/, monitoring/alerts/tests/, status/, tools/node-health-cli/, exporter tests. ruff check clean on all touched files.

Bonus: dashboard response-time measurement switched to time.perf_counter() — test_check_node_health_measures_response_time was flaky-failing on Windows clock granularity even before this PR.

No production config changes, no new node endpoints.

Closes #17180 (bounty: 25 RTC)

…ans up (#17180)

A 200 is not evidence of a node: when an attestation node's IP was
repurposed for an SPA, every monitor kept reporting the host healthy
forever. Add monitoring/node_probe.py, the single place that decides
what 'up' means (up|degraded|impostor|down|unreachable), and wire all
five monitors through it:

- status/status_server.py     state+error per node, impostor incident
- health-dashboard/server.py  NodeStatus.status carries the probe state
- monitoring/rustchain-exporter.py  node_health=0 on any failed scrape,
  new rustchain_last_successful_scrape_timestamp gauge
- tools/node_health_monitor.py      IMPOSTOR alert + table marker + state
- tools/node-health-cli             HealthStatus.state via shared probe

Status page/dashboard render impostor distinctly from up. Tests:
tests/test_node_liveness_body_validation.py covers genuine body,
HTML-200 SPA, keyless JSON, ok:false, HTTP 500 and timeout per monitor.
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Welcome to RustChain! Thanks for your first pull request.

Before we review, please make sure:

  • Non-doc PRs have a BCOS-L1 or BCOS-L2 label
  • Doc-only PRs are exempt from BCOS tier labels when they only touch docs/**, *.md, or common image/PDF files
  • New code files include an SPDX license header
  • You've tested your changes against the live node

Bounty tiers: Micro (1-10 RTC) | Standard (20-50) | Major (75-100) | Critical (100-150)

A maintainer will review your PR soon. Thanks for contributing!

@github-actions github-actions Bot added documentation Improvements or additions to documentation BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) tests Test suite changes size/XL PR: 500+ lines labels Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

This PR is quite large (XL). Consider splitting into smaller, focused PRs for faster review. Large PRs take longer to review and have higher risk of issues.

This branch has not been deployed

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

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) documentation Improvements or additions to documentation size/XL PR: 500+ lines tests Test suite changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants