Skip to content

rpc: return -32602 when eth_getLogs exceeds block range limit#20424

Merged
lupin012 merged 3 commits into
erigontech:mainfrom
Sahil-4555:fix/eth-getlogs-invalid-params-range-limit
Apr 12, 2026
Merged

rpc: return -32602 when eth_getLogs exceeds block range limit#20424
lupin012 merged 3 commits into
erigontech:mainfrom
Sahil-4555:fix/eth-getlogs-invalid-params-range-limit

Conversation

@Sahil-4555

Copy link
Copy Markdown
Contributor

This PR updates eth_getLogs so that when the requested block range is larger than the configured range limit, Erigon returns -32602 (invalid params) instead of -32000 (server error). This makes the behavior consistent with the other parameter validation errors already used in the same eth_getLogs flow and aligns Erigon with other clients such as Reth.

The change is implemented in getLogsV3 by returning an RPC invalid-params error for the block range limit check, while keeping the existing error message format unchanged. The related test was also updated to verify the exact RPC behavior, including that the returned error code is -32602 and that the message remains query block range exceeds server limit, narrow your filter: 5.

@yperbasis yperbasis added the RPC label Apr 8, 2026
@yperbasis yperbasis added this to the 3.5.0 milestone Apr 8, 2026
Comment thread rpc/jsonrpc/eth_receipts.go Outdated
@Sahil-4555 Sahil-4555 force-pushed the fix/eth-getlogs-invalid-params-range-limit branch 2 times, most recently from 5de8700 to c81ddcf Compare April 11, 2026 03:42
@Sahil-4555 Sahil-4555 requested a review from lupin012 April 11, 2026 03:42
@AskAlexSharov AskAlexSharov requested a review from Copilot April 11, 2026 04:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates eth_getLogs so exceeding the configured block range limit is treated as an invalid-params error (-32602) rather than a generic server error (-32000), aligning error semantics with other parameter-validation paths and other clients.

Changes:

  • Return rpc.InvalidParamsError from getLogsV3 when (end-begin) > rangeLimit.
  • Update TestGetLogs_RangeLimitExceeded to assert the exact RPC error code and message.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
rpc/jsonrpc/eth_receipts.go Switches block range limit violation to InvalidParamsError while preserving the existing error message.
rpc/jsonrpc/erigon_receipts_test.go Strengthens the range-limit test to validate RPC error type/code/message precisely.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rpc/jsonrpc/eth_receipts.go
@Sahil-4555 Sahil-4555 force-pushed the fix/eth-getlogs-invalid-params-range-limit branch from c81ddcf to e39d996 Compare April 11, 2026 04:20
@lupin012 lupin012 added this pull request to the merge queue Apr 12, 2026
Merged via the queue into erigontech:main with commit 22d4e31 Apr 12, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants