go-ethereum
go-ethereum copied to clipboard
Getting error `method net_version does not exist/is not available` calling NetworkID via geth
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.
That method in ethclient should be dropped (cc @fjl ), we don't expose the network id any more to the outside.
@karalabe I have two follow-up questions here:
- 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.
- If I wish to access the NetworkID, what should I do in that case ?
- 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.
- 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.
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?
I stand corrected. It was eth_version that was dropped.
@nidhi-singh02 please provide geth version
information
@
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 please provide
geth version
information
@holiman geth version is github.com/ethereum/go-ethereum v1.14.3
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
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
Hey @holiman @fjl , LMK if you need any other information from my end.