Open alcuadrado opened 5 years ago
Thanks for your detailed report, we'll take a look! I would be curious of what kind of problem you ran into with this behavior, and if there's a workaround you can share if anyone bumps into the same problem.
Side note: it seems weird that not finding a method doesn't return a 404 Not Found
in Geth.
Thanks for your detailed report, we'll take a look! I would be curious of what kind of problem you ran into with this behavior, and if there's a workaround you can share if anyone bumps into the same problem.
I found this when running this test against RskJ. Some libraries return different errors when a method is not found when connected RskJ than when connected to other nodes.
In my case, that wasn't a big issue, and I just disabled the test for now. The situation may be different for users with more complex error handling logic.
Side note: it seems weird that not finding a method doesn't return a
404 Not Found
in Geth.
I tried to get a 404
from Geth and Parity by sending the jsonrpc payload to a non-existent path and they still returned a 200
. Ganache returns a 404
in that case.
The jsonrpc 2.0
specification doesn't mention the HTTP transport, so it seems to be left to implementors: https://www.jsonrpc.org/specification#error_object.
Historically, jsonrpc 1.0
returned 404: https://www.jsonrpc.org/historical/json-rpc-over-http.html#errors.
The following specification for 2.0
suggests returning status 200
for both responses and errors: https://www.simple-is-better.org/json-rpc/transport_http.html.
jsonrpc4j
, the library we use, decided to follow the 1.0
specification: https://github.com/briandilley/jsonrpc4j/pull/73/files#diff-8c04bc130c55cd72d7d47e4799d80b78R186.
If a non-existent JSON-RPC method is called RskJ responds with a
404
HTTP status.While there's no mention of status codes in the JSON-RPC 2.0 specification, all the major Ethereum clients respond with a
200
in this case. I believe they always return200
.This behavior is not necessarily wrong but leads to small discrepancies between RSK and Ethereum when handling JSON-RPC errors.
RskJ reproduction
I'm running RskJ using the official fat jar distribution:
java -cp rskj-core-0.6.2-ORCHID-all.jar co.rsk.Start --regtest
.Sending a request like this gets me a
404
:Expected result
An example with Geth being run as
docker run -p 8545:8545 ethereum/client-go --dev --rpc --rpcapi "db,eth,net,web3,personal,shh" --rpccorsdomain "*" --rpcaddr 0.0.0.0
Sending a request like this gets me a
200
: