Skip to content

Conversation

@natanasow
Copy link
Member

@natanasow natanasow commented Jul 3, 2025

Description:

Some RPC endpoints, like eth_getBalance, do not validate the parameters array length properly. This can lead to a "500 Internal Server Error" when it should have been a 400 error instead.

Solution:

Ensure params array length is less or equal to indexes length here and throw INVALID_PARAMETERS if needed.

Affected JSON-RPC Methods:
This issue affects the RPC endpoints that do not use a parameters layout, i.e., RPC_LAYOUT.custom nor RPC_LAYOUT.REQUEST_DETAILS_ONLY, and logs requestDetails.formattedRequestId. These are:

  • eth_newFilter
  • eth_getFilterLogs
  • eth_getFilterChanges
  • eth_uninstallFilter
  • eth_getBalance
  • eth_getCode
  • eth_getBlockByHash
  • eth_getBlockTransactionCountByHash
  • eth_getBlockTransactionCountByNumber
  • eth_getTransactionByBlockHashAndIndex
  • eth_getTransactionByBlockNumberAndIndex
  • eth_getBlockByNumber
  • eth_getTransactionCount
  • eth_sendRawTransaction
  • eth_call
  • eth_getTransactionByHash
  • eth_getTransactionReceipt
  • eth_getLogs
  • eth_getBlockReceipts

Related issue(s):

Fixes #3858

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

@natanasow natanasow requested review from a team as code owners July 3, 2025 12:42
@natanasow natanasow requested a review from quiet-node July 3, 2025 12:42
@natanasow natanasow self-assigned this Jul 3, 2025
@natanasow natanasow added the enhancement New feature or request label Jul 3, 2025
@natanasow natanasow added this to the 0.70.0 milestone Jul 3, 2025
@github-actions
Copy link

github-actions bot commented Jul 3, 2025

Test Results

 20 files  +  4  276 suites  +54   17m 58s ⏱️ + 3m 6s
701 tests +150  696 ✅ +148  5 💤 +2  0 ❌ ±0 
717 runs  +150  712 ✅ +148  5 💤 +2  0 ❌ ±0 

Results for commit dddee32. ± Comparison against base commit 3684f3c.

♻️ This comment has been updated with latest results.

natanasow added 2 commits July 3, 2025 16:35
Signed-off-by: nikolay <[email protected]>
simzzz
simzzz previously approved these changes Jul 3, 2025
Copy link
Contributor

@simzzz simzzz left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@acuarica acuarica left a comment

Choose a reason for hiding this comment

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

can we include some tests in validators.spec.ts and rpcMethodDispatcher.spec.ts (where the error described in the original issue actually happens)?

Signed-off-by: nikolay <[email protected]>
@natanasow natanasow merged commit 8bd3667 into main Jul 4, 2025
62 of 64 checks passed
@natanasow natanasow deleted the 3858-ensure-rpc-params-array-length branch July 4, 2025 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ensure RPC parameters array has length according to RPC definition

5 participants