Skip to content

Conversation

@reedsa
Copy link
Contributor

@reedsa reedsa commented Jul 25, 2023

What was wrong?

When an invalid request is sent to a endpoint that does not exist or hasn't been implemented, the error returned does not comply with the JSON-RPC spec.

Closes ethereum/eth-tester#252

How was it fixed?

Return response objects with required fields for the RPC response.
Raise exception from error.data response to expose the underlying cause of the issue.

Todo:

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

@reedsa reedsa force-pushed the 252-handle-rpc-errors branch from ee911e3 to 8938f76 Compare July 26, 2023 18:26
@reedsa reedsa marked this pull request as ready for review July 26, 2023 19:27
@reedsa reedsa requested review from fselmo, kclowes, pacrob and wolovim July 26, 2023 19:28
Copy link
Contributor

@pacrob pacrob 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

@pacrob pacrob left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Collaborator

@kclowes kclowes left a comment

Choose a reason for hiding this comment

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

I left a couple comments around the same thing. Let me know if they don't make sense!

assert result is False

@pytest.mark.xfail(
raises=ValueError, reason="list_wallets not implemented in eth-tester"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice catch!

"code": -32601,
"message": "the method eth_getTransactionByHash does not exist/is not "
"available",
"data": MethodUnavailable("method not found"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is the actual response from a client (in this case Geth) that doesn't implement a method. The data key doesn't get returned, so we can't rely on that to determine which error to throw. We'll want to make this test pass without the data key.

Copy link
Collaborator

@kclowes kclowes left a comment

Choose a reason for hiding this comment

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

I left a few more comments, feel free to take them or leave them!

Copy link
Collaborator

@fselmo fselmo left a comment

Choose a reason for hiding this comment

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

Looks good 👍🏼 . Closer to homogeneity in the eth-tester responses 🎉

@reedsa reedsa merged commit d699e35 into ethereum:main Aug 1, 2023
@reedsa reedsa deleted the 252-handle-rpc-errors branch March 19, 2024 17:03
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.

Have error formatting comply with the JSON-RPC error format

4 participants