Skip to content

Periodically expire idle eth filters on a TTL #7265

Description

@akaladarshi

Summary

EthFilters created via eth_newFilter, eth_newBlockFilter, and eth_newPendingTransactionFilter are never cleaned up. They live until the user calls eth_uninstallFilter or the node restarts. Clients routinely abandon filters (poll a few times, disconnect, never uninstall), so abandoned filters accumulate and hold resources indefinitely.

Lotus also expire idle filters on a TTL, we don't.

Completion Criteria

We should add a periodic sweep that removes filters inactive for longer than a configurable timeout.

  • Track per-filter activity: Record a last_used timestamp per filter, bumped whenever the filter is polled (eth_getFilterChanges / eth_getFilterLogs), updated under the store lock so the sweep can't evict a filter that was just polled.
  • Periodic GC sweep: A background task in the EthEventHandler that wakes every sweep_interval and uninstalls every filter longer than TTL,
  • Applies to all filter types (event / block / pending-transaction).
  1. ConfigEventsConfig / env vars
    • Configurable TTL (default ~5 min, matching geth) and sweep interval (e.g. 60s).

Additional Links & Resources

  • Lotus expires filters via a lastTaken timestamp + a periodic sweep

Metadata

Metadata

Assignees

Labels

Type: TaskDiscrete task to implement

Type

Fields

No fields configured for Task.

Projects

Status
Ready

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions