Skip to content

fix: prevent nil pointer dereference in eth_simulateV1#1993

Closed
harshsingh-cs wants to merge 1 commit into
0xPolygon:masterfrom
harshsingh-cs:fix-eth-simulate-v1-nil-pointer
Closed

fix: prevent nil pointer dereference in eth_simulateV1#1993
harshsingh-cs wants to merge 1 commit into
0xPolygon:masterfrom
harshsingh-cs:fix-eth-simulate-v1-nil-pointer

Conversation

@harshsingh-cs
Copy link
Copy Markdown

@harshsingh-cs harshsingh-cs commented Jan 19, 2026

Add nil checks for BlockOverrides and StateOverrides before accessing their fields in processBlock(). This fixes a crash when eth_simulateV1 is called with minimal parameters that don't include these overrides.

The panic occurred at lines 237 and 242 where the code attempted to access nested fields without checking if the parent objects were nil.

Here is how we can reproduce

curl -s http://localhost:8545 -H 'content-type: application/json' \
--data '{
  "jsonrpc":"2.0",
  "id":1,
  "method":"eth_simulateV1",
  "params":[
    {"blockStateCalls":[{"calls":[{"from":"0x0000000000000000000000000000000000000000","to":"0x0000000000000000000000000000000000000000","data":"0x"}]}]},
    "latest"
  ]
}'
# => -32603 "method handler crashed"

Description

Please provide a detailed description of what was done in this PR

Changes

  • Bugfix (non-breaking change that solves an issue)
  • Hotfix (change that solves an urgent issue, and requires immediate attention)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)
  • Changes only for a subset of nodes

Breaking changes

Please complete this section if any breaking changes have been made, otherwise delete it

Nodes audience

In case this PR includes changes that must be applied only to a subset of nodes, please specify how you handled it (e.g. by adding a flag with a default value...)

Checklist

  • I have added at least 2 reviewer or the whole pos-v1 team
  • I have added sufficient documentation in code
  • I will be resolving comments - if any - by pushing each fix in a separate commit and linking the commit hash in the comment reply
  • Created a task in Jira and informed the team for implementation in Erigon client (if applicable)
  • Includes RPC methods changes, and the Notion documentation has been updated

Cross repository changes

  • This PR requires changes to heimdall
    • In case link the PR here:
  • This PR requires changes to matic-cli
    • In case link the PR here:

Testing

  • I have added unit tests
  • I have added tests to CI
  • I have tested this code manually on local environment
  • I have tested this code manually on remote devnet using express-cli
  • I have tested this code manually on amoy
  • I have created new e2e tests into express-cli

Manual tests

Please complete this section with the steps you performed if you ran manual tests for this functionality, otherwise delete it

Additional comments

Please post additional comments in this section if you have them, otherwise delete it

Add nil checks for BlockOverrides and StateOverrides before accessing
their fields in processBlock(). This fixes a crash when eth_simulateV1
is called with minimal parameters that don't include these overrides.

The panic occurred at lines 237 and 242 where the code attempted to
access nested fields without checking if the parent objects were nil.

Fixes #issue (method handler crashed with -32603 error)
@sonarqubecloud
Copy link
Copy Markdown

@kamuikatsurgi
Copy link
Copy Markdown
Member

Hey, this is already merged via this #1955. Closing this as a dup. Thanks for the contribution.

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