Skip to content

Commit

Permalink
fix: cluster-id 0 disc5 issue (#2562)
Browse files Browse the repository at this point in the history
  • Loading branch information
alrevuelta authored Apr 4, 2024
1 parent c87545d commit a76c958
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 20 deletions.
12 changes: 11 additions & 1 deletion apps/wakunode2/networks_config.nim
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,17 @@ type ClusterConf* = object
discv5Discovery*: bool
discv5BootstrapNodes*: seq[string]

# cluster-id=1
# cluster-id=0
# Cluster configuration for the default pubsub topic. Note that it
# overrides existing cli configuration
proc ClusterZeroConf*(T: type ClusterConf): ClusterConf =
return ClusterConf(
clusterId: 0.uint32,
pubsubTopics: @["/waku/2/default-waku/proto"]
# TODO: Add more config such as bootstrap, etc
)

# cluster-id=1 (aka The Waku Network)
# Cluster configuration corresponding to The Waku Network. Note that it
# overrides existing cli configuration
proc TheWakuNetworkConf*(T: type ClusterConf): ClusterConf =
Expand Down
46 changes: 27 additions & 19 deletions apps/wakunode2/wakunode2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -87,26 +87,34 @@ when isMainModule:
of inspectRlnDb:
doInspectRlnDb(conf)
of noCommand:
# The Waku Network config (cluster-id=1)
if conf.clusterId == 1:
let twnClusterConf = ClusterConf.TheWakuNetworkConf()
if len(conf.shards) != 0:
conf.pubsubTopics = conf.shards.mapIt(twnClusterConf.pubsubTopics[it.uint16])
case conf.clusterId
# cluster-id=0
of 0:
let clusterZeroConf = ClusterConf.ClusterZeroConf()
conf.pubsubTopics = clusterZeroConf.pubsubTopics
# TODO: Write some template to "merge" the configs
# cluster-id=1 (aka The Waku Network)
of 1:
let twnClusterConf = ClusterConf.TheWakuNetworkConf()
if len(conf.shards) != 0:
conf.pubsubTopics = conf.shards.mapIt(twnClusterConf.pubsubTopics[it.uint16])
else:
conf.pubsubTopics = twnClusterConf.pubsubTopics

# Override configuration
conf.maxMessageSize = twnClusterConf.maxMessageSize
conf.clusterId = twnClusterConf.clusterId
conf.rlnRelay = twnClusterConf.rlnRelay
conf.rlnRelayEthContractAddress = twnClusterConf.rlnRelayEthContractAddress
conf.rlnRelayDynamic = twnClusterConf.rlnRelayDynamic
conf.rlnRelayBandwidthThreshold = twnClusterConf.rlnRelayBandwidthThreshold
conf.discv5Discovery = twnClusterConf.discv5Discovery
conf.discv5BootstrapNodes =
conf.discv5BootstrapNodes & twnClusterConf.discv5BootstrapNodes
conf.rlnEpochSizeSec = twnClusterConf.rlnEpochSizeSec
conf.rlnRelayUserMessageLimit = twnClusterConf.rlnRelayUserMessageLimit
else:
conf.pubsubTopics = twnClusterConf.pubsubTopics

# Override configuration
conf.maxMessageSize = twnClusterConf.maxMessageSize
conf.clusterId = twnClusterConf.clusterId
conf.rlnRelay = twnClusterConf.rlnRelay
conf.rlnRelayEthContractAddress = twnClusterConf.rlnRelayEthContractAddress
conf.rlnRelayDynamic = twnClusterConf.rlnRelayDynamic
conf.rlnRelayBandwidthThreshold = twnClusterConf.rlnRelayBandwidthThreshold
conf.discv5Discovery = twnClusterConf.discv5Discovery
conf.discv5BootstrapNodes =
conf.discv5BootstrapNodes & twnClusterConf.discv5BootstrapNodes
conf.rlnEpochSizeSec = twnClusterConf.rlnEpochSizeSec
conf.rlnRelayUserMessageLimit = twnClusterConf.rlnRelayUserMessageLimit
discard

info "Running nwaku node", version = app.git_version
logConfig(conf)
Expand Down

0 comments on commit a76c958

Please sign in to comment.