From 6ab3c5b2cdbb9aa76d68f0879114b479c4721137 Mon Sep 17 00:00:00 2001 From: danisharora099 Date: Tue, 4 Jun 2024 13:50:10 -0400 Subject: [PATCH 1/6] fix: bootstrapping into default pubsub topic --- packages/discovery/src/dns/constants.ts | 5 +++-- packages/sdk/src/utils/discovery.ts | 22 ++++++++++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/packages/discovery/src/dns/constants.ts b/packages/discovery/src/dns/constants.ts index b7a5a77a1e..d18a975185 100644 --- a/packages/discovery/src/dns/constants.ts +++ b/packages/discovery/src/dns/constants.ts @@ -1,8 +1,9 @@ import type { NodeCapabilityCount } from "@waku/interfaces"; export const enrTree = { - TEST: "enrtree://AOGYWMBYOUIMOENHXCHILPKY3ZRFEULMFI4DOM442QSZ73TT2A7VI@test.waku.nodes.status.im", - SANDBOX: + DEFAULT_PUBSUB: + "enrtree://ANEDLO25QVUGJOUTQFRYKWX6P4Z4GKVESBMHML7DZ6YK4LGS5FC5O@prod.wakuv2.nodes.status.im", + TWN_SANDBOX: "enrtree://AIRVQ5DDA4FFWLRBCHJWUWOO6X6S4ZTZ5B667LQ6AJU6PEYDLRD5O@sandbox.waku.nodes.status.im" }; diff --git a/packages/sdk/src/utils/discovery.ts b/packages/sdk/src/utils/discovery.ts index 979ab18380..623dbd75cd 100644 --- a/packages/sdk/src/utils/discovery.ts +++ b/packages/sdk/src/utils/discovery.ts @@ -5,7 +5,11 @@ import { wakuLocalPeerCacheDiscovery, wakuPeerExchangeDiscovery } from "@waku/discovery"; -import { type Libp2pComponents, PubsubTopic } from "@waku/interfaces"; +import { + DefaultPubsubTopic, + type Libp2pComponents, + PubsubTopic +} from "@waku/interfaces"; const DEFAULT_NODE_REQUIREMENTS = { lightPush: 1, @@ -16,10 +20,20 @@ const DEFAULT_NODE_REQUIREMENTS = { export function defaultPeerDiscoveries( pubsubTopics: PubsubTopic[] ): ((components: Libp2pComponents) => PeerDiscovery)[] { - const discoveries = [ - wakuDnsDiscovery([enrTree["SANDBOX"]], DEFAULT_NODE_REQUIREMENTS), + const discoveries = []; + discoveries.push( wakuLocalPeerCacheDiscovery(), wakuPeerExchangeDiscovery(pubsubTopics) - ]; + ); + + //TODO: Add support for The Waku Network + //TODO: add issue here + const isDefaultPubsub = pubsubTopics.includes(DefaultPubsubTopic); + if (isDefaultPubsub) { + discoveries.push( + wakuDnsDiscovery([enrTree["DEFAULT_PUBSUB"]], DEFAULT_NODE_REQUIREMENTS) + ); + } + return discoveries; } From a95e17f8099705ea6711af911c3aa353a0446c6a Mon Sep 17 00:00:00 2001 From: danisharora099 Date: Tue, 4 Jun 2024 14:23:34 -0400 Subject: [PATCH 2/6] chore: update tests --- packages/discovery/src/dns/constants.ts | 4 +++- packages/discovery/src/dns/dns.spec.ts | 4 ++-- packages/tests/tests/dns-peer-discovery.spec.ts | 8 ++++---- packages/tests/tests/waku.node.optional.spec.ts | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/discovery/src/dns/constants.ts b/packages/discovery/src/dns/constants.ts index d18a975185..d3904618e7 100644 --- a/packages/discovery/src/dns/constants.ts +++ b/packages/discovery/src/dns/constants.ts @@ -4,7 +4,9 @@ export const enrTree = { DEFAULT_PUBSUB: "enrtree://ANEDLO25QVUGJOUTQFRYKWX6P4Z4GKVESBMHML7DZ6YK4LGS5FC5O@prod.wakuv2.nodes.status.im", TWN_SANDBOX: - "enrtree://AIRVQ5DDA4FFWLRBCHJWUWOO6X6S4ZTZ5B667LQ6AJU6PEYDLRD5O@sandbox.waku.nodes.status.im" + "enrtree://AIRVQ5DDA4FFWLRBCHJWUWOO6X6S4ZTZ5B667LQ6AJU6PEYDLRD5O@sandbox.waku.nodes.status.im", + TWN_TEST: + "enrtree://AOGYWMBYOUIMOENHXCHILPKY3ZRFEULMFI4DOM442QSZ73TT2A7VI@test.waku.nodes.status.im" }; export const DEFAULT_BOOTSTRAP_TAG_NAME = "bootstrap"; diff --git a/packages/discovery/src/dns/dns.spec.ts b/packages/discovery/src/dns/dns.spec.ts index a818c6d40d..cf184dbae4 100644 --- a/packages/discovery/src/dns/dns.spec.ts +++ b/packages/discovery/src/dns/dns.spec.ts @@ -275,7 +275,7 @@ describe("DNS Node Discovery [live data]", function () { this.timeout(10000); // Google's dns server address. Needs to be set explicitly to run in CI const dnsNodeDiscovery = await DnsNodeDiscovery.dnsOverHttp(); - const peers = await dnsNodeDiscovery.getPeers([enrTree.TEST], { + const peers = await dnsNodeDiscovery.getPeers([enrTree.TWN_TEST], { relay: maxQuantity, store: maxQuantity, filter: maxQuantity, @@ -298,7 +298,7 @@ describe("DNS Node Discovery [live data]", function () { this.timeout(10000); // Google's dns server address. Needs to be set explicitly to run in CI const dnsNodeDiscovery = await DnsNodeDiscovery.dnsOverHttp(); - const peers = await dnsNodeDiscovery.getPeers([enrTree.SANDBOX], { + const peers = await dnsNodeDiscovery.getPeers([enrTree.TWN_SANDBOX], { relay: maxQuantity, store: maxQuantity, filter: maxQuantity, diff --git a/packages/tests/tests/dns-peer-discovery.spec.ts b/packages/tests/tests/dns-peer-discovery.spec.ts index 14139dcba8..066cde0a3b 100644 --- a/packages/tests/tests/dns-peer-discovery.spec.ts +++ b/packages/tests/tests/dns-peer-discovery.spec.ts @@ -33,7 +33,7 @@ describe("DNS Discovery: Compliance Test", function () { } as unknown as Libp2pComponents; return new PeerDiscoveryDns(components, { - enrUrls: [enrTree["SANDBOX"]], + enrUrls: [enrTree["TWN_SANDBOX"]], wantedNodeCapabilityCount: { filter: 1 } @@ -66,7 +66,7 @@ describe("DNS Node Discovery [live data]", function () { const waku = await createLightNode({ libp2p: { peerDiscovery: [ - wakuDnsDiscovery([enrTree["SANDBOX"]], nodeRequirements) + wakuDnsDiscovery([enrTree["TWN_SANDBOX"]], nodeRequirements) ] } }); @@ -93,7 +93,7 @@ describe("DNS Node Discovery [live data]", function () { // Google's dns server address. Needs to be set explicitly to run in CI const dnsNodeDiscovery = await DnsNodeDiscovery.dnsOverHttp(); - const peers = await dnsNodeDiscovery.getPeers([enrTree["SANDBOX"]], { + const peers = await dnsNodeDiscovery.getPeers([enrTree["TWN_SANDBOX"]], { relay: maxQuantity, store: maxQuantity, filter: maxQuantity, @@ -120,7 +120,7 @@ describe("DNS Node Discovery [live data]", function () { const waku = await createLightNode({ libp2p: { peerDiscovery: [ - wakuDnsDiscovery([enrTree["SANDBOX"], enrTree["TEST"]], { + wakuDnsDiscovery([enrTree["TWN_SANDBOX"], enrTree["TWN_TEST"]], { filter: nodesToConnect }) ] diff --git a/packages/tests/tests/waku.node.optional.spec.ts b/packages/tests/tests/waku.node.optional.spec.ts index fb81951c12..40a22fe0d1 100644 --- a/packages/tests/tests/waku.node.optional.spec.ts +++ b/packages/tests/tests/waku.node.optional.spec.ts @@ -37,7 +37,7 @@ describe("Use static and several ENR trees for bootstrap", function () { peerDiscovery: [ bootstrap({ list: [multiAddrWithId.toString()] }), wakuDnsDiscovery( - [enrTree["SANDBOX"], enrTree["TEST"]], + [enrTree["TWN_SANDBOX"], enrTree["TWN_TEST"]], NODE_REQUIREMENTS ) ] From d01bea982df5f71fe167a40870b1d4003c522bbb Mon Sep 17 00:00:00 2001 From: danisharora099 Date: Tue, 4 Jun 2024 14:27:56 -0400 Subject: [PATCH 3/6] chore: update TODO with GH issue --- packages/sdk/src/utils/discovery.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sdk/src/utils/discovery.ts b/packages/sdk/src/utils/discovery.ts index 623dbd75cd..44ba1fd1eb 100644 --- a/packages/sdk/src/utils/discovery.ts +++ b/packages/sdk/src/utils/discovery.ts @@ -27,7 +27,7 @@ export function defaultPeerDiscoveries( ); //TODO: Add support for The Waku Network - //TODO: add issue here + //https://github.com/waku-org/nwaku/issues/2593 const isDefaultPubsub = pubsubTopics.includes(DefaultPubsubTopic); if (isDefaultPubsub) { discoveries.push( From a887af656f7cba885be64ee5f50af8012c592533 Mon Sep 17 00:00:00 2001 From: danisharora099 Date: Wed, 5 Jun 2024 15:41:31 -0400 Subject: [PATCH 4/6] chore: rename fleets --- packages/discovery/src/dns/constants.ts | 14 +++++++++----- packages/sdk/src/utils/discovery.ts | 11 ++++++++++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/packages/discovery/src/dns/constants.ts b/packages/discovery/src/dns/constants.ts index d3904618e7..f2c00af0ab 100644 --- a/packages/discovery/src/dns/constants.ts +++ b/packages/discovery/src/dns/constants.ts @@ -1,12 +1,16 @@ import type { NodeCapabilityCount } from "@waku/interfaces"; +/** + * The ENR tree for the different fleets. + * SANDBOX and TEST fleets are for The Waku Network. + * DEPRECATED_DEFAULT_PUBSUB is the fleet of nodes supporting the now deprecated DefaultPubsubTopic. + */ export const enrTree = { - DEFAULT_PUBSUB: - "enrtree://ANEDLO25QVUGJOUTQFRYKWX6P4Z4GKVESBMHML7DZ6YK4LGS5FC5O@prod.wakuv2.nodes.status.im", - TWN_SANDBOX: + SANDBOX: "enrtree://AIRVQ5DDA4FFWLRBCHJWUWOO6X6S4ZTZ5B667LQ6AJU6PEYDLRD5O@sandbox.waku.nodes.status.im", - TWN_TEST: - "enrtree://AOGYWMBYOUIMOENHXCHILPKY3ZRFEULMFI4DOM442QSZ73TT2A7VI@test.waku.nodes.status.im" + TEST: "enrtree://AOGYWMBYOUIMOENHXCHILPKY3ZRFEULMFI4DOM442QSZ73TT2A7VI@test.waku.nodes.status.im", + DEPRECATED_DEFAULT_PUBSUB: + "enrtree://ANEDLO25QVUGJOUTQFRYKWX6P4Z4GKVESBMHML7DZ6YK4LGS5FC5O@prod.wakuv2.nodes.status.im" }; export const DEFAULT_BOOTSTRAP_TAG_NAME = "bootstrap"; diff --git a/packages/sdk/src/utils/discovery.ts b/packages/sdk/src/utils/discovery.ts index 44ba1fd1eb..f8af613e2f 100644 --- a/packages/sdk/src/utils/discovery.ts +++ b/packages/sdk/src/utils/discovery.ts @@ -31,9 +31,18 @@ export function defaultPeerDiscoveries( const isDefaultPubsub = pubsubTopics.includes(DefaultPubsubTopic); if (isDefaultPubsub) { discoveries.push( - wakuDnsDiscovery([enrTree["DEFAULT_PUBSUB"]], DEFAULT_NODE_REQUIREMENTS) + wakuDnsDiscovery([enrTree["DEPRECATED_DEFAULT_PUBSUB"]], DEFAULT_NODE_REQUIREMENTS) ); } return discoveries; } + + +export function xdefaultPeerDiscoveries( + pubsubTopics: PubsubTopic[] +): ((components: Libp2pComponents) => PeerDiscovery)[] { + const isDefaultPubsubTopic = pubsubTopics.includes(DefaultPubsubTopic); + + const dnsEnrTree = isDefaultPubsubTopic ? enrTree["DEPRECATED_DEFAULT_PUBSUB"] : undefined; +} From 0adbf6da435fa3d7b2ea9d3fb1dfac0f95ca2194 Mon Sep 17 00:00:00 2001 From: danisharora099 Date: Wed, 5 Jun 2024 15:44:34 -0400 Subject: [PATCH 5/6] feat: use TWN fleets, or wakuv2.prod if DefaultPubsubTopic --- packages/sdk/src/utils/discovery.ts | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/packages/sdk/src/utils/discovery.ts b/packages/sdk/src/utils/discovery.ts index f8af613e2f..f18771f20b 100644 --- a/packages/sdk/src/utils/discovery.ts +++ b/packages/sdk/src/utils/discovery.ts @@ -20,29 +20,16 @@ const DEFAULT_NODE_REQUIREMENTS = { export function defaultPeerDiscoveries( pubsubTopics: PubsubTopic[] ): ((components: Libp2pComponents) => PeerDiscovery)[] { - const discoveries = []; - discoveries.push( + const isDefaultPubsubTopic = pubsubTopics.includes(DefaultPubsubTopic); + const dnsEnrTrees = isDefaultPubsubTopic + ? [enrTree["DEPRECATED_DEFAULT_PUBSUB"]] + : [enrTree["SANDBOX"], enrTree["TEST"]]; + + const discoveries = [ + wakuDnsDiscovery(dnsEnrTrees, DEFAULT_NODE_REQUIREMENTS), wakuLocalPeerCacheDiscovery(), wakuPeerExchangeDiscovery(pubsubTopics) - ); - - //TODO: Add support for The Waku Network - //https://github.com/waku-org/nwaku/issues/2593 - const isDefaultPubsub = pubsubTopics.includes(DefaultPubsubTopic); - if (isDefaultPubsub) { - discoveries.push( - wakuDnsDiscovery([enrTree["DEPRECATED_DEFAULT_PUBSUB"]], DEFAULT_NODE_REQUIREMENTS) - ); - } + ]; return discoveries; } - - -export function xdefaultPeerDiscoveries( - pubsubTopics: PubsubTopic[] -): ((components: Libp2pComponents) => PeerDiscovery)[] { - const isDefaultPubsubTopic = pubsubTopics.includes(DefaultPubsubTopic); - - const dnsEnrTree = isDefaultPubsubTopic ? enrTree["DEPRECATED_DEFAULT_PUBSUB"] : undefined; -} From 936472ddd4256a7066a7e7d0b1003cc5169872d5 Mon Sep 17 00:00:00 2001 From: danisharora099 Date: Thu, 6 Jun 2024 12:38:19 -0400 Subject: [PATCH 6/6] chore: update imports for enrtree --- packages/discovery/src/dns/dns.spec.ts | 4 ++-- packages/tests/tests/dns-peer-discovery.spec.ts | 8 ++++---- packages/tests/tests/waku.node.optional.spec.ts | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/discovery/src/dns/dns.spec.ts b/packages/discovery/src/dns/dns.spec.ts index cf184dbae4..a818c6d40d 100644 --- a/packages/discovery/src/dns/dns.spec.ts +++ b/packages/discovery/src/dns/dns.spec.ts @@ -275,7 +275,7 @@ describe("DNS Node Discovery [live data]", function () { this.timeout(10000); // Google's dns server address. Needs to be set explicitly to run in CI const dnsNodeDiscovery = await DnsNodeDiscovery.dnsOverHttp(); - const peers = await dnsNodeDiscovery.getPeers([enrTree.TWN_TEST], { + const peers = await dnsNodeDiscovery.getPeers([enrTree.TEST], { relay: maxQuantity, store: maxQuantity, filter: maxQuantity, @@ -298,7 +298,7 @@ describe("DNS Node Discovery [live data]", function () { this.timeout(10000); // Google's dns server address. Needs to be set explicitly to run in CI const dnsNodeDiscovery = await DnsNodeDiscovery.dnsOverHttp(); - const peers = await dnsNodeDiscovery.getPeers([enrTree.TWN_SANDBOX], { + const peers = await dnsNodeDiscovery.getPeers([enrTree.SANDBOX], { relay: maxQuantity, store: maxQuantity, filter: maxQuantity, diff --git a/packages/tests/tests/dns-peer-discovery.spec.ts b/packages/tests/tests/dns-peer-discovery.spec.ts index 066cde0a3b..14139dcba8 100644 --- a/packages/tests/tests/dns-peer-discovery.spec.ts +++ b/packages/tests/tests/dns-peer-discovery.spec.ts @@ -33,7 +33,7 @@ describe("DNS Discovery: Compliance Test", function () { } as unknown as Libp2pComponents; return new PeerDiscoveryDns(components, { - enrUrls: [enrTree["TWN_SANDBOX"]], + enrUrls: [enrTree["SANDBOX"]], wantedNodeCapabilityCount: { filter: 1 } @@ -66,7 +66,7 @@ describe("DNS Node Discovery [live data]", function () { const waku = await createLightNode({ libp2p: { peerDiscovery: [ - wakuDnsDiscovery([enrTree["TWN_SANDBOX"]], nodeRequirements) + wakuDnsDiscovery([enrTree["SANDBOX"]], nodeRequirements) ] } }); @@ -93,7 +93,7 @@ describe("DNS Node Discovery [live data]", function () { // Google's dns server address. Needs to be set explicitly to run in CI const dnsNodeDiscovery = await DnsNodeDiscovery.dnsOverHttp(); - const peers = await dnsNodeDiscovery.getPeers([enrTree["TWN_SANDBOX"]], { + const peers = await dnsNodeDiscovery.getPeers([enrTree["SANDBOX"]], { relay: maxQuantity, store: maxQuantity, filter: maxQuantity, @@ -120,7 +120,7 @@ describe("DNS Node Discovery [live data]", function () { const waku = await createLightNode({ libp2p: { peerDiscovery: [ - wakuDnsDiscovery([enrTree["TWN_SANDBOX"], enrTree["TWN_TEST"]], { + wakuDnsDiscovery([enrTree["SANDBOX"], enrTree["TEST"]], { filter: nodesToConnect }) ] diff --git a/packages/tests/tests/waku.node.optional.spec.ts b/packages/tests/tests/waku.node.optional.spec.ts index 40a22fe0d1..fb81951c12 100644 --- a/packages/tests/tests/waku.node.optional.spec.ts +++ b/packages/tests/tests/waku.node.optional.spec.ts @@ -37,7 +37,7 @@ describe("Use static and several ENR trees for bootstrap", function () { peerDiscovery: [ bootstrap({ list: [multiAddrWithId.toString()] }), wakuDnsDiscovery( - [enrTree["TWN_SANDBOX"], enrTree["TWN_TEST"]], + [enrTree["SANDBOX"], enrTree["TEST"]], NODE_REQUIREMENTS ) ]