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
This commit is contained in:
Danish Arora 2024-06-06 12:55:57 -04:00 committed by GitHub
parent c5302fd0c8
commit 16e9116c7c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 4 deletions

View File

@ -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";

View File

@ -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;
}