diff --git a/.github/ISSUE_TEMPLATE/bump_dependencies.md b/.github/ISSUE_TEMPLATE/bump_dependencies.md index 6c1e777a1..0413cbfd2 100644 --- a/.github/ISSUE_TEMPLATE/bump_dependencies.md +++ b/.github/ISSUE_TEMPLATE/bump_dependencies.md @@ -12,7 +12,6 @@ assignees: '' Update `nwaku` "vendor" dependencies. ### Items to bump -- [ ] negentropy - [ ] dnsclient.nim ( update to the latest tag version ) - [ ] nim-bearssl - [ ] nimbus-build-system @@ -38,12 +37,12 @@ Update `nwaku` "vendor" dependencies. - [ ] nim-sqlite3-abi ( update to the latest tag version ) - [ ] nim-stew - [ ] nim-stint -- [ ] nim-taskpools -- [ ] nim-testutils +- [ ] nim-taskpools ( update to the latest tag version ) +- [ ] nim-testutils ( update to the latest tag version ) - [ ] nim-toml-serialization - [ ] nim-unicodedb -- [ ] nim-unittest2 -- [ ] nim-web3 -- [ ] nim-websock +- [ ] nim-unittest2 ( update to the latest tag version ) +- [ ] nim-web3 ( update to the latest tag version ) +- [ ] nim-websock ( update to the latest tag version ) - [ ] nim-zlib -- [ ] zerokit ( this should be kept in version `v0.5.1` ) +- [ ] zerokit ( this should be kept in version `v0.7.0` ) diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index 3ac6ce15d..0582d5fd1 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -68,28 +68,6 @@ jobs: ./build_all.bat cd ../../../.. - - name: Building libunwind - run: | - cd vendor/nim-libbacktrace - mkdir -p vendor/libunwind/build - pushd vendor/libunwind - - cmake -S runtimes \ - -DLLVM_ENABLE_RUNTIMES="libunwind" \ - -DLIBUNWIND_ENABLE_SHARED=OFF -DLIBUNWIND_ENABLE_STATIC=ON \ - -DLIBUNWIND_INCLUDE_DOCS=OFF -DLIBUNWIND_INSTALL_HEADERS=ON \ - -DCMAKE_INSTALL_PREFIX="$(pwd)/../install/usr" \ - -G "MinGW Makefiles" -B build - - cd build - mingw32-make VERBOSE=1 clean - mingw32-make VERBOSE=1 unwind_static - mingw32-make VERBOSE=1 install-unwind - - popd - mkdir -p install/usr/lib - cp -r vendor/libunwind/build/lib/libunwind.a install/usr/lib/ - - name: Building miniupnpc run: | cd vendor/nim-nat-traversal/vendor/miniupnp/miniupnpc @@ -105,9 +83,6 @@ jobs: - name: Building wakunode2 run: | - cd vendor/nim-libbacktrace - cp ./vendor/libunwind/build/lib/libunwind.a install/usr/lib - cd ../.. make wakunode2 LOG_LEVEL=DEBUG V=3 -j8 - name: Check Executable diff --git a/apps/chat2/chat2.nim b/apps/chat2/chat2.nim index 127a761c0..9c0f47dcd 100644 --- a/apps/chat2/chat2.nim +++ b/apps/chat2/chat2.nim @@ -11,7 +11,6 @@ import confutils, chronicles, chronos, - stew/shims/net as stewNet, eth/keys, bearssl, stew/[byteutils, results], @@ -559,7 +558,7 @@ proc processInput(rfd: AsyncFD, rng: ref HmacDrbgContext) {.async.} = let rlnConf = WakuRlnConfig( dynamic: conf.rlnRelayDynamic, credIndex: conf.rlnRelayCredIndex, - chainId: conf.rlnRelayChainId, + chainId: UInt256.fromBytesBE(conf.rlnRelayChainId.toBytesBE()), ethClientUrls: conf.ethClientUrls.mapIt(string(it)), creds: some( RlnRelayCreds( diff --git a/apps/networkmonitor/networkmonitor_config.nim b/apps/networkmonitor/networkmonitor_config.nim index 04245f9dd..8f5298a53 100644 --- a/apps/networkmonitor/networkmonitor_config.nim +++ b/apps/networkmonitor/networkmonitor_config.nim @@ -5,7 +5,6 @@ import chronos, std/strutils, results, - stew/shims/net, regex type EthRpcUrl* = distinct string diff --git a/apps/networkmonitor/networkmonitor_utils.nim b/apps/networkmonitor/networkmonitor_utils.nim index f12b16014..25b79da65 100644 --- a/apps/networkmonitor/networkmonitor_utils.nim +++ b/apps/networkmonitor/networkmonitor_utils.nim @@ -3,7 +3,6 @@ import std/json, results, - stew/shims/net, chronicles, chronicles/topics_registry, chronos, diff --git a/apps/wakucanary/wakucanary.nim b/apps/wakucanary/wakucanary.nim index 3565c619f..84ac6350c 100644 --- a/apps/wakucanary/wakucanary.nim +++ b/apps/wakucanary/wakucanary.nim @@ -2,7 +2,6 @@ import std/[strutils, sequtils, tables, strformat], confutils, chronos, - stew/shims/net, chronicles/topics_registry, os import diff --git a/examples/filter_subscriber.nim b/examples/filter_subscriber.nim index 2216e4a41..5554966d4 100644 --- a/examples/filter_subscriber.nim +++ b/examples/filter_subscriber.nim @@ -1,7 +1,6 @@ import std/[tables, sequtils], stew/byteutils, - stew/shims/net, chronicles, chronos, confutils, diff --git a/examples/lightpush_publisher.nim b/examples/lightpush_publisher.nim index b0f919a89..9c7499695 100644 --- a/examples/lightpush_publisher.nim +++ b/examples/lightpush_publisher.nim @@ -1,7 +1,6 @@ import std/[tables, times, sequtils], stew/byteutils, - stew/shims/net, chronicles, results, chronos, diff --git a/examples/publisher.nim b/examples/publisher.nim index 907ce2274..8c2d03679 100644 --- a/examples/publisher.nim +++ b/examples/publisher.nim @@ -1,7 +1,6 @@ import std/[tables, times, sequtils], stew/byteutils, - stew/shims/net, chronicles, chronos, confutils, diff --git a/examples/subscriber.nim b/examples/subscriber.nim index 633bfa4ca..7eb900792 100644 --- a/examples/subscriber.nim +++ b/examples/subscriber.nim @@ -1,7 +1,6 @@ import std/[tables, sequtils], stew/byteutils, - stew/shims/net, chronicles, chronos, confutils, diff --git a/examples/wakustealthcommitments/node_spec.nim b/examples/wakustealthcommitments/node_spec.nim index b5dafb0be..fdcd36986 100644 --- a/examples/wakustealthcommitments/node_spec.nim +++ b/examples/wakustealthcommitments/node_spec.nim @@ -3,7 +3,6 @@ import waku/[common/logging, factory/[waku, networks_config, external_config]] import std/[options, strutils, os, sequtils], - stew/shims/net as stewNet, chronicles, chronos, metrics, diff --git a/tests/common/test_confutils_envvar.nim b/tests/common/test_confutils_envvar.nim index 676a35ae1..fca11cca6 100644 --- a/tests/common/test_confutils_envvar.nim +++ b/tests/common/test_confutils_envvar.nim @@ -3,7 +3,6 @@ import std/[os, options], results, - stew/shims/net as stewNet, testutils/unittests, confutils, confutils/defs, diff --git a/tests/common/test_enr_builder.nim b/tests/common/test_enr_builder.nim index 9fe8f6807..0cf7bcb55 100644 --- a/tests/common/test_enr_builder.nim +++ b/tests/common/test_enr_builder.nim @@ -1,6 +1,6 @@ {.used.} -import std/options, results, stew/shims/net, testutils/unittests +import std/[options, net], results, testutils/unittests import waku/common/enr, ../testlib/wakucore suite "nim-eth ENR - builder and typed record": diff --git a/tests/factory/test_external_config.nim b/tests/factory/test_external_config.nim index 5bd4e2c86..927246b0d 100644 --- a/tests/factory/test_external_config.nim +++ b/tests/factory/test_external_config.nim @@ -8,7 +8,8 @@ import libp2p/multiaddress, nimcrypto/utils, secp256k1, - confutils + confutils, + stint import ../../waku/factory/external_config, ../../waku/factory/networks_config, diff --git a/tests/node/peer_manager/peer_store/test_waku_peer_storage.nim b/tests/node/peer_manager/peer_store/test_waku_peer_storage.nim index 1edd9243e..c0e25ec6a 100644 --- a/tests/node/peer_manager/peer_store/test_waku_peer_storage.nim +++ b/tests/node/peer_manager/peer_store/test_waku_peer_storage.nim @@ -3,7 +3,6 @@ import testutils/unittests, libp2p/[multiaddress, peerid], libp2p/crypto/crypto, - stew/shims/net, eth/keys, eth/p2p/discoveryv5/enr, nimcrypto/utils diff --git a/tests/node/peer_manager/test_peer_manager.nim b/tests/node/peer_manager/test_peer_manager.nim index 6eddda0d6..ad1f1bf0e 100644 --- a/tests/node/peer_manager/test_peer_manager.nim +++ b/tests/node/peer_manager/test_peer_manager.nim @@ -1,9 +1,4 @@ -import - chronicles, - std/[options, tables, strutils], - stew/shims/net, - chronos, - testutils/unittests +import chronicles, std/[options, tables, strutils], chronos, testutils/unittests import waku/node/waku_node, @@ -23,7 +18,7 @@ suite "Peer Manager": asyncSetup: listenPort = Port(0) - listenAddress = ValidIpAddress.init("0.0.0.0") + listenAddress = parseIpAddress("0.0.0.0") serverKey = generateSecp256k1Key() clientKey = generateSecp256k1Key() clusterId = 1 diff --git a/tests/node/test_wakunode_filter.nim b/tests/node/test_wakunode_filter.nim index bf9f2495b..abf555b68 100644 --- a/tests/node/test_wakunode_filter.nim +++ b/tests/node/test_wakunode_filter.nim @@ -2,7 +2,6 @@ import std/[options, tables, sequtils, strutils, sets], - stew/shims/net as stewNet, testutils/unittests, chronos, chronicles, diff --git a/tests/node/test_wakunode_legacy_lightpush.nim b/tests/node/test_wakunode_legacy_lightpush.nim index dfc306de8..806bfe032 100644 --- a/tests/node/test_wakunode_legacy_lightpush.nim +++ b/tests/node/test_wakunode_legacy_lightpush.nim @@ -1,8 +1,7 @@ {.used.} import - std/[options, tempfiles], - stew/shims/net as stewNet, + std/[options, tempfiles, net], testutils/unittests, chronos, std/strformat, @@ -46,8 +45,8 @@ suite "Waku Legacy Lightpush - End To End": serverKey = generateSecp256k1Key() clientKey = generateSecp256k1Key() - server = newTestWakuNode(serverKey, ValidIpAddress.init("0.0.0.0"), Port(0)) - client = newTestWakuNode(clientKey, ValidIpAddress.init("0.0.0.0"), Port(0)) + server = newTestWakuNode(serverKey, parseIpAddress("0.0.0.0"), Port(0)) + client = newTestWakuNode(clientKey, parseIpAddress("0.0.0.0"), Port(0)) await allFutures(server.start(), client.start()) await server.start() @@ -70,7 +69,7 @@ suite "Waku Legacy Lightpush - End To End": asyncTest "Via 11/WAKU2-RELAY from Relay/Full Node": # Given a light lightpush client let lightpushClient = - newTestWakuNode(generateSecp256k1Key(), ValidIpAddress.init("0.0.0.0"), Port(0)) + newTestWakuNode(generateSecp256k1Key(), parseIpAddress("0.0.0.0"), Port(0)) lightpushClient.mountLegacyLightpushClient() # When the client publishes a message @@ -129,8 +128,8 @@ suite "RLN Proofs as a Lightpush Service": serverKey = generateSecp256k1Key() clientKey = generateSecp256k1Key() - server = newTestWakuNode(serverKey, ValidIpAddress.init("0.0.0.0"), Port(0)) - client = newTestWakuNode(clientKey, ValidIpAddress.init("0.0.0.0"), Port(0)) + server = newTestWakuNode(serverKey, parseIpAddress("0.0.0.0"), Port(0)) + client = newTestWakuNode(clientKey, parseIpAddress("0.0.0.0"), Port(0)) # mount rln-relay let wakuRlnConfig = WakuRlnConfig( @@ -162,7 +161,7 @@ suite "RLN Proofs as a Lightpush Service": asyncTest "Message is published when RLN enabled": # Given a light lightpush client let lightpushClient = - newTestWakuNode(generateSecp256k1Key(), ValidIpAddress.init("0.0.0.0"), Port(0)) + newTestWakuNode(generateSecp256k1Key(), parseIpAddress("0.0.0.0"), Port(0)) lightpushClient.mountLegacyLightPushClient() # When the client publishes a message diff --git a/tests/node/test_wakunode_legacy_store.nim b/tests/node/test_wakunode_legacy_store.nim index 8ede3f6f2..beed3c1c6 100644 --- a/tests/node/test_wakunode_legacy_store.nim +++ b/tests/node/test_wakunode_legacy_store.nim @@ -1,11 +1,6 @@ {.used.} -import - std/options, - stew/shims/net as stewNet, - testutils/unittests, - chronos, - libp2p/crypto/crypto +import std/options, testutils/unittests, chronos, libp2p/crypto/crypto import waku/[ @@ -66,8 +61,8 @@ suite "Waku Store - End to End - Sorted Archive": serverKey = generateSecp256k1Key() clientKey = generateSecp256k1Key() - server = newTestWakuNode(serverKey, ValidIpAddress.init("0.0.0.0"), Port(0)) - client = newTestWakuNode(clientKey, ValidIpAddress.init("0.0.0.0"), Port(0)) + server = newTestWakuNode(serverKey, parseIpAddress("0.0.0.0"), Port(0)) + client = newTestWakuNode(clientKey, parseIpAddress("0.0.0.0"), Port(0)) archiveDriver = newArchiveDriverWithMessages(pubsubTopic, archiveMessages) let mountArchiveResult = server.mountLegacyArchive(archiveDriver) @@ -440,7 +435,7 @@ suite "Waku Store - End to End - Sorted Archive": newArchiveDriverWithMessages(pubsubTopic, archiveMessages) otherServerKey = generateSecp256k1Key() otherServer = - newTestWakuNode(otherServerKey, ValidIpAddress.init("0.0.0.0"), Port(0)) + newTestWakuNode(otherServerKey, parseIpAddress("0.0.0.0"), Port(0)) mountOtherArchiveResult = otherServer.mountLegacyArchive(otherArchiveDriverWithMessages) assert mountOtherArchiveResult.isOk() @@ -522,8 +517,8 @@ suite "Waku Store - End to End - Unsorted Archive": serverKey = generateSecp256k1Key() clientKey = generateSecp256k1Key() - server = newTestWakuNode(serverKey, ValidIpAddress.init("0.0.0.0"), Port(0)) - client = newTestWakuNode(clientKey, ValidIpAddress.init("0.0.0.0"), Port(0)) + server = newTestWakuNode(serverKey, parseIpAddress("0.0.0.0"), Port(0)) + client = newTestWakuNode(clientKey, parseIpAddress("0.0.0.0"), Port(0)) let unsortedArchiveDriverWithMessages = @@ -678,8 +673,8 @@ suite "Waku Store - End to End - Archive with Multiple Topics": serverKey = generateSecp256k1Key() clientKey = generateSecp256k1Key() - server = newTestWakuNode(serverKey, ValidIpAddress.init("0.0.0.0"), Port(0)) - client = newTestWakuNode(clientKey, ValidIpAddress.init("0.0.0.0"), Port(0)) + server = newTestWakuNode(serverKey, parseIpAddress("0.0.0.0"), Port(0)) + client = newTestWakuNode(clientKey, parseIpAddress("0.0.0.0"), Port(0)) let archiveDriver = newSqliteArchiveDriver() .put(pubsubTopic, archiveMessages[0 ..< 6]) @@ -927,7 +922,7 @@ suite "Waku Store - End to End - Archive with Multiple Topics": let ephemeralServerKey = generateSecp256k1Key() ephemeralServer = - newTestWakuNode(ephemeralServerKey, ValidIpAddress.init("0.0.0.0"), Port(0)) + newTestWakuNode(ephemeralServerKey, parseIpAddress("0.0.0.0"), Port(0)) mountEphemeralArchiveResult = ephemeralServer.mountLegacyArchive(ephemeralArchiveDriver) assert mountEphemeralArchiveResult.isOk() @@ -970,7 +965,7 @@ suite "Waku Store - End to End - Archive with Multiple Topics": let mixedServerKey = generateSecp256k1Key() mixedServer = - newTestWakuNode(mixedServerKey, ValidIpAddress.init("0.0.0.0"), Port(0)) + newTestWakuNode(mixedServerKey, parseIpAddress("0.0.0.0"), Port(0)) mountMixedArchiveResult = mixedServer.mountLegacyArchive(mixedArchiveDriver) assert mountMixedArchiveResult.isOk() @@ -997,7 +992,7 @@ suite "Waku Store - End to End - Archive with Multiple Topics": let emptyServerKey = generateSecp256k1Key() emptyServer = - newTestWakuNode(emptyServerKey, ValidIpAddress.init("0.0.0.0"), Port(0)) + newTestWakuNode(emptyServerKey, parseIpAddress("0.0.0.0"), Port(0)) mountEmptyArchiveResult = emptyServer.mountLegacyArchive(emptyArchiveDriver) assert mountEmptyArchiveResult.isOk() @@ -1028,7 +1023,7 @@ suite "Waku Store - End to End - Archive with Multiple Topics": let voluminousServerKey = generateSecp256k1Key() voluminousServer = - newTestWakuNode(voluminousServerKey, ValidIpAddress.init("0.0.0.0"), Port(0)) + newTestWakuNode(voluminousServerKey, parseIpAddress("0.0.0.0"), Port(0)) mountVoluminousArchiveResult = voluminousServer.mountLegacyArchive(voluminousArchiveDriverWithMessages) assert mountVoluminousArchiveResult.isOk() diff --git a/tests/node/test_wakunode_lightpush.nim b/tests/node/test_wakunode_lightpush.nim index 8d48c8cb7..dccb899af 100644 --- a/tests/node/test_wakunode_lightpush.nim +++ b/tests/node/test_wakunode_lightpush.nim @@ -2,7 +2,6 @@ import std/[options, tempfiles], - stew/shims/net as stewNet, testutils/unittests, chronos, std/strformat, @@ -40,8 +39,8 @@ suite "Waku Lightpush - End To End": serverKey = generateSecp256k1Key() clientKey = generateSecp256k1Key() - server = newTestWakuNode(serverKey, ValidIpAddress.init("0.0.0.0"), Port(0)) - client = newTestWakuNode(clientKey, ValidIpAddress.init("0.0.0.0"), Port(0)) + server = newTestWakuNode(serverKey, parseIpAddress("0.0.0.0"), Port(0)) + client = newTestWakuNode(clientKey, parseIpAddress("0.0.0.0"), Port(0)) await allFutures(server.start(), client.start()) await server.start() @@ -63,7 +62,7 @@ suite "Waku Lightpush - End To End": asyncTest "Via 11/WAKU2-RELAY from Relay/Full Node": # Given a light lightpush client let lightpushClient = - newTestWakuNode(generateSecp256k1Key(), ValidIpAddress.init("0.0.0.0"), Port(0)) + newTestWakuNode(generateSecp256k1Key(), parseIpAddress("0.0.0.0"), Port(0)) lightpushClient.mountLightpushClient() # When the client publishes a message @@ -123,8 +122,8 @@ suite "RLN Proofs as a Lightpush Service": serverKey = generateSecp256k1Key() clientKey = generateSecp256k1Key() - server = newTestWakuNode(serverKey, ValidIpAddress.init("0.0.0.0"), Port(0)) - client = newTestWakuNode(clientKey, ValidIpAddress.init("0.0.0.0"), Port(0)) + server = newTestWakuNode(serverKey, parseIpAddress("0.0.0.0"), Port(0)) + client = newTestWakuNode(clientKey, parseIpAddress("0.0.0.0"), Port(0)) # mount rln-relay let wakuRlnConfig = WakuRlnConfig( @@ -156,7 +155,7 @@ suite "RLN Proofs as a Lightpush Service": asyncTest "Message is published when RLN enabled": # Given a light lightpush client let lightpushClient = - newTestWakuNode(generateSecp256k1Key(), ValidIpAddress.init("0.0.0.0"), Port(0)) + newTestWakuNode(generateSecp256k1Key(), parseIpAddress("0.0.0.0"), Port(0)) lightpushClient.mountLightPushClient() # When the client publishes a message diff --git a/tests/node/test_wakunode_peer_exchange.nim b/tests/node/test_wakunode_peer_exchange.nim index 26837869d..3996be0dc 100644 --- a/tests/node/test_wakunode_peer_exchange.nim +++ b/tests/node/test_wakunode_peer_exchange.nim @@ -5,7 +5,6 @@ import testutils/unittests, chronos, chronicles, - stew/shims/net, libp2p/switch, libp2p/peerId, libp2p/crypto/crypto, diff --git a/tests/node/test_wakunode_peer_manager.nim b/tests/node/test_wakunode_peer_manager.nim index 88fcc827f..0ef2b1a13 100644 --- a/tests/node/test_wakunode_peer_manager.nim +++ b/tests/node/test_wakunode_peer_manager.nim @@ -3,7 +3,6 @@ import os, std/[options, tables], - stew/shims/net as stewNet, testutils/unittests, chronos, # chronos/timer, @@ -32,7 +31,7 @@ const DEFAULT_PROTOCOLS: seq[string] = @["/ipfs/id/1.0.0", "/libp2p/autonat/1.0.0", "/libp2p/circuit/relay/0.2.0/hop"] let - listenIp = ValidIpAddress.init("0.0.0.0") + listenIp = parseIpAddress("0.0.0.0") listenPort = Port(0) suite "Peer Manager": diff --git a/tests/node/test_wakunode_relay_rln.nim b/tests/node/test_wakunode_relay_rln.nim index afc282d50..66866c4da 100644 --- a/tests/node/test_wakunode_relay_rln.nim +++ b/tests/node/test_wakunode_relay_rln.nim @@ -2,7 +2,6 @@ import std/[tempfiles, strutils, options], - stew/shims/net as stewNet, stew/results, testutils/unittests, chronos, @@ -121,8 +120,8 @@ suite "Waku RlnRelay - End to End - Static": serverKey = generateSecp256k1Key() clientKey = generateSecp256k1Key() - server = newTestWakuNode(serverKey, ValidIpAddress.init("0.0.0.0"), Port(0)) - client = newTestWakuNode(clientKey, ValidIpAddress.init("0.0.0.0"), Port(0)) + server = newTestWakuNode(serverKey, parseIpAddress("0.0.0.0"), Port(0)) + client = newTestWakuNode(clientKey, parseIpAddress("0.0.0.0"), Port(0)) await allFutures(server.start(), client.start()) @@ -410,8 +409,8 @@ suite "Waku RlnRelay - End to End - OnChain": serverKey = generateSecp256k1Key() clientKey = generateSecp256k1Key() - server = newTestWakuNode(serverKey, ValidIpAddress.init("0.0.0.0"), Port(0)) - client = newTestWakuNode(clientKey, ValidIpAddress.init("0.0.0.0"), Port(0)) + server = newTestWakuNode(serverKey, parseIpAddress("0.0.0.0"), Port(0)) + client = newTestWakuNode(clientKey, parseIpAddress("0.0.0.0"), Port(0)) await allFutures(server.start(), client.start()) diff --git a/tests/node/test_wakunode_sharding.nim b/tests/node/test_wakunode_sharding.nim index bdd6859b9..5b99689be 100644 --- a/tests/node/test_wakunode_sharding.nim +++ b/tests/node/test_wakunode_sharding.nim @@ -1,16 +1,10 @@ {.used.} -import - std/[options, sequtils, tempfiles], - testutils/unittests, - chronos, - chronicles, - stew/shims/net as stewNet +import std/[options, sequtils, tempfiles], testutils/unittests, chronos, chronicles import std/[sequtils, tempfiles], stew/byteutils, - stew/shims/net as stewNet, testutils/unittests, chronos, libp2p/switch, @@ -35,7 +29,7 @@ import import waku_relay/protocol const - listenIp = ValidIpAddress.init("0.0.0.0") + listenIp = parseIpAddress("0.0.0.0") listenPort = Port(0) suite "Sharding": diff --git a/tests/node/test_wakunode_store.nim b/tests/node/test_wakunode_store.nim index 622322d92..00dbfb7ee 100644 --- a/tests/node/test_wakunode_store.nim +++ b/tests/node/test_wakunode_store.nim @@ -1,11 +1,6 @@ {.used.} -import - std/[options, sequtils, sets], - stew/shims/net as stewNet, - testutils/unittests, - chronos, - libp2p/crypto/crypto +import std/[options, sequtils, sets], testutils/unittests, chronos, libp2p/crypto/crypto import waku/[ @@ -75,8 +70,8 @@ suite "Waku Store - End to End - Sorted Archive": serverKey = generateSecp256k1Key() clientKey = generateSecp256k1Key() - server = newTestWakuNode(serverKey, ValidIpAddress.init("0.0.0.0"), Port(0)) - client = newTestWakuNode(clientKey, ValidIpAddress.init("0.0.0.0"), Port(0)) + server = newTestWakuNode(serverKey, parseIpAddress("0.0.0.0"), Port(0)) + client = newTestWakuNode(clientKey, parseIpAddress("0.0.0.0"), Port(0)) archiveDriver = newArchiveDriverWithMessages(pubsubTopic, messages) let mountArchiveResult = server.mountArchive(archiveDriver) @@ -480,7 +475,7 @@ suite "Waku Store - End to End - Sorted Archive": ) otherServerKey = generateSecp256k1Key() otherServer = - newTestWakuNode(otherServerKey, ValidIpAddress.init("0.0.0.0"), Port(0)) + newTestWakuNode(otherServerKey, parseIpAddress("0.0.0.0"), Port(0)) mountOtherArchiveResult = otherServer.mountArchive(otherArchiveDriverWithMessages) assert mountOtherArchiveResult.isOk() @@ -571,8 +566,8 @@ suite "Waku Store - End to End - Unsorted Archive": serverKey = generateSecp256k1Key() clientKey = generateSecp256k1Key() - server = newTestWakuNode(serverKey, ValidIpAddress.init("0.0.0.0"), Port(0)) - client = newTestWakuNode(clientKey, ValidIpAddress.init("0.0.0.0"), Port(0)) + server = newTestWakuNode(serverKey, parseIpAddress("0.0.0.0"), Port(0)) + client = newTestWakuNode(clientKey, parseIpAddress("0.0.0.0"), Port(0)) let unsortedArchiveDriverWithMessages = @@ -788,8 +783,8 @@ suite "Waku Store - End to End - Unsorted Archive without provided Timestamp": serverKey = generateSecp256k1Key() clientKey = generateSecp256k1Key() - server = newTestWakuNode(serverKey, ValidIpAddress.init("0.0.0.0"), Port(0)) - client = newTestWakuNode(clientKey, ValidIpAddress.init("0.0.0.0"), Port(0)) + server = newTestWakuNode(serverKey, parseIpAddress("0.0.0.0"), Port(0)) + client = newTestWakuNode(clientKey, parseIpAddress("0.0.0.0"), Port(0)) let unsortedArchiveDriverWithMessages = @@ -938,8 +933,8 @@ suite "Waku Store - End to End - Archive with Multiple Topics": serverKey = generateSecp256k1Key() clientKey = generateSecp256k1Key() - server = newTestWakuNode(serverKey, ValidIpAddress.init("0.0.0.0"), Port(0)) - client = newTestWakuNode(clientKey, ValidIpAddress.init("0.0.0.0"), Port(0)) + server = newTestWakuNode(serverKey, parseIpAddress("0.0.0.0"), Port(0)) + client = newTestWakuNode(clientKey, parseIpAddress("0.0.0.0"), Port(0)) let archiveDriver = newSqliteArchiveDriver().put(pubsubTopic, messages[0 ..< 6]).put( pubsubTopicB, messages[6 ..< 10] @@ -1189,7 +1184,7 @@ suite "Waku Store - End to End - Archive with Multiple Topics": let ephemeralServerKey = generateSecp256k1Key() ephemeralServer = - newTestWakuNode(ephemeralServerKey, ValidIpAddress.init("0.0.0.0"), Port(0)) + newTestWakuNode(ephemeralServerKey, parseIpAddress("0.0.0.0"), Port(0)) mountEphemeralArchiveResult = ephemeralServer.mountArchive(ephemeralArchiveDriver) assert mountEphemeralArchiveResult.isOk() @@ -1231,7 +1226,7 @@ suite "Waku Store - End to End - Archive with Multiple Topics": let mixedServerKey = generateSecp256k1Key() mixedServer = - newTestWakuNode(mixedServerKey, ValidIpAddress.init("0.0.0.0"), Port(0)) + newTestWakuNode(mixedServerKey, parseIpAddress("0.0.0.0"), Port(0)) mountMixedArchiveResult = mixedServer.mountArchive(mixedArchiveDriver) assert mountMixedArchiveResult.isOk() @@ -1258,7 +1253,7 @@ suite "Waku Store - End to End - Archive with Multiple Topics": let emptyServerKey = generateSecp256k1Key() emptyServer = - newTestWakuNode(emptyServerKey, ValidIpAddress.init("0.0.0.0"), Port(0)) + newTestWakuNode(emptyServerKey, parseIpAddress("0.0.0.0"), Port(0)) mountEmptyArchiveResult = emptyServer.mountArchive(emptyArchiveDriver) assert mountEmptyArchiveResult.isOk() @@ -1298,7 +1293,7 @@ suite "Waku Store - End to End - Archive with Multiple Topics": let voluminousServerKey = generateSecp256k1Key() voluminousServer = - newTestWakuNode(voluminousServerKey, ValidIpAddress.init("0.0.0.0"), Port(0)) + newTestWakuNode(voluminousServerKey, parseIpAddress("0.0.0.0"), Port(0)) mountVoluminousArchiveResult = voluminousServer.mountArchive(voluminousArchiveDriverWithMessages) assert mountVoluminousArchiveResult.isOk() diff --git a/tests/test_peer_manager.nim b/tests/test_peer_manager.nim index 1c2805710..9ef5ddd90 100644 --- a/tests/test_peer_manager.nim +++ b/tests/test_peer_manager.nim @@ -2,7 +2,6 @@ import std/[sequtils, times, sugar, net], - stew/shims/net as stewNet, testutils/unittests, chronos, json_rpc/rpcserver, @@ -39,7 +38,7 @@ procSuite "Peer Manager": asyncTest "connectPeer() works": # Create 2 nodes let nodes = toSeq(0 ..< 2).mapIt( - newTestWakuNode(generateSecp256k1Key(), ValidIpAddress.init("0.0.0.0"), Port(0)) + newTestWakuNode(generateSecp256k1Key(), parseIpAddress("0.0.0.0"), Port(0)) ) await allFutures(nodes.mapIt(it.start())) @@ -58,7 +57,7 @@ procSuite "Peer Manager": asyncTest "dialPeer() works": # Create 2 nodes let nodes = toSeq(0 ..< 2).mapIt( - newTestWakuNode(generateSecp256k1Key(), ValidIpAddress.init("0.0.0.0"), Port(0)) + newTestWakuNode(generateSecp256k1Key(), parseIpAddress("0.0.0.0"), Port(0)) ) await allFutures(nodes.mapIt(it.start())) @@ -93,7 +92,7 @@ procSuite "Peer Manager": asyncTest "dialPeer() fails gracefully": # Create 2 nodes and start them let nodes = toSeq(0 ..< 2).mapIt( - newTestWakuNode(generateSecp256k1Key(), ValidIpAddress.init("0.0.0.0"), Port(0)) + newTestWakuNode(generateSecp256k1Key(), parseIpAddress("0.0.0.0"), Port(0)) ) await allFutures(nodes.mapIt(it.start())) await allFutures(nodes.mapIt(it.mountRelay())) @@ -121,8 +120,7 @@ procSuite "Peer Manager": asyncTest "Adding, selecting and filtering peers work": let - node = - newTestWakuNode(generateSecp256k1Key(), ValidIpAddress.init("0.0.0.0"), Port(0)) + node = newTestWakuNode(generateSecp256k1Key(), parseIpAddress("0.0.0.0"), Port(0)) # Create filter peer filterLoc = MultiAddress.init("/ip4/127.0.0.1/tcp/0").tryGet() @@ -155,7 +153,7 @@ procSuite "Peer Manager": asyncTest "Peer manager keeps track of connections": # Create 2 nodes let nodes = toSeq(0 ..< 2).mapIt( - newTestWakuNode(generateSecp256k1Key(), ValidIpAddress.init("0.0.0.0"), Port(0)) + newTestWakuNode(generateSecp256k1Key(), parseIpAddress("0.0.0.0"), Port(0)) ) await allFutures(nodes.mapIt(it.start())) @@ -208,7 +206,7 @@ procSuite "Peer Manager": asyncTest "Peer manager updates failed peers correctly": # Create 2 nodes let nodes = toSeq(0 ..< 2).mapIt( - newTestWakuNode(generateSecp256k1Key(), ValidIpAddress.init("0.0.0.0"), Port(0)) + newTestWakuNode(generateSecp256k1Key(), parseIpAddress("0.0.0.0"), Port(0)) ) await allFutures(nodes.mapIt(it.start())) @@ -310,7 +308,7 @@ procSuite "Peer Manager": # Simulate restart by initialising a new node using the same storage let node3 = newTestWakuNode( generateSecp256k1Key(), - ValidIpAddress.init("127.0.0.1"), + parseIpAddress("127.0.0.1"), Port(56037), peerStorage = storage, ) @@ -383,7 +381,7 @@ procSuite "Peer Manager": # Simulate restart by initialising a new node using the same storage let node3 = newTestWakuNode( generateSecp256k1Key(), - ValidIpAddress.init("127.0.0.1"), + parseIpAddress("127.0.0.1"), Port(56037), peerStorage = storage, ) @@ -419,7 +417,7 @@ procSuite "Peer Manager": # different network node1 = newTestWakuNode( generateSecp256k1Key(), - ValidIpAddress.init("0.0.0.0"), + parseIpAddress("0.0.0.0"), port, clusterId = 3, shards = @[uint16(0)], @@ -428,14 +426,14 @@ procSuite "Peer Manager": # same network node2 = newTestWakuNode( generateSecp256k1Key(), - ValidIpAddress.init("0.0.0.0"), + parseIpAddress("0.0.0.0"), port, clusterId = 4, shards = @[uint16(0)], ) node3 = newTestWakuNode( generateSecp256k1Key(), - ValidIpAddress.init("0.0.0.0"), + parseIpAddress("0.0.0.0"), port, clusterId = 4, shards = @[uint16(0)], @@ -475,12 +473,12 @@ procSuite "Peer Manager": storage = WakuPeerStorage.new(database)[] node1 = newTestWakuNode( generateSecp256k1Key(), - ValidIpAddress.init("0.0.0.0"), + parseIpAddress("0.0.0.0"), Port(0), peerStorage = storage, ) node2 = - newTestWakuNode(generateSecp256k1Key(), ValidIpAddress.init("0.0.0.0"), Port(0)) + newTestWakuNode(generateSecp256k1Key(), parseIpAddress("0.0.0.0"), Port(0)) peerInfo2 = node2.switch.peerInfo betaCodec = "/vac/waku/relay/2.0.0-beta2" stableCodec = "/vac/waku/relay/2.0.0" @@ -508,10 +506,7 @@ procSuite "Peer Manager": # Simulate restart by initialising a new node using the same storage let node3 = newTestWakuNode( - generateSecp256k1Key(), - ValidIpAddress.init("0.0.0.0"), - Port(0), - peerStorage = storage, + generateSecp256k1Key(), parseIpAddress("0.0.0.0"), Port(0), peerStorage = storage ) (await node3.mountRelay()).isOkOr: @@ -546,7 +541,7 @@ procSuite "Peer Manager": let nodes = toSeq(0 ..< 4).mapIt( newTestWakuNode( nodeKey = generateSecp256k1Key(), - bindIp = ValidIpAddress.init("0.0.0.0"), + bindIp = parseIpAddress("0.0.0.0"), bindPort = Port(0), wakuFlags = some(CapabilitiesBitfield.init(@[Relay])), ) @@ -616,7 +611,7 @@ procSuite "Peer Manager": let nodes = toSeq(0 ..< 4).mapIt( newTestWakuNode( nodeKey = generateSecp256k1Key(), - bindIp = ValidIpAddress.init("0.0.0.0"), + bindIp = parseIpAddress("0.0.0.0"), bindPort = Port(0), wakuFlags = some(CapabilitiesBitfield.init(@[Relay])), ) @@ -684,7 +679,7 @@ procSuite "Peer Manager": asyncTest "Peer store keeps track of incoming connections": # Create 4 nodes let nodes = toSeq(0 ..< 4).mapIt( - newTestWakuNode(generateSecp256k1Key(), ValidIpAddress.init("0.0.0.0"), Port(0)) + newTestWakuNode(generateSecp256k1Key(), parseIpAddress("0.0.0.0"), Port(0)) ) # Start them @@ -778,8 +773,7 @@ procSuite "Peer Manager": let basePeerId = "16Uiu2HAm7QGEZKujdSbbo1aaQyfDPQ6Bw3ybQnj6fruH5Dxwd7D" let - node = - newTestWakuNode(generateSecp256k1Key(), ValidIpAddress.init("0.0.0.0"), Port(0)) + node = newTestWakuNode(generateSecp256k1Key(), parseIpAddress("0.0.0.0"), Port(0)) peers = toSeq(1 .. 4) .mapIt(parsePeerInfo("/ip4/0.0.0.0/tcp/30300/p2p/" & basePeerId & $it)) .filterIt(it.isOk()) @@ -818,7 +812,7 @@ procSuite "Peer Manager": asyncTest "connectedPeers() returns expected number of connections per protocol": # Create 4 nodes let nodes = toSeq(0 ..< 4).mapIt( - newTestWakuNode(generateSecp256k1Key(), ValidIpAddress.init("0.0.0.0"), Port(0)) + newTestWakuNode(generateSecp256k1Key(), parseIpAddress("0.0.0.0"), Port(0)) ) # Start them with relay + filter @@ -873,7 +867,7 @@ procSuite "Peer Manager": asyncTest "getNumStreams() returns expected number of connections per protocol": # Create 2 nodes let nodes = toSeq(0 ..< 2).mapIt( - newTestWakuNode(generateSecp256k1Key(), ValidIpAddress.init("0.0.0.0"), Port(0)) + newTestWakuNode(generateSecp256k1Key(), parseIpAddress("0.0.0.0"), Port(0)) ) # Start them with relay + filter @@ -1140,7 +1134,7 @@ procSuite "Peer Manager": asyncTest "colocationLimit is enforced by pruneConnsByIp()": # Create 5 nodes let nodes = toSeq(0 ..< 5).mapIt( - newTestWakuNode(generateSecp256k1Key(), ValidIpAddress.init("0.0.0.0"), Port(0)) + newTestWakuNode(generateSecp256k1Key(), parseIpAddress("0.0.0.0"), Port(0)) ) # Start them with relay + filter diff --git a/tests/test_relay_peer_exchange.nim b/tests/test_relay_peer_exchange.nim index a729ff1a7..a5e3b63ee 100644 --- a/tests/test_relay_peer_exchange.nim +++ b/tests/test_relay_peer_exchange.nim @@ -2,7 +2,6 @@ import std/[sequtils, options], - stew/shims/net, testutils/unittests, chronos, libp2p/peerid, diff --git a/tests/test_waku_dnsdisc.nim b/tests/test_waku_dnsdisc.nim index 7028b20eb..758bdb3ca 100644 --- a/tests/test_waku_dnsdisc.nim +++ b/tests/test_waku_dnsdisc.nim @@ -2,7 +2,6 @@ import std/[sequtils, tables], - stew/shims/net, results, stew/base32, testutils/unittests, diff --git a/tests/test_waku_keepalive.nim b/tests/test_waku_keepalive.nim index d4d05ad97..3fcf01b8e 100644 --- a/tests/test_waku_keepalive.nim +++ b/tests/test_waku_keepalive.nim @@ -1,7 +1,6 @@ {.used.} import - stew/shims/net as stewNet, testutils/unittests, chronos, chronicles, diff --git a/tests/test_waku_metadata.nim b/tests/test_waku_metadata.nim index aa22a43f4..b30fd1712 100644 --- a/tests/test_waku_metadata.nim +++ b/tests/test_waku_metadata.nim @@ -5,7 +5,6 @@ import testutils/unittests, chronos, chronicles, - stew/shims/net, libp2p/switch, libp2p/peerId, libp2p/crypto/crypto, diff --git a/tests/test_waku_switch.nim b/tests/test_waku_switch.nim index e58bff12e..3e6fd08eb 100644 --- a/tests/test_waku_switch.nim +++ b/tests/test_waku_switch.nim @@ -75,8 +75,15 @@ suite "Waku Switch": completionFut = newFuture[bool]() proto = new LPProtocol proto.codec = customProtoCodec - proto.handler = proc(conn: Connection, proto: string) {.async.} = - assert (await conn.readLp(1024)) == msg.toBytes() + proto.handler = proc( + conn: Connection, proto: string + ) {.async: (raises: [CancelledError]).} = + try: + assert (await conn.readLp(1024)) == msg.toBytes() + except LPStreamError: + error "Connection read error", error = getCurrentExceptionMsg() + assert false, getCurrentExceptionMsg() + completionFut.complete(true) await proto.start() diff --git a/tests/test_wakunode.nim b/tests/test_wakunode.nim index 51dd999b0..e50f3fe98 100644 --- a/tests/test_wakunode.nim +++ b/tests/test_wakunode.nim @@ -3,7 +3,6 @@ import std/[sequtils, strutils, net], stew/byteutils, - stew/shims/net as stewNet, testutils/unittests, chronicles, chronos, @@ -15,7 +14,8 @@ import libp2p/protocols/pubsub/pubsub, libp2p/protocols/pubsub/gossipsub, libp2p/nameresolving/mockresolver, - eth/p2p/discoveryv5/enr + eth/p2p/discoveryv5/enr, + eth/net/utils import waku/[waku_core, waku_node, node/peer_manager], ./testlib/wakucore, ./testlib/wakunode diff --git a/tests/testlib/wakunode.nim b/tests/testlib/wakunode.nim index 87fdbcf5f..54719aac1 100644 --- a/tests/testlib/wakunode.nim +++ b/tests/testlib/wakunode.nim @@ -1,7 +1,6 @@ import std/options, results, - stew/shims/net, chronos, libp2p/switch, libp2p/builders, diff --git a/tests/waku_core/test_published_address.nim b/tests/waku_core/test_published_address.nim index 37f263ea0..9d6201a77 100644 --- a/tests/waku_core/test_published_address.nim +++ b/tests/waku_core/test_published_address.nim @@ -1,6 +1,6 @@ {.used.} -import stew/shims/net as stewNet, std/strutils, testutils/unittests +import std/[strutils, net], testutils/unittests import ../testlib/wakucore, ../testlib/wakunode suite "Waku Core - Published Address": diff --git a/tests/waku_discv5/utils.nim b/tests/waku_discv5/utils.nim index 422e13fd9..5a69108c5 100644 --- a/tests/waku_discv5/utils.nim +++ b/tests/waku_discv5/utils.nim @@ -1,9 +1,4 @@ -import - std/options, - stew/shims/net, - chronos, - libp2p/crypto/crypto as libp2p_keys, - eth/keys as eth_keys +import std/options, chronos, libp2p/crypto/crypto as libp2p_keys, eth/keys as eth_keys import waku/ diff --git a/tests/waku_enr/test_sharding.nim b/tests/waku_enr/test_sharding.nim index 7c65d83fb..0984b7d8d 100644 --- a/tests/waku_enr/test_sharding.nim +++ b/tests/waku_enr/test_sharding.nim @@ -2,7 +2,6 @@ import stew/results, - stew/shims/net, chronos, testutils/unittests, libp2p/crypto/crypto as libp2p_keys, diff --git a/tests/waku_enr/utils.nim b/tests/waku_enr/utils.nim index 8f79b1d8f..7302c2112 100644 --- a/tests/waku_enr/utils.nim +++ b/tests/waku_enr/utils.nim @@ -2,7 +2,6 @@ import std/options, sequtils, results, - stew/shims/net, chronos, libp2p/crypto/crypto as libp2p_keys, eth/keys as eth_keys diff --git a/tests/waku_relay/test_message_id.nim b/tests/waku_relay/test_message_id.nim index 633303120..6dcd72ab7 100644 --- a/tests/waku_relay/test_message_id.nim +++ b/tests/waku_relay/test_message_id.nim @@ -1,7 +1,7 @@ import unittest, results, - stew/[shims/net, byteutils], + stew/byteutils, nimcrypto/sha2, libp2p/protocols/pubsub/rpc/messages diff --git a/tests/waku_relay/test_protocol.nim b/tests/waku_relay/test_protocol.nim index d0e8a7ed6..bc2097caa 100644 --- a/tests/waku_relay/test_protocol.nim +++ b/tests/waku_relay/test_protocol.nim @@ -2,7 +2,6 @@ import std/[options, strformat], - stew/shims/net as stewNet, testutils/unittests, chronos, libp2p/protocols/pubsub/[pubsub, gossipsub], diff --git a/tests/waku_relay/test_wakunode_relay.nim b/tests/waku_relay/test_wakunode_relay.nim index 5d5ce8458..c9c8d82ef 100644 --- a/tests/waku_relay/test_wakunode_relay.nim +++ b/tests/waku_relay/test_wakunode_relay.nim @@ -3,7 +3,6 @@ import std/[os, sequtils, sysrand, math], stew/byteutils, - stew/shims/net as stewNet, testutils/unittests, chronos, libp2p/switch, diff --git a/tests/waku_relay/utils.nim b/tests/waku_relay/utils.nim index 6de28583e..309f800dc 100644 --- a/tests/waku_relay/utils.nim +++ b/tests/waku_relay/utils.nim @@ -3,7 +3,6 @@ import std/[strutils, sequtils, tempfiles], stew/byteutils, - stew/shims/net as stewNet, chronos, chronicles, libp2p/switch, diff --git a/tests/waku_rln_relay/rln/test_wrappers.nim b/tests/waku_rln_relay/rln/test_wrappers.nim index 26e18f9da..f19599e4f 100644 --- a/tests/waku_rln_relay/rln/test_wrappers.nim +++ b/tests/waku_rln_relay/rln/test_wrappers.nim @@ -3,7 +3,6 @@ import testutils/unittests, chronicles, chronos, - stew/shims/net as stewNet, eth/keys, bearssl, stew/[results], diff --git a/tests/waku_rln_relay/test_rln_group_manager_onchain.nim b/tests/waku_rln_relay/test_rln_group_manager_onchain.nim index 7ba64e39b..b19d15030 100644 --- a/tests/waku_rln_relay/test_rln_group_manager_onchain.nim +++ b/tests/waku_rln_relay/test_rln_group_manager_onchain.nim @@ -57,19 +57,21 @@ suite "Onchain group manager": raiseAssert "Expected error when chainId does not match" asyncTest "should initialize when chainId is set to 0": - manager.chainId = 0 + manager.chainId = 0x0'u256 (await manager.init()).isOkOr: raiseAssert $error asyncTest "should error on initialization when loaded metadata does not match": (await manager.init()).isOkOr: - raiseAssert $error + assert false, $error let metadataSetRes = manager.setMetadata() assert metadataSetRes.isOk(), metadataSetRes.error let metadataOpt = manager.rlnInstance.getMetadata().valueOr: - raiseAssert $error + assert false, $error + return + assert metadataOpt.isSome(), "metadata is not set" let metadata = metadataOpt.get() @@ -84,17 +86,12 @@ suite "Onchain group manager": ethContractAddress: $differentContractAddress, rlnInstance: manager.rlnInstance, onFatalErrorAction: proc(errStr: string) = - raiseAssert errStr + assert false, errStr , ) let e = await manager2.init() (e).isErrOr: - raiseAssert "Expected error when contract address doesn't match" - - echo "---" - discard "persisted data: contract address mismatch" - echo e.error - echo "---" + assert false, "Expected error when contract address doesn't match" asyncTest "should error if contract does not exist": manager.ethContractAddress = "0x0000000000000000000000000000000000000000" diff --git a/tests/waku_rln_relay/test_rln_group_manager_static.nim b/tests/waku_rln_relay/test_rln_group_manager_static.nim index 5d1916f63..73dff8a8b 100644 --- a/tests/waku_rln_relay/test_rln_group_manager_static.nim +++ b/tests/waku_rln_relay/test_rln_group_manager_static.nim @@ -13,7 +13,7 @@ import waku_rln_relay/group_manager/static/group_manager, ] -import stew/shims/net, chronos, libp2p/crypto/crypto, eth/keys, dnsdisc/builder +import chronos, libp2p/crypto/crypto, eth/keys, dnsdisc/builder import std/tempfiles diff --git a/tests/waku_rln_relay/test_waku_rln_relay.nim b/tests/waku_rln_relay/test_waku_rln_relay.nim index e89d8e2e6..d09764ca2 100644 --- a/tests/waku_rln_relay/test_waku_rln_relay.nim +++ b/tests/waku_rln_relay/test_waku_rln_relay.nim @@ -3,7 +3,6 @@ import std/[options, os, sequtils, tempfiles], stew/byteutils, - stew/shims/net as stewNet, testutils/unittests, chronos, chronicles, @@ -247,7 +246,7 @@ suite "Waku rln relay": .setMetadata( RlnMetadata( lastProcessedBlock: 128, - chainId: 1155511, + chainId: 1155511'u256, contractAddress: "0x9c09146844c1326c2dbc41c451766c7138f88155", ) ) @@ -265,7 +264,7 @@ suite "Waku rln relay": .setMetadata( RlnMetadata( lastProcessedBlock: 128, - chainId: 1155511, + chainId: 1155511'u256, contractAddress: "0x9c09146844c1326c2dbc41c451766c7138f88155", ) ) @@ -278,7 +277,7 @@ suite "Waku rln relay": let metadata = metadataOpt.get() check: metadata.lastProcessedBlock == 128 - metadata.chainId == 1155511 + metadata.chainId == 1155511'u256 metadata.contractAddress == "0x9c09146844c1326c2dbc41c451766c7138f88155" test "getMetadata: empty rln metadata": diff --git a/tests/waku_rln_relay/test_wakunode_rln_relay.nim b/tests/waku_rln_relay/test_wakunode_rln_relay.nim index 7620dfc14..312fe5cfc 100644 --- a/tests/waku_rln_relay/test_wakunode_rln_relay.nim +++ b/tests/waku_rln_relay/test_wakunode_rln_relay.nim @@ -3,7 +3,6 @@ import std/[sequtils, tempfiles], stew/byteutils, - stew/shims/net as stewNet, testutils/unittests, chronicles, chronos, diff --git a/tests/waku_rln_relay/utils_onchain.nim b/tests/waku_rln_relay/utils_onchain.nim index 433f865c4..0c7fcce26 100644 --- a/tests/waku_rln_relay/utils_onchain.nim +++ b/tests/waku_rln_relay/utils_onchain.nim @@ -13,6 +13,7 @@ import web3, web3/conversions, web3/eth_api_types, + json_rpc/rpcclient, json, libp2p/crypto/crypto, eth/keys, @@ -29,7 +30,7 @@ import ../testlib/common, ./utils -const CHAIN_ID* = 1337 +const CHAIN_ID* = 1337'u256 template skip0xPrefix(hexStr: string): int = ## Returns the index of the first meaningful char in `hexStr` by skipping @@ -74,7 +75,8 @@ proc uploadRLNContract*(ethClientAddress: string): Future[Address] {.async.} = let add = web3.defaultAccount debug "contract deployer account address ", add - let balance = await web3.provider.eth_getBalance(web3.defaultAccount, "latest") + let balance = + await web3.provider.eth_getBalance(web3.defaultAccount, blockId("latest")) debug "Initial account balance: ", balance # deploy poseidon hasher bytecode diff --git a/tests/waku_rln_relay/utils_static.nim b/tests/waku_rln_relay/utils_static.nim index 8f564beb1..cbf3e9253 100644 --- a/tests/waku_rln_relay/utils_static.nim +++ b/tests/waku_rln_relay/utils_static.nim @@ -3,7 +3,6 @@ import std/[sequtils, tempfiles], stew/byteutils, - stew/shims/net as stewNet, chronos, chronicles, libp2p/switch, diff --git a/tests/waku_store/test_wakunode_store.nim b/tests/waku_store/test_wakunode_store.nim index 1d5e4dcfd..b20309079 100644 --- a/tests/waku_store/test_wakunode_store.nim +++ b/tests/waku_store/test_wakunode_store.nim @@ -2,7 +2,6 @@ import std/sequtils, - stew/shims/net as stewNet, testutils/unittests, chronicles, chronos, diff --git a/tests/wakunode2/test_app.nim b/tests/wakunode2/test_app.nim index 2ee933e3f..4f52732da 100644 --- a/tests/wakunode2/test_app.nim +++ b/tests/wakunode2/test_app.nim @@ -1,7 +1,6 @@ {.used.} import - stew/shims/net, testutils/unittests, chronicles, chronos, diff --git a/tests/wakunode2/test_validators.nim b/tests/wakunode2/test_validators.nim index 23a3e5d6f..44b6ae118 100644 --- a/tests/wakunode2/test_validators.nim +++ b/tests/wakunode2/test_validators.nim @@ -2,7 +2,6 @@ import std/[sequtils, sysrand, math], - stew/shims/net as stewNet, testutils/unittests, chronos, libp2p/crypto/crypto, diff --git a/tests/wakunode_rest/test_rest_cors.nim b/tests/wakunode_rest/test_rest_cors.nim index 7d29711b1..58e70aa25 100644 --- a/tests/wakunode_rest/test_rest_cors.nim +++ b/tests/wakunode_rest/test_rest_cors.nim @@ -1,7 +1,6 @@ {.used.} import - stew/shims/net, testutils/unittests, presto, presto/client as presto_client, diff --git a/tests/wakunode_rest/test_rest_debug.nim b/tests/wakunode_rest/test_rest_debug.nim index 3129b3544..9add57cbe 100644 --- a/tests/wakunode_rest/test_rest_debug.nim +++ b/tests/wakunode_rest/test_rest_debug.nim @@ -1,7 +1,6 @@ {.used.} import - stew/shims/net, testutils/unittests, presto, presto/client as presto_client, diff --git a/tests/wakunode_rest/test_rest_filter.nim b/tests/wakunode_rest/test_rest_filter.nim index 556b6b52e..dcd430a0e 100644 --- a/tests/wakunode_rest/test_rest_filter.nim +++ b/tests/wakunode_rest/test_rest_filter.nim @@ -3,7 +3,6 @@ import chronos/timer, stew/byteutils, - stew/shims/net, testutils/unittests, presto, presto/client as presto_client, diff --git a/tests/wakunode_rest/test_rest_health.nim b/tests/wakunode_rest/test_rest_health.nim index 3c7c94e87..1f6c6314f 100644 --- a/tests/wakunode_rest/test_rest_health.nim +++ b/tests/wakunode_rest/test_rest_health.nim @@ -2,7 +2,6 @@ import std/tempfiles, - stew/shims/net, testutils/unittests, presto, presto/client as presto_client, diff --git a/tests/wakunode_rest/test_rest_lightpush.nim b/tests/wakunode_rest/test_rest_lightpush.nim index 72e309a13..035b2a884 100644 --- a/tests/wakunode_rest/test_rest_lightpush.nim +++ b/tests/wakunode_rest/test_rest_lightpush.nim @@ -3,7 +3,6 @@ import std/sequtils, stew/byteutils, - stew/shims/net, testutils/unittests, presto, presto/client as presto_client, diff --git a/tests/wakunode_rest/test_rest_lightpush_legacy.nim b/tests/wakunode_rest/test_rest_lightpush_legacy.nim index e1d6dca30..f50703bae 100644 --- a/tests/wakunode_rest/test_rest_lightpush_legacy.nim +++ b/tests/wakunode_rest/test_rest_lightpush_legacy.nim @@ -3,7 +3,6 @@ import std/sequtils, stew/byteutils, - stew/shims/net, testutils/unittests, presto, presto/client as presto_client, diff --git a/tests/wakunode_rest/test_rest_relay.nim b/tests/wakunode_rest/test_rest_relay.nim index 8bca121e3..208b86190 100644 --- a/tests/wakunode_rest/test_rest_relay.nim +++ b/tests/wakunode_rest/test_rest_relay.nim @@ -3,7 +3,6 @@ import std/[sequtils, strformat, tempfiles], stew/byteutils, - stew/shims/net, testutils/unittests, presto, presto/client as presto_client, @@ -320,7 +319,7 @@ suite "Waku v2 Rest API - Relay": check: # Node should be subscribed to all shards node.wakuRelay.subscribedTopics == - @["/waku/2/rs/1/7", "/waku/2/rs/1/2", "/waku/2/rs/1/5"] + @["/waku/2/rs/1/5", "/waku/2/rs/1/7", "/waku/2/rs/1/2"] await restServer.stop() await restServer.closeWait() diff --git a/tests/wakunode_rest/test_rest_store.nim b/tests/wakunode_rest/test_rest_store.nim index d0631bfbf..f08ed0a17 100644 --- a/tests/wakunode_rest/test_rest_store.nim +++ b/tests/wakunode_rest/test_rest_store.nim @@ -2,7 +2,6 @@ import std/[options, sugar], - stew/shims/net as stewNet, chronicles, chronos/timer, testutils/unittests, diff --git a/tools/rln_keystore_generator/rln_keystore_generator.nim b/tools/rln_keystore_generator/rln_keystore_generator.nim index cd501e52d..ee5911abf 100644 --- a/tools/rln_keystore_generator/rln_keystore_generator.nim +++ b/tools/rln_keystore_generator/rln_keystore_generator.nim @@ -20,7 +20,7 @@ type RlnKeystoreGeneratorConf* = object execute*: bool ethContractAddress*: string ethClientUrls*: seq[string] - chainId*: uint + chainId*: UInt256 credPath*: string credPassword*: string userMessageLimit*: uint64 diff --git a/vendor/nim-chronicles b/vendor/nim-chronicles index 81a4a7a36..a8fb38a10 160000 --- a/vendor/nim-chronicles +++ b/vendor/nim-chronicles @@ -1 +1 @@ -Subproject commit 81a4a7a360c78be9c80c8f735c76b6d4a1517304 +Subproject commit a8fb38a10bcb548df78e9a70bd77b26bb50abd12 diff --git a/vendor/nim-chronos b/vendor/nim-chronos index c04576d82..0646c444f 160000 --- a/vendor/nim-chronos +++ b/vendor/nim-chronos @@ -1 +1 @@ -Subproject commit c04576d829b8a0a1b12baaa8bc92037501b3a4a0 +Subproject commit 0646c444fce7c7ed08ef6f2c9a7abfd172ffe655 diff --git a/vendor/nim-eth b/vendor/nim-eth index c6c9dc7ae..a1f7d63ab 160000 --- a/vendor/nim-eth +++ b/vendor/nim-eth @@ -1 +1 @@ -Subproject commit c6c9dc7ae01656eba8126b913e84bdfb95c8c323 +Subproject commit a1f7d63ababa6ce90798e16a110fc4e43ac93f03 diff --git a/vendor/nim-faststreams b/vendor/nim-faststreams index 2b08c774a..c51315d0a 160000 --- a/vendor/nim-faststreams +++ b/vendor/nim-faststreams @@ -1 +1 @@ -Subproject commit 2b08c774afaafd600cf4c6f994cf78b8aa090c0c +Subproject commit c51315d0ae5eb2594d0bf41181d0e1aca1b3c01d diff --git a/vendor/nim-json-rpc b/vendor/nim-json-rpc index c0ac84873..cbe8edf69 160000 --- a/vendor/nim-json-rpc +++ b/vendor/nim-json-rpc @@ -1 +1 @@ -Subproject commit c0ac848733e42e672081f429fb146451894f7711 +Subproject commit cbe8edf69d743a787b76b1cd25bfc4eae89927f7 diff --git a/vendor/nim-libbacktrace b/vendor/nim-libbacktrace index dbade9ba2..822849874 160000 --- a/vendor/nim-libbacktrace +++ b/vendor/nim-libbacktrace @@ -1 +1 @@ -Subproject commit dbade9ba250da7db519c5cdfb225d03ca1255efc +Subproject commit 822849874926ba3849a86cb3eafdf017bd11bd2d diff --git a/vendor/nim-libp2p b/vendor/nim-libp2p index 78a434405..cd60b254a 160000 --- a/vendor/nim-libp2p +++ b/vendor/nim-libp2p @@ -1 +1 @@ -Subproject commit 78a434405435b69a24e8b263d48d622d57c4db5b +Subproject commit cd60b254a0700b0daac7a6cb2c0c48860b57c539 diff --git a/vendor/nim-metrics b/vendor/nim-metrics index 25ffd054f..11d0cddfb 160000 --- a/vendor/nim-metrics +++ b/vendor/nim-metrics @@ -1 +1 @@ -Subproject commit 25ffd054fd774f8cf7935e75d6cad542306d7802 +Subproject commit 11d0cddfb0e711aa2a8c75d1892ae24a64c299fc diff --git a/vendor/nim-nat-traversal b/vendor/nim-nat-traversal index 213ac13df..dfbf8c9ad 160000 --- a/vendor/nim-nat-traversal +++ b/vendor/nim-nat-traversal @@ -1 +1 @@ -Subproject commit 213ac13dfe5c4830474912c48181b86b73f1ec1f +Subproject commit dfbf8c9ad3655f238b350f690bbfce5ec34d25fb diff --git a/vendor/nim-regex b/vendor/nim-regex index 0673df07c..4593305ed 160000 --- a/vendor/nim-regex +++ b/vendor/nim-regex @@ -1 +1 @@ -Subproject commit 0673df07cb266e15942c3b5f5b8a4732f049cd73 +Subproject commit 4593305ed1e49731fc75af1dc572dd2559aad19c diff --git a/vendor/nim-secp256k1 b/vendor/nim-secp256k1 index 62e16b4df..f808ed5e7 160000 --- a/vendor/nim-secp256k1 +++ b/vendor/nim-secp256k1 @@ -1 +1 @@ -Subproject commit 62e16b4dff513f1eea7148a8cbba8a8c547b9546 +Subproject commit f808ed5e7a7bfc42204ec7830f14b7a42b63c284 diff --git a/vendor/nim-sqlite3-abi b/vendor/nim-sqlite3-abi index cc4fefd53..d08e96487 160000 --- a/vendor/nim-sqlite3-abi +++ b/vendor/nim-sqlite3-abi @@ -1 +1 @@ -Subproject commit cc4fefd538aa43814c5864c540fb75b567c2dcc3 +Subproject commit d08e964872271e83fb1b6de67ad57c2d0fcdfe63 diff --git a/vendor/nim-stew b/vendor/nim-stew index 687d1b4ab..58abb4891 160000 --- a/vendor/nim-stew +++ b/vendor/nim-stew @@ -1 +1 @@ -Subproject commit 687d1b4ab1a91e6cc9c92e4fd4d98bec7874c259 +Subproject commit 58abb4891f97c6cdc07335e868414e0c7b736c68 diff --git a/vendor/nim-taskpools b/vendor/nim-taskpools index 7b74a716a..9e8ccc754 160000 --- a/vendor/nim-taskpools +++ b/vendor/nim-taskpools @@ -1 +1 @@ -Subproject commit 7b74a716a40249720fd7da428113147942b9642d +Subproject commit 9e8ccc754631ac55ac2fd495e167e74e86293edb diff --git a/vendor/nim-testutils b/vendor/nim-testutils index 14a56ae5a..94d68e796 160000 --- a/vendor/nim-testutils +++ b/vendor/nim-testutils @@ -1 +1 @@ -Subproject commit 14a56ae5aada81bed43e29d2368fc8ab8a449bf5 +Subproject commit 94d68e796c045d5b37cabc6be32d7bfa168f8857 diff --git a/vendor/nim-unittest2 b/vendor/nim-unittest2 index 88a613ffa..8b51e99b4 160000 --- a/vendor/nim-unittest2 +++ b/vendor/nim-unittest2 @@ -1 +1 @@ -Subproject commit 88a613ffa4dbe452971beb937ea2db736dc9a9f4 +Subproject commit 8b51e99b4a57fcfb31689230e75595f024543024 diff --git a/vendor/nim-web3 b/vendor/nim-web3 index 94aac8a77..3ef986c9d 160000 --- a/vendor/nim-web3 +++ b/vendor/nim-web3 @@ -1 +1 @@ -Subproject commit 94aac8a77cd265fe779ce8ed25a028340b925fd1 +Subproject commit 3ef986c9d93604775595f116a35c6ac0bf5257fc diff --git a/vendor/nim-zlib b/vendor/nim-zlib index 3f7998095..daa8723fd 160000 --- a/vendor/nim-zlib +++ b/vendor/nim-zlib @@ -1 +1 @@ -Subproject commit 3f7998095264d262a8d99e2be89045e6d9301537 +Subproject commit daa8723fd32299d4ca621c837430c29a5a11e19a diff --git a/vendor/nimbus-build-system b/vendor/nimbus-build-system index 8fafcd0ba..0be0663e1 160000 --- a/vendor/nimbus-build-system +++ b/vendor/nimbus-build-system @@ -1 +1 @@ -Subproject commit 8fafcd0bac9f409091b7bcaee62ab6330f57441e +Subproject commit 0be0663e1af76e869837226a4ef3e586fcc737d3 diff --git a/vendor/nimcrypto b/vendor/nimcrypto index dc07e3058..19c41d6be 160000 --- a/vendor/nimcrypto +++ b/vendor/nimcrypto @@ -1 +1 @@ -Subproject commit dc07e3058c6904eef965394493b6ea99aa2adefc +Subproject commit 19c41d6be4c00b4a2c8000583bd30cf8ceb5f4b1 diff --git a/vendor/nph b/vendor/nph index 0d8000e74..3191cc71f 160000 --- a/vendor/nph +++ b/vendor/nph @@ -1 +1 @@ -Subproject commit 0d8000e741fa11ed48fdd116f24b4251b92aa9b5 +Subproject commit 3191cc71f4d49473de6cf73a2680009a92419407 diff --git a/waku.nimble b/waku.nimble index 9cf73295f..6ec05caaf 100644 --- a/waku.nimble +++ b/waku.nimble @@ -8,7 +8,7 @@ license = "MIT or Apache License 2.0" #bin = @["build/waku"] ### Dependencies -requires "nim >= 2.0.8", +requires "nim >= 2.2.4", "chronicles", "confutils", "chronos", diff --git a/waku/discovery/autonat_service.nim b/waku/discovery/autonat_service.nim index c4e2dd8ed..efc3de561 100644 --- a/waku/discovery/autonat_service.nim +++ b/waku/discovery/autonat_service.nim @@ -26,7 +26,7 @@ proc getAutonatService*(rng: ref HmacDrbgContext): AutonatService = proc statusAndConfidenceHandler( networkReachability: NetworkReachability, confidence: Opt[float] - ): Future[void] {.async.} = + ): Future[void] {.gcsafe, async: (raises: [CancelledError]).} = if confidence.isSome(): info "Peer reachability status", networkReachability = networkReachability, confidence = confidence.get() diff --git a/waku/factory/conf_builder/rln_relay_conf_builder.nim b/waku/factory/conf_builder/rln_relay_conf_builder.nim index ea87eb278..455f0a57f 100644 --- a/waku/factory/conf_builder/rln_relay_conf_builder.nim +++ b/waku/factory/conf_builder/rln_relay_conf_builder.nim @@ -1,4 +1,4 @@ -import chronicles, std/options, results +import chronicles, std/options, results, stint, stew/endians2 import ../waku_conf logScope: @@ -9,7 +9,7 @@ logScope: ############################## type RlnRelayConfBuilder* = object enabled*: Option[bool] - chainId*: Option[uint] + chainId*: Option[UInt256] ethClientUrls*: Option[seq[string]] ethContractAddress*: Option[string] credIndex*: Option[uint] @@ -26,8 +26,11 @@ proc init*(T: type RlnRelayConfBuilder): RlnRelayConfBuilder = proc withEnabled*(b: var RlnRelayConfBuilder, enabled: bool) = b.enabled = some(enabled) -proc withChainId*(b: var RlnRelayConfBuilder, chainId: uint) = - b.chainId = some(chainId) +proc withChainId*(b: var RlnRelayConfBuilder, chainId: uint | UInt256) = + when chainId is uint: + b.chainId = some(UInt256.fromBytesBE(chainId.toBytesBE())) + else: + b.chainId = some(chainId) proc withCredIndex*(b: var RlnRelayConfBuilder, credIndex: uint) = b.credIndex = some(credIndex) diff --git a/waku/factory/conf_builder/waku_conf_builder.nim b/waku/factory/conf_builder/waku_conf_builder.nim index 44cb706af..ab53a965f 100644 --- a/waku/factory/conf_builder/waku_conf_builder.nim +++ b/waku/factory/conf_builder/waku_conf_builder.nim @@ -2,6 +2,7 @@ import libp2p/crypto/crypto, libp2p/multiaddress, std/[net, options, sequtils, strutils], + stint, chronicles, chronos, results @@ -292,7 +293,7 @@ proc nodeKey( proc applyClusterConf(builder: var WakuConfBuilder) = # Apply cluster conf, overrides most values passed individually # If you want to tweak values, don't use clusterConf - if builder.clusterConf.isNone: + if builder.clusterConf.isNone(): return let clusterConf = builder.clusterConf.get() @@ -417,7 +418,7 @@ proc build*( warn("Cluster Id was not specified, defaulting to 0") 0.uint16 else: - builder.clusterId.get() + builder.clusterId.get().uint16 let numShardsInNetwork = if builder.numShardsInNetwork.isSome(): diff --git a/waku/factory/external_config.nim b/waku/factory/external_config.nim index 800b61e63..2b156fc8e 100644 --- a/waku/factory/external_config.nim +++ b/waku/factory/external_config.nim @@ -4,6 +4,8 @@ import chronicles, chronos, regex, + stew/endians2, + stint, confutils, confutils/defs, confutils/std/net, @@ -867,7 +869,7 @@ proc defaultWakuNodeConf*(): ConfResult[WakuNodeConf] = proc toKeystoreGeneratorConf*(n: WakuNodeConf): RlnKeystoreGeneratorConf = RlnKeystoreGeneratorConf( execute: n.execute, - chainId: n.rlnRelayChainId, + chainId: UInt256.fromBytesBE(n.rlnRelayChainId.toBytesBE()), ethClientUrls: n.ethClientUrls.mapIt(string(it)), ethContractAddress: n.rlnRelayEthContractAddress, userMessageLimit: n.rlnRelayUserMessageLimit, diff --git a/waku/factory/networks_config.nim b/waku/factory/networks_config.nim index aceada3fe..8b5f4a628 100644 --- a/waku/factory/networks_config.nim +++ b/waku/factory/networks_config.nim @@ -1,5 +1,7 @@ {.push raises: [].} +import stint + # TODO: Rename this type to match file name type ClusterConf* = object @@ -7,7 +9,7 @@ type ClusterConf* = object clusterId*: uint16 rlnRelay*: bool rlnRelayEthContractAddress*: string - rlnRelayChainId*: uint + rlnRelayChainId*: UInt256 rlnRelayDynamic*: bool rlnEpochSizeSec*: uint64 rlnRelayUserMessageLimit*: uint64 @@ -20,13 +22,14 @@ type ClusterConf* = object # Cluster configuration corresponding to The Waku Network. Note that it # overrides existing cli configuration proc TheWakuNetworkConf*(T: type ClusterConf): ClusterConf = + const RelayChainId = 11155111'u256 return ClusterConf( maxMessageSize: "150KiB", clusterId: 1, rlnRelay: true, rlnRelayEthContractAddress: "0xfe7a9eabcE779a090FD702346Fd0bFAc02ce6Ac8", rlnRelayDynamic: true, - rlnRelayChainId: 11155111, + rlnRelayChainId: RelayChainId, rlnEpochSizeSec: 600, rlnRelayUserMessageLimit: 100, numShardsInNetwork: 8, diff --git a/waku/node/peer_manager/peer_manager.nim b/waku/node/peer_manager/peer_manager.nim index 75c72449a..40a13b601 100644 --- a/waku/node/peer_manager/peer_manager.nim +++ b/waku/node/peer_manager/peer_manager.nim @@ -1103,8 +1103,13 @@ proc new*( online: true, ) - proc peerHook(peerId: PeerId, event: PeerEvent): Future[void] {.gcsafe.} = - onPeerEvent(pm, peerId, event) + proc peerHook( + peerId: PeerId, event: PeerEvent + ): Future[void] {.gcsafe, async: (raises: [CancelledError]).} = + try: + await onPeerEvent(pm, peerId, event) + except CatchableError: + error "exception in onPeerEvent", error = getCurrentExceptionMsg() var peerStore = pm.switch.peerStore diff --git a/waku/node/waku_node.nim b/waku/node/waku_node.nim index e38b1e795..152c7125d 100644 --- a/waku/node/waku_node.nim +++ b/waku/node/waku_node.nim @@ -1475,7 +1475,7 @@ proc start*(node: WakuNode) {.async.} = ## with announced addrs after start let addressMapper = proc( listenAddrs: seq[MultiAddress] - ): Future[seq[MultiAddress]] {.async.} = + ): Future[seq[MultiAddress]] {.gcsafe, async: (raises: [CancelledError]).} = return node.announcedAddresses node.switch.peerInfo.addressMappers.add(addressMapper) diff --git a/waku/node/waku_switch.nim b/waku/node/waku_switch.nim index 48d3612e3..cc99f46ae 100644 --- a/waku/node/waku_switch.nim +++ b/waku/node/waku_switch.nim @@ -20,7 +20,7 @@ const MaxConnectionsPerPeer* = 1 proc withWsTransport*(b: SwitchBuilder): SwitchBuilder = b.withTransport( - proc(upgr: Upgrade): Transport = + proc(upgr: Upgrade, privateKey: crypto.PrivateKey): Transport = WsTransport.new(upgr) ) @@ -48,7 +48,7 @@ proc withWssTransport*( let key: TLSPrivateKey = getSecureKey(secureKeyPath) let cert: TLSCertificate = getSecureCert(secureCertPath) b.withTransport( - proc(upgr: Upgrade): Transport = + proc(upgr: Upgrade, privateKey: crypto.PrivateKey): Transport = WsTransport.new( upgr, tlsPrivateKey = key, diff --git a/waku/waku_filter_v2/client.nim b/waku/waku_filter_v2/client.nim index 2007371c7..2ad275a94 100644 --- a/waku/waku_filter_v2/client.nim +++ b/waku/waku_filter_v2/client.nim @@ -174,7 +174,7 @@ proc registerPushHandler*(wfc: WakuFilterClient, handler: FilterPushHandler) = wfc.pushHandlers.add(handler) proc initProtocolHandler(wfc: WakuFilterClient) = - proc handler(conn: Connection, proto: string) {.async.} = + proc handler(conn: Connection, proto: string) {.async: (raises: [CancelledError]).} = ## Notice that the client component is acting as a server of WakuFilterPushCodec messages while not conn.atEof(): var buf: seq[byte] diff --git a/waku/waku_filter_v2/protocol.nim b/waku/waku_filter_v2/protocol.nim index c3a4683f7..80f60fdd3 100644 --- a/waku/waku_filter_v2/protocol.nim +++ b/waku/waku_filter_v2/protocol.nim @@ -287,14 +287,20 @@ proc handleMessage*( waku_filter_handle_message_duration_seconds.observe(handleMessageDurationSec) proc initProtocolHandler(wf: WakuFilter) = - proc handler(conn: Connection, proto: string) {.async.} = + proc handler(conn: Connection, proto: string) {.async: (raises: [CancelledError]).} = debug "filter subscribe request handler triggered", peerId = shortLog(conn.peerId), conn var response: FilterSubscribeResponse wf.peerRequestRateLimiter.checkUsageLimit(WakuFilterSubscribeCodec, conn): - let buf = await conn.readLp(int(DefaultMaxSubscribeSize)) + var buf: seq[byte] + try: + buf = await conn.readLp(int(DefaultMaxSubscribeSize)) + except LPStreamError: + error "failed to read stream in readLp", + remote_peer_id = conn.peerId, error = getCurrentExceptionMsg() + return waku_service_network_bytes.inc( amount = buf.len().int64, labelValues = [WakuFilterSubscribeCodec, "in"] @@ -302,14 +308,19 @@ proc initProtocolHandler(wf: WakuFilter) = let decodeRes = FilterSubscribeRequest.decode(buf) if decodeRes.isErr(): - error "Failed to decode filter subscribe request", + error "failed to decode filter subscribe request", peer_id = conn.peerId, err = decodeRes.error waku_filter_errors.inc(labelValues = [decodeRpcFailure]) return let request = decodeRes.value #TODO: toAPI() split here - response = await wf.handleSubscribeRequest(conn.peerId, request) + try: + response = await wf.handleSubscribeRequest(conn.peerId, request) + except CatchableError: + error "handleSubscribeRequest failed", + remote_peer_id = conn.peerId, err = getCurrentExceptionMsg() + return debug "sending filter subscribe response", peer_id = shortLog(conn.peerId), response = response @@ -322,7 +333,11 @@ proc initProtocolHandler(wf: WakuFilter) = statusDesc: some("filter request rejected due rate limit exceeded"), ) - await conn.writeLp(response.encode().buffer) #TODO: toRPC() separation here + try: + await conn.writeLp(response.encode().buffer) #TODO: toRPC() separation here + except LPStreamError: + error "failed to write stream in writeLp", + remote_peer_id = conn.peerId, error = getCurrentExceptionMsg() return wf.handler = handler @@ -355,8 +370,16 @@ proc new*( peerRequestRateLimiter: PerPeerRateLimiter(setting: rateLimitSetting), ) - proc peerEventHandler(peerId: PeerId, event: PeerEvent): Future[void] {.gcsafe.} = - wf.onPeerEventHandler(peerId, event) + proc peerEventHandler( + peerId: PeerId, event: PeerEvent + ): Future[void] {.gcsafe, async: (raises: [CancelledError]).} = + try: + await wf.onPeerEventHandler(peerId, event) + except CatchableError: + error "onPeerEventHandler failed", + remote_peer_id = shortLog(peerId), + event = event, + error = getCurrentExceptionMsg() peerManager.addExtPeerEventHandler(peerEventHandler, PeerEventKind.Left) diff --git a/waku/waku_lightpush/protocol.nim b/waku/waku_lightpush/protocol.nim index 57a95e107..1165cbb52 100644 --- a/waku/waku_lightpush/protocol.nim +++ b/waku/waku_lightpush/protocol.nim @@ -114,16 +114,24 @@ proc handleRequest*( return pushResponse proc initProtocolHandler(wl: WakuLightPush) = - proc handle(conn: Connection, proto: string) {.async.} = + proc handler(conn: Connection, proto: string) {.async: (raises: [CancelledError]).} = var rpc: LightpushResponse wl.requestRateLimiter.checkUsageLimit(WakuLightPushCodec, conn): - let buffer = await conn.readLp(DefaultMaxRpcSize) + var buffer: seq[byte] + try: + buffer = await conn.readLp(DefaultMaxRpcSize) + except LPStreamError: + error "lightpush read stream failed", error = getCurrentExceptionMsg() + return waku_service_network_bytes.inc( amount = buffer.len().int64, labelValues = [WakuLightPushCodec, "in"] ) - rpc = await handleRequest(wl, conn.peerId, buffer) + try: + rpc = await handleRequest(wl, conn.peerId, buffer) + except CatchableError: + error "lightpush failed handleRequest", error = getCurrentExceptionMsg() do: debug "lightpush request rejected due rate limit exceeded", peerId = conn.peerId, limit = $wl.requestRateLimiter.setting @@ -139,12 +147,15 @@ proc initProtocolHandler(wl: WakuLightPush) = ) ) - await conn.writeLp(rpc.encode().buffer) + try: + await conn.writeLp(rpc.encode().buffer) + except LPStreamError: + error "lightpush write stream failed", error = getCurrentExceptionMsg() ## For lightpush might not worth to measure outgoing trafic as it is only ## small respones about success/failure - wl.handler = handle + wl.handler = handler wl.codec = WakuLightPushCodec proc new*( diff --git a/waku/waku_lightpush_legacy/protocol.nim b/waku/waku_lightpush_legacy/protocol.nim index 5de25ead9..feb6e17dc 100644 --- a/waku/waku_lightpush_legacy/protocol.nim +++ b/waku/waku_lightpush_legacy/protocol.nim @@ -64,16 +64,24 @@ proc handleRequest*( return rpc proc initProtocolHandler(wl: WakuLegacyLightPush) = - proc handle(conn: Connection, proto: string) {.async.} = + proc handler(conn: Connection, proto: string) {.async: (raises: [CancelledError]).} = var rpc: PushRPC wl.requestRateLimiter.checkUsageLimit(WakuLegacyLightPushCodec, conn): - let buffer = await conn.readLp(DefaultMaxRpcSize) + var buffer: seq[byte] + try: + buffer = await conn.readLp(DefaultMaxRpcSize) + except LPStreamError: + error "lightpush legacy read stream failed", error = getCurrentExceptionMsg() + return waku_service_network_bytes.inc( amount = buffer.len().int64, labelValues = [WakuLegacyLightPushCodec, "in"] ) - rpc = await handleRequest(wl, conn.peerId, buffer) + try: + rpc = await handleRequest(wl, conn.peerId, buffer) + except CatchableError: + error "lightpush legacy handleRequest failed", error = getCurrentExceptionMsg() do: debug "lightpush request rejected due rate limit exceeded", peerId = conn.peerId, limit = $wl.requestRateLimiter.setting @@ -89,12 +97,15 @@ proc initProtocolHandler(wl: WakuLegacyLightPush) = ) ) - await conn.writeLp(rpc.encode().buffer) + try: + await conn.writeLp(rpc.encode().buffer) + except LPStreamError: + error "lightpush legacy write stream failed", error = getCurrentExceptionMsg() ## For lightpush might not worth to measure outgoing trafic as it is only ## small respones about success/failure - wl.handler = handle + wl.handler = handler wl.codec = WakuLegacyLightPushCodec proc new*( diff --git a/waku/waku_metadata/protocol.nim b/waku/waku_metadata/protocol.nim index 8e4640ce7..13a2916b3 100644 --- a/waku/waku_metadata/protocol.nim +++ b/waku/waku_metadata/protocol.nim @@ -70,7 +70,11 @@ proc request*( return ok(response) proc initProtocolHandler(m: WakuMetadata) = - proc handle(conn: Connection, proto: string) {.async, gcsafe, closure.} = + proc handler(conn: Connection, proto: string) {.async: (raises: [CancelledError]).} = + defer: + # close, no data is expected + await conn.closeWithEof() + let res = catch: await conn.readLp(RpcResponseMaxBytes) let buffer = res.valueOr: @@ -88,12 +92,13 @@ proc initProtocolHandler(m: WakuMetadata) = localShards = m.shards, peer = conn.peerId - discard await m.respond(conn) + try: + discard await m.respond(conn) + except CatchableError: + error "Failed to respond to WakuMetadata request", + error = getCurrentExceptionMsg() - # close, no data is expected - await conn.closeWithEof() - - m.handler = handle + m.handler = handler m.codec = WakuMetadataCodec proc new*( diff --git a/waku/waku_peer_exchange/protocol.nim b/waku/waku_peer_exchange/protocol.nim index 2732cb1c1..14de77c67 100644 --- a/waku/waku_peer_exchange/protocol.nim +++ b/waku/waku_peer_exchange/protocol.nim @@ -243,7 +243,7 @@ proc updatePxEnrCache(wpx: WakuPeerExchange) {.async.} = wpx.populateEnrCache() proc initProtocolHandler(wpx: WakuPeerExchange) = - proc handler(conn: Connection, proto: string) {.async, gcsafe, closure.} = + proc handler(conn: Connection, proto: string) {.async: (raises: [CancelledError]).} = var buffer: seq[byte] wpx.requestRateLimiter.checkUsageLimit(WakuPeerExchangeCodec, conn): try: @@ -253,9 +253,13 @@ proc initProtocolHandler(wpx: WakuPeerExchange) = waku_px_errors.inc(labelValues = [exc.msg]) ( - await wpx.respondError( - PeerExchangeResponseStatusCode.BAD_REQUEST, some(exc.msg), conn - ) + try: + await wpx.respondError( + PeerExchangeResponseStatusCode.BAD_REQUEST, some(exc.msg), conn + ) + except CatchableError: + error "could not send error response", error = getCurrentExceptionMsg() + return ).isOkOr: error "Failed to respond with BAD_REQUEST:", error = $error return @@ -266,26 +270,41 @@ proc initProtocolHandler(wpx: WakuPeerExchange) = error "Failed to decode PeerExchange request", error = $decBuf.error ( - await wpx.respondError( - PeerExchangeResponseStatusCode.BAD_REQUEST, some($decBuf.error), conn - ) + try: + await wpx.respondError( + PeerExchangeResponseStatusCode.BAD_REQUEST, some($decBuf.error), conn + ) + except CatchableError: + error "could not send error response decode", + error = getCurrentExceptionMsg() + return ).isOkOr: error "Failed to respond with BAD_REQUEST:", error = $error return let enrs = wpx.getEnrsFromCache(decBuf.get().request.numPeers) debug "peer exchange request received", enrs = $enrs - (await wpx.respond(enrs, conn)).isErrOr: - waku_px_peers_sent.inc(enrs.len().int64()) + + try: + (await wpx.respond(enrs, conn)).isErrOr: + waku_px_peers_sent.inc(enrs.len().int64()) + except CatchableError: + error "could not send response", error = getCurrentExceptionMsg() do: - ( - await wpx.respondError( - PeerExchangeResponseStatusCode.TOO_MANY_REQUESTS, none(string), conn - ) - ).isOkOr: - error "Failed to respond with TOO_MANY_REQUESTS:", error = $error - # close, no data is expected - await conn.closeWithEof() + defer: + # close, no data is expected + await conn.closeWithEof() + + try: + ( + await wpx.respondError( + PeerExchangeResponseStatusCode.TOO_MANY_REQUESTS, none(string), conn + ) + ).isOkOr: + error "Failed to respond with TOO_MANY_REQUESTS:", error = $error + except CatchableError: + error "could not send error response", error = getCurrentExceptionMsg() + return wpx.handler = handler wpx.codec = WakuPeerExchangeCodec diff --git a/waku/waku_relay/protocol.nim b/waku/waku_relay/protocol.nim index daaf056b7..8da3f89b5 100644 --- a/waku/waku_relay/protocol.nim +++ b/waku/waku_relay/protocol.nim @@ -144,7 +144,7 @@ type PublishOutcome* {.pure.} = enum CannotGenerateMessageId proc initProtocolHandler(w: WakuRelay) = - proc handler(conn: Connection, proto: string) {.async.} = + proc handler(conn: Connection, proto: string) {.async: (raises: [CancelledError]).} = ## main protocol handler that gets triggered on every ## connection for a protocol string ## e.g. ``/wakusub/0.0.1``, etc... diff --git a/waku/waku_rendezvous/protocol.nim b/waku/waku_rendezvous/protocol.nim index 9f1aa69cb..a26eaca6f 100644 --- a/waku/waku_rendezvous/protocol.nim +++ b/waku/waku_rendezvous/protocol.nim @@ -123,7 +123,7 @@ proc batchRequest*( conn let reqCatch = catch: - await self.rendezvous.request(namespace, count, peers) + await self.rendezvous.request(Opt.some(namespace), count, peers) for conn in conns: await conn.close() diff --git a/waku/waku_rln_relay/group_manager/on_chain/group_manager.nim b/waku/waku_rln_relay/group_manager/on_chain/group_manager.nim index 600291ecf..54290a77a 100644 --- a/waku/waku_rln_relay/group_manager/on_chain/group_manager.nim +++ b/waku/waku_rln_relay/group_manager/on_chain/group_manager.nim @@ -57,7 +57,7 @@ type ethRpc*: Option[Web3] wakuRlnContract*: Option[WakuRlnContractWithSender] registrationTxHash*: Option[TxHash] - chainId*: uint + chainId*: UInt256 keystorePath*: Option[string] keystorePassword*: Option[string] registrationHandler*: Option[RegistrationHandler] @@ -239,8 +239,12 @@ method register*( # TODO: make this robust. search within the event list for the event debug "ts receipt", receipt = tsReceipt[] - if tsReceipt.status.isNone() or tsReceipt.status.get() != 1.Quantity: - raise newException(ValueError, "register: transaction failed") + if tsReceipt.status.isNone(): + raise newException(ValueError, "register: transaction failed status is None") + if tsReceipt.status.get() != 1.Quantity: + raise newException( + ValueError, "register: transaction failed status is: " & $tsReceipt.status.get() + ) let firstTopic = tsReceipt.logs[0].topics[0] # the hash of the signature of MemberRegistered(uint256,uint32) event is equal to the following hex value @@ -485,9 +489,9 @@ method init*(g: OnchainGroupManager): Future[GroupManagerResult[void]] {.async.} let ethRpc: Web3 = (await establishConnection(g)).valueOr: return err("failed to connect to Ethereum clients: " & $error) - var fetchedChainId: uint + var fetchedChainId: UInt256 g.retryWrapper(fetchedChainId, "Failed to get the chain id"): - uint(await ethRpc.provider.eth_chainId()) + await ethRpc.provider.eth_chainId() # Set the chain id if g.chainId == 0: @@ -555,7 +559,7 @@ method init*(g: OnchainGroupManager): Future[GroupManagerResult[void]] {.async.} warn "could not initialize with persisted rln metadata" elif metadataGetOptRes.get().isSome(): let metadata = metadataGetOptRes.get().get() - if metadata.chainId != uint(g.chainId): + if metadata.chainId != g.chainId: return err("persisted data: chain id mismatch") if metadata.contractAddress != g.ethContractAddress.toLower(): return err("persisted data: contract address mismatch") diff --git a/waku/waku_rln_relay/protocol_types.nim b/waku/waku_rln_relay/protocol_types.nim index c6f52e00b..867878886 100644 --- a/waku/waku_rln_relay/protocol_types.nim +++ b/waku/waku_rln_relay/protocol_types.nim @@ -131,6 +131,13 @@ proc encode*(nsp: RateLimitProof): ProtoBuffer = output.finish3() return output +func encode*(x: UInt32): seq[byte] = + ## the Ethereum ABI imposes a 32 byte width for every type + let numTargetBytes = 32 div 8 + let paddingBytes = 32 - numTargetBytes + let paddingZeros = newSeq[byte](paddingBytes) + paddingZeros & @(stint.toBytesBE(x)) + type SpamHandler* = proc(wakuMessage: WakuMessage): void {.gcsafe, closure, raises: [Defect].} diff --git a/waku/waku_rln_relay/rln/wrappers.nim b/waku/waku_rln_relay/rln/wrappers.nim index 24682dda6..2e10c7e37 100644 --- a/waku/waku_rln_relay/rln/wrappers.nim +++ b/waku/waku_rln_relay/rln/wrappers.nim @@ -4,6 +4,7 @@ import options, eth/keys, stew/[arrayops, byteutils, endians2], + stint, results, std/[sequtils, strutils, tables] @@ -410,7 +411,7 @@ proc getMerkleRoot*(rlnInstance: ptr RLN): MerkleNodeResult = type RlnMetadata* = object lastProcessedBlock*: uint64 - chainId*: uint64 + chainId*: UInt256 contractAddress*: string validRoots*: seq[MerkleNode] @@ -419,7 +420,7 @@ proc serialize(metadata: RlnMetadata): seq[byte] = ## returns the serialized metadata return concat( @(metadata.lastProcessedBlock.toBytes()), - @(metadata.chainId.toBytes()), + @(metadata.chainId.toBytes(Endianness.littleEndian)[0 .. 7]), @(hexToSeqByte(toLower(metadata.contractAddress))), @(uint64(metadata.validRoots.len()).toBytes()), @(serialize(metadata.validRoots)), @@ -427,7 +428,7 @@ proc serialize(metadata: RlnMetadata): seq[byte] = type MerkleNodeSeq = seq[MerkleNode] -proc deserialize*(T: type MerkleNodeSeq, merkleNodeByteSeq: seq[byte]): T = +proc deserialize(T: type MerkleNodeSeq, merkleNodeByteSeq: seq[byte]): T = ## deserializes a byte seq to a seq of MerkleNodes ## the order of serialization is |merkle_node_len<8>|merkle_node[len]| @@ -489,7 +490,7 @@ proc getMetadata*(rlnInstance: ptr RLN): RlnRelayResult[Option[RlnMetadata]] = var lastProcessedBlock: uint64 - chainId: uint64 + chainId: UInt256 contractAddress: string validRoots: MerkleNodeSeq @@ -500,7 +501,9 @@ proc getMetadata*(rlnInstance: ptr RLN): RlnRelayResult[Option[RlnMetadata]] = lastProcessedBlock = uint64.fromBytes(metadataBytes[lastProcessedBlockOffset .. chainIdOffset - 1]) - chainId = uint64.fromBytes(metadataBytes[chainIdOffset .. contractAddressOffset - 1]) + chainId = UInt256.fromBytes( + metadataBytes[chainIdOffset .. contractAddressOffset - 1], Endianness.littleEndian + ) contractAddress = byteutils.toHex(metadataBytes[contractAddressOffset .. validRootsOffset - 1]) let validRootsBytes = metadataBytes[validRootsOffset .. metadataBytes.high] diff --git a/waku/waku_rln_relay/rln_relay.nim b/waku/waku_rln_relay/rln_relay.nim index 48b3e8d79..965c8c021 100644 --- a/waku/waku_rln_relay/rln_relay.nim +++ b/waku/waku_rln_relay/rln_relay.nim @@ -44,7 +44,7 @@ type RlnRelayConf* = object of RootObj credIndex*: Option[uint] ethContractAddress*: string ethClientUrls*: seq[string] - chainId*: uint + chainId*: UInt256 creds*: Option[RlnRelayCreds] treePath*: string epochSizeSec*: uint64 diff --git a/waku/waku_store/protocol.nim b/waku/waku_store/protocol.nim index aa22fe5cd..5e13c9a77 100644 --- a/waku/waku_store/protocol.nim +++ b/waku/waku_store/protocol.nim @@ -88,7 +88,7 @@ proc initProtocolHandler(self: WakuStore) = statusDesc: $ErrorCode.TOO_MANY_REQUESTS, ).encode().buffer - proc handler(conn: Connection, proto: string) {.async, gcsafe, closure.} = + proc handler(conn: Connection, proto: string) {.async: (raises: [CancelledError]).} = var successfulQuery = false ## only consider the correct queries in metrics var resBuf: StoreResp var queryDuration: float @@ -106,7 +106,14 @@ proc initProtocolHandler(self: WakuStore) = let queryStartTime = getTime().toUnixFloat() - resBuf = await self.handleQueryRequest(conn.peerId, reqBuf) + try: + resBuf = await self.handleQueryRequest(conn.peerId, reqBuf) + except CatchableError: + error "store query failed in handler", + remote_peer_id = conn.peerId, + requestId = resBuf.requestId, + error = getCurrentExceptionMsg() + return queryDuration = getTime().toUnixFloat() - queryStartTime waku_store_time_seconds.set(queryDuration, ["query-db-time"]) diff --git a/waku/waku_store_legacy/protocol.nim b/waku/waku_store_legacy/protocol.nim index d72308e63..79d0f03a1 100644 --- a/waku/waku_store_legacy/protocol.nim +++ b/waku/waku_store_legacy/protocol.nim @@ -110,7 +110,7 @@ proc initProtocolHandler(ws: WakuStore) = ), ).encode().buffer - proc handler(conn: Connection, proto: string) {.async, closure.} = + proc handler(conn: Connection, proto: string) {.async: (raises: [CancelledError]).} = var successfulQuery = false ## only consider the correct queries in metrics var resBuf: StoreResp var queryDuration: float @@ -127,7 +127,13 @@ proc initProtocolHandler(ws: WakuStore) = ) let queryStartTime = getTime().toUnixFloat() - resBuf = await ws.handleLegacyQueryRequest(conn.peerId, reqBuf) + try: + resBuf = await ws.handleLegacyQueryRequest(conn.peerId, reqBuf) + except CatchableError: + error "legacy store query handler failed", + remote_peer_id = conn.peerId, error = getCurrentExceptionMsg() + return + queryDuration = getTime().toUnixFloat() - queryStartTime waku_legacy_store_time_seconds.set(queryDuration, ["query-db-time"]) successfulQuery = true diff --git a/waku/waku_store_sync/reconciliation.nim b/waku/waku_store_sync/reconciliation.nim index d9912a3df..cb5c1bc3d 100644 --- a/waku/waku_store_sync/reconciliation.nim +++ b/waku/waku_store_sync/reconciliation.nim @@ -322,11 +322,12 @@ proc new*( remoteNeedsTx: remoteNeedsTx, ) - let handler = proc(conn: Connection, proto: string) {.async, closure.} = - (await sync.processRequest(conn)).isOkOr: - error "request processing error", error = error - - return + proc handler(conn: Connection, proto: string) {.async: (raises: [CancelledError]).} = + try: + (await sync.processRequest(conn)).isOkOr: + error "request processing error", error = error + except CatchableError: + error "exception in reconciliation handler", error = getCurrentExceptionMsg() sync.handler = handler sync.codec = WakuReconciliationCodec diff --git a/waku/waku_store_sync/transfer.nim b/waku/waku_store_sync/transfer.nim index c1e5d3e37..78b83c601 100644 --- a/waku/waku_store_sync/transfer.nim +++ b/waku/waku_store_sync/transfer.nim @@ -130,7 +130,7 @@ proc needsReceiverLoop(self: SyncTransfer) {.async.} = return proc initProtocolHandler(self: SyncTransfer) = - let handler = proc(conn: Connection, proto: string) {.async, closure.} = + proc handler(conn: Connection, proto: string) {.async: (raises: [CancelledError]).} = while true: if not self.inSessions.contains(conn.peerId): error "unwanted peer, disconnecting", remote = conn.peerId @@ -156,10 +156,14 @@ proc initProtocolHandler(self: SyncTransfer) = let hash = computeMessageHash(pubsub, msg) - #TODO verify msg RLN proof... - - (await self.wakuArchive.syncMessageIngress(hash, pubsub, msg)).isOkOr: - error "failed to archive message", error = $error + try: + #TODO verify msg RLN proof... + (await self.wakuArchive.syncMessageIngress(hash, pubsub, msg)).isOkOr: + error "failed to archive message", error = $error + continue + except CatchableError: + error "syncMessageIngress failed", + remote_peer_id = conn.peerId, error = getCurrentExceptionMsg() continue let id = SyncID(time: msg.timestamp, hash: hash)