Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(wakucanary): add canary tool #1205

Merged
merged 8 commits into from
Oct 11, 2022
Merged

chore(wakucanary): add canary tool #1205

merged 8 commits into from
Oct 11, 2022

Conversation

alrevuelta
Copy link
Contributor

@alrevuelta alrevuelta commented Sep 30, 2022

closes #754

  • Creates a tool that allows to check if i) a given node is reachable and ii) it supports a set of protocols.
  • See README for usage instruction.

@alrevuelta alrevuelta changed the title chore(wakucanary): create folder structure chore(wakucanary): add canary tool Sep 30, 2022
@status-im-auto
Copy link
Collaborator

status-im-auto commented Sep 30, 2022

Jenkins Builds

Click to see older builds (13)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ fe5b7d9 #1 2022-09-30 13:36:47 ~16 min macos 📦bin
✔️ fe5b7d9 #1 2022-09-30 13:37:57 ~17 min linux 📦bin
✔️ ccf5df6 #2 2022-10-03 17:16:57 ~15 min linux 📦bin
✔️ ccf5df6 #2 2022-10-03 17:18:37 ~17 min macos 📦bin
✔️ c2716ac #3 2022-10-04 11:27:23 ~14 min macos 📦bin
✔️ c2716ac #3 2022-10-04 11:27:59 ~15 min linux 📦bin
✔️ fe1d0c4 #4 2022-10-05 15:03:54 ~17 min linux 📦bin
✔️ fe1d0c4 #4 2022-10-05 15:07:09 ~20 min macos 📦bin
c4c6da2 #5 2022-10-06 10:40:09 ~16 min linux 📄log
✔️ c4c6da2 #5 2022-10-06 10:54:28 ~31 min macos 📦bin
5bf48e0 #6 2022-10-06 11:00:17 ~16 min linux 📄log
445c7b3 #7 2022-10-06 11:03:06 ~16 min linux 📄log
✔️ 445c7b3 #7 2022-10-06 11:04:45 ~18 min macos 📦bin
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ fe3219e #8 2022-10-07 12:15:32 ~15 min macos 📦bin
✔️ fe3219e #8 2022-10-07 12:15:58 ~16 min linux 📦bin
✔️ a7a354c #9 2022-10-11 03:30:00 ~15 min macos 📦bin
✔️ a7a354c #9 2022-10-11 03:31:09 ~16 min linux 📦bin

@alrevuelta alrevuelta force-pushed the add-canary-tool branch 2 times, most recently from ccf5df6 to c2716ac Compare October 4, 2022 11:12
@alrevuelta alrevuelta marked this pull request as ready for review October 5, 2022 14:41
@alrevuelta
Copy link
Contributor Author

@jm-clius @jakubgs

This first approach ensures:

  • We can connect to the node before a timeout expires.
  • For storenode checks that /vac/waku/store/ is supported
  • For staticnode checks that /vac/waku/relay/ is supported
  • Do we need extra checks? See below.

Example:

make wakucanary

Peer is reachable on port 30303 and supports /vac/waku/store/ protocol:

$ ./build/wakucanary --storenode=/ip4/8.210.222.231/tcp/30303/p2p/16Uiu2HAm4v86W3bmT1BiH6oSPzcsSr24iDQpSN5Qa992BCjjwgrD
$ echo $?
> 0

Peer is not reachable on port 1000

$ ./build/wakucanary --staticnode=/ip4/8.210.222.231/tcp/1000/p2p/16Uiu2HAm4v86W3bmT1BiH6oSPzcsSr24iDQpSN5Qa992BCjjwgrD
$ echo $?
> 1

Questions:

  • Do we need to perform extra checks? @jm-clius suggested that in the store case we could try retrieving a message, to double check that is indeed working as a store node. Mind elaborating more on the requirements? Just a naive node.query? Perhaps this also involves also sending a message to the node and then retrieving that same message? Otherwise what can we query?
  • Is filternode and lightpush out of scope of this PR?

