Repository navigation
refactor(node): one CapacityBond watcher feeding both registry projections (#1110) - #1226
Conversation
There was a problem hiding this comment.
Code Review
This pull request consolidates the bootstrap and event-watching logic for the CapacityBond contract into a single unified capacity_bond_registry module, eliminating duplicate RPC queries and poll loops for ChainStakerSet and ChainNodeAddressDirectory. Additionally, it deduplicates the AbortOnDrop helper struct by centralizing it in chain_events. Feedback is provided to set a bounded timeout for RPC calls in the watcher configuration to prevent potential hangs.
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.
| }, | ||
| initial_backoff: WATCHER_INITIAL_BACKOFF, | ||
| max_backoff: WATCHER_MAX_BACKOFF, | ||
| rpc_call_timeout: None, |
There was a problem hiding this comment.
All RPC calls should have a bounded timeout to prevent a stalled RPC provider from permanently wedging the watcher tick and blocking graceful shutdown. Please set rpc_call_timeout to a reasonable duration (e.g., 10 seconds) instead of None.
| rpc_call_timeout: None, | |
| rpc_call_timeout: Some(Duration::from_secs(10)), |
References
- Ensure all RPC calls have a bounded timeout. If a timeout configuration is optional (None), default it to a reasonable duration (e.g., 10 seconds) rather than running unbounded.
There was a problem hiding this comment.
The premise here is incorrect, but the rule behind it caught something real — one line off, and in a way this PR made worse. Both addressed in 79fde77.
On the literal suggestion — None is not unbounded. timed does:
let d = timeout.unwrap_or(DEFAULT_RPC_CALL_TIMEOUT); // = Duration::from_secs(10)So rpc_call_timeout: None already is a bounded 10s. Some(Duration::from_secs(10)) is a behavioural no-op that hardcodes the constant at the call site and silently decouples it from DEFAULT_RPC_CALL_TIMEOUT, and None is the convention here — 5 of the 6 watchers pass it. Not taking this one.
On the rule — there is a genuinely unbounded RPC, ~300 lines up. ContractReads::node_id_of did a bare .nodeIdOf(op).call().await. WatcherConfig::rpc_call_timeout only covers the loop's own get_logs; timed's own doc spells this out — a sink's follow-up read "stays unbounded unless the sink wraps it itself (as blacklist_watcher::scope_check does)".
And that's this PR's own regression, which is why it's fixed here rather than deferred. Pre-merge, a stalled nodeIdOf wedged only the staker-set loop — node-address ran its own. Post-merge there is one loop feeding both projections, so it wedges the bindings too. Now bounded via timed, following the scope_check precedent. A timeout surfaces as Err, landing in the path on_operator_change already handles (counts staker_set_watcher_resolve_failure, skips, no stream backoff) — covered by the existing node_id_of_failure_bumps_resolve_failure_and_returns_ok.
Two knock-ons:
timed now takes IntoFuture instead of Future, so an alloy .call() (an EthCall, not a future) wraps directly rather than every caller writing .into_future(). tokio::time::timeout already accepted IntoFuture — my wrapper was what narrowed it. Every Future is an IntoFuture, so it's a strict widening.
timed's timeout arm had no test at all, meaning the bound I just added rested on untested code. Added three, on a paused clock so they cost no wall time: a hanging call times out at the default and names itself, an explicit timeout beats the default, and a prompt success passes through.
809 node tests pass.
There was a problem hiding this comment.
Pull request overview
Refactors the node’s CapacityBond-derived registries so a single bootstrap + eth_getLogs watcher drives both the staker-set projection (active membership) and the optional node→operator-address bindings projection, reducing duplicated chain reads/loops when node-to-node pull-through is enabled.
Changes:
- Introduces
dht::capacity_bond_registryto perform onegetActiveNodesenumeration and run one watcher that demuxes events into both projections. - Updates runtime wiring to bootstrap the shared registry once and plumb
staker_setand (optionally)node_addressesfrom the returned handles. - Centralizes the previously copy-pasted
AbortOnDropwrapper intochain_events, removing duplicated definitions across watchers/services.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| crates/node/src/dht/capacity_bond_registry.rs | New shared CapacityBond bootstrap + watcher feeding both projections, with unit tests for event handling and hooks. |
| crates/node/src/runtime/mod.rs | Switches from per-projection bootstraps to shared registry bootstrap; sources staker set + optional node-address resolver from it. |
| crates/node/src/dht/chain_staker_set.rs | Converts to a projection-only façade built from shared parts; shares watcher lifetime via Arc<AbortOnDrop>. |
| crates/node/src/dht/node_address.rs | Converts to a projection-only façade built from shared parts; exposes internal binding mutation helpers for shared sink. |
| crates/node/src/dht/mod.rs | Exposes the new capacity_bond_registry module. |
| crates/node/src/chain_events/mod.rs | Adds a shared AbortOnDrop type used across chain watchers/services. |
| crates/node/src/slash_watcher.rs | Removes local AbortOnDrop copy; imports the shared one. |
| crates/node/src/reputation_indexer.rs | Removes local AbortOnDrop copy; imports the shared one. |
| crates/node/src/payment_settlement.rs | Removes local AbortOnDrop copy; imports the shared one. |
| crates/node/src/dht/chain_origin_directory.rs | Removes local AbortOnDrop copy; imports the shared one. |
| crates/node/src/buyer_channel.rs | Removes local AbortOnDrop copy; imports the shared one. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (11)
WalkthroughThe change centralizes watcher cancellation, merges CapacityBond staker and address tracking into one registry bootstrap and event loop, refactors projection modules, and updates runtime startup to consume the shared registry handles. ChangesCapacityBond registry integration
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Runtime
participant Registry
participant CapacityBond
participant Projections
Runtime->>Registry: bootstrap shared registry
Registry->>CapacityBond: getActiveNodes snapshot
Registry->>CapacityBond: start shared event watcher
CapacityBond-->>Registry: CapacityBond events
Registry->>Projections: update staker set and bindings
Registry-->>Runtime: return RegistryHandles
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 |
268954f to
7eb3cd4
Compare
36229e6 to
eb4bc58
Compare
7eb3cd4 to
3e51cc5
Compare
eb4bc58 to
fbf8074
Compare
…rm (#1110) Review on #1226 flagged `rpc_call_timeout: None` as an unbounded RPC and asked for `Some(Duration::from_secs(10))`. That premise is wrong: `timed` does `unwrap_or(DEFAULT_RPC_CALL_TIMEOUT)`, so `None` already IS 10s. The suggestion is a behavioural no-op that would hardcode the constant at the call site and diverge from `DEFAULT_RPC_CALL_TIMEOUT`, and 5 of 6 watchers pass `None` as the convention. But the rule behind it is right, and points at a real unbounded call the review missed 300 lines up: `ContractReads::node_id_of` did a bare `.nodeIdOf(op).call().await`. `WatcherConfig::rpc_call_timeout` covers only the loop's own `get_logs` — `timed`'s own doc says sink follow-ups stay unbounded unless the sink wraps itself. This matters more BECAUSE of the merge, and the regression is this PR's own: a stalled `nodeIdOf` used to wedge only the staker-set loop, since node-address ran its own; now one loop feeds both projections, so it wedges bindings too. Bound it here rather than defer, following the `blacklist_watcher::scope_check` precedent. A timeout surfaces as `Err`, which `on_operator_change` already counts via `staker_set_watcher_resolve_failure` and skips without tripping the stream backoff — the path `node_id_of_failure_bumps_resolve_failure_and_returns_ok` already covers. `timed` now takes `IntoFuture` rather than `Future`, so an alloy `.call()` (an `EthCall`, not a future) wraps directly instead of every caller spelling `.into_future()`. Every `Future` is an `IntoFuture`, so this is a strict widening and existing callers are untouched. `tokio::time::timeout` already accepted `IntoFuture` — the wrapper was what narrowed it. `timed`'s timeout arm had NO test, so the bound rested on untested code. Added three (paused clock, no wall-clock cost): a hanging call times out at the default and names itself, an explicit timeout wins over the default, and a prompt success passes through. fmt/clippy/doc clean; 809 node tests pass. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`struct AbortOnDrop(JoinHandle<()>)` plus its `Drop` impl was copy-pasted SEVEN times — slash, reputation-indexer, node-address, settlement, origin-directory, buyer-channel, and staker-set — all byte-identical. That made it read as though each watcher had its own teardown policy when they never differed. Pure move: one definition in `chain_events`, seven local copies deleted. No behavior change. Prepares the CapacityBond watcher merge, where two of those copies have to unify anyway. clippy/fmt clean; 795 node tests pass. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…tions (#1110) `ChainStakerSet` (membership) and `ChainNodeAddressDirectory` (node→address bindings) are both derived from the same CapacityBond contract, but each ran its own bootstrap and its own `eth_getLogs` loop against the same address — with node-address's two topics a strict SUBSET of staker-set's five. Two paginated `getActiveNodes` reads at boot, two poll loops forever after. Add `dht::capacity_bond_registry`: one enumeration, one loop, demuxing to both projections. Watchers drop 7 → 6 (6 → 6 in the default config, where pull-through is off — see below). `chain_staker_set` and `node_address` keep their facades, trait impls, projection helpers and all their existing tests; each loses its bootstrap/sink/hooks/pagination and gains `from_parts`. The correctness point that shapes the sink: only the ENUMERATION differs between the two views. The live arms are a clean union — `NodeRegistered` inserts into both unfiltered, because staker-set's live arm applies no `isActive` check either (its filter is bootstrap-only). Reading "staker-set is the filtered view" as a live-path difference and encoding it in the sink would drop registrations from the active set. - One sink with match arms, not a `Tee<A,B>`: `NodeRegistered` is the only shared topic and is the whole point — one `decode_log_data` feeds both. A tee decodes twice and needs `log.clone()` (`apply` takes `Log` by value). Follows the `ChainOriginDirectory` precedent (2 addresses x 7 topics, one sink). - `NodeAutoEjected` deactivates WITHOUT clearing the binding: ejection flips `isActive` only, and the operator may still be owed payment on an open channel. This is the most plausible silent bug in the merge and has a dedicated test. - Bindings are `Option`-gated on `node_to_node_pull_through_enabled`. The reason is metric semantics, not cost: building it unconditionally would publish `node_address_directory_size` on every default node, meaning "registered nodes" rather than "resolvable payout targets". - Both gauge families are kept, node-address's gated on the projection existing. They now describe one shared loop, so they are perfectly correlated — but freezing `node_address_watcher_down_seconds` at 0 forever would be an alert that can never fire, which is worse than deleting it. Retiring one is a follow-up. - `seed_cursor: Some(snapshot_block)` closes a latent gap both watchers had: events landing between the enumeration and the first tick's head read were missed. Head is read BEFORE the enumeration (the `ChainOriginDirectory` ordering) — the reverse would lose exactly the events being recovered. This matters more since #1221 made gossip announce ACCEPTANCE depend on live registry freshness. - `RegistryChainReads` makes the event handlers unit-testable without a provider: these two modules had ZERO tests before, and now have 11. Removing a non-fatal error path (deliberate, and unreachable): node-address bootstrap failure used to log-and-disable pull-through. `getActiveNodes` failure was ALREADY fatal — the unconditional staker-set bootstrap ran first and propagated it, so node-address's arm was never reached on that path. With the read shared, the bindings projection has no RPC of its own; it derives from page data already in hand and cannot fail independently. No node that boots today loses pull-through; none that boots today starts failing. fmt/clippy(--all-targets, incl. anvil-e2e)/doc clean; 806 node tests pass. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…rm (#1110) Review on #1226 flagged `rpc_call_timeout: None` as an unbounded RPC and asked for `Some(Duration::from_secs(10))`. That premise is wrong: `timed` does `unwrap_or(DEFAULT_RPC_CALL_TIMEOUT)`, so `None` already IS 10s. The suggestion is a behavioural no-op that would hardcode the constant at the call site and diverge from `DEFAULT_RPC_CALL_TIMEOUT`, and 5 of 6 watchers pass `None` as the convention. But the rule behind it is right, and points at a real unbounded call the review missed 300 lines up: `ContractReads::node_id_of` did a bare `.nodeIdOf(op).call().await`. `WatcherConfig::rpc_call_timeout` covers only the loop's own `get_logs` — `timed`'s own doc says sink follow-ups stay unbounded unless the sink wraps itself. This matters more BECAUSE of the merge, and the regression is this PR's own: a stalled `nodeIdOf` used to wedge only the staker-set loop, since node-address ran its own; now one loop feeds both projections, so it wedges bindings too. Bound it here rather than defer, following the `blacklist_watcher::scope_check` precedent. A timeout surfaces as `Err`, which `on_operator_change` already counts via `staker_set_watcher_resolve_failure` and skips without tripping the stream backoff — the path `node_id_of_failure_bumps_resolve_failure_and_returns_ok` already covers. `timed` now takes `IntoFuture` rather than `Future`, so an alloy `.call()` (an `EthCall`, not a future) wraps directly instead of every caller spelling `.into_future()`. Every `Future` is an `IntoFuture`, so this is a strict widening and existing callers are untouched. `tokio::time::timeout` already accepted `IntoFuture` — the wrapper was what narrowed it. `timed`'s timeout arm had NO test, so the bound rested on untested code. Added three (paused clock, no wall-clock cost): a hanging call times out at the default and names itself, an explicit timeout wins over the default, and a prompt success passes through. fmt/clippy/doc clean; 809 node tests pass. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
79fde77 to
5758ca6
Compare
Gas snapshotNo gas changes vs base. |
Contracts coverageLine coverage: 88.92% (2488/2798 lines) |
Coverage reportTotal: 80.96% (was 80.58%, ▲ +0.37%) — 48230/59576 lines
History
|
) 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]>
* refactor(node): retire StakerSet::subscribe_changes (#1231) `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]> * refactor(node): retire the node_address_watcher_* metric family (#1231) 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]> * docs(node): re-anchor the staker-set watcher metric docs post-#1226 (#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]> * refactor(node): split hooks() and close the established-leg test gap (#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]> * docs(node): correct four claims the #1231 cleanup left inaccurate (#1231) 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]> --------- Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Why
ChainStakerSet(membership) andChainNodeAddressDirectory(node→address bindings) are both derived from the same CapacityBond contract, but each ran its own bootstrap and its owneth_getLogsloop against the same address — with node-address's two topics a strict subset of staker-set's five. Two paginatedgetActiveNodesreads at boot, two poll loops forever after.dht::capacity_bond_registrydoes one enumeration and runs one loop, demuxing to both projections.Scope honesty:
node_addressis gated oncache.node_to_node_pull_through_enabled, which is off by default — so in the default config only one of these existed already and this saves nothing. The wins land when pull-through is on: one fewer poll loop and one fewergetActiveNodespagination.The correctness point that shapes the sink
Only the enumeration differs. The live arms are a clean union:
NodeRegisteredinserts into both projections unfiltered, because staker-set's live arm applies noisActivecheck either (chain_staker_set.rs:216-226— its filter is bootstrap-only). Reading "staker-set is the filtered view, node-address is the unfiltered one" as a live-path difference and encoding it in the sink would drop registrations from the active set. The module doc says so explicitly.At bootstrap they genuinely diverge:
activeappliesisActiveper entry;bindingsapplies no filter, because an operator mid-unbonding is momentarily inactive but still payable.Design
Tee<A,B>.NodeRegisteredis the only shared topic and is the whole point — onedecode_log_datafeeds both. A tee decodes twice and needslog.clone()(applytakesLogby value). Follows theChainOriginDirectoryprecedent.NodeAutoEjecteddeactivates without clearing the binding — ejection flipsisActiveonly, and the operator may still be owed payment on an open channel. The most plausible silent bug here; it has a dedicated test.Option-gated. The reason is metric semantics, not cost: building unconditionally would publishnode_address_directory_sizeon every default node meaning "registered nodes" rather than "resolvable payout targets".node_address_watcher_down_secondsat 0 forever is an alert that can never fire, which is worse than deleting it. Retiring one is a follow-up.seed_cursor: Some(snapshot_block)closes a latent gap both watchers had (events between the enumeration and the first tick's head read were missed). Head is read before the enumeration — the reverse loses exactly the events being recovered. This matters more since fix(gossip,node): enforce rule-2 staked-node check against the live registry (#1170) #1221 made gossip announce acceptance depend on live registry freshness.RegistryChainReadsmakes the event handlers unit-testable without a provider. These modules had zero tests; they now have 11.Node-address bootstrap failure used to log-and-disable pull-through. But
getActiveNodesfailure was already fatal: the unconditional staker-set bootstrap ran first and propagated it, so node-address's arm was never reached on that path. With the read shared, the bindings projection has no RPC of its own — it derives from page data already in hand and cannot fail independently. No node that boots today loses pull-through; none that boots today starts failing.Verification
fmt/clippy --all-targets(incl.anvil-e2e) /docclean; 806 node tests pass (795 → 806). The 11 new tests includenode_auto_ejected_deactivates_but_keeps_the_binding,node_registered_with_bindings_off_updates_only_the_staker_set,node_id_of_failure_bumps_resolve_failure_and_returns_ok, and both composed-hook cases. Every pre-existing test in the two stripped modules is untouched — if any had needed editing, the split went wrong.Also included: a preparatory commit hoisting
AbortOnDropintochain_events. It was copy-pasted seven times, byte-identical; the merge forces two copies to unify anyway.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Reliability