Repository navigation
feat(node): uniform watcher liveness, panic, and enforcement observability - #1325
Conversation
…ility The node's six chain-event watchers share one `resumable_watcher::run` loop whose health machine is error-triggered: `*_down_seconds` moves only on a tick `Err`, so a task that panics while healthy, wedges, or exits cleanly leaves the gauge at a healthy `0` — a dead watcher is byte-identical to a live one. Three of the six lacked the down-family entirely, the detached task's panic was discarded silently, and the blacklist watcher could stop enforcing the deny-set after initial sync while every metric read green. This batch adds a uniform observability surface across all six watchers: - Liveness: a per-watcher `*_last_tick_timestamp_seconds` gauge stamped on every successful tick via a new metric-agnostic `on_tick_success` loop hook. Staleness detects panic/wedge/clean-exit where the down-family cannot (#1316, #1320). - Panic visibility: a `PanicGuard` drop-guard in `run` fires `*_task_panicked_total` + `error!` only on an unwind, mirroring the `WarmOutcome` precedent (#1316). - Down-family parity: blacklist, settlement, and reputation-indexer gain the `*_restarts_total` / `*_down_seconds` family their peers already had (#1283). - Enforcement metric: `blacklist_enforcement_failures_total` fed from `rescan`'s `Recheck::Failed` arm, so a slashable "deny-set not fully enforced" condition has its own signal even after the initial-sync gate fires (#1319). - Shutdown correctness: the shared loop suppresses the `on_established` and `on_backoff` edges once the token is cancelled, so an orderly stop mid-sync stamps no false drift window (#1321) and — critically — never signals the blacklist readiness gate `Ok` on an incomplete deny-set replay (fail-closed). - Docs: appendix-observability watcher section + Prometheus alerts (per-watcher staleness with a `> 0` sentinel guard, task-panic, enforcement-failure), plus the #1322 "alert on the gauge, not the restart-counter rate" runbook note. Supersedes #1315, absorbing its blacklist-family design and test harness. Resolves #1316, #1320, #1283, #1319, #1321, #1322. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Warning Review limit reached
Next review available in: 47 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (2)
WalkthroughThe PR adds watcher liveness, panic, downtime, and blacklist enforcement metrics. Resumable watchers gain tick and panic hooks, watcher bootstraps wire those hooks into ChangesWatcher observability
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Watcher
participant Metrics
participant Prometheus
Watcher->>Metrics: record successful tick or panic
Watcher->>Metrics: record downtime transitions
Metrics-->>Prometheus: expose watcher metrics
Prometheus->>Prometheus: evaluate staleness and failure alerts
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces a uniform observability and liveness tracking system across all six chain-event watchers. It adds positive liveness signals (*_last_tick_timestamp_seconds), panic tracking counters (*_task_panicked_total) via a new PanicGuard in the resumable watcher loop, and specific blacklist enforcement failure metrics. Additionally, it brings the blacklist, settlement, and reputation indexer watchers to full downtime metric parity, updates Prometheus alerting rules, and adds comprehensive unit tests. No review comments were provided, so there is no feedback to address.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Coverage reportTotal: 81.63% (was 81.50%, ▲ +0.13%) — 50382/61722 lines
History
|
There was a problem hiding this comment.
Pull request overview
This PR strengthens node chain-event watcher observability by adding uniform positive-signal liveness gauges, panic visibility, and parity in downtime metrics across all six watchers, plus alerting/docs to operationalize the new signals.
Changes:
- Added per-watcher liveness stamping (
*_last_tick_timestamp_seconds) and per-watcher panic counters (*_task_panicked_total) via newresumable_watcherhooks. - Extended downtime metrics parity to previously uncovered watchers (blacklist, settlement, reputation-indexer) and added a dedicated blacklist enforcement-failure counter.
- Added Prometheus alert rules and updated observability documentation to recommend gauge-based liveness/downtime alerting.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| monitoring/prometheus-alerts.yml | Adds alert rules for watcher staleness, task panics, and blacklist enforcement failures. |
| crates/node/src/chain_events/resumable_watcher.rs | Introduces on_tick_success/on_task_panic hooks, shutdown edge suppression, and panic guard plumbing. |
| crates/node/src/metrics.rs | Defines new watcher liveness/panic/enforcement metrics and corresponding recorders/tests. |
| crates/node/src/blacklist_watcher.rs | Wires new watcher hooks, threads metrics into the sink, and counts enforcement failures from rescans. |
| crates/node/src/slash_watcher.rs | Wires tick-success liveness and panic hooks for the slash watcher. |
| crates/node/src/payment_settlement.rs | Adds full watcher hook wiring (established/backoff/tick/panic) for settlement watcher. |
| crates/node/src/reputation_indexer.rs | Adds established/backoff parity, plus tick/panic hooks for the reputation indexer watcher. |
| crates/node/src/dht/chain_origin_directory.rs | Wires tick-success liveness and panic hooks for origin-directory watcher. |
| crates/node/src/dht/capacity_bond_registry.rs | Wires tick-success liveness and panic hooks for staker-set watcher. |
| crates/node/src/chain_events/shared_head.rs | Updates tests to account for the expanded WatcherConfig struct fields. |
| crates/node/src/runtime/mod.rs | Threads node_metrics into blacklist watcher spawn callsite. |
| adr/appendix-observability.md | Documents new watcher liveness/panic/enforcement metrics and recommended alerting strategy. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…p flaky clock test Two findings from automated review of #1325: - `PanicGuard::drop` fires an arbitrary caller-supplied `on_task_panic` hook while the thread is already unwinding, so a (contract-violating) hook panic would double-panic and abort the process. Unlike the `WarmOutcome` precedent, which calls one hardcoded infallible method, this guard fires a `Box<dyn Fn>`, so wrap that one call in `catch_unwind` as a backstop. Cold path (panic only). - `unix_now_secs_is_a_plausible_wall_clock` asserted an absolute epoch floor, which tests the host/CI clock rather than the code (flaky on a misconfigured or pre-epoch clock, where production correctly returns the 0 sentinel). The wall-clock-stamping behavior is already covered non-flakily by `watcher_liveness_gauges_stamp_wall_clock_on_tick` via a relative `>= before` bound, so remove the redundant test. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Context
The node's six chain-event watchers (slash, staker-set, origin-directory, blacklist, settlement, reputation-indexer) share one
resumable_watcher::runloop whose health machine is error-triggered:*_down_secondsmoves only when a poll tick returnsErr. A task that panics while healthy, wedges in an uncovered await, or exits cleanly on shutdown leaves the down-since state unset, so*_down_secondsreads a healthy0— a dead watcher is byte-identical to a live one. On top of that, three of the six lacked the down-family entirely, the detached task's panic was discarded silently, and the blacklist watcher could stop enforcing the deny-set after initial sync while every metric read green (a slashable exposure).This batch gives all six watchers a uniform, positive-signal observability surface.
Supersedes #1315 (absorbs its blacklist-family design and
FlakyHead/await_metrictest harness; discards its stale base + unrelated churn).Resolves #1316, #1320, #1283, #1319, #1321, #1322.
What changed
*_last_tick_timestamp_seconds, stamped on every successful tick via a new metric-agnosticon_tick_successloop hook. Staleness detects panic/wedge/clean-exit uniformly, where the error-triggered down-family detects none (node: chain watcher task panics are invisible (detached JoinHandle + zero-valued downtime gauge) #1316, Blacklist watcher downtime family is error-triggered: panic and wedge both scrape healthy #1320).PanicGuarddrop-guard inrunfires*_task_panicked_total+error!only on an actual unwind, mirroring the in-repoWarmOutcomeprecedent (node: chain watcher task panics are invisible (detached JoinHandle + zero-valued downtime gauge) #1316).*_restarts_total/*_down_secondsfamily their three peers already had (node: blacklist watcher lacks health metrics (no on_backoff/on_established hooks) #1283).blacklist_enforcement_failures_total, fed fromrescan'sRecheck::Failedarm + an aggregatewarn!, so the slashable "deny-set not fully enforced" condition has its own signal even after the initial-sync gate fires (Blacklist enforcement failures are unobservable after initial sync #1319).on_established/on_backoffedges once the token is cancelled, so an orderly stop mid-sync stamps no false drift window (Graceful shutdown during initial blacklist sync counts a false drift window #1321) and never signals the blacklist readiness gateOkon an incomplete deny-set replay (fail-closed preserved).> 0sentinel guard so a fresh boot / disabled watcher doesn't self-fire), task-panic, and enforcement-failure; plus the Poisoned down_since silently freezes *_watcher_restarts_total (family-wide) #1322 "alert on the gauge, not the restart-counter rate" runbook note.Review
This branch was reviewed by the pr-review-toolkit (code / tests / silent-failure / type-design / comments). All actionable findings were applied before this PR, including a readiness-gate fail-open that an earlier revision of the #1321 fix introduced (now fixed by moving shutdown-awareness into the shared loop) and a cancel-path that discarded already-observed enforcement failures.
Verification
cargo clippy --workspace --all-targets -- -D warnings✔cargo fmt -- --check✔RUSTDOCFLAGS="-D warnings" cargo doc✔cargo nextest run -p decdn-node→ 877 passed (incl. new tests: liveness fires-every-tick, panic-guard + false-positive control, end-to-endrunpanic, shutdown edge-suppression, Blacklist enforcement failures are unobservable after initial sync #1319 aggregate count, down-family parity, poisoned-lock)prometheus-alerts.ymlparses (promtool not installed locally)🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Documentation