@alrevuelta alrevuelta requested review from jm-clius and jakubgs October 5, 2022 14:54
@jm-clius
Copy link
Contributor

jm-clius commented Oct 5, 2022

Thanks for this and good work! I'll do a more in depth review tomorrow, but a couple of initial comments:

  • I like the idea proposed above to just configure a (series of?) --address: and --protocol:. I think it will make the tool more extensible.
  • Checking if filter and lightpush protocols are supported does not need to be out of scope if it's simple to add (basically repeating what is done for relay and store). I think application-specific logic (such as doing an actual store query) is out of scope for this PR.
  • Please follow the Nim style guide for styling😄. It's based on https://nim-lang.org/docs/nep1.html. proc names should be camelCase(). Constants are very controversial and very inconsistently styled throughout the codebase (and in submodules). The style guide only suggests not using CAPITAL_CASE. We have mostly started refactoring to PascalCase for const to get everything in nwaku at least consistent (even though there are still exceptions), so this will be your safest bet.

Copy link
Contributor Author

@alrevuelta alrevuelta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jm-clius

  • Implemented @jakubgs idea with multiple --protocol + just one address
  • Add support for filter and lightpush and removed my attempt of "application-specific logic (such as doing an actual store query)"
  • Fixed naming convention.

tools/wakucanary/wakucanary.nim Outdated Show resolved Hide resolved
@jakubgs
Copy link
Contributor

jakubgs commented Oct 6, 2022

Thanks for this PR. I built it locally and tried using it against one of the hosts in our status.test fleet:

 > ./build/wakucanary --protocol=filter --address=/dns4/node-01.do-ams3.status.test.statusim.net/tcp/30303/p2p/16Uiu2HAkukebeXjTQ9QDBeNDWuGfbaSg79wkkhK4vPocLgR6QFDf          
