Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nidhi-singh02 opened this issue May 14, 2024 · 11 comments
Labels

Comments

@nidhi-singh02
Copy link

nidhi-singh02 commented May 14, 2024

System information

Geth version: geth version - 1.14.3
CL client & version: e.g. lighthouse/nimbus/prysm@v1.0.0
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 -

func (ec *Client) NetworkID(ctx context.Context) (*big.Int, error) {

Backtrace

[backtrace]

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

@karalabe
Copy link
Member

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

@nidhi-singh02
Copy link
Author

@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 ?

@karalabe
Copy link
Member

  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.

@fjl
Copy link
Contributor

fjl commented May 14, 2024

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 fjl reopened this May 14, 2024
@karalabe
Copy link
Member

I stand corrected. It was eth_version that was dropped.

@holiman
Copy link
Contributor

holiman commented May 14, 2024

@nidhi-singh02 please provide geth version information

@nidhi-singh02
Copy link
Author

@

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

type Client struct {
.

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

@nidhi-singh02
Copy link
Author

@nidhi-singh02 please provide geth version information

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

@holiman
Copy link
Contributor

holiman commented May 15, 2024

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

@nidhi-singh02
Copy link
Author

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants