Add predefined nodes (#313)

This commit is contained in:
Felicio Mununga 2022-10-05 16:28:54 +02:00 committed by GitHub
parent 42d24f567c
commit 788fe3ba34
No known key found for this signature in database
GPG Key ID: 0EB8D75C775AB6F1
2 changed files with 44 additions and 13 deletions

View File

@ -6,12 +6,9 @@ import { hexToBytes } from 'ethereum-cryptography/utils'
import { Protocols, WakuMessage } from 'js-waku'
import { createWaku } from 'js-waku/lib/create_waku'
import { PeerDiscoveryStaticPeers } from 'js-waku/lib/peer_discovery_static_list'
import {
Fleet,
getPredefinedBootstrapNodes,
} from 'js-waku/lib/predefined_bootstrap_nodes'
import { waitForRemotePeer } from 'js-waku/lib/wait_for_remote_peer'
import { peers } from '../consts/peers'
import { ApplicationMetadataMessage } from '../protos/application-metadata-message'
import { Account } from './account'
import { ActivityCenter } from './activityCenter'
@ -65,14 +62,8 @@ class Client {
static async start(options: ClientOptions) {
// Waku
const fleet = options.environment === 'test' ? Fleet.Test : Fleet.Prod
/**
* >only connects to 1 remote node because of the limited number of nodes
* >run by Status and the limited number of connections provided by these nodes
* >
* >@see https://forum.vac.dev/t/waku-v2-scalability-studies/142/2
*/
const peers = getPredefinedBootstrapNodes(fleet)
const { environment = 'production' } = options
const waku = await createWaku({
defaultBootstrap: false,
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
@ -80,7 +71,15 @@ class Client {
emitSelf: true,
relayKeepAlive: 15,
libp2p: {
peerDiscovery: [new PeerDiscoveryStaticPeers(peers)],
peerDiscovery: [
/**
* >only connects to 1 remote node because of the limited number of nodes
* >run by Status and the limited number of connections provided by these nodes
* >
* >@see https://forum.vac.dev/t/waku-v2-scalability-studies/142/2
*/
new PeerDiscoveryStaticPeers(peers[environment], { maxPeers: 1 }),
],
},
})
await waku.start()

View File

@ -0,0 +1,32 @@
/**
* source: @see https://fleets.status.im
*/
// note!: users may experience additional latency due to cross-regional connection
// todo: use "dynamic" discovery protocol instead
// todo?: use a regional map together with an environment variable for the peer selection (e.g. `VERCEL_REGION`, but probably limited to Serverless Functions)
export const peers = {
production: [
// Nim
'/dns4/node-01.ac-cn-hongkong-c.status.prod.statusim.net/tcp/443/wss/p2p/16Uiu2HAkvEZgh3KLwhLwXg95e5ojM8XykJ4Kxi2T7hk22rnA7pJC',
'/dns4/node-01.do-ams3.status.prod.statusim.net/tcp/443/wss/p2p/16Uiu2HAm6HZZr7aToTvEBPpiys4UxajCTU97zj5v7RNR2gbniy1D',
'/dns4/node-01.gc-us-central1-a.status.prod.statusim.net/tcp/443/wss/p2p/16Uiu2HAkwBp8T6G77kQXSNMnxgaMky1JeyML5yqoTHRM8dbeCBNb',
'/dns4/node-02.ac-cn-hongkong-c.status.prod.statusim.net/tcp/443/wss/p2p/16Uiu2HAmFy8BrJhCEmCYrUfBdSNkrPw6VHExtv4rRp1DSBnCPgx8',
'/dns4/node-02.do-ams3.status.prod.statusim.net/tcp/443/wss/p2p/16Uiu2HAmSve7tR5YZugpskMv2dmJAsMUKmfWYEKRXNUxRaTCnsXV',
'/dns4/node-02.gc-us-central1-a.status.prod.statusim.net/tcp/443/wss/p2p/16Uiu2HAmDQugwDHM3YeUp86iGjrUvbdw3JPRgikC7YoGBsT2ymMg',
// Go
// '/dns4/node-01.ac-cn-hongkong-c.go-waku.prod.statusim.net/tcp/443/wss/p2p/16Uiu2HAkwUKwy66nhcSFeW7y5qijNqXC4ZD3TaMMqnoEbh3wK2xU',
// '/dns4/node-01.do-ams3.go-waku.prod.statusim.net/tcp/443/wss/p2p/16Uiu2HAkyScd7DiwgMwzfw8CFFhznH3wRzciqEUfjDzn7vyimR8c',
// '/dns4/node-01.gc-us-central1-a.go-waku.prod.statusim.net/tcp/443/wss/p2p/16Uiu2HAmKTYnoPKebjWy63e1zPKiYRCQvm25W5mNSnCFE8EmzLga',
],
test: [
// Nim
'/dns4/node-01.ac-cn-hongkong-c.status.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAm2BjXxCp1sYFJQKpLLbPbwd5juxbsYofu3TsS3auvT9Yi',
'/dns4/node-01.do-ams3.status.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAkukebeXjTQ9QDBeNDWuGfbaSg79wkkhK4vPocLgR6QFDf',
'/dns4/node-01.gc-us-central1-a.status.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAmGDX3iAFox93PupVYaHa88kULGqMpJ7AEHGwj3jbMtt76',
// Go
// '/dns4/node-01.ac-cn-hongkong-c.go-waku.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAmBDbMWFiG9ki8sDw6fYtraSxo4oHU9HbuN43S2HVyq1FD',
// '/dns4/node-01.do-ams3.go-waku.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAm9vnvCQgCDrynDK1h7GJoEZVGvnuzq84RyDQ3DEdXmcX7',
// '/dns4/node-01.gc-us-central1-a.go-waku.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAmPz63Xc6AuVkDeujz7YeZta18rcdau3Y1BzaxKAfDrBqz',
],
}