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

Identity REST API endpoint returns 0.0.0.0 address #6060

Open
jakubgs opened this issue Mar 11, 2024 · 7 comments
Open

Identity REST API endpoint returns 0.0.0.0 address #6060

jakubgs opened this issue Mar 11, 2024 · 7 comments
Assignees

Comments

@jakubgs
Copy link
Member

jakubgs commented Mar 11, 2024

Describe the bug
Currently the /eth/v1/node/identity REST API endpoint returns incorrect multiaddress under p2p_addresses:

jakubgs@linux-01.ih-eu-mda1.nimbus.sepolia:~ % c -s 0:9311/eth/v1/node/identity | jq '.data | { p2p_addresses, discovery_addresses }'
{
  "p2p_addresses": [
    "/ip4/0.0.0.0/tcp/9011/p2p/16Uiu2HAmQEmCoEfKQ7ZdPyw1vkMYPLfosfksRUJwssvyDzAosGgm"
  ],
  "discovery_addresses": [
    "/ip4/185.181.230.77/udp/9011/p2p/16Uiu2HAmQEmCoEfKQ7ZdPyw1vkMYPLfosfksRUJwssvyDzAosGgm"
  ]
}

As can be seen the discovery_addresses is correctly using the known public IP address - most probably thanks to the correct value of the --nat=extip:... flag - while p2p_addresses returns 0.0.0.0.

Additional context
Present currently for all 4 main branches:

jakubgs@linux-01.ih-eu-mda1.nimbus.sepolia:~ % for port in $(seq 9311 9314); do c 0:$port/eth/v1/node/identity | jq -c .data.p2p_addresses; done
["/ip4/0.0.0.0/tcp/9011/p2p/16Uiu2HAmQEmCoEfKQ7ZdPyw1vkMYPLfosfksRUJwssvyDzAosGgm"]
["/ip4/0.0.0.0/tcp/9012/p2p/16Uiu2HAm5rcnvjSbXMtzosDnGBsgwi5REfxCNCjeqcYDnHf86XsF"]
["/ip4/0.0.0.0/tcp/9013/p2p/16Uiu2HAmCDZ2qDxdoRYdYGYentnSndWfTYuSSh9jzzK3Qc6QGd1q"]
["/ip4/0.0.0.0/tcp/9014/p2p/16Uiu2HAmGXdiCU2VX9GpuTq3GPm28gBncaBLWEcN8MZaskXcYhYb"]
@cheatfate
Copy link
Contributor

This is libp2p known issue and probably limitation.

@jakubgs
Copy link
Member Author

jakubgs commented Mar 19, 2024

What do you mean by "limitation"? I'd assume that If it works for discovery it can be made to work for the p2p address.

@cheatfate
Copy link
Contributor

Usually developers prefer to use 0.0.0.0 which forces OS to bound server to all available interfaces. But this comes with limitation that when you will request local address of bound socket you will receive 0.0.0.0:<some port> instead of real interface address. To get this addresses you need to enumerate all the interfaces and bound to their IP addresses manually. But there is no such functionality in nim-libp2p yet, so REST server reports what nim-libp2p provides to it.
And to note that that provided multiaddresses are 100% correct, but i agree this addresses are unusable...

@cheatfate
Copy link
Contributor

By word "limitation" i mean that nim-libp2p developers do not implemented this functionality yet and i have not seen such functionality in plans.

@jakubgs
Copy link
Member Author

jakubgs commented Mar 20, 2024

To get this addresses you need to enumerate all the interfaces and bound to their IP addresses manually. But there is no such functionality in nim-libp2p yet, so REST server reports what nim-libp2p provides to it.

I though that's what --nat=extip:... is for. To avoid having to guess which interface is the correct one.

@cheatfate
Copy link
Contributor

libp2p should collect its own addresses while talking with other nodes during identify phase. And replace 0.0.0.0 with this addresses.

@jakubgs
Copy link
Member Author

jakubgs commented Mar 21, 2024

I see, well, then I guess the only sensible thing is to patch it after querying the API since fixing this is too difficult?

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

No branches or pull requests

2 participants