Repository navigation
chore: tech-debt batch — watcher comment rot, publish CLI dedup, watcher-module boundary (#1111, #1080, #1092) - #1137
Conversation
PR #1110 replaced the per-watcher eth_newFilter subscription loops with the shared resumable_watcher eth_getLogs poller, but several doc comments in adjacent files still described the deleted machinery (run_watcher_once, watcher_loop, "resubscribe", "filter expiry", "event stream errored"). Reword them to the poll-tick / backoff vocabulary of resumable_watcher (run, run_tick, on_established, on_backoff, idle tick, window re-scan) and point the metric docs at the hooks that now drive them. Also covers four adjacent "event stream" rot sites surfaced alongside the ones the issue enumerated. Doc-only — no behavior change. Closes #1111 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…leton (#1080) Two duplications flagged non-blocking in the #1074 review, captured so they can't drift: 1. Chain-coordinate resolution. The rpc_url/chain_id/data_dir/keystore flag>config>default precedence was inlined in both `resolve` (node) and `resolve_publish` (publish). Extract a shared `CommonChainArgs` `#[command(flatten)]` struct embedded by both `ChainArgs` and `PublishChainArgs`, and route `resolve_publish` through the existing `resolve_common` helper (already shared by `resolve`/`resolve_appeal`), so the precedence lives in exactly one place. The only user-visible change is `--capacity-bond-address` now sorting after the common flag group in `node`'s --help; all flags and behavior are unchanged. 2. Submit skeleton. `namespace_create`, `claim`, and `assign` each repeated the preflight -> load-signer -> build-provider preamble. Factor it into `signer_and_provider` (returning owned signer+provider — build_provider is `+ use<>`, so the provider clones the signer and borrows nothing), and add `assignment_ctx` parallel to the existing `registry_ctx` so `assign` no longer inlines the resolve+parse-address block. No behavior change; verified by the existing resolver/format unit tests (678 pass) and dry-run runs of all three publish subcommands. Closes #1080 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The abstraction #1092 asked for already exists: PR #1110/#1106/#1108 built `resumable_watcher` and migrated ALL seven on-chain watchers (settlement, slash, blacklist, reputation_indexer, and the three DHT watchers) onto it. There are no hand-rolled resubscribe/backfill/backoff loops left, and the 9k-vs-10k span drift the issue cites is already gone. What remained was the module boundary, which this finishes: - Relocate the windowing/reorg primitives (`backfill_windows`, `check_backfill_range`, `MAX_BACKFILL_BLOCK_SPAN`, `REORG_MARGIN_BLOCKS`) and their window-math tests out of `payment_settlement` into a new `chain_events::backfill`. This removes `resumable_watcher`'s upward dependency into `payment_settlement` (flagged "for now" in its imports) — chain_events no longer reaches up into a consumer. - Unify the per-watcher backoff constants. Six files each defined their own `WATCHER_INITIAL_BACKOFF`/`WATCHER_MAX_BACKOFF` (or `INITIAL_BACKOFF`/ `MAX_BACKOFF`) with identical 1s/1min values; they now share `chain_events::{WATCHER_INITIAL_BACKOFF, WATCHER_MAX_BACKOFF}`. The slash watcher's deliberate 30s ceiling is preserved as an explicit, documented local override (a missed `Slashed` burns the operator's 30-day appeal window), as is blacklist's `rpc_call_timeout`. No behavior change. Verified: 2215/2215 workspace tests pass, clippy clean, and the relocated window-math tests now run as `chain_events::backfill::tests`. Closes #1092 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Warning Review limit reached
Next review available in: 34 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 (7)
WalkthroughThe change centralizes shared chain CLI options under ChangesCLI common argument integration
Chain-events watcher infrastructure
Estimated code review effort: 4 (Complex) | ~45 minutes 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.71% (2452/2764 lines) |
There was a problem hiding this comment.
Code Review
This pull request refactors the codebase to eliminate logic drift across CLI commands and blockchain watchers. It introduces a unified CommonChainArgs struct to consolidate shared blockchain coordinates and keys across all on-chain CLI commands. Additionally, it centralizes watcher windowing, reorg-margin primitives, and default exponential backoff constants into a new chain_events::backfill module, updating all corresponding watchers to utilize these shared components. I have no further feedback to provide as there are no review comments.
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.
There was a problem hiding this comment.
Pull request overview
Tech-debt batch that (1) updates watcher-adjacent docs to match the post-#1110 eth_getLogs poll-tick model, (2) deduplicates CLI chain-coordinate resolution and publish submission preamble, and (3) finishes the chain_events module boundary by moving shared backfill/reorg primitives + backoff constants into chain_events so watcher consumers can’t drift.
Changes:
- Reworded metrics / wiring / handler docs away from subscription-era terminology (“resubscribe”, “event stream ended”) to poll-tick/backoff semantics.
- Introduced
CommonChainArgs(flattened) and routedpublishchain resolution through the shared resolver; factoredpublishsubmit preamble intosigner_and_provider. - Moved
MAX_BACKFILL_BLOCK_SPAN,REORG_MARGIN_BLOCKS, and window-math helpers intochain_events::backfill, and centralized default watcher backoff constants inchain_events.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/node/src/slash_watcher.rs | Uses shared backfill/reorg/backoff constants; documents the slash watcher’s deliberate backoff-cap override. |
| crates/node/src/reputation_wiring.rs | Updates doc wording to poll-tick/backoff + downtime-gap semantics. |
| crates/node/src/reputation_indexer.rs | Removes duplicated backoff constants and imports shared watcher constants. |
| crates/node/src/payment_settlement.rs | Switches to shared chain_events backfill primitives/constants; removes local copies + migrates tests. |
| crates/node/src/metrics.rs | Updates watcher-metric docs to reference poll-tick hooks and resumable_watcher behavior. |
| crates/node/src/handlers/client.rs | Updates idempotency docs to reference poll-tick re-scans instead of resubscribe. |
| crates/node/src/dht/node_address.rs | Imports shared backoff and backfill span constants (removes duplicated backoff consts). |
| crates/node/src/dht/chain_staker_set.rs | Imports shared backoff and backfill span constants (removes duplicated backoff consts). |
| crates/node/src/dht/chain_origin_directory.rs | Imports shared backfill/reorg/backoff constants (removes duplicated backoff consts). |
| crates/node/src/chain_events/resumable_watcher.rs | Removes dependency on payment_settlement for windowing; uses chain_events backfill helpers. |
| crates/node/src/chain_events/mod.rs | Exposes backfill module + shared backoff constants for watchers. |
| crates/node/src/chain_events/backfill.rs | New shared home for windowing + reorg-margin primitives and their unit tests. |
| crates/node/src/buyer_channel.rs | Repoints reconciliation scan to shared chain_events backfill helpers/constants. |
| crates/node/src/blacklist_watcher.rs | Uses shared backfill/reorg/backoff constants; keeps watcher-specific RPC timeout. |
| crates/common/src/cli/publish.rs | Switches PublishChainArgs to embed flattened CommonChainArgs. |
| crates/common/src/cli/node.rs | Switches ChainArgs to embed flattened CommonChainArgs. |
| crates/common/src/cli/mod.rs | Re-exports CommonChainArgs via the CLI module surface. |
| crates/common/src/cli/common.rs | Adds CommonChainArgs definition and documentation for shared chain-coordinate flags. |
| crates/cli/src/commands/setup.rs | Updates field access for config/dry-run/json/password-file via chain.common.*. |
| crates/cli/src/commands/register.rs | Updates field access for config/dry-run/json via chain.common.*. |
| crates/cli/src/commands/publish.rs | Dedups publish submit preamble (signer_and_provider) and adds assignment_ctx; updates to chain.common.*. |
| crates/cli/src/commands/chain_ctx.rs | Routes publish resolution through shared resolve_common(&CommonChainArgs, ...); updates tests accordingly. |
| crates/cli/src/commands/bond.rs | Updates field access for config/dry-run/json via chain.common.*. |
| crates/cli/src/commands/appeal.rs | Updates field access for config/dry-run/json via chain.common.*. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage reportTotal: 80.25% (was 80.23%, ▲ +0.02%) — 45181/56300 lines
History
|
The #1111 reword grafted the new poll-tick clause onto the old parenthetical, leaving a double parenthesis — "backoff path (`on_backoff`) (a resolution failure ...)" — and a 95-char line. Rewrap: the trailing parenthetical becomes a colon clause, and the "A sustained nonzero rate ... means ..." sentence is kept intact. Doc-only. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…r test gap Multi-agent review findings on #1137. Four of the comments this PR itself wrote were factually wrong — verified each against the code before fixing. Wrong docs (all introduced or carried forward by this PR): - chain_events/backfill.rs module doc claimed an "earlier 9k-vs-10k span split between the slash and settlement watchers" that this module "prevents". Both halves are false. Git history (f28b994, #651) shows the 9k came from the origin directory, never slash_watcher; and REPLAY_WINDOW_BLOCKS = 9_000 is STILL live at chain_origin_directory.rs:127, driving a hand-rolled window walk that bypasses backfill_windows. The claim was taken from issue #1092's text without checking. Now names the real pair and records the divergence as a known, still-open follow-up rather than pretending it is fixed. - REORG_MARGIN_BLOCKS doc cited slash_watcher as the sharing rationale, but reorg_margin is read only by CursorPolicy::Persisted; slash_watcher is HeadMinusWindow, so the margin is inert there. Now cites the two watchers that actually rewind (settlement, origin directory). - metrics.rs watcher_persist_failure said the failure is "swallowed" and pairs with "per-site warn!s in SettlementSink::apply". Three of the four arms return Err (failing the tick); only forget_channel swallows, and it has the sole warn site. Both the field doc and the method doc now describe the real per-arm recovery. - metrics.rs staker_set_watcher_restarts said the loop-level warn is "reached via on_backoff", inverting the relationship: the warn is unconditional in the Err arm; the hook is what bumps the counter. Also: buyer_channel doc still pointed at payment_settlement for the window helpers this PR moved; the shared --chain-id help promised an RPC-mismatch check that only publish/setup perform, and dropped the "default Arbitrum Sepolia" hint; slash_watcher's local WATCHER_MAX_BACKOFF is renamed SLASH_MAX_BACKOFF so the deliberate 30s override is obvious at the WatcherConfig site rather than reading as if it came from the shared constant. Test gap (a real hole this PR's refactor opened): resolve_common returns (String, u64, PathBuf, PathBuf) — data_dir and keystore are the same type, so transposing them at resolve_publish's destructure compiles silently. No test asserted ResolvedPublish's data_dir/keystore, so that bug would have shipped green and handed the data dir to the keystore loader on every `decdn publish` submit. Verified by injecting the swap: it compiled, the node-path test still passed, and only the new tests caught it. Adds resolve_publish_{keystore_defaults_under_data_dir,config_fills_unset_flags, missing_rpc_url_errors} (bringing publish to parity with the node resolver) and a Cli::command().debug_assert() test — clap builds subcommands lazily, so a duplicate arg id from the new shared flatten struct would otherwise panic at runtime rather than fail CI. 2219/2219 pass; clippy + cargo doc clean. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The backfill module doc flagged the origin directory's hand-rolled genesis replay as "a follow-up" with no tracking issue. Point it at #1139, and record that its 9k span is a deliberate margin under the provider 10k eth_getLogs cap (not drift) so the next reader doesn't "fix" the divergence by unifying the value — the defect is the duplicated loop, not the constant. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Multi-agent review pass — findings + fixesRan five specialized reviewers over the diff (code quality, comment accuracy, silent failures, type design, test coverage). Three of them independently confirmed no behavior change — byte-diffing the moved code, checking The real findings were in this PR's own comments, and one test gap. Wrong comments this PR introduced (fixed in c35ac67)The irony is not lost — a comment-rot PR that wrote four wrong comments. Each verified against the code before fixing:
Also: the Test gap this PR's refactor opened (closed in c35ac67)
I confirmed this was real, not theoretical, by injecting the swap: it compiled clean and the full suite passed, because the node-path test ( Added 2219/2219 pass (was 2215); clippy + Deferred to follow-upsKept out of this PR because they'd break its zero-behavior-change contract:
|
Batch of three low-risk tech-debt cleanups. One commit per issue; no behavior change in any of them.
Commits
1.
docs(node): reword watcher comments to the poll-tick vocabulary (#1111)PR #1110 replaced the per-watcher
eth_newFiltersubscription loops with the sharedresumable_watchereth_getLogspoller, but doc comments in adjacent files still described the deleted machinery (run_watcher_once,watcher_loop, "resubscribe", "filter expiry", "event stream errored").Reworded to the poll-tick/backoff vocabulary (
run,run_tick,on_established,on_backoff, idle tick, window re-scan) and pointed the metric docs at the hooks that now drive them. Also covers four adjacent "event stream" rot sites found alongside the ones the issue enumerated. Doc-only — every changed line is a///or//!.2.
refactor(cli): dedup publish chain-coordinate resolution + submit skeleton (#1080)resolve(node) andresolve_publish(publish) — the drift risk the issue calls out. Extracted a sharedCommonChainArgs#[command(flatten)]struct embedded by bothChainArgsandPublishChainArgs, and routedresolve_publishthrough the existingresolve_commonhelper (already shared byresolve/resolve_appeal). Precedence now lives in exactly one place.namespace_create,claim, andassigneach repeated the preflight → load-signer → build-provider preamble. Factored intosigner_and_provider, plus anassignment_ctxparallel to the existingregistry_ctxsoassignno longer inlines the resolve+parse-address block.The one user-visible change:
--capacity-bond-addressnow sorts after the common flag group indecdn node's--help. All flags and behavior are otherwise unchanged.3.
refactor(node): finish generalizing the watcher module (#1092)The issue is largely already delivered. PR #1110/#1106/#1108 built
resumable_watcherand migrated all seven on-chain watchers onto it — there are no hand-rolled resubscribe/backfill/backoff loops left, and the 9k-vs-10k span drift the issue cites is already gone. What remained was the module boundary:backfill_windows,check_backfill_range,MAX_BACKFILL_BLOCK_SPAN,REORG_MARGIN_BLOCKS) and their tests out ofpayment_settlementinto a newchain_events::backfill, removingresumable_watcher's upward dependency into a consumer.rpc_call_timeout.Verification
cargo nextest run— 2215/2215 passcargo clippy --all-targets— clean workspace-widecargo fmt --check,cargo doc,cargo deny— clean (all pre-commit hooks green on each commit)chain_events::backfill::testsdecdn node register --help/publish {namespace create,claim,assign} --help— all flags presentpublishsubcommands exercising both flag precedence and config fallbackCloses #1111
Closes #1080
Closes #1092
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Documentation