Skip to content

fix(node): shrink the eth_getLogs window on provider range caps; alert on never-ticked watchers - #2152

Merged
thiras merged 5 commits into
mainfrom
fix/getlogs-range-shrink
Sep 25, 2026
Merged

thiras merged 5 commits into
mainfrom
fix/getlogs-range-shrink

Conversation

@thiras

@thiras thiras commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

What

After the testnet RPC moved to dRPC's free tier, every chain watcher on all 7 nodes (blacklist, slash, staker_set, settlement, fee_shares) went blind, and nothing alerted.

  • Poller. Every eth_getLogs failed with code 35: ranges over 10000 blocks are not supported on free plan; the real cap is about 100–178 blocks. The multiplexed poller scanned [cursor, head] in fixed 10 000-block windows and never looked at the error. The cursor held, and each backoff retry asked for a wider range, so it never recovered.
  • Monitoring. Every *WatcherStalled rule and every watcher-tick panel filters last_tick > 0. A watcher that never ticked reads 0, so it was invisible. *_watcher_down_seconds was climbing, but no rule reads it.

Poller fix (crates/node/src/chain_events/multiplexed_poller.rs)

  • run_tick walks the range one window at a time with a per-poller span.
  • When a JSON-RPC error message names a range or result limit (the rule is in is_range_rejection), the poller halves the attempted window and retries at once. The smaller span holds for the process lifetime.
  • Timeouts, rate limits, "out of range" (a lagging backend) and every other error keep the backoff path, so a transient fault can't shrink the span.
  • A rejected one-block window fails the tick instead of looping.

New knob: blockchain.get_logs_max_block_span (default 10 000, must be > 0) sets the starting span. It appears in config validate and in the default template.

Monitoring fix

  • The five *WatcherStalled rules gain an or decdn_<watcher>_watcher_down_seconds > 180 arm. down_seconds counts from the first failed tick, and it stays 0 for an unregistered fee_shares route.
  • "Oldest watcher tick", "Watcher tick age" and "Settlement watcher freshness" now show a failing watcher that never ticked by its down_seconds, instead of dropping it.
  • The ADR appendix alert row and the runbook RPC section are updated to match.

Reviewer notes

  • Read is_range_rejection and the while start <= to loop in run_tick first.
  • Why match on the message and not the error code: providers disagree on codes (dRPC 35, Alchemy -32600, Infura -32005, QuickNode -32614), and the shrink is sticky. A generic "any non-rate-limit error" rule would let one transient -32000 pin the span at 1.
  • No regrow, on purpose: at the default 7 s poll interval, a live-tail window is about 30 blocks, so a shrunk span only costs extra backfill calls.
  • backfill_windows is replaced by a one-window window_end, because the span can change between windows. MAX_BACKFILL_BLOCK_SPAN moves to decdn_common::config::DEFAULT_GET_LOGS_MAX_BLOCK_SPAN.
  • The live Grafana Cloud rules and dashboards are not synced from the repo. They need republishing after merge.

Verification

  • cargo fmt -- --check, cargo clippy --workspace --all-targets --all-features -- -D warnings, and RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items are all clean.

  • cargo nextest run --workspace: 3960/3960 passed. This includes new poller tests:

    • A wiremock provider capped at 150 blocks, with a 1 651-block gap: one tick completes, the accepted windows are contiguous and cover the gap, and tick 2 sends no rejected request.
    • An Alchemy -32600 rejection halves the window and the tick completes; a 429 and a one-block rejection both take the backoff path.
    • is_range_rejection over the dRPC, Alchemy, Infura, QuickNode, rate-limit, out-of-range and transport cases.
    • Resolver tests for the knob.
  • Ran the new alert expression against live Grafana Cloud data during the current outage: it fires for all 7 nodes, where the old rules were silent. The new panel expression returns every watcher with its down_seconds (about 1 600 s).

  • pre-commit run passes.

  • cargo fmt -- --check

  • cargo clippy --workspace --all-targets --all-features -- -D warnings

  • cargo nextest run

  • User-visible change: CHANGELOG.md entry added

  • PR title uses an allowed type, lowercase subject

🤖 Generated with Claude Code

…t on never-ticked watchers

The chain-event poller scanned [cursor, head] in fixed 10 000-block
windows and never read the error. A provider with a lower range cap
(dRPC free tier ~150 blocks, Alchemy free tier 10) rejected every
window; the cursor held and each backoff retry asked for a wider range,
so all five chain watchers stayed blind until restart.

- run_tick walks windows with a per-poller span. A JSON-RPC error whose
  message names a range or result limit halves the attempted window and
  retries at once; the smaller span holds for the process lifetime.
  Timeouts, rate limits and other errors keep the backoff path.
- blockchain.get_logs_max_block_span (default 10 000, > 0) sets the
  starting span; surfaced in config validate and the default template.
- The five *WatcherStalled alerts gain a
  decdn_<watcher>_watcher_down_seconds > 180 arm: the tick arm's > 0
  guard hid a watcher that never ticked. The three watcher-tick panels
  show such a watcher by its down-seconds instead of dropping it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Copilot AI lite review requested due to automatic review settings September 25, 2026 01:14
