Skip to content

node floods anvil with eth_getFilterChanges (250ms local poll × ~20 watch filters) #1011

Closed

Description

@thiras

Summary

Against a localhost anvil, a decdn-node issues ~80 eth_getFilterChanges/sec in steady state — almost all returning empty. This is environmental (it does not reproduce against the live Arbitrum Sepolia testnet), but it floods the local dev RPC and the node logs.

Root cause

Two factors compound:

1. anvil is auto-detected as "local", forcing a 250 ms filter poll interval. Every provider is built bare:

// crates/node/src/runtime/mod.rs:676 (and ~6 other sites)
let chain_provider = ProviderBuilder::new().connect_http(rpc_url.clone());

connect_http runs guess_local(); for 127.0.0.1/localhost it returns true, and alloy hard-codes the filter poll interval:

// alloy-rpc-client-2.1.0/src/client.rs:233
poll_interval: if is_local { AtomicU64::new(250) } else { AtomicU64::new(7000) },

So each filter polls every 250 ms (4×/sec) on anvil; against the real testnet (is_local == false) the same code polls every 7 s, which is why this never shows up in production.

2. A node holds ~20 long-lived .watch() log filters concurrently, each running its own FilterPollerBuilder that issues one eth_getFilterChanges per tick:

Watcher Filters
dht/chain_origin_directory.rs 7
dht/chain_staker_set.rs 5
payment_settlement.rs 4
dht/node_address.rs 2
reputation_indexer.rs 2

~20 filters × 4 polls/sec ≈ 80 eth_getFilterChanges/sec. (Transient watch_pending_transaction confirmations during settlement and the block heartbeat poller add a bit more.) The watcher logic itself is correct — this is purely the poll-interval default × filter count.

Proposed fixes (do in order; 1 and 3 are complementary)

1. Minimal / surgical — set the poll interval explicitly

Add a small helper in runtime/mod.rs that builds providers and calls provider.client().set_poll_interval(...) with a sane fixed value (~1 s) instead of inheriting alloy's 250 ms local default. Route the ~7 provider-construction sites through it. Cuts the local rate ~4× with zero behavior change on the live testnet. Add a focused test asserting the configured interval is applied.

2. Config-driven interval

Promote the helper's value to a blockchain.event_poll_interval_ms config knob (default preserves current testnet behavior). Per the config-knob convention this touches ~5 sites (struct, resolver, config validate summary, DEFAULT_CONFIG template, docs), so it is split out from (1).

3. Structural — one filter per contract

Collapse the per-event filters into a single multi-topic Filter per contract (event_signature OR-set) and demux by topic0. Turns ~20 filters into ~5, independent of poll interval — the largest reduction and the only one that also helps on the real testnet. Larger change; do after (1).

Acceptance

  • (1) Providers use an explicit poll interval; eth_getFilterChanges rate against anvil drops ~4×; test added.
  • (2) Interval is configurable via blockchain.event_poll_interval_ms.
  • (3) Per-contract event filters consolidated; total live filter count materially reduced.

Activity

  1. added
    kind:bug
    rust
    on Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind:bugrust

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions