Repository navigation
refactor(node): retire dead/redundant watcher surface (#1231) - #1234
Conversation
`ChainStakerSet` maintained a `broadcast::Sender<StakerChange>` and republished on every membership change. Nothing subscribed. The only call site of `subscribe_changes` in the repo was a unit test asserting the receiver never fires, so every `send` in `apply_change` was unconditionally a `SendError` — a fully-built producer pipeline with no consumer, plus a 128-slot channel whose capacity rationale described a slow subscriber that did not exist. Removed: the trait method and its four impls, both `changes_tx` fields, `CHANGES_CHANNEL_CAPACITY`, the `broadcast::channel` construction, the send, and the test. `apply_change` stays — it also republishes `staker_set_active_count` and mutates the set — but now returns whether membership actually moved. The two idempotence tests used `rx.try_recv()` as their *observation channel*, so deleting the sender would have deleted the assertion mechanism, not just a field. The bool is what `apply_change` already computed internally, and it tests the same property more directly than the channel did. `StakerChange` survives as the internal change-representation, but moves from `staker_set` to `chain_staker_set` as `pub(super)`: `ConfigStakerSet` no longer touches it, and its only producer (`capacity_bond_registry`) and only consumer (`apply_change`) are both on the chain-backed path. It also stops being public API — `dht::mod`'s `pub use` drops it. Its doc referenced `StakerSet::subscribe_changes`, which would have dangled. `ConfigStakerSet` and the `dht_loopback` `AllStaked` stub both lose the sender they held solely to satisfy the trait, and `AllStaked` collapses to a unit struct. The trait doc now records that the absence of a subscription seam is deliberate, so the next reader adds one alongside a consumer rather than ahead of one. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Since #1226 collapsed the node-address and staker-set watchers into one `capacity-bond` loop, `decdn_node_address_watcher_{restarts_total, down_seconds}` moved in lockstep with their staker-set counterparts — one loop's health reported twice. #1226 kept both deliberately, on two grounds. Both fail: - "Retiring one would break existing dashboards and alerts." No dashboard, alert, ADR, or runbook in this repo has ever referenced the family: it appears in neither `monitoring/grafana-dashboard.json` nor `monitoring/prometheus-alerts.yml`, and `grep -rn node_address adr/ docs/ monitoring/` is empty. - "Freezing `node_address_watcher_down_seconds` at 0 forever would be an alert that can never fire, which is worse than deleting it." This was the stronger argument, and it cut the other way — the family was gated on the bindings projection existing, so a pull-through-off node reported exactly that frozen 0. `decdn_node_address_directory_size` is **kept**. It is not correlated with anything: it measures the projection rather than the loop, has its own producers in `set_binding` / `remove_binding` plus the bootstrap seed, moves only on `NodeRegistered`/`NodeDeregistered` while the active set moves on all five events, and has its own tests. With the trio gone, `hooks()` loses its `bindings_live` parameter — the gate existed only for the deleted metrics — and the two `composed_hooks_*` tests collapse into one. `node_address_directory_size` keeps its own independent `track_node_addresses` gate at the bootstrap site. The replacement statement lands where `hooks` is: the capacity-bond loop's health is `staker_set_watcher_*`, and it covers the bindings projection because one loop feeds both. Removing exported metrics is operator-visible even with no in-repo consumer, so this carries a CHANGELOG entry naming the migration. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…1231) The observability docs for the staker-set watcher family still describe the pre-#1092/#1106/#1226 world. Two kinds of rot, both fixed here: **Dangling function references.** `adr/appendix-observability.md` and `metrics.rs` attribute the metrics' paired `warn!` sites to `watcher_loop` and `apply_operator_change`. Neither function exists anywhere in the tree. They are now `resumable_watcher::run` ("watcher RPC error; restarting after backoff") and `capacity_bond_registry`'s `RegistrySink::on_operator_change`. **`eth_newFilter`-era language.** The docs describe down-seconds in terms of "no established filters" and "a healthy filter stream persists indefinitely", and the restart counter in terms of "a clean stream end (filter expiry / provider rotation)". There are no filters — #1106 removed `eth_newFilter`/`eth_getFilterChanges` from the hot path (the default public Arbitrum Sepolia RPC rejects them with -32601), and the watchers have been `eth_getLogs` pollers since. Re-anchored to the poll tick, and the restart counter's filter-expiry carve-out is dropped: a poll loop has no stream to end cleanly. The ADR section intro also now attributes the metrics to the one shared `capacity-bond` loop, and records that they cover the bindings projection because the same loop feeds it — which is what makes them sufficient after #1231 retired the parallel node-address family. Also fixes the identical "no established filters" claim on `origin_directory_watcher_down_seconds` (#651). Not this issue's family, but the same stale claim a few lines away in the same file; leaving it behind in a doc block being cleaned for staleness is worse than the original. The `##### Active-Staker Set Watcher Metrics` heading is unchanged, so `docs/runbook.md`'s anchor into it still resolves. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (10)
💤 Files with no reviewable changes (1)
WalkthroughThe PR removes ChangesShared Capacity-Bond Watcher
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant CapacityBondWatcher
participant RegistrySink
participant Projections
participant Metrics
CapacityBondWatcher->>RegistrySink: emit capacity-bond log event
RegistrySink->>Projections: update active set and optional bindings
RegistrySink->>Metrics: record shared watcher metrics
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 |
Gas snapshotNo gas changes vs base. |
Contracts coverageLine coverage: 88.92% (2488/2798 lines) |
There was a problem hiding this comment.
Pull request overview
This PR removes unused watcher-related surfaces in decdn-node and updates observability documentation to match the current eth_getLogs-polling watcher architecture. It simplifies the DHT staker-set API by retiring the unused change-subscription seam and removes redundant node-address watcher health metrics that became perfectly correlated after the shared CapacityBond watcher refactor.
Changes:
- Retires
StakerSet::subscribe_changesand the associated broadcast plumbing; replaces the former “observable” signal in tests with an explicitapply_change -> boolmutation result. - Removes the redundant
decdn_node_address_watcher_{restarts_total,down_seconds}metrics and the related hooks/state, leavingdecdn_staker_set_watcher_*as the shared CapacityBond loop health signal. - Updates observability docs + inline metric docs to reference the current implementation points (
resumable_watcher::run,RegistrySink::on_operator_change) and polling semantics.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| crates/node/tests/dht_loopback.rs | Drops now-removed subscribe_changes plumbing from a test stub staker set. |
| crates/node/src/metrics.rs | Removes node-address watcher metric fields/state and updates watcher metric docs to match polling + new warn sites. |
| crates/node/src/dht/staker_set.rs | Removes subscribe_changes from the StakerSet trait and simplifies ConfigStakerSet. |
| crates/node/src/dht/mod.rs | Stops exporting StakerChange from the public dht module surface. |
| crates/node/src/dht/chain_staker_set.rs | Moves StakerChange internal, removes broadcast sender, and makes apply_change return whether it mutated. |
| crates/node/src/dht/chain_origin_directory.rs | Updates tests to match the simplified StakerSet trait (no subscription method). |
| crates/node/src/dht/capacity_bond_registry.rs | Removes staker-change broadcast + node-address watcher hooks; uses only staker-set watcher health hooks. |
| CHANGELOG.md | Adds an operator-facing note about removed metrics and the migration path. |
| adr/appendix-observability.md | Fixes stale watcher/metric documentation to reference the current polling watcher and warn sites. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request removes redundant decdn_node_address_watcher_* metrics and the unused StakerChange broadcast channel mechanism. These changes simplify the codebase by consolidating observability for the shared capacity-bond loop and removing unused code paths. Documentation and tests have been updated to reflect these removals. I have no further feedback to provide.
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.12% (was 80.96%, ▲ +0.17%) — 48406/59669 lines
History
|
…1231) Finishes the `bindings_live` removal. `hooks()` returned a positional `(WatcherHook, WatcherHook)` of two structurally identical boxed closures — `let (on_established, on_backoff) = hooks(&metrics)` type-checks identically when reversed, and the consequence is a silent metrics inversion: failures would close the drift window instead of opening it. The `bindings_live` gate was the only reason for a combined function returning a pair. With it gone, this matches the convention every other watcher already uses (`slash_watcher`, `chain_origin_directory`): two named functions, inlined at the `WatcherConfig` literal, so there is nothing to transpose. The guard test could not see either failure. Its `down_seconds 0` assertion holds whether or not `established()` is ever called — `down_since.elapsed()` floors to 0 for the first full second — and the surviving `restarts_total 1` assertion is driven solely by `backoff()`. Verified: the test stayed green both with the tuple reversed and with the `established` hook body replaced by a no-op, leaving that leg with zero coverage. Asserting on a third call fixes it. `backoff_started` is edge-triggered on `down_since` being unset, so the re-arm to 2 only counts if `established` actually closed the window. Verified this fails on the neutered hook and on the reversed tuple, and passes on correct code. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
) Same standard this PR applied to the observability appendix, turned on its own prose. Each is verified against code, not restated from intent. - `RegistryHandles` claimed `node_address_directory_size` "stays absent" with pull-through off. It does not: `DecdnMetrics` registers as one unconditional group, so the gauge exports a permanent `0` on every default node (pull-through is off by default) — indistinguishable from a pull-through-on node whose directory collapsed, which is the alert condition. This is the mirror of the frozen-at-0 argument used to retire `node_address_watcher_*`, so the doc now states the constraint instead of denying it. Making it genuinely absent needs a split group or labelled family; left as follow-up. - The CHANGELOG's "has independent producers" was false — every producer is the shared `capacity-bond` loop. The projection-vs-loop clause is the correct and sufficient rationale on its own. - `apply_change`'s bool was justified as "the only observable signal that a change was real". It is not: `staker_set_active_count` is republished only on mutation, and a test observes realness through exactly that gauge. Re-anchored to the `HashSet::insert`/`remove` contract it actually mirrors — a return value justifiable only by its tests should not exist. - `ConfigStakerSet` described itself as what the runtime wires "until" the chain set "is ready". It shipped in #1110 and is wired at runtime/mod.rs:744; every remaining `ConfigStakerSet` construction is under `#[cfg(test)]`. Also drops "subscribes to", which collides with the vocabulary this PR retired — it is an `eth_getLogs` poll. The runbook still scoped these metrics to the staker set "specific"ally, the framing f152fa3 re-anchored in the appendix. Post-#1226 one loop feeds both projections, and the operator impact of the bindings half — missed `NodeRegistered` bindings leave providers unpayable and silently skipped — was deleted along with the retired metric's doc and survived nowhere in the tree. Restored where an operator reads during an incident. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Closes #1231.
Two cleanups #1110/#1226 revealed, each needing a judgement call rather than a mechanical delete. Five commits, reviewable independently — the last two are self-review corrections, see § Review findings.
1.
StakerSet::subscribe_changes— retiredChainStakerSetmaintained abroadcast::Sender<StakerChange>(capacity 128) and republished on every membership change. Nothing subscribed. The only call site in the repo was a unit test asserting the receiver never fires, so everysendinapply_changewas unconditionally aSendError— a fully-built producer pipeline with no consumer, plus a channel whose capacity rationale ("sized so a slow subscriber…") described a subscriber that did not exist.The issue asks whether this is a planned extension point or genuinely unused. It's unused: nothing in the tree wants to react to membership changes, and the gap-is-the-bug reading would require naming the consumer that should exist. Re-add a subscription alongside the code that needs it — the trait doc now says so.
apply_changenow returnsbool. This is the non-obvious part: the two idempotence tests usedrx.try_recv()as their observation channel, so deleting the sender would have deleted the assertion mechanism, not just a field. The bool is themutatedflagapply_changealready computed internally, and it tests the property more directly than the channel did.StakerChangesurvives as the internal change-representation (capacity_bond_registrystill builds it,apply_changestill consumes it) but moves tochain_staker_setaspub(super)—ConfigStakerSetno longer touches it, and both its producer and consumer are on the chain-backed path. It also leaves the public API (dht::mod'spub usedrops it).2.
node_address_watcher_*— retiredSince #1226 collapsed the two loops into one,
restarts_total/down_secondsmoved in lockstep with their staker-set counterparts — one loop's health reported twice.#1226's stated reasons for keeping it both fail:
monitoring/grafana-dashboard.json, notmonitoring/prometheus-alerts.yml, andgrep -rn node_address adr/ docs/ monitoring/is empty.down_secondsat 0 forever would be an alert that can never fire, which is worse than deleting it." This was the stronger argument — and it cut the other way. The family was gated on the bindings projection existing, so a node with pull-through off reported exactly that frozen 0. The doc argued for deletion by its own criterion.node_address_directory_sizeis kept — the issue frames this as retiring "the family", but that gauge is not correlated with anything: it measures the projection's cardinality, not the loop's health, moves only onNodeRegistered/NodeDeregisteredwhile the active set moves on all five events, and has its own tests. (An earlier revision of this description also claimed "independent producers" — that was false, every producer is the shared loop, and the claim is gone from the CHANGELOG too. The projection-vs-loop distinction carries the argument on its own.)Falls out nicely: the
bindings_livegate existed only for the deleted metrics, so it goes — and with it the reasonhooks()was one function returning a pair (see § Review findings).3. Stale observability docs
Independent of the above, and true regardless:
warn!sites towatcher_loopandapply_operator_change— neither exists anywhere in the tree. Nowresumable_watcher::runandRegistrySink::on_operator_change.eth_newFilter-era language. "no established filters", "a healthy filter stream persists indefinitely", "a clean stream end (filter expiry / provider rotation)". There are no filters — Node event watchers hard-depend on eth_newFilter; switch to eth_getLogs polling #1106 removed them from the hot path (the default public Arbitrum Sepolia RPC rejects them with-32601). Re-anchored to theeth_getLogspoll tick.origin_directory_watcher_down_seconds(DHT: chain-backed StakerSet + OriginDirectory + alloy bindings for the on-chain fallback #651) — not this issue's family, but the same claim a few lines away in a file being cleaned for exactly that.Review findings
A multi-agent review of the first three commits surfaced two things worth fixing here rather than deferring. Both are additions to this PR, not rewrites of it.
hooks()returned a transposable pair, and the guard test could not see it.(WatcherHook, WatcherHook)is two structurally identical boxed closures, solet (on_established, on_backoff) = hooks(&metrics)type-checks identically when reversed — and the consequence is a silent metrics inversion, with failures closing the drift window instead of opening it.bindings_livewas the only reason for a combined function returning a pair, so removing the gate is what made the split available:established_hook/backoff_hook, inlined at theWatcherConfigliteral, matchingslash_watcherandchain_origin_directory.The test was the sharper problem. Its
down_seconds 0assertion holds whether or notestablished()is ever called —down_since.elapsed()floors to0for the first full second — so theestablishedleg had zero coverage while the assertion message claimed the opposite. Verified by mutation: the old test stayed green both with the pair transposed and with the hook body replaced by a no-op. Asserting on a third call fixes it, sincebackoff_startedis edge-triggered ondown_sincebeing unset and only re-arms to2ifestablishedreally closed the window.Four claims in this PR's own prose were inaccurate — the same standard the docs commit applied to the appendix, turned on itself:
RegistryHandlessaidnode_address_directory_size"stays absent" with pull-through off. It does not:DecdnMetricsregisters as one unconditional group, so it exports a permanent0on every default node — indistinguishable from the collapsed-directory condition you would alert on. That is the mirror of the frozen-at-0 argument used to retirenode_address_watcher_*, so the doc now states the constraint. A real fix needs a split group or labelled family; filed as follow-up.apply_change's bool was justified as "the only observable signal that a change was real" — it is not,staker_set_active_countis mutation-gated and a test observes realness through it. Re-anchored to theHashSet::insert/removecontract it mirrors.ConfigStakerSetstill described itself as what the runtime wires "until" the chain set "is ready". It shipped in feat(node): eth_getLogs resumable watcher, off eth_newFilter (#1106, #1108, #1092) #1110; every remaining construction is under#[cfg(test)].The runbook also still scoped these metrics to the staker set "specific"ally — the framing f152fa3 re-anchored in the appendix. Post-#1226 one loop feeds both projections, and the bindings-half operator impact (missed
NodeRegisteredbindings leave providers unpayable and silently skipped) was deleted with the retired metric's doc and survived nowhere in the tree. Restored to the runbook, where it gets read during an incident.Follow-ups (not this PR)
node_address_directory_sizeexports a permanent0when pull-through is off (pre-existing, refactor(node): one CapacityBond watcher feeding both registry projections (#1110) #1226). Needs a split metrics group or labelled family.UnbondingRequesteddispatch arm has no test despite being live in the subscribed OR-set; if miswired it falls to the_ =>catch-all and an unbonding operator stays active until some other event lands. Absent onmaintoo.Corrections to the issue text
*_cycle_establishedmetric. There isn't one —cycle_establishedis only a method that clearsdown_since. The real family isrestarts_total+down_seconds(+resolve_failures_total/active_counton the staker-set side).node_address_*family; the correct scope is three items, not four (see above).Verification
cargo nextest run -p decdn-node— 807/807 pass (809 on this branch's base, minus thesubscribe_changestest and one collapsedcomposed_hooks_*)establishedhook body neutered, and passes on correct codecargo clippy --workspace --all-targets— cleanpre-commit run --all-files— all hooks pass, includingcargo doc(which caught a public module doc linking to the now-privateStakerChange) and ADR reference hygienedocs/runbook.md's anchor into the ADR section still resolves — the heading is unchangedNotes for review
StakerSetispub, so removing a trait method is a semver break for any out-of-tree impl. In-repo onlytests/dht_loopback.rs. Pre-tag, so low stakes.Follow-up from #1110 / #1226. Second of four in the watcher-hygiene batch (#1228 → #1231 → #1227 → #1230). Independent of #1233 (#1228) — branched from
main, no shared files.🤖 Generated with Claude Code