diff --git a/apps/wakucanary/README.md b/apps/wakucanary/README.md index 2f8e5275ec..6ae4ca3e9f 100644 --- a/apps/wakucanary/README.md +++ b/apps/wakucanary/README.md @@ -15,9 +15,11 @@ The following options are available: -p, --protocol Protocol required to be supported: store,relay,lightpush,filter (can be used multiple times). -l, --log-level Sets the log level [=LogLevel.DEBUG]. - -np, --node-port Listening port for waku node [=60000]. + -np, --node-port Listening port for waku node [=60000]. --websocket-secure-key-path Secure websocket key path: '/path/to/key.txt' . --websocket-secure-cert-path Secure websocket Certificate path: '/path/to/cert.txt' . + -c, --cluster-id Cluster ID of the fleet node to check status [Default=1] + -s, --shard Shards index to subscribe to topics [ Argument may be repeated ] ``` diff --git a/apps/wakucanary/wakucanary.nim b/apps/wakucanary/wakucanary.nim index 175c962ed2..8aa75affd0 100644 --- a/apps/wakucanary/wakucanary.nim +++ b/apps/wakucanary/wakucanary.nim @@ -84,6 +84,21 @@ type WakuCanaryConf* = object desc: "Ping the peer node to measure latency", defaultValue: true, name: "ping" .}: bool + shards* {. + desc: "Shards index to subscribe to [0..MAX_SHARDS-1]. Argument may be repeated.", + defaultValue: @[], + name: "shard", + abbr: "s" + .}: seq[uint16] + + clusterId* {. + desc: + "Cluster id that the node is running in. Node in a different cluster id is disconnected.", + defaultValue: 1, + name: "cluster-id", + abbr: "c" + .}: uint16 + proc parseCmdArg*(T: type chronos.Duration, p: string): T = try: result = chronos.seconds(parseInt(p)) @@ -190,6 +205,13 @@ proc main(rng: ref HmacDrbgContext): Future[int] {.async.} = var enrBuilder = EnrBuilder.init(nodeKey) + let relayShards = RelayShards.init(conf.clusterId, conf.shards).valueOr: + error "Relay shards initialization failed", error = error + return 1 + enrBuilder.withWakuRelaySharding(relayShards).isOkOr: + error "Building ENR with relay sharding failed", error = error + return 1 + let recordRes = enrBuilder.build() let record = if recordRes.isErr(): @@ -214,6 +236,8 @@ proc main(rng: ref HmacDrbgContext): Future[int] {.async.} = ) let node = builder.build().tryGet() + node.mountMetadata(conf.clusterId).isOkOr: + error "failed to mount waku metadata protocol: ", err = error if conf.ping: try: diff --git a/waku/node/peer_manager/peer_manager.nim b/waku/node/peer_manager/peer_manager.nim index 679041580f..a2993c5241 100644 --- a/waku/node/peer_manager/peer_manager.nim +++ b/waku/node/peer_manager/peer_manager.nim @@ -380,8 +380,8 @@ proc onPeerMetadata(pm: PeerManager, peerId: PeerId) {.async.} = pm.peerStore.hasPeer(peerId, WakuRelayCodec) and not metadata.shards.anyIt(pm.wakuMetadata.shards.contains(it)) ): - let myShardsString = "[ " & toSeq(pm.wakuMetadata.shards).join(", ") & "]" - let otherShardsString = "[ " & metadata.shards.join(", ") & "]" + let myShardsString = "[ " & toSeq(pm.wakuMetadata.shards).join(", ") & " ]" + let otherShardsString = "[ " & metadata.shards.join(", ") & " ]" reason = "no shards in common: my_shards = " & myShardsString & " others_shards = " & otherShardsString