INF 2022-10-06 19:17:52.140+02:00 Cli flags:                                 tid=1782632 address=/dns4/node-01.do-ams3.status.test.statusim.net/tcp/30303/p2p/16Uiu2HAkukebeXjTQ9QDBeNDWuGfbaSg79wkkhK4vPocLgR6QFDf timeout=10s0ns protocols="@[\"filter\"]"
INF 2022-10-06 19:17:52.144+02:00 Initializing networking                    tid=1782632 addrs=@[/ip4/0.0.0.0/tcp/60000]
DBG 2022-10-06 19:17:52.145+02:00 creating new PeerManager                   tid=1782632
DBG 2022-10-06 19:17:52.145+02:00 no peer storage found                      tid=1782632
DBG 2022-10-06 19:17:52.145+02:00 About to accept incoming connection        topics="libp2p switch" tid=1782632
DBG 2022-10-06 19:17:52.145+02:00 Started libp2p node                        topics="libp2p switch" tid=1782632 peer="(peerId: \"16Uiu2HAmJo5vyXn1ozArrdsUqB9zkTLAkkNuWQatee2vdkhNUx51\", addrs: @[\"/ip4/0.0.0.0/tcp/60000\"], protocols: @[\"/ipfs/id/1.0.0\"], protoVersion: \"ipfs/0.1.0\", agentVersion: \"nim-libp2p/0.0.1\")"
INF 2022-10-06 19:17:52.145+02:00 PeerInfo                                   topics="wakunode" tid=1782632 peerId=16U*hNUx51 addrs=@[/ip4/0.0.0.0/tcp/60000]
INF 2022-10-06 19:17:52.145+02:00 Listening on                               topics="wakunode" tid=1782632 full=[/ip4/0.0.0.0/tcp/60000/p2p/16Uiu2HAmJo5vyXn1ozArrdsUqB9zkTLAkkNuWQatee2vdkhNUx51]
INF 2022-10-06 19:17:52.145+02:00 DNS: discoverable ENR                      topics="wakunode" tid=1782632 enr=enr:-IS4QPtaLoDYYcR4FeYtTfARqdFI83BeiIvAxK_rpIodFrM8IpPB-OosDrFPvnOO-t_YPsBAbfq-cRfYzId7xmvLHqwBgmlkgnY0gmlwhAAAAACJc2VjcDI1NmsxoQNbORQH7KtY178hYw1DObALNhIAf0HOeNz4644Ff2WK7IN0Y3CC6mA
INF 2022-10-06 19:17:52.145+02:00 Node started successfully                  topics="wakunode" tid=1782632
INF 2022-10-06 19:17:52.145+02:00 connectToNodes                             topics="wakupeers" tid=1782632 len=1
INF 2022-10-06 19:17:52.145+02:00 Connecting to node                         topics="wakupeers" tid=1782632 remotePeer=16Uiu2HAkukebeXjTQ9QDBeNDWuGfbaSg79wkkhK4vPocLgR6QFDf source=api
INF 2022-10-06 19:17:52.145+02:00 Attempting dial                            topics="wakupeers" tid=1782632 wireAddr=/dns4/node-01.do-ams3.status.test.statusim.net/tcp/30303 peerId=16U*R6QFDf
DBG 2022-10-06 19:17:52.145+02:00 Adding peer to manager                     topics="wakupeers" tid=1782632 peerId=16U*R6QFDf addr=/dns4/node-01.do-ams3.status.test.statusim.net/tcp/30303 proto=/vac/waku/relay/2.0.0
INF 2022-10-06 19:17:52.145+02:00 Dialing peer from manager                  topics="wakupeers" tid=1782632 wireAddr=@[/dns4/node-01.do-ams3.status.test.statusim.net/tcp/30303] peerId=16U*R6QFDf
DBG 2022-10-06 19:17:52.145+02:00 Dialing peer                               topics="libp2p dialer" tid=1782632 peerId=ok(16Uiu2HAkukebeXjTQ9QDBeNDWuGfbaSg79wkkhK4vPocLgR6QFDf)
DBG 2022-10-06 19:17:52.147+02:00 Dialing failed                             topics="libp2p dialer" tid=1782632 msg="(97) Address family not supported by protocol" peerId=ok(16Uiu2HAkukebeXjTQ9QDBeNDWuGfbaSg79wkkhK4vPocLgR6QFDf)
DBG 2022-10-06 19:17:52.147+02:00 Error dialing                              topics="libp2p dialer" tid=1782632 conn=Connection(nil) msg="Unable to establish outgoing link"
DBG 2022-10-06 19:17:52.147+02:00 Dialing remote peer failed                 topics="wakupeers" tid=1782632 msg="Unable to establish outgoing link"
ERR 2022-10-06 19:17:52.147+02:00 Failed to connect to peer                  topics="wakupeers" tid=1782632 wireAddr=/dns4/node-01.do-ams3.status.test.statusim.net/tcp/30303 peerId=16U*R6QFDf
ERR 2022-10-06 19:17:57.152+02:00 Could not connect                          tid=1782632 peerId=16U*R6QFDf
ERR 2022-10-06 19:17:57.152+02:00 The node has some problems (see logs)      tid=1782632

Some questions:

  1. Why did it fail? That node is up and the port is open, and I know Vac team is using those nodes for tests.
  2. Why are the Dialing failed and Error dialing debug level and not error or warning?
  3. What does (97) Address family not supported by protocol mean in this context?

@jm-clius
Copy link
Contributor

jm-clius commented Oct 6, 2022

Thanks for this PR. I built it locally and tried using it against one of the hosts in our status.test fleet:

Perhaps you can try with /ip4/64.225.81.237/tcp/30303/p2p/16Uiu2HAkukebeXjTQ9QDBeNDWuGfbaSg79wkkhK4vPocLgR6QFDf. Guessing it's the DNS resolution, which would indeed be a feature to add, but is unrelated to the core liveness check.

@jakubgs
Copy link
Contributor

jakubgs commented Oct 6, 2022

Ah, fair point, but yeah, would be good, especially since we want to use the multiaddress from consul to generate checks, and the one in consul are the ones with DNS entries. Or more specifically they are the ones the node API gives me:

[email protected]:/docker/nim-waku-v2 % /docker/nim-waku-v2/rpc.sh get_waku_v2_debug_v1_info
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "listenAddresses": [
      "/dns4/node-01.do-ams3.wakuv2.test.statusim.net/tcp/30303/p2p/16Uiu2HAmPLe7Mzm8TsYUubgCAW1aJoeFScxrLj8ppHFivPo97bUZ",
      "/dns4/node-01.do-ams3.wakuv2.test.statusim.net/tcp/8000/wss/p2p/16Uiu2HAmPLe7Mzm8TsYUubgCAW1aJoeFScxrLj8ppHFivPo97bUZ"
    ],
    "enrUri": "enr:-M-4QCtJKX2WDloRYDT4yjeMGKUCRRcMlsNiZP3cnPO0HZn6IdJ035RPCqsQ5NvTyjqHzKnTM6pc2LoKliV4CeV0WrgBgmlkgnY0gmlwhIbRi9KKbXVsdGlhZGRyc7EALzYobm9kZS0wMS5kby1hbXMzLndha3V2Mi50ZXN0LnN0YXR1c2ltLm5ldAYfQN4DiXNlY3AyNTZrMaEDnr03Tuo77930a7sYLikftxnuG3BbC3gCFhA4632ooDaDdGNwgnZfg3VkcIIjKIV3YWt1Mg8"
  }
}

And that's why I'm using that. So either add support for DNS in the canary, or add support for returning the multiaddress with the IP in the API. Or I have to do some kind of disgusting hacky regex replacement to make the DNS one into an IP one.

But yes, that does indeed work:

 > ./build/wakucanary --protocol=filter --address=/ip4/64.225.81.237/tcp/30303/p2p/16Uiu2HAkukebeXjTQ9QDBeNDWuGfbaSg79wkkhK4vPocLgR6QFDf
