Skip to content

Commit

Permalink
Add predefined nodes (status-im#313)
Browse files Browse the repository at this point in the history
  • Loading branch information
felicio authored Oct 5, 2022
1 parent 42d24f5 commit 788fe3b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 13 deletions.
25 changes: 12 additions & 13 deletions packages/status-js/src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -65,22 +62,24 @@ 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
// @ts-ignore
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()
Expand Down
32 changes: 32 additions & 0 deletions packages/status-js/src/consts/peers.ts
Original file line number Diff line number Diff line change
@@ -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',
],
}

0 comments on commit 788fe3b

Please sign in to comment.