Skip to content

fix(rpc): improve parameter validation in get_logs and service methods#121

Merged
louisliu2048 merged 3 commits intomainfrom
zjg/fix-legacy-without-parameters
Jan 26, 2026
Merged

fix(rpc): improve parameter validation in get_logs and service methods#121
louisliu2048 merged 3 commits intomainfrom
zjg/fix-legacy-without-parameters

Conversation

@zjg555543
Copy link
Contributor

Background

The legacy RPC router middleware assumes request parameters are always present and unconditionally unwraps them in handle_block_param_methods and handle_eth_get_logs. When a user sends an RPC request without parameters (e.g., {"jsonrpc":"2.0","method":"eth_getBlockByNumber","id":1}), req.params().as_str() returns None, causing the unwrap to panic and crashing the service.

Changes

Replace unsafe .unwrap() calls with let-else pattern that returns a proper JSON-RPC error response (INVALID_PARAMS_CODE / -32602) when parameters are missing:

  • crates/legacy-rpc/src/service.rs: Fix handle_block_param_methods
  • crates/legacy-rpc/src/get_logs.rs: Fix handle_eth_get_logs

@zjg555543 zjg555543 force-pushed the zjg/fix-legacy-without-parameters branch from 46d00d3 to ceeed6c Compare January 26, 2026 10:49
@louisliu2048 louisliu2048 merged commit 2761dac into main Jan 26, 2026
Vui-Chee added a commit that referenced this pull request Jan 30, 2026
* dev:
  fix: upgrade reth v1.10.2 version with bug fixes (#134)
  Update dependencies, use reth v1.10.2 and builder v0.3.0 (#133)
  chore: fix rust formatter (#132)
  chore: better rename, fix unused variable warning (#99) (#131)
  Fix comments (#127)
  Add trace log on tx cache hits (#126)
  replace magic error code number to INTERNAL_ERROR_CODE (#125)
  feat(legacy): remove eth_transactionPreExec (#124)
  fix tools readme (#123)
  fix(rpc): improve parameter validation in get_logs and service methods (#121)
  remove output file on error (#119)
  feat(legacy): support legacy routing for batch requests (#117)
  fix(legacy): avoid possible panic on malformed block params (#111)
  fallback to legacy if res is empty (#118)
  refactor(rpc): remove transaction_pre_exec API (#120)
  use XLayerPayloadServiceBuilder to simplify main() codes, merge to main branch (#112)
  fix(tools): check end block >= start block (#116)
  forward req to legacy on err (#110)
  fix: resolve audit issues related to flashblocks subscription (#113)
  fix(rpc): add trace_address for delegatecall and fix address format c… (#104)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants