From 16e9116c7cf6be876e174fe9259921c8d5397a88 Mon Sep 17 00:00:00 2001 From: Danish Arora <35004822+danisharora099@users.noreply.github.com> Date: Thu, 6 Jun 2024 12:55:57 -0400 Subject: [PATCH] fix: bootstrapping with default pubsub topic (#2031) * fix: bootstrapping into default pubsub topic * chore: update tests * chore: update TODO with GH issue * chore: rename fleets * feat: use TWN fleets, or wakuv2.prod if DefaultPubsubTopic * chore: update imports for enrtree --- packages/discovery/src/dns/constants.ts | 11 +++++++++-- packages/sdk/src/utils/discovery.ts | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/packages/discovery/src/dns/constants.ts b/packages/discovery/src/dns/constants.ts index b7a5a77a1e..f2c00af0ab 100644 --- a/packages/discovery/src/dns/constants.ts +++ b/packages/discovery/src/dns/constants.ts @@ -1,9 +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 = { - TEST: "enrtree://AOGYWMBYOUIMOENHXCHILPKY3ZRFEULMFI4DOM442QSZ73TT2A7VI@test.waku.nodes.status.im", SANDBOX: - "enrtree://AIRVQ5DDA4FFWLRBCHJWUWOO6X6S4ZTZ5B667LQ6AJU6PEYDLRD5O@sandbox.waku.nodes.status.im" + "enrtree://AIRVQ5DDA4FFWLRBCHJWUWOO6X6S4ZTZ5B667LQ6AJU6PEYDLRD5O@sandbox.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 979ab18380..f18771f20b 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,16 @@ const DEFAULT_NODE_REQUIREMENTS = { export function defaultPeerDiscoveries( pubsubTopics: PubsubTopic[] ): ((components: Libp2pComponents) => PeerDiscovery)[] { + const isDefaultPubsubTopic = pubsubTopics.includes(DefaultPubsubTopic); + const dnsEnrTrees = isDefaultPubsubTopic + ? [enrTree["DEPRECATED_DEFAULT_PUBSUB"]] + : [enrTree["SANDBOX"], enrTree["TEST"]]; + const discoveries = [ - wakuDnsDiscovery([enrTree["SANDBOX"]], DEFAULT_NODE_REQUIREMENTS), + wakuDnsDiscovery(dnsEnrTrees, DEFAULT_NODE_REQUIREMENTS), wakuLocalPeerCacheDiscovery(), wakuPeerExchangeDiscovery(pubsubTopics) ]; + return discoveries; }