Skip to content

Commit

Permalink
chore: add back "feat: shards.test fleet""
Browse files Browse the repository at this point in the history
This reverts commit a33ff4d.
  • Loading branch information
richard-ramos authored and iurimatias committed Dec 8, 2023
1 parent ae82394 commit abb298b
Show file tree
Hide file tree
Showing 10 changed files with 135 additions and 54 deletions.
120 changes: 74 additions & 46 deletions fleets.json

Large diffs are not rendered by default.

27 changes: 24 additions & 3 deletions src/app/core/fleets/fleet_configuration.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ type
GoWakuTest = "go-waku.test"
StatusTest = "status.test"
StatusProd = "status.prod"
ShardsTest = "shards.test"

FleetNodes* {.pure.} = enum
Bootnodes = "boot",
Mailservers = "mail",
Rendezvous = "rendezvous",
Whisper = "whisper",
Waku = "tcp/p2p/waku"
WakuENR = "enr/p2p/waku"
WakuBoot = "tcp/p2p/waku/boot"
WakuBootENR = "enr/p2p/waku/boot"
WakuStore = "tcp/p2p/waku/store"
Websocket = "wss/p2p/waku"

Meta* = object
Expand Down Expand Up @@ -54,14 +59,30 @@ proc extractConfig(self: FleetConfiguration, jsonString: string) {.gcsafe.} =
self.fleet[fleet][nodes][server] = fleetJson["fleets"][fleet][nodes][server].getStr

proc getNodes*(self: FleetConfiguration, fleet: Fleet, nodeType: FleetNodes = FleetNodes.Bootnodes): seq[string] =
if not self.fleet[$fleet].hasKey($nodeType): return
result = toSeq(self.fleet[$fleet][$nodeType].values)
var t = nodeType
if fleet == Fleet.ShardsTest:
case nodeType:
of Bootnodes: t = WakuBoot
of Mailservers: t = WakuStore
of WakuENR: t = WakuBootENR
else: discard

if not self.fleet[$fleet].hasKey($t): return
result = toSeq(self.fleet[$fleet][$t].values)

proc getMailservers*(self: FleetConfiguration, fleet: Fleet, isWakuV2: bool): Table[string, string] =
# TODO: If using wakuV2, this assumes that Waku nodes in fleet.status.json are also store nodes.
# Maybe it make senses to add a "waku-store" section in case we want to have separate node types?
# Discuss with @iurimatias, @cammellos and Vac team
let fleetKey = if isWakuV2: $FleetNodes.Waku else: $FleetNodes.Mailservers
var fleetKey: string
if isWakuV2:
if fleet == Fleet.ShardsTest:
fleetKey = $FleetNodes.WakuStore
else:
fleetKey = $FleetNodes.Waku
else:
fleetKey = $FleetNodes.Mailservers

if not self.fleet[$fleet].hasKey(fleetKey) :
result = initTable[string,string]()
return
Expand Down
10 changes: 7 additions & 3 deletions src/app_service/service/accounts/service.nim
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ QtObject:

proc getDefaultNodeConfig*(self: Service, installationId: string, recoverAccount: bool): JsonNode =
let fleet = Fleet.StatusProd
let dnsDiscoveryURL = @["enrtree://AL65EKLJAUXKKPG43HVTML5EFFWEZ7L4LOKTLZCLJASG4DSESQZEC@prod.status.nodes.status.im"]
let dnsDiscoveryURL = "enrtree://AL65EKLJAUXKKPG43HVTML5EFFWEZ7L4LOKTLZCLJASG4DSESQZEC@prod.status.nodes.status.im"

result = NODE_CONFIG.copy()
result["ClusterConfig"]["Fleet"] = newJString($fleet)
Expand All @@ -326,8 +326,12 @@ QtObject:

# TODO: fleet.status.im should have different sections depending on the node type
# or maybe it's not necessary because a node has the identify protocol
result["ClusterConfig"]["WakuNodes"] = %* dnsDiscoveryURL
result["ClusterConfig"]["DiscV5BootstrapNodes"] = %* dnsDiscoveryURL
result["ClusterConfig"]["WakuNodes"] = %* @[dnsDiscoveryURL]

var discV5Bootnodes = self.fleetConfiguration.getNodes(fleet, FleetNodes.WakuENR)
discV5Bootnodes.add(dnsDiscoveryURL)

result["ClusterConfig"]["DiscV5BootstrapNodes"] = %* discV5Bootnodes

if TEST_PEER_ENR != "":
let testPeerENRArr = %* @[TEST_PEER_ENR]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ type
StoreCapacity*: int
StoreSeconds*: int
EnableFilterFullNode*: bool
UseShardAsDefaultTopic*: bool

ShhextConfig* = object
PFSEnabled*: bool
Expand Down Expand Up @@ -330,6 +331,7 @@ proc toWaku2Config*(jsonObj: JsonNode): Waku2Config =
discard jsonObj.getProp("StoreCapacity", result.StoreCapacity)
discard jsonObj.getProp("StoreSeconds", result.StoreSeconds)
discard jsonObj.getProp("EnableFilterFullNode", result.EnableFilterFullNode)
discard jsonObj.getProp("UseShardAsDefaultTopic", result.UseShardAsDefaultTopic)

proc toWakuConfig*(jsonObj: JsonNode): WakuConfig =
discard jsonObj.getProp("Enabled", result.Enabled)
Expand Down
14 changes: 13 additions & 1 deletion src/app_service/service/node_configuration/service.nim
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ proc getBloomLevel*(self: Service): string =
else:
return BLOOM_LEVEL_LIGHT

