-
Notifications
You must be signed in to change notification settings - Fork 181
Open
Labels
Type: BugSomething isn't workingSomething isn't working
Description
Describe the bug
Forest seems to always fallback to v1 endpoint. Instead, it should properly handle invalid paths - in the example case, there is no v666 so it should be 404 on HTTP layer.
❯ curl localhost:2345/rpc/v666 \
--request POST \
-s -w "%{http_code}" \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{"id":1,"jsonrpc":"2.0","method":"eth_feeHistory","params":["0x5","latest",[20,30]]}'
{"jsonrpc":"2.0","id":1,"result":{"oldestBlock":"0x2fcc88","baseFeePerGas":["0x66","0x6c","0x69","0x65","0x64","0x64"],"gasUsedRatio":[0.6011979329,0.3396640094,0.2831463153,0.2632643891,0.2767177349],"reward":[["0x1f056","0x1f0c0"],["0x1f12f","0x1f1d9"],["0x1f150","0x1f19c"],["0x1f060","0x1f17e"],["0x1f120","0x1f1ff"]]}}200⏎
❯ curl localhost:2345/rpc/v666 \
--request POST \
-s -w "%{http_code}" \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{"id":1,"jsonrpc":"2.0","method":"eth_feeHistoryyy","params":["0x5","latest",[20,30]]}'
{"jsonrpc":"2.0","id":1,"error":{"code":-32601,"message":"Method not found"}}200⏎
❯ curl localhost:2345/invoke/cthulhu \
--request POST \
-s -w "%{http_code}" \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{"id":1,"jsonrpc":"2.0","method":"eth_feeHistory","params":["0x5","latest",[20,30]]}'
{"jsonrpc":"2.0","id":1,"result":{"oldestBlock":"0x2fcc8c","baseFeePerGas":["0x64","0x64","0x64","0x64","0x64","0x64"],"gasUsedRatio":[0.2767177349,0.3581083985,0.2956367897,0.2886976504,0.1243660782],"reward":[["0x1f120","0x1f1ff"],["0x1ee6b","0x1ef2c"],["0x1efe3","0x1f0e6"],["0x1f001","0x1f0d6"],["0x1f042","0x1f04e"]]}}200⏎
If there would be a v666 endpoint with this data, it'd be correct.
Expected behaviour
Forest on the RPC port should return 404 on invalid paths, e.g., /rpc/v666 or /invoke/cthulhu. Note that it should still return 200 and -32601 RPC error code on an existing endpoint but unsupported method.
Screenshots
Environment (please complete the following information):
- OS:
- Branch/commit a86d740
- Hardware
Other information and links
Metadata
Metadata
Assignees
Labels
Type: BugSomething isn't workingSomething isn't working
Type
Projects
Status
New