hedera-json-rpc-relay icon indicating copy to clipboard operation
hedera-json-rpc-relay copied to clipboard

Some Methods fail to send a response when called with WS endpoint

Open simsonraj opened this issue 1 year ago • 1 comments

Description

Some methods such as ( noticed so far)

  • eth_blockNumber
  • estimateGasPrice Does not return any response when accessed through go-ethereum client whereas it works with ethers.js clients

Steps to reproduce

import ( "context" "log" "github.com/ethereum/go-ethereum/ethclient" )

func main() { client, err := ethclient.Dial("WSS_URL") block, _ := client.BlockNumber(context.Background()) log.Println("Block: ", block) }

Additional context

No response

Hedera network

testnet

Version

0.47.0-rc3

Operating system

None

simsonraj avatar May 07 '24 18:05 simsonraj

I have drilled this how the request is sent via go-ethereum vs Ethers.js go-ethereum sends no params for these requests - so its treated as undefined by the Relay code & it panics without proper exception handling & null checks

It works with Ethers.js because it sends an empty array image

simsonraj avatar May 07 '24 18:05 simsonraj

Thanks for the ticket and this is indeed a great catch!

Essentially go-ethereum package does not include params field in the jsonrpc request objects for the methods that do not require any params, i.e. eth_chainId, eth_gasPrice, eth_blockNumber, etc. This results in the undefined for params field and eventually leads to the error while parsing the value in the server. Still not sure how I missed this case where params could be undefined, especially when I covered all the validation checks for other fields in the jsonrpc object like theid, jsonrpc, method. Anywho, the work is in review. Easy fix!

quiet-node avatar May 15 '24 00:05 quiet-node