waku-org / nwaku

Waku node and protocol.
Other
201 stars 53 forks source link

waku_info wrong values #339

Closed decanus closed 3 years ago

decanus commented 3 years ago

Problem

It seems as though waku_info returns the wrong IP for a node. We are currently creating a node with the following paramters:

cmd:~ % d inspect nim-waku-v2 | jq '.[].Config.Cmd'
[
  "--store=true",
  "--relay=true",
  "--filter=true",
  "--dbpath=/data",
  "--nodekey=d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35",
  "--nat=extip:134.209.139.210",
  "--log-level=info",
  "--rpc-port=8545",
  "--rpc-address=0.0.0.0",
  "--tcp-port=30303",
  "--udp-port=30303",
  "--metrics-server=True",
  "--metrics-server-port=8008",
  "--metrics-server-address=0.0.0.0"
]

notice the --nat=extip:134.209.139.210 however upon calling the waku_info we get:

cmd:~ % curl -s -XPOST -H "Content-type: application/json" --data "{\"method\":\"waku_info\",\"params\":[],\"id\":1}" http://127.0.0.1:8545/ | jq .
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "/ip4/0.0.0.0/tcp/30303/p2p/16Uiu2HAmPLe7Mzm8TsYUubgCAW1aJoeFScxrLj8ppHFivPo97bUZ",
  "error": null
}

This causes https://fleets.status.im to show incorrect data.

Acceptance Criteria

oskarth commented 3 years ago

This seems to come from info method in wakunode2. Did you check if the IP is logged correctly in peerInfo? See this line let listenStr = $peerInfo.addrs[0] & "/p2p/" & $peerInfo.peerId - it might be that 0.0.0.0 is just the first address and not the one we want to print.

jm-clius commented 3 years ago

Suggested easy solution

That is exactly right, @oskarth. The info method returns the only announced peerInfo address and that is the host address. Setting the host address requires configuring the --listen-address option for the wakunode2. Since this is missing from the configuration, the address defaults to 0.0.0.0.

I think the easiest solution, for now, is to modify the config by adding --listen-address=134.209.139.210 explicitly. I'm not sure where exactly this config lives (@jakubgs, perhaps you can direct me?) or if NAT should be configured for this host at all.

Next steps

As far as I can tell there're no mechanisms implemented in nim-libp2p to announce addresses other than the host address, such as for NAT purposes (also see this comment in nimbus-eth2). For wakunode2, though, we can (and should) advertise the external IP and port as the listening address. A (seeming) bug in the NAT setup code will currently cause the external port to default to 0 under any configuration. I'll investigate.

UPDATE:

Since 134.209.139.210 is not visible to the host it should not be configured as the listen-address, as host will attempt binding it to socket (thanks, @jakubgs). Will rather then proceed to make info announce the external IP. Side note: since the rpc-api has been updated to the json-rpc-api with accompanying method name changes, I'll also fix the infrastructure tasks affected.