Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixing shards validation
Browse files Browse the repository at this point in the history
gabrielmer committed Aug 28, 2024

Verified

This commit was signed with the committer’s verified signature.
MrAlex94 Alex Kontos
1 parent 05dafd7 commit 471bb6d
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions waku/factory/external_config.nim
Original file line number Diff line number Diff line change
@@ -312,8 +312,9 @@ type WakuNodeConf* = object
name: "keep-alive"
.}: bool

networkShards* {.desc: "Number of shards in the network", name: "network-shards".}:
uint32
networkShards* {.
desc: "Number of shards in the network", defaultValue: 0, name: "network-shards"
.}: uint32

pubsubTopics* {.
desc:
2 changes: 1 addition & 1 deletion waku/factory/node_factory.nim
Original file line number Diff line number Diff line change
@@ -117,7 +117,7 @@ proc getNetworkShards*(conf: WakuNodeConf): uint32 =
if conf.networkShards != 0:
return conf.networkShards
# If conf.networkShards is not set, use the number of shards configured as networkShards
return uint32(conf.shards.len)
return uint32(max(conf.shards) + 1)

proc setupProtocols(
node: WakuNode, conf: WakuNodeConf, nodeKey: crypto.PrivateKey
7 changes: 6 additions & 1 deletion waku/factory/waku.nim
Original file line number Diff line number Diff line change
@@ -116,6 +116,11 @@ proc init*(T: type Waku, conf: WakuNodeConf): Result[Waku, string] =

if shardsOpt.isSome():
let relayShards = shardsOpt.get()
if relayShards.clusterId != conf.clusterId:
error "clusterId of the pubsub topic should match the node's cluster",
nodeCluster = conf.clusterId, pubsubCluster = relayShards.clusterId
return err("clusterId of the pubsub topic should match the node's cluster")

for shard in relayShards.shardIds:
shards.add(shard)
confCopy.shards = shards
@@ -149,7 +154,7 @@ proc init*(T: type Waku, conf: WakuNodeConf): Result[Waku, string] =
info "Running nwaku node", version = git_version
logConfig(confCopy)

let validateShardsRes = validateShards(conf)
let validateShardsRes = validateShards(confCopy)
if validateShardsRes.isErr():
error "Failed validating shards", error = $validateShardsRes.error
return err("Failed validating shards: " & $validateShardsRes.error)

0 comments on commit 471bb6d

Please sign in to comment.