INF 2022-10-06 19:29:05.751+02:00 Cli flags:                                 tid=1800434 address=/ip4/64.225.81.237/tcp/30303/p2p/16Uiu2HAkukebeXjTQ9QDBeNDWuGfbaSg79wkkhK4vPocLgR6QFDf timeout=10s0ns protocols="@[\"filter\"]"
INF 2022-10-06 19:29:05.756+02:00 Initializing networking                    tid=1800434 addrs=@[/ip4/0.0.0.0/tcp/60000]
DBG 2022-10-06 19:29:05.756+02:00 creating new PeerManager                   tid=1800434
DBG 2022-10-06 19:29:05.756+02:00 no peer storage found                      tid=1800434
DBG 2022-10-06 19:29:05.756+02:00 About to accept incoming connection        topics="libp2p switch" tid=1800434
DBG 2022-10-06 19:29:05.757+02:00 Started libp2p node                        topics="libp2p switch" tid=1800434 peer="(peerId: \"16Uiu2HAkzYFHu4ZsjHUP2wFNwuK2GiLQnb4JQRLNWJQKWfuqMDJf\", addrs: @[\"/ip4/0.0.0.0/tcp/60000\"], protocols: @[\"/ipfs/id/1.0.0\"], protoVersion: \"ipfs/0.1.0\", agentVersion: \"nim-libp2p/0.0.1\")"
INF 2022-10-06 19:29:05.757+02:00 PeerInfo                                   topics="wakunode" tid=1800434 peerId=16U*uqMDJf addrs=@[/ip4/0.0.0.0/tcp/60000]
INF 2022-10-06 19:29:05.757+02:00 Listening on                               topics="wakunode" tid=1800434 full=[/ip4/0.0.0.0/tcp/60000/p2p/16Uiu2HAkzYFHu4ZsjHUP2wFNwuK2GiLQnb4JQRLNWJQKWfuqMDJf]
INF 2022-10-06 19:29:05.757+02:00 DNS: discoverable ENR                      topics="wakunode" tid=1800434 enr=enr:-IS4QEfIbVhOBAa9uHq7yBxlZBgWQlwDK6JCY5o08Aa_U7QFc_2GoDUy0mADfyabGPDQYPA-OJJhB01Fz3P7woSe3IsBgmlkgnY0gmlwhAAAAACJc2VjcDI1NmsxoQJL-ZXttc9XVXyK7sQFu1mb-LrqyqwMskapnfB3M7nmUIN0Y3CC6mA
INF 2022-10-06 19:29:05.757+02:00 Node started successfully                  topics="wakunode" tid=1800434
INF 2022-10-06 19:29:05.757+02:00 connectToNodes                             topics="wakupeers" tid=1800434 len=1
INF 2022-10-06 19:29:05.757+02:00 Connecting to node                         topics="wakupeers" tid=1800434 remotePeer=16Uiu2HAkukebeXjTQ9QDBeNDWuGfbaSg79wkkhK4vPocLgR6QFDf source=api
INF 2022-10-06 19:29:05.757+02:00 Attempting dial                            topics="wakupeers" tid=1800434 wireAddr=/ip4/64.225.81.237/tcp/30303 peerId=16U*R6QFDf
DBG 2022-10-06 19:29:05.757+02:00 Adding peer to manager                     topics="wakupeers" tid=1800434 peerId=16U*R6QFDf addr=/ip4/64.225.81.237/tcp/30303 proto=/vac/waku/relay/2.0.0
INF 2022-10-06 19:29:05.757+02:00 Dialing peer from manager                  topics="wakupeers" tid=1800434 wireAddr=@[/ip4/64.225.81.237/tcp/30303] peerId=16U*R6QFDf
DBG 2022-10-06 19:29:05.757+02:00 Dialing peer                               topics="libp2p dialer" tid=1800434 peerId=ok(16Uiu2HAkukebeXjTQ9QDBeNDWuGfbaSg79wkkhK4vPocLgR6QFDf)
DBG 2022-10-06 19:29:06.017+02:00 no handlers                                topics="libp2p multistream" tid=1800434 conn=16U*R6QFDf:633f106297b675d81cd7f373 protocol=/vac/waku/relay/2.0.0
DBG 2022-10-06 19:29:06.192+02:00 decodeMsg: decoded identify                topics="libp2p identify" tid=1800434 pubkey=Some(s...06d8)) addresses=/dns4/node-01.do-ams3.status.test.statusim.net/tcp/30303,/dns4/node-01.do-ams3.status.test.statusim.net/tcp/443/wss protocols=/ipfs/id/1.0.0,/vac/waku/relay/2.0.0,/ipfs/ping/1.0.0,/vac/waku/store/2.0.0-beta4,/vac/waku/lightpush/2.0.0-beta1,/vac/waku/filter/2.0.0-beta1 observable_address=/ip4/82.139.21.242/tcp/48854 proto_version=ipfs/0.1.0 agent_version=nim-libp2p/0.0.1 signedPeerRecord=None
DBG 2022-10-06 19:29:06.193+02:00 Dial successful                            topics="libp2p dialer" tid=1800434 conn=16U*R6QFDf:633f106197b675d81cd7f371 peerId=16U*R6QFDf
DBG 2022-10-06 19:29:06.193+02:00 no handlers                                topics="libp2p multistream" tid=1800434 conn=16U*R6QFDf:633f106297b675d81cd7f373 protocol=/vac/waku/relay/2.0.0
INF 2022-10-06 19:29:06.328+02:00 Successfully connected to peer             topics="wakupeers" tid=1800434 wireAddr=/ip4/64.225.81.237/tcp/30303 peerId=16U*R6QFDf
INF 2022-10-06 19:29:11.333+02:00 Supported protocol ok:                     tid=1800434 expected=/vac/waku/lightpush/ supported=/vac/waku/lightpush/2.0.0-beta1
INF 2022-10-06 19:29:11.333+02:00 The node is reachable and supports all specified protocols tid=1800434

