Skip to content

Observability: surface ChainStakerSet watcher drift via a metric (not just a warn! log) #783

Closed

Description

@thiras

Problem

ChainStakerSet documents that on a mid-run watcher RPC outage the cached active-staker set "can drift from chain state," and the only operator-visible signal is a warn! log line — explicitly not covered by decdn_rpc_healthy (which tracks a different watchdog). See crates/node/src/dht/chain_staker_set.rs (§Failure model, ~L28–37; backoff/restart in watcher_loop).

This is a pre-existing limitation, but #757 (probe-time stake-lane reservation, PR #782) added a new consumer that makes the drift revenue-impacting: under an active reservation, a stale active set decides which probes are shed. If the watcher is down and an operator's bond was slashed/unbonded on-chain, the node keeps treating them as stake-lane (and keeps shedding paying end-clients to reserve headroom for a no-longer-eligible peer); conversely a newly-registered operator is wrongly reserved out. The DHT Store/FindValue admission path has the same dependency.

A "documented degradation" is only acceptable if it's alertable. Today it relies on log-grep.

Proposal

Expose watcher health as metric(s) so the drift window is dashboard-visible and alertable, e.g. one or more of:

  • decdn_staker_set_watcher_restarts_total (counter) — incremented each time watcher_loop re-establishes filters after an error.
  • decdn_staker_set_last_event_seconds / decdn_staker_set_watcher_down_seconds (gauge) — time since the last successful event-stream cycle, so an alert can fire on a sustained outage.
  • (optional) decdn_staker_set_active_count (gauge) — current cached active-set size, to spot a collapse.

Register in adr/appendix-observability.md (the canonical metric registry) alongside the existing decdn_rpc_healthy row, with recommended alert thresholds.

Notes

  • A getActiveNodes resync-on-extended-outage path is already noted as a separate follow-up in the same module doc; this issue is only about observability of the existing watcher, not the resync logic.
  • Touches crates/node/src/dht/chain_staker_set.rs + crates/node/src/metrics.rs + the observability appendix.

Surfaced during the PR #782 review (silent-failure analysis).

Activity

  1. added
    kind:feature
    rust
    on Jun 2, 2026
  2. github-actions commented on Jun 2, 2026

    @github-actions

    🎯 Triage report

    This issue requests Prometheus-style metrics (watcher_restarts_total, last_event_seconds, optionally active_count) for the ChainStakerSet watcher loop to make silent RPC outages alertable. The motivation is strengthened by PR #782 making the stale active-set revenue-impacting: a drifted set causes wrong probe-shedding decisions. The scope is narrow and well-specified — three concrete metric names, two source files, and one ADR appendix update.

    📊 Assessment

    Dimension Value Reasoning
    Type Task Additive observability work with no design ambiguity; not a bug fix or feature request
    Labels enhancement, technical, rust (already applied) Accurate; medium priority label could also apply given revenue-impact context from #782
    Coding agent Suitable Requirements are fully specified: metric names, types, registration point (metrics.rs), and documentation target (appendix-observability.md) are all named. Touched files are identified. No design decisions required.

    🔗 Similar issues

    💡 Notes and suggestions

    Implementation checklist:

    • In crates/node/src/metrics.rs: register decdn_staker_set_watcher_restarts_total (Counter), decdn_staker_set_watcher_down_seconds or decdn_staker_set_last_event_seconds (Gauge), and optionally decdn_staker_set_active_count (Gauge).
    • In crates/node/src/dht/chain_staker_set.rs: increment the restart counter at the top of each watcher_loop retry; update the last-event gauge on each successful filter cycle; update active_count whenever the cached set is replaced.
    • In adr/appendix-observability.md: add a new table row for each metric with description, type, and recommended alert threshold (e.g., alert if watcher_down_seconds > 300).
    • Verify clippy anti-panic policy (unwrap_used, expect_used) is respected in new metric registration code.

    Priority note: The medium label from #751 would be appropriate here given the revenue-impact path identified in #782. Maintainers may want to tag it accordingly.

    Out of scope (per issue): The getActiveNodes resync-on-extended-outage path is explicitly deferred; do not implement it here.

    Generated by Agentic Triage for issue #783 · sonnet46 479.5K · ◷

    Add this agentic workflows to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/issue-triage.md@94ec5db57374c5b04a4b8eef8b4413f9af44d63f
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind:featureprio:mediumrust

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions