waku-org / nwaku

Waku node and protocol.
Other
184 stars 47 forks source link

bug: missing `multiaddrs` in received response from peer-exchange and dns-discovery query #1464

Closed danisharora099 closed 1 year ago

danisharora099 commented 1 year ago

Problem

Using the nwaku test fleet to do a peer-exchange query, I successfully receive new nodes. However, on decoding the bytes, I seem to be missing multiaddrs on these nodes, while they should include multiaddrs.

Update: same issue is also seen while receiving a dns-discovery peer

Impact

Blocker to enable peer-exchange js-waku as a discovery mechanism

To reproduce

  1. Go to js-waku
  2. Checkout to danisharora/fix-px-peer-discovery
  3. cd packages/peer-exchange
  4. run npx mocha and check dev console logs (I've left a few console.log statements in there to help with debugging)

Expected behavior

The enr bytes received in the peer-exchange response should have multiaddrs to be dialable by libp2p.

Screenshots/logs

nwaku version/commit hash

v0.13.0

Additional context

fryorcraken commented 1 year ago

@danisharora099 please provide:

danisharora099 commented 1 year ago
fryorcraken commented 1 year ago

Node queried is the test fleet There are several nodes in the test fleet, would be good to provide a peer id.

danisharora099 commented 1 year ago

Node queried is the test fleet There are several nodes in the test fleet, would be good to provide a peer id.

Few of the peer IDs in test fleet queried: 12D3KooWRoeQEUnLJo6x2uGpwuN11gEXZF97m7kxhAM46VAFWKSe, 16Uiu2HAmPLe7Mzm8TsYUubgCAW1aJoeFScxrLj8ppHFivPo97bUZ

danisharora099 commented 1 year ago

Update: I've been able to reproduce the same issue in dns-discovery as well: https://github.com/waku-org/js-waku/pull/1084

Acc to my interpretation, there are two possibilities:

  1. ENR isn't parsed properly in js-waku (seems more probable at this point? in which case, we'll move this issue to js-waku)
  2. multiaddr isn't sent properly by nwaku in the query response
fryorcraken commented 1 year ago
1. ENR isn't parsed properly in js-waku (seems more probable at this point? in which case, we'll move this issue to `js-waku`)

Locally I can confirm that nwaku v0.13 does include multiaddrs in ENR:

▶ git diff
diff --git a/packages/tests/tests/enr.node.spec.ts b/packages/tests/tests/enr.node.spec.ts
index 415e91aa..0d897e2f 100644
--- a/packages/tests/tests/enr.node.spec.ts
+++ b/packages/tests/tests/enr.node.spec.ts
@@ -24,6 +24,7 @@ describe("ENR Interop: nwaku", function () {
       store: false,
       filter: false,
       lightpush: false,
+      websocketSupport: true,
     });
     const multiAddrWithId = await nwaku.getMultiaddrWithId();

@@ -39,6 +40,7 @@ describe("ENR Interop: nwaku", function () {

     expect(nwakuInfo.enrUri).to.not.be.undefined;
     const dec = await ENR.decodeTxt(nwakuInfo.enrUri ?? "");
+    console.log(dec.multiaddrs?.map((ma) => ma.toString()));
     expect(dec.peerId?.toString()).to.eq(nimPeerId.toString());
     expect(dec.waku2).to.deep.eq({
       relay: true,

output:

[ '/ip4/127.0.0.1/tcp/8005/ws' ]
danisharora099 commented 1 year ago

Update: upon looking into why multiaddrs aren't being parsed correctly for the original issue/ENRs, it was seen that those ENRs don't contain decoded fields called multiaddrs while the ones retrieved from nwakuInfo.enrUri locally started nwaku from js-waku does contain that.

The ENRs sent from the fleet do contain tcp4 and udp4 multiaddrs, but the current ENR parser in js-waku looks for multiaddrs field which leads it to return undefined

I'm unsure why the inconsistencies with the ENR serialization exist, and which is the correct standard, and would appreciate some direction on that.

Some ENRs to decode/look into to better understand the above:

https://enr-viewer.com/ can be used to easily decode/visualise decoded ENRs

cc @fryorcraken

fryorcraken commented 1 year ago

Investigation seems fair to me. @kaiserd are you able to take a look?

alrevuelta commented 1 year ago

I would say its not a bug but a feature. As per the WAKU2-ENR spec multiaddrs section:

To save space, multiaddrs key SHOULD only be used for connection details that cannot be represented using the EIP-778 pre-defined keys.

Which I assume its websockets.

I can confirm that a nwaku node that doesn't enable websocket-support=true flag, does not contain any multiaddrs , which is expected since this code just checks if websockets is enabled. Also the comment "# Only add ws/wss to multiaddrs field" makes me think its expected.

So long story short, a node not supporting websockets, will have its multiaddrs section empty.

fryorcraken commented 1 year ago

I can confirm that a nwaku node that doesn't enable websocket-support=true flag, does not contain any multiaddrs

Except that some of the nodes returned in the issue description are nodes from the wakuv2 fleet, where all nodes have websocket enabled.

danisharora099 commented 1 year ago

update:

enr:-Nm4QLHYoJ5WYQoVzyqPR-pwIeQvi3ONWs-EPwk3uUiBiDseN9Dd7fYbCvkMdeXcuZ-8U9IYdGm38VxSDf_Oq3zZ0cEBgmlkgnY0gmlwhGia74CKbXVsdGlhZGRyc7g6ADg2MW5vZGUtMDEuZ2MtdXMtY2VudHJhbDEtYS53YWt1djIudGVzdC5zdGF0dXNpbS5uZXQGH0DeA4lzZWNwMjU2azGhA1giYsmWV9r2yJZYAiMGHJfjLlLeqAuTAokUGPN__pkxg3RjcIJ2X4N1ZHCCIyiFd2FrdTIP

and

enr:-JK4QAmmBzjI8YAKKT-9pH_-a5y-9lSjNyY8dNd45AW1M6BhbhPtfGDQrLD73ZjgRKqqmRRAvKiUmSA-5hKoZfDhPqwBgmlkgnY0gmlwhGia74CJc2VjcDI1NmsxoQNYImLJllfa9siWWAIjBhyX4y5S3qgLkwKJFBjzf_6ZMYN0Y3CCdl-DdWRwgiMohXdha3UyDw

point to the same IP/node ID/peer ID, and are different ENRs.

The difference is: the first one is picked directly from https://fleets.status.im and contains multiaddrs, while the second one was parsed and derived from the enrtree: AOGECG2SPND25EEFMAJ5WF3KSGJNSGV356DSTL2YVLLZWIV6SAYBM:test.waku.nodes.status.im and does not contain multiaddrs.

cc @fryorcraken @alrevuelta

alrevuelta commented 1 year ago

Looking into the code, nwaku peer exchange just sends the enr it gets from discv5, so perhaps the issue is not in pex but in the enrs stored in dns disc.

Using nwaku, if I use the following dns disc url, I get the following enrs. Note that all of them contain the multiaddress field. enrtree://AOGECG2SPND25EEFMAJ5WF3KSGJNSGV356DSTL2YVLLZWIV6SAYBM@prod.nodes.status.im

enr:-M-4QHL_casP1Jy4KntHNWT3p1XkPxm1BJSxDi7KucSqZ2PgT97d4xEQ4cJx-bgw0SRu-nO4y5k0jTQN4AH7utodtZMBgmlkgnY0gmlwhKEj9HmKbXVsdGlhZGRyc7EALzYobm9kZS0wMi5kby1hbXMzLnN0YXR1cy5wcm9kLnN0YXR1c2ltLm5ldAYBu94DiXNlY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WUsM_BpA0BgmlkgnY0gmlwhI_G-a6KbXVsdGlhZGRyc7EALzYobm9kZS0wMS5kby1hbXMzLnN0YXR1cy5wcm9kLnN0YXR1c2ltLm5ldAYBu94DiXNlY3AyNTZrMaECoVyonsTGEQvVioM562Q1fjzTb_vKD152PPIdsV7sM6SDdGNwgnZfg3VkcIIjKIV3YWt1Mg8

enr:-Nm4QEM3eNGY4ZLO30zZkhgyXhKowmX6_rJCSoQlUS7-WBs9LmoM2DtKEMOzxkwF1c1WVojeXdcn8eBI-XVRHeMP66UBgmlkgnY0gmlwhCKE1emKbXVsdGlhZGRyc7g6ADg2MW5vZGUtMDIuZ2MtdXMtY2VudHJhbDEtYS5zdGF0dXMucHJvZC5zdGF0dXNpbS5uZXQGAbveA4lzZWNwMjU2azGhAwtASPpiz5Gq3zuFuWF4MTviQVipi3HaQGytF-4wfbdvg3RjcIJ2X4N1ZHCCIyiFd2FrdTIP

But using the test.waku fleet, none of them contain the multiaddress field.

enrtree://AOGECG2SPND25EEFMAJ5WF3KSGJNSGV356DSTL2YVLLZWIV6SAYBM@test.waku.nodes.status.im

enr:-JK4QBcAt01zOZ-mu7JYvjNrYt2AGb2MZz_eH1ciG9vauuPbDwe1VkL5_XsnOyNYI_F-2iCtrPloeiG7e05q8dpm4bABgmlkgnY0gmlwhC_y0kmJc2VjcDI1NmsxoQIQJvj-KupljjSnBp2yz1PFl2SeELNwMSG68nL3Oz1SrIN0Y3CCdl-DdWRwgiMohXdha3UyDw

enr:-JK4QAmmBzjI8YAKKT-9pH_-a5y-9lSjNyY8dNd45AW1M6BhbhPtfGDQrLD73ZjgRKqqmRRAvKiUmSA-5hKoZfDhPqwBgmlkgnY0gmlwhGia74CJc2VjcDI1NmsxoQNYImLJllfa9siWWAIjBhyX4y5S3qgLkwKJFBjzf_6ZMYN0Y3CCdl-DdWRwgiMohXdha3UyDw

enr:-JK4QK3z-AuQU_QGpYjj3G8qRKzFjRo4xdezGdLkqr5cJ6OGVLTatuUHjK2qaYdOHlztrVvFHDfAxJRntoKMYQhqQAABgmlkgnY0gmlwhIbRi9KJc2VjcDI1NmsxoQOevTdO6jvv3fRruxguKR-3Ge4bcFsLeAIWEDjrfaigNoN0Y3CCdl-DdWRwgiMohXdha3UyDw

I can confirm what @fryorcraken said that wakuv2.test infra has websockets activates.

So I would say the enrs stored in enrtree://AOGECG2SPND25EEFMAJ5WF3KSGJNSGV356DSTL2YVLLZWIV6SAYBM@test.waku.nodes.status.im are wrong (perhaps outdated and were generated before enabling websockets)?

kaiserd commented 1 year ago

I have nothing to add to @alrevuelta 's answer. Thanks :). @jm-clius do you know why the testfleet enrtree ENRs do not contain multiaddresses?

danisharora099 commented 1 year ago

Summarising: the conclusion so far is that the ENRs stored in enrtree://AOGECG2SPND25EEFMAJ5WF3KSGJNSGV356DSTL2YVLLZWIV6SAYBM@test.waku.nodes.status.im are outdated.

jm-clius commented 1 year ago

Thanks for reporting this @danisharora099.

Note that this issue has been reported before, so I'm closing that one as a duplicate: https://github.com/waku-org/nwaku/issues/1323

I've also opened a relevant infra issue to update these lists: https://github.com/status-im/infra-nim-waku/issues/64

danisharora099 commented 1 year ago

Superseded by https://github.com/status-im/infra-nim-waku/issues/64

Thanks all!