Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bootstrapping with default pubsub topic #2031

Merged
merged 6 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/discovery/src/dns/constants.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import type { NodeCapabilityCount } from "@waku/interfaces";

export const enrTree = {
TEST: "enrtree://AOGYWMBYOUIMOENHXCHILPKY3ZRFEULMFI4DOM442QSZ73TT2A7VI@test.waku.nodes.status.im",
SANDBOX:
"enrtree://AIRVQ5DDA4FFWLRBCHJWUWOO6X6S4ZTZ5B667LQ6AJU6PEYDLRD5O@sandbox.waku.nodes.status.im"
DEFAULT_PUBSUB:
danisharora099 marked this conversation as resolved.
Show resolved Hide resolved
"enrtree://ANEDLO25QVUGJOUTQFRYKWX6P4Z4GKVESBMHML7DZ6YK4LGS5FC5O@prod.wakuv2.nodes.status.im",
TWN_SANDBOX:
"enrtree://AIRVQ5DDA4FFWLRBCHJWUWOO6X6S4ZTZ5B667LQ6AJU6PEYDLRD5O@sandbox.waku.nodes.status.im",
TWN_TEST:
"enrtree://AOGYWMBYOUIMOENHXCHILPKY3ZRFEULMFI4DOM442QSZ73TT2A7VI@test.waku.nodes.status.im"
};

export const DEFAULT_BOOTSTRAP_TAG_NAME = "bootstrap";
Expand Down
4 changes: 2 additions & 2 deletions packages/discovery/src/dns/dns.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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], {
danisharora099 marked this conversation as resolved.
Show resolved Hide resolved
relay: maxQuantity,
store: maxQuantity,
filter: maxQuantity,
Expand All @@ -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,
Expand Down
22 changes: 18 additions & 4 deletions packages/sdk/src/utils/discovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
//https://github.com/waku-org/nwaku/issues/2593
danisharora099 marked this conversation as resolved.
Show resolved Hide resolved
const isDefaultPubsub = pubsubTopics.includes(DefaultPubsubTopic);
if (isDefaultPubsub) {
discoveries.push(
wakuDnsDiscovery([enrTree["DEFAULT_PUBSUB"]], DEFAULT_NODE_REQUIREMENTS)
);
}

return discoveries;
}
8 changes: 4 additions & 4 deletions packages/tests/tests/dns-peer-discovery.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
]
}
});
Expand All @@ -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,
Expand All @@ -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
})
]
Expand Down
2 changes: 1 addition & 1 deletion packages/tests/tests/waku.node.optional.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
]
Expand Down
Loading