rpc: add --rpc.logs.maxresults limit on log rpc-API#19721
Merged
AskAlexSharov merged 9 commits intoMar 15, 2026
Conversation
…nt limits across log APIs - Add --rpc.logs.maxresults flag (default 20000): maximum number of logs returned by eth_getLogs, erigon_getLogs, erigon_getLatestLogs - Change --rpc.blockrange.limit default from 0 (unlimited) to 1000 - Enforce both limits consistently in eth_getLogs, erigon_getLogs, erigon_getLatestLogs, overlay_getLogs, trace_filter - In erigon_getLatestLogs, skip the block range check when logCount or blockCount is explicitly provided by the caller - Remove hardcoded constants GetLatestLogMaxLogCount (30000) and GetLatestLogMaxBlockCount (1000) in favour of the global config params - Rename BaseAPI.rangeLimit to blockRangeLimit and HttpCfg.RangeLimit to BlockRangeLimit for clarity - Add unit tests covering range limit exceeded/ok, max results ok, logCount/blockCount vs limits, and range check bypass with count options Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
690e372 to
97dab58
Compare
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Distinguish error messages for explicit vs implicit limit violations: - When user explicitly passes logCount/blockCount that exceed server limits, return "requested logCount/blockCount exceeds server limit: requested N, maximum M" - When a query is too broad (block range or accumulated log results exceed limits), return "query block range exceeds server limit, narrow your filter" / "query returns too many logs, narrow your filter" Also print rpc.blockrange.limit and rpc.logs.maxresults in the "[rpc] endpoint opened" startup log so operators can verify the active configuration at a glance. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
AskAlexSharov
approved these changes
Mar 15, 2026
lupin012
added a commit
that referenced
this pull request
Mar 17, 2026
close #19719 Provided configuration parameters on logs mgt that, when properly tuned by the service provider, allow the system to avoid being OOM killed: - --rpc.blockrange.limit (default changed: 0 → 1000): maximum block range (end - begin) allowed for range queries. The flag already existed but defaulted to 0 (unlimited), leaving APIs exposed to unbounded block scans. - --rpc.logs.maxresults (default: 20000): new flag — maximum number of logs returned per call. Previously unbounded. APIs affected Both limits are enforced consistently across: - eth_getLogs - erigon_getLogs - erigon_getLatestLogs - overlay_getLogs - trace_filter (block range only) Behaviour - Exceeding --rpc.blockrange.limit with an explicit fromBlock/toBlock range returns an error (query block range exceeds server limit, narrow your filter: N). - Exceeding --rpc.logs.maxresults when a query returns too many results returns an error (query returns too many logs, narrow your filter: N). - In erigon_getLatestLogs, when the caller explicitly provides logCount or blockCount that exceed the configured limits, a distinct error is returned indicating the requested value and the maximum (requested logCount/blockCount exceeds server limit: requested N, maximum M). - Setting either flag to 0 disables the respective limit (unlimited). - In erigon_getLatestLogs, when the caller explicitly provides logCount or blockCount, the block range check on fromBlock/toBlock is skipped — the count-based limit takes precedence. - The previous hardcoded constants GetLatestLogMaxLogCount (30000) and GetLatestLogMaxBlockCount (1000) have been removed in favour of the global config parameters. --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
AskAlexSharov
pushed a commit
that referenced
this pull request
Apr 24, 2026
…herry-pick) (#20784) Provided configuration parameters on logs mgt that, when properly tuned by the service provider, allow the system to avoid being OOM killed: - --rpc.blockrange.limit (default changed: 0 → 1000): maximum block range (end - begin) allowed for range queries. The flag already existed but defaulted to 0 (unlimited), leaving APIs exposed to unbounded block scans. - --rpc.logs.maxresults (default: 20000): new flag — maximum number of logs returned per call. Previously unbounded. APIs affected Both limits are enforced consistently across: - eth_getLogs - erigon_getLogs - erigon_getLatestLogs - overlay_getLogs - trace_filter (block range only) Behaviour - Exceeding --rpc.blockrange.limit with an explicit fromBlock/toBlock range returns an error (query block range exceeds server limit, narrow your filter: N). - Exceeding --rpc.logs.maxresults when a query returns too many results returns an error (query returns too many logs, narrow your filter: N). - In erigon_getLatestLogs, when the caller explicitly provides logCount or blockCount that exceed the configured limits, a distinct error is returned indicating the requested value and the maximum (requested logCount/blockCount exceeds server limit: requested N, maximum M). - Setting either flag to 0 disables the respective limit (unlimited). - In erigon_getLatestLogs, when the caller explicitly provides logCount or blockCount, the block range check on fromBlock/toBlock is skipped — the count-based limit takes precedence. - The previous hardcoded constants GetLatestLogMaxLogCount (30000) and GetLatestLogMaxBlockCount (1000) have been removed in favour of the global config parameters. --------- Co-authored-by: Claude Sonnet 4.6 <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.
close #19719
Provided configuration parameters on logs mgt that, when properly tuned by the service provider, allow the system to avoid being OOM killed:
APIs affected
Both limits are enforced consistently across:
Behaviour