Add wakuv2 fleets

This commit is contained in:
Richard Ramos 2021-06-04 13:38:25 -04:00 committed by Iuri Matias
parent 26c17afb5d
commit 561991da67
11 changed files with 123 additions and 44 deletions

View File

@ -62,9 +62,9 @@
"boot-01.gc-us-central1-a.eth.staging": "enode://10a78c17929a7019ef4aa2249d7302f76ae8a06f40b2dc88b7b31ebff4a623fbb44b4a627acba296c1ced3775d91fbe18463c15097a6a36fdb2c804ff3fc5b35@35.238.97.234:443"
},
"mail": {
"mail-01.ac-cn-hongkong-c.eth.staging": "enode://b74859176c9751d314aeeffc26ec9f866a412752e7ddec91b19018a18e7cca8d637cfe2cedcb972f8eb64d816fbd5b4e89c7e8c7fd7df8a1329fa43db80b0bfe@47.52.90.156:30504",
"mail-01.do-ams3.eth.staging": "enode://69f72baa7f1722d111a8c9c68c39a31430e9d567695f6108f31ccb6cd8f0adff4991e7fdca8fa770e75bc8a511a87d24690cbc80e008175f40c157d6f6788d48@206.189.240.16:30504",
"mail-01.gc-us-central1-a.eth.staging": "enode://e4fc10c1f65c8aed83ac26bc1bfb21a45cc1a8550a58077c8d2de2a0e0cd18e40fd40f7e6f7d02dc6cd06982b014ce88d6e468725ffe2c138e958788d0002a7f@35.239.193.41:30504"
"mail-01.ac-cn-hongkong-c.eth.staging": "enode://b74859176c9751d314aeeffc26ec9f866a412752e7ddec91b19018a18e7cca8d637cfe2cedcb972f8eb64d816fbd5b4e89c7e8c7fd7df8a1329fa43db80b0bfe@47.52.90.156:443",
"mail-01.do-ams3.eth.staging": "enode://69f72baa7f1722d111a8c9c68c39a31430e9d567695f6108f31ccb6cd8f0adff4991e7fdca8fa770e75bc8a511a87d24690cbc80e008175f40c157d6f6788d48@206.189.240.16:443",
"mail-01.gc-us-central1-a.eth.staging": "enode://e4fc10c1f65c8aed83ac26bc1bfb21a45cc1a8550a58077c8d2de2a0e0cd18e40fd40f7e6f7d02dc6cd06982b014ce88d6e468725ffe2c138e958788d0002a7f@35.239.193.41:443"
},
"rendezvous": {
"boot-01.ac-cn-hongkong-c.eth.staging": "/ip4/47.91.229.44/tcp/30703/ethv4/16Uiu2HAmRnt2Eyoknh3auxh4fJwkRgqkH1gqrWGes8Pk1k3MV4xu",
@ -72,9 +72,9 @@
"boot-01.gc-us-central1-a.eth.staging": "/ip4/35.238.97.234/tcp/30703/ethv4/16Uiu2HAm6G9sDMkrB4Xa5EH3Zx2dysCxFgBTSRzghic3Z9tRFRNE"
},
"whisper": {
"node-01.ac-cn-hongkong-c.eth.staging": "enode://00395686f5954662a3796e170b9e87bbaf68a050d57e9987b78a2292502dae44aae2b8803280a017ec9af9be0b3121db9d6b3693ab3a0451a866bcbedd58fdac@47.52.226.137:30305",
"node-01.do-ams3.eth.staging": "enode://914c0b30f27bab30c1dfd31dad7652a46fda9370542aee1b062498b1345ee0913614b8b9e3e84622e84a7203c5858ae1d9819f63aece13ee668e4f6668063989@167.99.19.148:30305",
"node-01.gc-us-central1-a.eth.staging": "enode://2d897c6e846949f9dcf10279f00e9b8325c18fe7fa52d658520ad7be9607c83008b42b06aefd97cfe1fdab571f33a2a9383ff97c5909ed51f63300834913237e@35.192.0.86:30305"
"node-01.ac-cn-hongkong-c.eth.staging": "enode://088cf5a93c576fae52f6f075178467b8ff98bacf72f59e88efb16dfba5b30f80a4db78f8e3cb3d87f2f6521746ef4a8768465ef2896c6af24fd77a425e95b6dd@47.52.226.137:443",
"node-01.do-ams3.eth.staging": "enode://914c0b30f27bab30c1dfd31dad7652a46fda9370542aee1b062498b1345ee0913614b8b9e3e84622e84a7203c5858ae1d9819f63aece13ee668e4f6668063989@167.99.19.148:443",
"node-01.gc-us-central1-a.eth.staging": "enode://d3878441652f010326889f28360e69f2d09d06540f934fada0e17b374ce5319de64279aba3c44a5bf807d9967c6d705b3b4c6b03fa70763240e2ee6af01a539e@35.192.0.86:443"
}
},
"eth.test": {
@ -99,14 +99,33 @@
"node-01.gc-us-central1-a.eth.test": "enode://f593a27731bc0f8eb088e2d39222c2d59dfb9bf0b3950d7a828d51e8ab9e08fffbd9916a82fd993c1a080c57c2bd70ed6c36f489a969de697aff93088dbee1a9@35.194.31.108:443"
}
},
"wakuv2.prod": {
"waku": {
"node-01.ac-cn-hongkong-c.wakuv2.prod": "/ip4/8.210.222.231/tcp/30303/p2p/16Uiu2HAm4v86W3bmT1BiH6oSPzcsSr24iDQpSN5Qa992BCjjwgrD",
"node-01.do-ams3.wakuv2.prod": "/ip4/188.166.135.145/tcp/30303/p2p/16Uiu2HAmL5okWopX7NqZWBUKVqW8iUxCEmd5GMHLVPwCgzYzQv3e",
"node-01.gc-us-central1-a.wakuv2.prod": "/ip4/34.121.100.108/tcp/30303/p2p/16Uiu2HAmVkKntsECaYfefR1V2yCR79CegLATuTPE6B9TxgxBiiiA"
},
"waku-websocket": {
"node-01.ac-cn-hongkong-c.wakuv2.prod": "/dns4/node-01.ac-cn-hongkong-c.wakuv2.prod.statusim.net/tcp/443/wss/p2p/16Uiu2HAm4v86W3bmT1BiH6oSPzcsSr24iDQpSN5Qa992BCjjwgrD",
"node-01.do-ams3.wakuv2.prod": "/dns4/node-01.do-ams3.wakuv2.prod.statusim.net/tcp/443/wss/p2p/16Uiu2HAmL5okWopX7NqZWBUKVqW8iUxCEmd5GMHLVPwCgzYzQv3e",
"node-01.gc-us-central1-a.wakuv2.prod": "/dns4/node-01.gc-us-central1-a.wakuv2.prod.statusim.net/tcp/443/wss/p2p/16Uiu2HAmVkKntsECaYfefR1V2yCR79CegLATuTPE6B9TxgxBiiiA"
}
},
"wakuv2.test": {
"waku": {
"node-01.do-ams3.wakuv2.test": "/ip4/0.0.0.0/tcp/60000/p2p/16Uiu2HAmPLe7Mzm8TsYUubgCAW1aJoeFScxrLj8ppHFivPo97bUZ"
"node-01.ac-cn-hongkong-c.wakuv2.test": "/ip4/47.242.210.73/tcp/30303/p2p/16Uiu2HAkvWiyFsgRhuJEb9JfjYxEkoHLgnUQmr1N5mKWnYjxYRVm",
"node-01.do-ams3.wakuv2.test": "/ip4/134.209.139.210/tcp/30303/p2p/16Uiu2HAmPLe7Mzm8TsYUubgCAW1aJoeFScxrLj8ppHFivPo97bUZ",
"node-01.gc-us-central1-a.wakuv2.test": "/ip4/104.154.239.128/tcp/30303/p2p/16Uiu2HAmJb2e28qLXxT5kZxVUUoJt72EMzNGXB47Rxx5hw3q4YjS"
},
"waku-websocket": {
"node-01.ac-cn-hongkong-c.wakuv2.test": "/dns4/node-01.ac-cn-hongkong-c.wakuv2.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAkvWiyFsgRhuJEb9JfjYxEkoHLgnUQmr1N5mKWnYjxYRVm",
"node-01.do-ams3.wakuv2.test": "/dns4/node-01.do-ams3.wakuv2.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAmPLe7Mzm8TsYUubgCAW1aJoeFScxrLj8ppHFivPo97bUZ",
"node-01.gc-us-central1-a.wakuv2.test": "/dns4/node-01.gc-us-central1-a.wakuv2.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAmJb2e28qLXxT5kZxVUUoJt72EMzNGXB47Rxx5hw3q4YjS"
}
}
},
"meta": {
"hostname": "bots-01.ac-cn-hongkong-c.eth.prod",
"timestamp": "2020-11-06T16:00:14.829950"
"hostname": "node-01.do-ams3.proxy.misc",
"timestamp": "2021-06-04T15:30:41.320046"
}
}

