Repository navigation
feat(evm-processor): filterLogsOnNode RPC ingestion setting - #702
Merged
Merged
Conversation
Without a gateway, the RPC data source fetches every finalized block
(eth_getBlockByNumber) and all its logs (unfiltered eth_getLogs per 10
blocks), then filters logs locally. The number of calls grows with the
block range, not with the number of matching logs.
`setRpcDataIngestionSettings({filterLogsOnNode: {blockRange}})` lets
ranges whose requests select blocks by logs only be fetched with
eth_getLogs filtered by address and topics, over splits of `blockRange`
blocks. Only blocks with matching logs are fetched, plus the last block
of each split for the processor's progress. Log relations work: the
transaction comes with the block, receipts/traces/state diffs are
fetched per matching block, and `transactionLogs` gets all logs of
matching blocks. Ranges with other requests or includeAllBlocks, and
hot blocks, are ingested as before.
The logs bloom check cannot work on filtered results, so a node that
misses logs goes unnoticed; the setting documents this. Logs whose
blockHash differs from the fetched block are retried, then rejected.
eth_getLogs also splits ranges on common provider block-range limit
errors and follows Alchemy's suggested range, in both modes.
Tests pin the current cold ingestion (every block fetched, unfiltered
eth_getLogs, local filtering, bloom check) and eth_getLogs splitting,
and cover the new mode.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Transaction-log refetches can accept logs from the wrong fork without retry, while oversized unfiltered batches increase memory usage and delay checkpoints.
2 open issues
What changed in this PR
Adds optional node-side log filtering to speed up finalized EVM ingestion without a gateway.
Changes:
- Fetches matching logs and their blocks, plus a progress header.
- Handles provider range limits while preserving filters.
- Adds ingestion tests, fixtures, and a minor-release change record.
| File | Description |
|---|---|
evm/evm-processor/src/processor.ts |
Exposes and documents the setting. |
evm/evm-processor/src/ds-rpc/rpc.ts |
Implements filtered fetching and range-error handling. |
evm/evm-processor/src/ds-rpc/rpc.test.ts |
Tests range splitting and filter propagation. |
evm/evm-processor/src/ds-rpc/log-filter.ts |
Builds filters and determines eligibility. |
evm/evm-processor/src/ds-rpc/log-filter.test.ts |
Tests eligibility and matching. |
evm/evm-processor/src/ds-rpc/cold.test.ts |
Tests default and filtered ingestion. |
evm/evm-processor/src/ds-rpc/client.ts |
Routes finalized requests through filtered ingestion. |
evm/evm-processor/src/ds-rpc/chain.fixture.ts |
Provides an in-memory chain and RPC mock. |
common/changes/@subsquid/evm-processor/feat-evm-rpc-filtered-logs_2026-12-04-20-15.json |
Records the feature for release. |
Review effort: Balanced
…ck batches - The per-block eth_getLogs refetch for the transactionLogs relation is now checked against the block hash too, retrying on a mismatch like the filtered response. - Each run of consecutive ranges gets its own cold-ingest split size, so ranges that are not filtered keep batches of at most 10 blocks instead of one batch of up to `blockRange` blocks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The ingestion loop can advance to the next run before the current run finishes, allowing later blocks to be checkpointed while an earlier block is permanently skipped.
1 open issue
2 resolved since last review
Review effort: Balanced
…op on head With stopOnHead, cold ingestion of a run of ranges can end at the chain head before the run's end. Starting the next run with a fresh head could then deliver blocks past a gap. Stop instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Why
Without a gateway, the RPC data source fetches every finalized block with
eth_getBlockByNumber, and all its logs with an unfilteredeth_getLogsper 10 blocks, then filters logs locally. For a contract with few events, the number of calls grows with the block range rather than with the number of matching logs. Some public endpoints also refuseeth_getLogswithout an address, so this mode cannot backfill from them at all.What
A new optional setting:
For finalized ranges whose requests select blocks by logs only (
addLog, with any relation, noincludeAllBlocks):eth_getLogsper distinct address/topics filter over each split of up toblockRangeblocks. Overlapping results are deduplicated.transaction: transactions come with the block.transactionTraces,transactionStateDiffs: fetched per matching block, as before.transactionLogs: gets all logs of the matching blocks.includeAllBlocks, are ingested as before. When those share a processor with filtered ranges, they are fetched in 10-block pieces.Trade-off: the logs bloom check cannot work on filtered results, so a node that misses logs goes unnoticed. The setting's doc comment says so. A log whose
blockHashdiffers from the fetched block's hash causes a retry, then an error.Both modes:
eth_getLogsnow also splits ranges on common provider block-range limit errors and follows Alchemy's suggested range. Before, these errors stopped the processor.Tests
master):eth_getLogscarries only the range, logs are filtered locally, and the bloom check rejects a block with logs missing;eth_getLogsrange splitting.blockRangeand on provider range errors;transactionLogs;blockHashmismatch;blockRange.Checked against Ethereum mainnet over the same 1,000 finalized blocks, with output identical in both modes:
filterLogsOnNodegasUsed(2,765 items)🤖 Generated with Claude Code