@thiras thiras self-assigned this Sep 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Two moderate poller findings remain unresolved, along with one documentation nit.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Improves chain-watcher recovery from capped eth_getLogs ranges and makes never-ticked watchers observable.

Changes:

  • Adds adaptive range shrinking and configurable starting spans.
  • Updates watcher alerts and dashboards to include downtime.
  • Updates configuration, tests, runbook, ADR, and changelog.
File Summary Review notes
monitoring/​prometheus-alerts.yml Adds downtime-based stalled-watcher alerts. —
monitoring/​grafana-dashboard.json Updates fleet watcher-age panels. —
monitoring/​dashboard-chain.json Updates watcher freshness panels. —
docs/​runbook.md Documents capped-provider diagnosis. Nit (1 vote): Correct the listed alert names and include DecdnFeeSharesWatcherStalled.
crates/​node/​tests/​sighup_signal.rs Updates test configuration. —
crates/​node/​tests/​anvil_bringup_shutdown_e2e.rs Updates E2E configuration. —
crates/​node/​src/​runtime/​reload.rs Updates reload test configuration. —
crates/​node/​src/​runtime/​mod.rs Wires the configured polling span. —
crates/​node/​src/​chain_events/​resumable_watcher.rs Updates watcher scanning documentation. —
crates/​node/​src/​chain_events/​multiplexed_poller.rs Implements adaptive polling and coverage. Moderate (2 votes): Avoid overflow when halving a span covering [0, u64::MAX]. Moderate (1 vote): Narrow results matching to result-limit-specific wording.
crates/​node/​src/​chain_events/​mod.rs Updates chain-event exports. —
crates/​node/​src/​chain_events/​backfill.rs Replaces fixed window generation. —
crates/​common/​src/​config/​types.rs Adds the configuration-file option. —
crates/​common/​src/​config/​resolved.rs Adds the resolved setting. —
crates/​common/​src/​config/​mod.rs Resolves, validates, and tests the setting. —
crates/​cli/​tests/​config_validate.rs Updates validation fixtures. —
crates/​cli/​src/​commands/​config.rs Exposes the setting in validation and templates. —
CHANGELOG.md Documents the fixes and new option. —
adr/​appendix-observability.md Updates watcher alert guidance. —

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-code-quality

github-code-quality Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit f04c411 in the fix/getlogs-range-sh... branch remains at 85%, unchanged from commit 1bedff5 in the main branch.

Show a line coverage summary of the most impacted files.
File main 1bedff5 fix/getlogs-range-sh... f04c411 +/-
crates/node/src...s/client/mod.rs 96% 95% -1%
crates/incentiv...eth_identity.rs 99% 98% -1%
crates/node/src/runtime/mod.rs 49% 49% 0%
crates/node/src...gin/pull_leg.rs 89% 89% 0%
crates/client/src/scheduler.rs 95% 95% 0%
crates/cache/src/engine.rs 94% 94% 0%
crates/node/src/metrics.rs 96% 96% 0%
crates/node/src...ntime/reload.rs 97% 97% 0%
crates/node/src...nts/backfill.rs 98% 99% +1%
crates/node/src...lexed_poller.rs 90% 92% +2%

Updated September 25, 2026 02:25 UTC

- halved_span computes half a rejected window from end - start, so a
  window spanning all of u64 cannot overflow.
- A "results" message counts as a range rejection only with a limit
  word (more than / exceed / max / limit / too many).
- Runbook: list the five stalled alerts that exist.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@thiras

thiras commented Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

Other overview items, fixed in 4af7395:

  • results matching: a message containing "results" now counts as a range rejection only if it also contains "more than", "exceed", "max", "limit" or "too many". Covered by tests for the Infura and geth result-cap messages, plus a negative case ("failed to marshal results").
  • Runbook alert list: it now lists the five stalled alerts that exist, adding DecdnFeeSharesWatcherStalled and dropping the nonexistent DecdnOriginDirectoryWatcherStalled and the rate_bounds gauge.

thiras and others added 2 commits September 25, 2026 04:35
Review follow-ups for the range-cap shrink:

- is_range_rejection now needs range/results wording AND a limit word
  (limit, max, exceed, up to, over, more than, too many/wide/large, not
  supported). Head-lag errors such as "block range extends beyond
  current head block" no longer shrink the sticky span.
- A rejected one-block window fails with context saying the provider
  cannot serve the chain watchers.
- Test: a result cap on a later window retries from that window's start;
  each log is applied exactly once.
- Docs: the runbook leads with the shrink warn! and says to configure the
  logged span, not the provider's quoted limit; stalled-alert
  descriptions cover failing ticks; ADR watcher-liveness text names all
  five watchers and multiplexed_poller; span docs say "half the rejected
  window"; stale watcher counts and panel names fixed.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…flapping watchers

Review follow-ups that were deferred from the range-cap shrink:

- WindowSpan (chain_events/backfill.rs) owns the learned span: halve on a
  rejection, double after 32 accepted full windows up to the ceiling. A
  transient or misclassified rejection no longer costs throughput until
  restart. Shrinks to a new low log at warn; the regrow/re-shrink cycle
  against a known cap logs at debug.