View File

@ -27,9 +27,15 @@ QtObject:
proc setFleet*(self: Fleets, newFleet: string) {.slot.} =
discard self.status.settings.saveSetting(Setting.Fleet, newFleet)
let fleet = parseEnum[Fleet](newFleet)
let installationId = self.status.settings.getSetting[:string](Setting.InstallationId)
let updatedNodeConfig = self.status.accounts.getNodeConfig(self.status.fleet.config, installationId, $self.status.settings.getCurrentNetwork(), fleet)
discard self.status.settings.saveSetting(Setting.NodeConfig, updatedNodeConfig)
let installationId = status_settings.getSetting[string](Setting.InstallationId)
let updatedNodeConfig = status_accounts.getNodeConfig(self.status.fleet.config, installationId, $status_settings.getCurrentNetwork(), fleet)
discard status_settings.saveSetting(Setting.NodeConfig, updatedNodeConfig)
let isWakuV2 = if fleet == WakuV2Prod or fleet == WakuV2Test: true else: false
# Updating waku version because it makes no sense for some fleets to run under wakuv1 or v2 config
if isWakuV2:
status_settings.setWakuVersion(2)
else:
status_settings.setWakuVersion(1)
self.fleetChanged(newFleet)
quit(QuitSuccess) # quits the app TODO: change this to logout instead when supported