proc isShardFleet(config: NodeConfigDto): bool =
return case config.ClusterConfig.Fleet:
of $Fleet.ShardsTest: true
else: false

proc setWakuConfig(configuration: NodeConfigDto, wakuVersion: int): NodeConfigDto =
var newConfiguration = configuration
Expand All @@ -129,6 +133,7 @@ proc setWakuConfig(configuration: NodeConfigDto, wakuVersion: int): NodeConfigDt
newConfiguration.WakuV2Config.EnableDiscV5 = true
newConfiguration.WakuV2Config.DiscoveryLimit = 20
newConfiguration.WakuV2Config.Rendezvous = true
newConfiguration.WakuV2Config.UseShardAsDefaultTopic = isShardFleet(newConfiguration)

return newConfiguration

Expand Down Expand Up @@ -230,11 +235,18 @@ proc setFleet*(self: Service, fleet: string): bool =
dnsDiscoveryURL.add("enrtree://AIO6LUM3IVWCU2KCPBBI6FEH2W42IGK3ASCZHZGG5TIXUR56OGQUO@test.status.nodes.status.im")
of Fleet.StatusProd:
dnsDiscoveryURL.add("enrtree://AL65EKLJAUXKKPG43HVTML5EFFWEZ7L4LOKTLZCLJASG4DSESQZEC@prod.status.nodes.status.im")
of Fleet.ShardsTest:
dnsDiscoveryURL.add("enrtree://AMOJVZX4V6EXP7NTJPMAYJYST2QP6AJXYW76IU6VGJS7UVSNDYZG4@boot.test.shards.nodes.status.im")
else:
wakuVersion = 1

newConfiguration.ClusterConfig.WakuNodes = dnsDiscoveryURL
newConfiguration.ClusterConfig.DiscV5BootstrapNodes = dnsDiscoveryURL

var discV5Bootnodes = self.fleetConfiguration.getNodes(fleetType, FleetNodes.WakuENR)
if dnsDiscoveryURL.len != 0:
discV5Bootnodes.add(dnsDiscoveryURL[0])

newConfiguration.ClusterConfig.DiscV5BootstrapNodes = discV5Bootnodes

newConfiguration = setWakuConfig(newConfiguration, wakuVersion)

Expand Down
2 changes: 2 additions & 0 deletions src/app_service/service/settings/dto/settings.nim
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ type PinnedMailserver* = object
goWakuTest*: string
statusTest*: string
statusProd*: string
shardsTest*: string

type CurrentUserStatus* = object
statusType*: StatusType
Expand Down Expand Up @@ -163,6 +164,7 @@ proc toPinnedMailserver*(jsonObj: JsonNode): PinnedMailserver =
discard jsonObj.getProp("go-waku.test", result.goWakuTest)
discard jsonObj.getProp("status.test", result.statusTest)
discard jsonObj.getProp("status.prod", result.statusProd)
discard jsonObj.getProp("shards.test", result.shardsTest)

proc toCurrentUserStatus*(jsonObj: JsonNode): CurrentUserStatus =
var statusTypeInt: int
Expand Down
4 changes: 4 additions & 0 deletions src/app_service/service/settings/service.nim
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,8 @@ QtObject:
return self.settings.pinnedMailserver.statusTest
elif (fleet == Fleet.StatusProd):
return self.settings.pinnedMailserver.statusProd
elif (fleet == Fleet.ShardsTest):
return self.settings.pinnedMailserver.shardsTest
return ""

proc pinMailserver*(self: Service, mailserverID: string, fleet: Fleet): bool =
Expand All @@ -438,6 +440,8 @@ QtObject:
self.settings.pinnedMailserver.statusTest = mailserverID
elif (fleet == Fleet.StatusProd):
self.settings.pinnedMailserver.statusProd = mailserverID
elif (fleet == Fleet.ShardsTest):
self.settings.pinnedMailserver.shardsTest = mailserverID
return true
return false

Expand Down
6 changes: 6 additions & 0 deletions ui/app/AppLayouts/Profile/popups/FleetsModal.qml
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,11 @@ ModalPopup {
fleetName: Constants.status_prod
buttonGroup: fleetSettings
}

FleetRadioSelector {
advancedStore: popup.advancedStore
fleetName: Constants.shards_test
buttonGroup: fleetSettings
}
}
}
3 changes: 2 additions & 1 deletion ui/app/AppLayouts/Profile/stores/AdvancedStore.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ QtObject {
property bool isWakuV2: root.fleet === Constants.waku_prod ||
root.fleet === Constants.waku_test ||
root.fleet === Constants.status_test ||
root.fleet === Constants.status_prod
root.fleet === Constants.status_prod ||
root.fleet === Constants.shards_test

readonly property bool isFakeLoadingScreenEnabled: localAppSettings.fakeLoadingScreenEnabled ?? false
property bool isManageCommunityOnTestModeEnabled: false
Expand Down
1 change: 1 addition & 0 deletions ui/imports/utils/Constants.qml
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,7 @@ QtObject {
readonly property string waku_test: "wakuv2.test"
readonly property string status_test: "status.test"
readonly property string status_prod: "status.prod"
readonly property string shards_test: "shards.test"

readonly property int browserSearchEngineNone: 0
readonly property int browserSearchEngineGoogle: 1
Expand Down

0 comments on commit abb298b

Please sign in to comment.