Skip to content

rpc: add --rpc.logs.maxresults limit on log rpc-API#19721

Merged
AskAlexSharov merged 9 commits into
mainfrom
lupin012/add_log_maxResult_params_for_rpcLogsApi
Mar 15, 2026
Merged

rpc: add --rpc.logs.maxresults limit on log rpc-API#19721
AskAlexSharov merged 9 commits into
mainfrom
lupin012/add_log_maxResult_params_for_rpcLogsApi

Conversation

@lupin012

@lupin012 lupin012 commented Mar 7, 2026

Copy link
Copy Markdown
Contributor

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.

…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>
@lupin012 lupin012 force-pushed the lupin012/add_log_maxResult_params_for_rpcLogsApi branch from 690e372 to 97dab58 Compare March 9, 2026 17:17
lupin012 and others added 5 commits March 12, 2026 21:46
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>
@lupin012 lupin012 marked this pull request as ready for review March 14, 2026 21:55
@AskAlexSharov AskAlexSharov merged commit 0ff1ccb into main Mar 15, 2026
39 of 40 checks passed
@AskAlexSharov AskAlexSharov deleted the lupin012/add_log_maxResult_params_for_rpcLogsApi branch March 15, 2026 00:31
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Erigon is OOM killed by OS during eth_getLogs()

3 participants