Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix eth_getBlockByNumber with empty params returns #8134

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

iryoung
Copy link

@iryoung iryoung commented Jan 17, 2025

PR description

This PR addresses a bug in the eth_getBlockByNumber method, where invoking it with empty parameters results in the error message "Invalid block, unable to parse RLP".

There're some consideration while I investigate & fix the bug

  • I would have preferred to use the message proposed in the issue; however, a pre-defined error message better fits this situation, so I opted to use it.

  • Adding data would require modifications to org.hyperledger.besu.ethereum.api.jsonrpc.execution.BaseJsonRpcProcessor.process(), which is outside the scope of this fix.

  • The message for RpcErrorType.INVALID_BLOCK_PARAMS might seem slightly inconsistent, but adjusting it is also beyond the scope of this PR.

  • Request

POST http://localhost:8545
Content-Type: application/json

{"jsonrpc":"2.0","id":"53","method":"eth_getBlockByNumber","params":[]}
  • Before
{
  "jsonrpc": "2.0",
  "id": "53",
  "error": {
    "code": -32602,
    "message": "Invalid block, unable to parse RLP"
  }
}
  • After
{
  "jsonrpc": "2.0",
  "id": "53",
  "error": {
    "code": -32602,
    "message": "Invalid block number params"
  }
}

Fixed Issue(s)

fixes #7918

Thanks for sending a pull request! Have you done the following?

  • Checked out our contribution guidelines?
  • Considered documentation and added the doc-change-required label to this PR if updates are required.
  • Considered the changelog and included an update if required.
  • For database changes (e.g. KeyValueSegmentIdentifier) considered compatibility and performed forwards and backwards compatibility tests

Locally, you can run these tests to catch failures early:

  • unit tests: ./gradlew build
  • acceptance tests: ./gradlew acceptanceTest
  • integration tests: ./gradlew integrationTest
  • reference tests: ./gradlew ethereum:referenceTests:referenceTests

Signed-off-by: Iryoung Jeong <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant