go-ethereum icon indicating copy to clipboard operation
go-ethereum copied to clipboard

Getting error `method net_version does not exist/is not available` calling NetworkID via geth

Open nidhi-singh02 opened this issue 9 months ago • 14 comments

System information

Geth version: geth version - 1.14.3 CL client & version: e.g. lighthouse/nimbus/[email protected] OS & Version: Windows/Linux/OSX Commit hash : (if develop)

Expected behaviour

The method should return me the Network ID.

Actual behaviour

I am getting error method net_version does not exist/is not available I have checked the nodes, http-api net,eth is enabled. If I try to run the curl command on the RPC endpoint of the node, it works fine.

config toml of my node has HTTPModules = ["admin", "engine", "net", "web3", "eth", "debug", "txpool"]

Steps to reproduce the behaviour

Through code, try to invoke NetworkID referred here - https://github.com/ethereum/go-ethereum/blob/6154f87c33303698ad962427f619c6f129640c1e/ethclient/ethclient.go#L356

Backtrace

[backtrace]

When submitting logs: please submit them as text and not screenshots.

nidhi-singh02 avatar May 14 '24 07:05 nidhi-singh02

That method in ethclient should be dropped (cc @fjl ), we don't expose the network id any more to the outside.

karalabe avatar May 14 '24 09:05 karalabe

@karalabe I have two follow-up questions here:

  1. If the code base has NetworkID method, then why I am not able to access it ? If you are planning to remove it in future, then how I am facing issue at this point of time, curious about that.
  2. If I wish to access the NetworkID, what should I do in that case ?

nidhi-singh02 avatar May 14 '24 09:05 nidhi-singh02

  1. It's a legacy method that was dropped from the server side many years ago. I guess it got left over in the client side.
  2. Apart from a handful of strange networks, everyone sets the network id and chain id to the same number. Most probably you want to chain id, not the network id. 2b. Originally the purpose of the network ID was to split multiple ethereum networks. Later the chain ID was introduced to not only split at a networking level, but also at a consensus level. It's a superset of the network ID if you will. The only reason the notion of a network ID exists is because it's hard to remove features, but it's not used meaningfully in production networks.

karalabe avatar May 14 '24 09:05 karalabe

net_version does exist in the server implementation, and it does return the networkID. So it should work. Maybe it's an issue with a proxy? @nidhi-singh02 are you pointing your ethclient directly at the node endpoint?

fjl avatar May 14 '24 11:05 fjl

I stand corrected. It was eth_version that was dropped.

karalabe avatar May 14 '24 11:05 karalabe

@nidhi-singh02 please provide geth version information

holiman avatar May 14 '24 11:05 holiman

@

net_version does exist in the server implementation, and it does return the networkID. So it should work. Maybe it's an issue with a proxy? @nidhi-singh02 are you pointing your ethclient directly at the node endpoint?

Thanks for the clarification. I have embedded this Client struct into my code https://github.com/ethereum/go-ethereum/blob/d2f00cb54edc4486314c25d9e6c5b739009c2201/ethclient/ethclient.go#L35.

When I call ChainID() it works fine, doesn't seem issue with proxy here.

nidhi-singh02 avatar May 14 '24 16:05 nidhi-singh02

@nidhi-singh02 please provide geth version information

@holiman geth version is github.com/ethereum/go-ethereum v1.14.3

nidhi-singh02 avatar May 14 '24 16:05 nidhi-singh02

If I try to run the curl command on the RPC endpoint of the node, it works fine.

Wait, please demonstrate what you mean by this

holiman avatar May 15 '24 07:05 holiman

If I try to run the curl command on the RPC endpoint of the node, it works fine.

Wait, please demonstrate what you mean by this

I have my nodes running locally, when I run the net_version API on the RPC endpoint of my EL node, I get the required network ID in response.

This is the curl I am referring to curl --data '{"jsonrpc":"2.0","method":"net_version", "id":2}' -H "Content-Type: application/json" localhost:xxxx

nidhi-singh02 avatar May 16 '24 07:05 nidhi-singh02

Hey @holiman @fjl , LMK if you need any other information from my end.

nidhi-singh02 avatar May 21 '24 15:05 nidhi-singh02