View File

@ -1,36 +1,35 @@
import json, os, nimcrypto, uuids, json_serialization, chronicles, strutils
from status_go import multiAccountGenerateAndDeriveAddresses, generateAlias, identicon, saveAccountAndLogin, login, openAccounts
from status_go import multiAccountGenerateAndDeriveAddresses, generateAlias, identicon, saveAccountAndLogin, login, openAccounts, getNodeConfig
import core
import ../utils as utils
import ../types as types
import accounts/constants
import ../signals/types as signal_types
import ../wallet/account
from settings as status_settings import nil
proc getNetworkConfig(currentNetwork: string): JsonNode =
result = constants.DEFAULT_NETWORKS.first("id", currentNetwork)
proc getNodeConfig*(fleetConfig: FleetConfig, installationId: string, networkConfig: JsonNode, fleet: Fleet = Fleet.PROD, bloomFilterMode = false): JsonNode =
proc getNodeConfig*(fleetConfig: FleetConfig, installationId: string, networkConfig: JsonNode, fleet: Fleet = Fleet.PROD, bloomFilterMode = false, useDefaultConfig: bool = false): JsonNode =
let upstreamUrl = networkConfig["config"]["UpstreamConfig"]["URL"]
var newDataDir = networkConfig["config"]["DataDir"].getStr
newDataDir.removeSuffix("_rpc")
if useDefaultConfig:
result = constants.NODE_CONFIG.copy()
else:
result = getNodeConfig().parseJSON()
result["ClusterConfig"]["Fleet"] = newJString($fleet)
result["ClusterConfig"]["BootNodes"] = %* (@[])
result["ClusterConfig"]["TrustedMailServers"] = %* (@[])
result["ClusterConfig"]["StaticNodes"] = %* (@[])
result["ClusterConfig"]["RendezvousNodes"] = %* (@[])
result["ClusterConfig"]["WakuNodes"] = %*(@[
"/ip4/134.209.113.86/tcp/9000/p2p/16Uiu2HAmVVi6Q4j7MAKVibquW8aA27UNrA4Q8Wkz9EetGViu8ZF1",
])
result["ClusterConfig"]["WakuStoreNodes"] = %*(@[
"/ip4/134.209.113.86/tcp/9000/p2p/16Uiu2HAmVVi6Q4j7MAKVibquW8aA27UNrA4Q8Wkz9EetGViu8ZF1"
])
result["ClusterConfig"]["BootNodes"] = %* fleetConfig.getNodes(fleet, FleetNodes.Bootnodes)
result["ClusterConfig"]["TrustedMailServers"] = %* fleetConfig.getNodes(fleet, FleetNodes.Mailservers)
result["ClusterConfig"]["StaticNodes"] = %* fleetConfig.getNodes(fleet, FleetNodes.Whisper)
result["ClusterConfig"]["RendezvousNodes"] = %* fleetConfig.getNodes(fleet, FleetNodes.Rendezvous)
result["ClusterConfig"]["WakuNodes"] = %* fleetConfig.getNodes(fleet, FleetNodes.Waku)
result["ClusterConfig"]["WakuStoreNodes"] = %* fleetConfig.getNodes(fleet, FleetNodes.Waku)
result["Rendezvous"] = newJBool(false)
result["NetworkId"] = networkConfig["config"]["NetworkId"]
result["DataDir"] = newDataDir.newJString()
result["UpstreamConfig"]["Enabled"] = networkConfig["config"]["UpstreamConfig"]["Enabled"]
@ -43,9 +42,9 @@ proc getNodeConfig*(fleetConfig: FleetConfig, installationId: string, networkCon
# result["ListenAddr"] = if existsEnv("STATUS_PORT"): newJString("0.0.0.0:" & $getEnv("STATUS_PORT")) else: newJString("0.0.0.0:30305")
result["WakuConfig"]["BloomFilterMode"] = newJBool(bloomFilterMode)
proc getNodeConfig*(fleetConfig: FleetConfig, installationId: string, currentNetwork: string = constants.DEFAULT_NETWORK_NAME, fleet: Fleet = Fleet.PROD, bloomFilterMode = false): JsonNode =
proc getNodeConfig*(fleetConfig: FleetConfig, installationId: string, currentNetwork: string = constants.DEFAULT_NETWORK_NAME, fleet: Fleet = Fleet.PROD, bloomFilterMode = false, useDefaultConfig: bool = false): JsonNode =
let networkConfig = getNetworkConfig(currentNetwork)
result = getNodeConfig(fleetConfig, installationId, networkConfig, fleet, bloomFilterMode)
result = getNodeConfig(fleetConfig, installationId, networkConfig, fleet, bloomFilterMode, useDefaultConfig)
proc hashPassword*(password: string): string =
result = "0x" & $keccak_256.digest(password)
@ -177,7 +176,7 @@ proc getAccountSettings*(account: GeneratedAccount, defaultNetworks: JsonNode, i
"wallet-root-address": account.derived.walletRoot.address,
"preview-privacy?": true,
"signing-phrase": generateSigningPhrase(3),
"log-level": "DEBUG",
"log-level": "INFO",
"latest-derived-path": 0,
"networks/networks": defaultNetworks,
"currency": "usd",
@ -197,7 +196,7 @@ proc setupAccount*(fleetConfig: FleetConfig, account: GeneratedAccount, password
let accountData = getAccountData(account)
let installationId = $genUUID()
var settingsJSON = getAccountSettings(account, constants.DEFAULT_NETWORKS, installationId)
var nodeConfig = getNodeConfig(fleetConfig, installationId)
var nodeConfig = getNodeConfig(fleetConfig, installationId, constants.DEFAULT_NETWORK_NAME, Fleet.PROD, true)
result = saveAccountAndLogin(account, $accountData, password, $nodeConfig, $settingsJSON)

View File

@ -124,13 +124,13 @@ var NODE_CONFIG* = %* {
#"ListenAddr": ":30304",
"LogEnabled": true,
"LogFile": "geth.log",
"LogLevel": "DEBUG",
"LogLevel": "INFO",
"MailserversConfig": {
"Enabled": true
},
"Name": "StatusDesktop",
"NetworkId": 1,
"NoDiscovery": true,
"NoDiscovery": false,
"PermissionsConfig": {
"Enabled": true
},
@ -160,8 +160,14 @@ var NODE_CONFIG* = %* {
"Enabled": true,
"URL": "https://mainnet.infura.io/v3/" & INFURA_TOKEN_RESOLVED
},
"WakuV2Config": {
"WakuConfig": {
"BloomFilterMode": nil,
"Enabled": true,
"LightClient": true,
"MinimumPoW": 0.001
},
"WakuV2Config": {
"Enabled": false,
"Host": "0.0.0.0",
"Port": 0
},

View File

@ -8,6 +8,8 @@ import
./core, ../types, ../signals/types as statusgo_types, ./accounts/constants,
../utils
from status_go import getNodeConfig
var
settings {.threadvar.}: JsonNode
settingsInited {.threadvar.}: bool
@ -113,3 +115,24 @@ proc getMailservers*():JsonNode =
let fleet = getSetting[string](Setting.Fleet, $Fleet.PROD)
result = callPrivateRPC("mailservers_getMailservers").parseJSON()["result"]
proc getWakuVersion*():int =
let nodeConfig = getNodeConfig().parseJSON()
if nodeConfig["WakuConfig"]["Enabled"].getBool():
return 1
if nodeConfig["WakuV2Config"]["Enabled"].getBool():
return 2
return 0
proc setWakuVersion*(newVersion: int) =
let nodeConfig = getNodeConfig().parseJSON()
if newVersion == 1:
nodeConfig["WakuConfig"]["Enabled"] = newJBool(true)
nodeConfig["WakuV2Config"]["Enabled"] = newJBool(false)
nodeConfig["NoDiscovery"] = newJBool(false)
nodeConfig["Rendezvous"] = newJBool(true)
else:
nodeConfig["WakuConfig"]["Enabled"] = newJBool(false)
nodeConfig["WakuV2Config"]["Enabled"] = newJBool(true)
nodeConfig["NoDiscovery"] = newJBool(true)
nodeConfig["Rendezvous"] = newJBool(false)
discard saveSetting(Setting.NodeConfig, nodeConfig)

View File

@ -146,6 +146,11 @@ proc requestMessages*(self: MailserverModel) =
debug "Requesting messages from", mailserver=self.activeMailserver
discard status_mailservers.requestAllHistoricMessages()
proc requestStoreMessages*(self: MailserverModel, topics: seq[string], fromValue: int64 = 0, toValue: int64 = 0, force: bool = false) =
debug "Requesting messages from", mailserver=self.activeMailserver
let generatedSymKey = status_chat.generateSymKeyFromPassword()
status_mailservers.requestStoreMessages(topics, generatedSymKey, self.activeMailserver, 1000, fromValue, toValue, force)
proc requestMoreMessages*(self: MailserverModel, chatId: string) =
debug "Requesting more messages from", mailserver=self.activeMailserver, chatId=chatId
discard status_mailservers.syncChatFromSyncedFrom(chatId)

View File

@ -230,6 +230,7 @@ type
Prod = "eth.prod",
Staging = "eth.staging",
Test = "eth.test",
WakuV2Prod = "wakuv2.prod"
WakuV2Test = "wakuv2.test"
FleetNodes* {.pure.} = enum
@ -263,8 +264,12 @@ proc toFleetConfig*(jsonString: string): FleetConfig =
proc getNodes*(self: FleetConfig, fleet: Fleet, nodeType: FleetNodes = FleetNodes.Bootnodes): seq[string] =
if not self.fleet[$fleet].hasKey($nodeType): return
result = toSeq(self.fleet[$fleet][$nodeType].values)
proc getMailservers*(self: FleetConfig, fleet: Fleet): Table[string, string] =
if not self.fleet[$fleet].hasKey($FleetNodes.Mailservers):
result = initTable[string,string]()
return
result = self.fleet[$fleet][$FleetNodes.Mailservers]

View File

@ -15,17 +15,23 @@ StatusRadioButtonRow {
if (checked) {
if (profileModel.fleets.fleet === fleetName) return;
newFleet = fleetName;
confirmDialog.open();
openPopup(confirmDialogComponent)
}
}
Component {
id: confirmDialogComponent
ConfirmationDialog {
id: confirmDialog
//% "Warning!"
title: qsTrId("close-app-title")
//% "Change fleet to %1"
confirmationText: qsTrId("change-fleet-to--1").arg(newFleet)
onConfirmButtonClicked: profileModel.fleets.setFleet(newFleet)
onClosed: profileModel.fleets.triggerFleetChange()
onClosed: {
profileModel.fleets.triggerFleetChange()
destroy();
}
}
}
}

View File

@ -36,5 +36,13 @@ ModalPopup {
FleetRadioSelector {
fleetName: Constants.eth_test
}
FleetRadioSelector {
fleetName: Constants.waku_prod
}
FleetRadioSelector {
fleetName: Constants.waku_test
}
}
}

View File

@ -120,6 +120,8 @@ QtObject {
readonly property string eth_prod: "eth.prod"
readonly property string eth_staging: "eth.staging"
readonly property string eth_test: "eth.test"
readonly property string waku_prod: "wakuv2.prod"
readonly property string waku_test: "wakuv2.test"
readonly property int browserSearchEngineNone: 0
readonly property int browserSearchEngineGoogle: 1

@ -1 +1 @@
Subproject commit f1ec58561d7b48f6c8b664f3806fd8a113164fba
Subproject commit f4463f3955a96e162e9881b73ba02f819e0374a4