Nice.

@jakubgs
Copy link
Contributor

jakubgs commented Oct 6, 2022

Oh, and would it be a lot of work to add 1 letter alias flags?

@jakubgs
Copy link
Contributor

jakubgs commented Oct 6, 2022

Very nice:

INF 2022-10-06 19:34:38.213+02:00 Supported protocol ok:                     tid=1808921 expected=/vac/waku/relay/ supported=/vac/waku/relay/2.0.0
INF 2022-10-06 19:34:38.213+02:00 Supported protocol ok:                     tid=1808921 expected=/vac/waku/store/ supported=/vac/waku/store/2.0.0-beta4
INF 2022-10-06 19:34:38.213+02:00 Supported protocol ok:                     tid=1808921 expected=/vac/waku/lightpush/ supported=/vac/waku/lightpush/2.0.0-beta1
ERR 2022-10-06 19:34:38.213+02:00 Not all protocols are supported:           tid=1808921 expected="@[\"static\", \"store\", \"filter\", \"lightpush\"]" supported="@[\"/ipfs/id/1.0.0\", \"/vac/waku/relay/2.0.0\", \"/ipfs/ping/1.0.0\", \"/vac/waku/store/2.0.0-beta4\", \"/vac/waku/lightpush/2.0.0-beta1\", \"/vac/waku/filter/2.0.0-beta1\"]"

Not sure about that : in that messages, but that's just a nitpick.

EDIT: Waaait, I checked for lightpush and the log says it is there - /vac/waku/lightpush/2.0.0-beta1 - but fails.

@jakubgs
Copy link
Contributor

jakubgs commented Oct 10, 2022

Okay, now it detects lightpush as expected:

INF 2022-10-10 10:57:09.721+02:00 Supported protocol ok                      tid=3298482 expected=/vac/waku/relay/ supported=/vac/waku/relay/2.0.0
INF 2022-10-10 10:57:09.721+02:00 Supported protocol ok                      tid=3298482 expected=/vac/waku/store/ supported=/vac/waku/store/2.0.0-beta4
INF 2022-10-10 10:57:09.721+02:00 Supported protocol ok                      tid=3298482 expected=/vac/waku/lightpush/ supported=/vac/waku/lightpush/2.0.0-beta1
INF 2022-10-10 10:57:09.721+02:00 Supported protocol ok                      tid=3298482 expected=/vac/waku/filter/ supported=/vac/waku/filter/2.0.0-beta1
INF 2022-10-10 10:57:09.721+02:00 The node is reachable and supports all specified protocols tid=3298482

Nice. And --log-level works too, thanks!

But yeah, considering you give a DNS multiaddress via RPC API, and that's the address we expose via https://fleets.status.im/ it would make sense to support the addresses we publish.

Copy link
Contributor

@jm-clius jm-clius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Useful tool! Congrats on your first PR for nwaku. :) I agree that supporting DNS address resolution will be useful as that is how we publish most addresses. This can be a subsequent PR, though, so feel free to merge this first.

tools/README.md Outdated Show resolved Hide resolved
tools/wakucanary/wakucanary.nim Outdated Show resolved Hide resolved
waku.nimble Show resolved Hide resolved
@jakubgs
Copy link
Contributor

jakubgs commented Oct 10, 2022

I'm fine with DNS support being added in separate PR, as this is an already working change that can be merged.

@alrevuelta
Copy link
Contributor Author

alrevuelta commented Oct 11, 2022

Great! Thanks for the comments. Will address the DNS support in another PR. Just rebased and fixed a typo, no changes. Can I get ✅ again?

Edit: Wops, looks like its not needed to aprove again.

@alrevuelta alrevuelta merged commit a36de40 into master Oct 11, 2022
@alrevuelta alrevuelta deleted the add-canary-tool branch October 11, 2022 03:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Waku v2 canary tool
4 participants