-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added phase 2 - waku-simulatior integration in README.md
- Loading branch information
1 parent
6485550
commit 78ed6a7
Showing
12 changed files
with
557 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
NWAKU_IMAGE=quay.io/wakuorg/nwaku-pr:2800-rln-v2 | ||
|
||
START_PUBLISHING_AFTER=30 # seconds | ||
NUM_MESSAGES=250 | ||
DELAY_MESSAGES=200 # gap between messages | ||
|
||
MIN_MESSAGE_SIZE=1Kb | ||
MAX_MESSAGE_SIZE=120Kb | ||
|
||
# PUBSUB=/waku/2/rs/66/0 | ||
# CONTENT_TOPIC=/tester/1/light-pubsub-example/proto | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
when (NimMajor, NimMinor) < (1, 4): | ||
{.push raises: [Defect].} | ||
else: | ||
{.push raises: [].} | ||
|
||
import | ||
std/[options, strutils, os, sequtils, net, strformat], | ||
chronicles, | ||
chronos, | ||
metrics, | ||
libbacktrace, | ||
system/ansi_c, | ||
libp2p/crypto/crypto, | ||
confutils, | ||
libp2p/wire | ||
|
||
import | ||
../../waku/common/logging, | ||
../../waku/factory/waku, | ||
../../waku/factory/external_config, | ||
../../waku/node/health_monitor, | ||
../../waku/node/waku_metrics, | ||
../../waku/waku_api/rest/builder as rest_server_builder, | ||
../../waku/node/peer_manager, | ||
../../waku/waku_lightpush/common, | ||
../../waku/waku_relay, | ||
../../waku/waku_filter_v2, | ||
../../waku/waku_api/rest/client, | ||
../../waku/waku_api/rest/admin/client, | ||
./tester_config, | ||
./lightpush_publisher, | ||
./filter_subscriber | ||
|
||
logScope: | ||
topics = "diagnose connections" | ||
|
||
proc logSelfPeersLoop(pm: PeerManager, interval: Duration) {.async.} = | ||
trace "Starting logSelfPeersLoop diagnosys loop" | ||
while true: | ||
let selfLighpushPeers = pm.peerStore.getPeersByProtocol(WakuLightPushCodec) | ||
let selfRelayPeers = pm.peerStore.getPeersByProtocol(WakuRelayCodec) | ||
let selfFilterPeers = pm.peerStore.getPeersByProtocol(WakuFilterSubscribeCodec) | ||
|
||
let printable = catch: | ||
"""*------------------------------------------------------------------------------------------* | ||
| Self ({pm.switch.peerInfo}) peers: | ||
*------------------------------------------------------------------------------------------* | ||
| Lightpush peers({selfLighpushPeers.len()}): ${selfLighpushPeers} | ||
*------------------------------------------------------------------------------------------* | ||
| Filter peers({selfFilterPeers.len()}): ${selfFilterPeers} | ||
*------------------------------------------------------------------------------------------* | ||
| Relay peers({selfRelayPeers.len()}): ${selfRelayPeers} | ||
*------------------------------------------------------------------------------------------*""".fmt() | ||
|
||
if printable.isErr(): | ||
echo "Error while printing statistics: " & printable.error().msg | ||
else: | ||
echo printable.get() | ||
|
||
await sleepAsync(interval) | ||
|
||
proc logServiceRelayPeers( | ||
pm: PeerManager, codec: string, interval: Duration | ||
) {.async.} = | ||
trace "Starting service node connectivity diagnosys loop" | ||
while true: | ||
echo "*------------------------------------------------------------------------------------------*" | ||
echo "| Service peer connectivity:" | ||
let selfLighpushPeers = pm.selectPeer(codec) | ||
if selfLighpushPeers.isSome(): | ||
let ma = selfLighpushPeers.get().addrs[0] | ||
var serviceIp = initTAddress(ma).valueOr: | ||
echo "Error while parsing multiaddress: " & $error | ||
continue | ||
|
||
serviceIp.port = Port(8645) | ||
let restClient = newRestHttpClient(initTAddress($serviceIp)) | ||
|
||
let getPeersRes = await restClient.getPeers() | ||
|
||
if getPeersRes.status == 200: | ||
let nrOfPeers = getPeersRes.data.len() | ||
echo "Service node (@" & $ma & ") peers: " & $getPeersRes.data | ||
else: | ||
echo "Error while fetching service node (@" & $ma & ") peers: " & | ||
$getPeersRes.data | ||
else: | ||
echo "No service node peers found" | ||
|
||
echo "*------------------------------------------------------------------------------------------*" | ||
|
||
await sleepAsync(interval) | ||
|
||
proc startPeriodicPeerDiagnostic*(pm: PeerManager, codec: string) {.async.} = | ||
asyncSpawn logSelfPeersLoop(pm, chronos.seconds(20)) | ||
asyncSpawn logServiceRelayPeers(pm, codec, chronos.seconds(20)) |
Oops, something went wrong.