- decdn_chain_get_logs_span and decdn_chain_get_logs_range_rejections_total,
  wired through poller-level hooks; plotted on the chain dashboard.
- DecdnChainWatcherFlapping: >= 5 drift windows in 30 m for 15 m on any
  watcher's restarts_total. Each recovery resets the stalled alerts, so a
  watcher failing on and off lagged head unseen (hil1: 8-17 windows per
  30 m for ~8 h; healthy nodes 0-2).
- runtime::chain_poller_builder carries the config-driven poller settings;
  a unit test pins that get_logs_max_block_span reaches the poller.
- ADR registry rows and flapping alert row, runbook, CHANGELOG.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@thiras

thiras commented Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

Follow-ups from the multi-agent review, all in 1720644:

  • The span grows back. WindowSpan halves the span on a rejection and doubles it after 32 accepted full windows in a row, up to the configured ceiling, so a transient or misclassified rejection no longer costs throughput until restart. A shrink to a new low logs at warn!; the shrink-and-regrow cycle against a known cap logs at debug!.
  • Span metrics. decdn_chain_get_logs_span (gauge) and decdn_chain_get_logs_range_rejections_total (counter), wired through poller-level hooks. The chain dashboard gains an "eth_getLogs window span" panel.
  • Flapping alert. DecdnChainWatcherFlapping fires on 5 or more drift windows in 30 minutes, sustained for 15 minutes. Checked against 3 days of Grafana Cloud data: it fires for the whole of hil1's Alchemy incident (8–17 windows per 30 minutes for about 8 hours), which neither stalled-alert arm caught, and fires once, at the same moment, on fra1, hel1 and nbg1.
  • Wiring test. runtime::chain_poller_builder now builds the poller from config, and chain_poller_builder_uses_the_configured_get_logs_span checks that the configured span reaches it.
  • Docs. ADR registry rows plus a flapping alert row (the restart-counter note now allows this one use), runbook guidance, and CHANGELOG.

3969/3969 tests pass. Clippy (--all-features), rustdoc and pre-commit are clean.

Second review round on the span follow-ups:

- WindowSpan counts every accepted window toward the regrow, the short
  live-tail ones too. A caught-up node now climbs back to the ceiling
  after a transient rejection instead of parking the span (and the gauge)
  far below it for good. A real cap shows as rejections that keep coming.
- shrink never goes above the current span; the ceiling is a NonZeroU64
  (one validation point in build()); shrink/record_success are
  #[must_use]; the result is a named Shrunk { span, rejected_probe }.
- Log level follows the probe, not an all-time minimum: warn on any
  shrink except a rejected regrow probe, so a later real cap above an old
  transient low is still logged at warn.
- DecdnChainWatcherFlapping uses increase() over a label_replace subquery
  (a daemon restart no longer clears it), folds the five watchers into one
  alert per node, and needs >= 4 windows per 30 m held for 45 m, so a
  single burst cannot fire it. Checked on 3 days of fleet data.
- Tests: metric wiring through chain_poller_builder, run()'s starting
  span, one-block rejection counted, re-rejection after a regrow, and a
  gate pinning what the flapping rule's name pattern matches.
- Docs: the rejection counter, not the gauge, is the cap signal; ADR note
  heading, poison note, runbook, dashboard legend calcs, CHANGELOG.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@thiras

thiras commented Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

Second review round (code, tests, comments, silent failures, type design), fixed in f04c411:

  • Every accepted window counts toward the regrow. Short live-tail windows used to be skipped, so after one transient rejection the span, and the gauge, stayed about 180× below the ceiling. The docs meanwhile told operators to set the ceiling to it. A caught-up node now climbs back to the ceiling; the documented cap signal is rejections that keep coming.
  • The flapping rule survives daemon restarts. The old x - x offset 30m form read negative after a restart, and live data shows it cleared hil1's pending alert at its 15-minute mark. It is now increase() over a label_replace subquery, folded to one alert per node (the watchers share one poller). It needs 4 or more windows per 30 minutes held for 45 minutes: the old for: 15m could not absorb a burst, and a 4-minute fleet blip would have raised 15 alerts. Rechecked on 3 days of data: it fires only on hil1, continuously through the incident.
  • Log level. A shrink warns unless it is a rejected regrow probe. The old all-time-minimum check could leave a later real cap at debug! after an early transient.
  • WindowSpan. shrink is clamped to the current span, the ceiling is a NonZeroU64, both methods are #[must_use], and the shrink result is a named Shrunk.
  • Tests.
    • The metrics are exercised end to end through chain_poller_builder.
    • run() reports the starting span.
    • A one-block rejection is counted.
    • A regrown span that is rejected again reports correctly.
    • A gate pins the five counters the flapping rule's name pattern matches.

3972/3972 tests pass. Clippy (--all-features, plus the anvil-e2e targets), rustdoc and pre-commit are clean.

@thiras
thiras merged commit 3ebf5f1 into main Sep 25, 2026
30 checks passed
@thiras
thiras deleted the fix/getlogs-range-shrink branch September 25, 2026 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants