diff --git a/examples/v2/chat2.nim b/apps/chat2/chat2.nim similarity index 97% rename from examples/v2/chat2.nim rename to apps/chat2/chat2.nim index 57322478a..a261d14a0 100644 --- a/examples/v2/chat2.nim +++ b/apps/chat2/chat2.nim @@ -21,16 +21,17 @@ import libp2p/[switch, # manage transports, a single entry poi protocols/secure/secio, # define the protocol of secure input / output, allows encrypted communication that uses public keys to validate signed messages instead of a certificate authority like in TLS nameresolving/dnsresolver,# define DNS resolution muxers/muxer] # define an interface for stream multiplexing, allowing peers to offer many protocols over a single connection -import ../../waku/v2/protocol/waku_message, - ../../waku/v2/protocol/waku_lightpush, - ../../waku/v2/protocol/waku_filter, - ../../waku/v2/protocol/waku_store, - ../../waku/v2/node/[wakunode2, waku_payload], - ../../waku/v2/node/dnsdisc/waku_dnsdisc, - ../../waku/v2/node/peer_manager/peer_manager, - ../../waku/v2/utils/[peers, time], - ../../waku/common/utils/nat, - ./config_chat2 +import + ../../waku/v2/protocol/waku_message, + ../../waku/v2/protocol/waku_lightpush, + ../../waku/v2/protocol/waku_filter, + ../../waku/v2/protocol/waku_store, + ../../waku/v2/node/[wakunode2, waku_payload], + ../../waku/v2/node/dnsdisc/waku_dnsdisc, + ../../waku/v2/node/peer_manager/peer_manager, + ../../waku/v2/utils/[peers, time], + ../../waku/common/utils/nat, + ./config_chat2 when defined(rln) or defined(rlnzerokit): import diff --git a/examples/v2/config_chat2.nim b/apps/chat2/config_chat2.nim similarity index 99% rename from examples/v2/config_chat2.nim rename to apps/chat2/config_chat2.nim index 0db31a6d2..6a4d8648b 100644 --- a/examples/v2/config_chat2.nim +++ b/apps/chat2/config_chat2.nim @@ -5,8 +5,9 @@ import libp2p/crypto/crypto, libp2p/crypto/secp, nimcrypto/utils, - eth/keys, - ../../waku/v2/protocol/waku_message + eth/keys +import + ../../../waku/v2/protocol/waku_message type Fleet* = enum diff --git a/examples/v2/matterbridge/chat2bridge.nim b/apps/chat2bridge/chat2bridge.nim similarity index 99% rename from examples/v2/matterbridge/chat2bridge.nim rename to apps/chat2bridge/chat2bridge.nim index ca21756da..ee8bd6f4c 100644 --- a/examples/v2/matterbridge/chat2bridge.nim +++ b/apps/chat2bridge/chat2bridge.nim @@ -7,14 +7,14 @@ import stew/[byteutils, endians2], stew/shims/net as stewNet, json_rpc/rpcserver, # Matterbridge client imports - ../../../waku/common/utils/matterbridge_client, + ../../waku/common/utils/matterbridge_client, # Waku v2 imports libp2p/crypto/crypto, libp2p/errors, ../../../waku/v2/protocol/waku_message, ../../../waku/v2/node/wakunode2, # Chat 2 imports - ../chat2, + ../chat2/chat2, # Common cli config ./config_chat2bridge diff --git a/examples/v2/matterbridge/config_chat2bridge.nim b/apps/chat2bridge/config_chat2bridge.nim similarity index 100% rename from examples/v2/matterbridge/config_chat2bridge.nim rename to apps/chat2bridge/config_chat2bridge.nim diff --git a/waku/common/README.md b/apps/wakubridge/README.md similarity index 100% rename from waku/common/README.md rename to apps/wakubridge/README.md diff --git a/waku/common/config_bridge.nim b/apps/wakubridge/config_bridge.nim similarity index 100% rename from waku/common/config_bridge.nim rename to apps/wakubridge/config_bridge.nim diff --git a/waku/common/wakubridge.nim b/apps/wakubridge/wakubridge.nim similarity index 96% rename from waku/common/wakubridge.nim rename to apps/wakubridge/wakubridge.nim index b0a01349a..219a278e4 100644 --- a/waku/common/wakubridge.nim +++ b/apps/wakubridge/wakubridge.nim @@ -12,15 +12,15 @@ import eth/[keys, p2p], eth/common/utils, eth/p2p/[enode, peer_pool], eth/p2p/discoveryv5/random2, - ../v1/protocol/waku_protocol, + ../../waku/v1/protocol/waku_protocol, # Waku v2 imports libp2p/crypto/crypto, libp2p/nameresolving/nameresolver, - ../v2/utils/namespacing, - ../v2/utils/time, - ../v2/protocol/waku_message, - ../v2/node/wakunode2, - ../v2/node/peer_manager/peer_manager, + ../../waku/v2/utils/namespacing, + ../../waku/v2/utils/time, + ../../waku/v2/protocol/waku_message, + ../../waku/v2/node/wakunode2, + ../../waku/v2/node/peer_manager/peer_manager, # Common cli config ./config_bridge @@ -322,15 +322,15 @@ proc stop*(bridge: WakuBridge) {.async.} = when isMainModule: import libp2p/nameresolving/dnsresolver, - ./utils/nat, - ../whisper/whispernodes, - ../v1/node/rpc/wakusim, - ../v1/node/rpc/waku, - ../v1/node/rpc/key_storage, - ../v2/node/jsonrpc/[debug_api, - filter_api, - relay_api, - store_api] + ../../waku/common/utils/nat, + ../../waku/whisper/whispernodes, + ../../waku/v1/node/rpc/wakusim, + ../../waku/v1/node/rpc/waku, + ../../waku/v1/node/rpc/key_storage, + ../../waku/v2/node/jsonrpc/[debug_api, + filter_api, + relay_api, + store_api] proc startV2Rpc(node: WakuNode, rpcServer: RpcHttpServer, conf: WakuNodeConf) = installDebugApiHandlers(node, rpcServer) diff --git a/tests/v2/test_waku_bridge.nim b/tests/v2/test_waku_bridge.nim index 08637aab0..3ab282bbd 100644 --- a/tests/v2/test_waku_bridge.nim +++ b/tests/v2/test_waku_bridge.nim @@ -12,14 +12,13 @@ import libp2p/protocols/pubsub/rpc/messages, libp2p/protocols/pubsub/pubsub, eth/p2p, - eth/keys, - ../../waku/common/wakubridge, + eth/keys +import ../../waku/v1/protocol/waku_protocol, ../../waku/v2/protocol/waku_message, - ../../waku/v2/protocol/waku_store, - ../../waku/v2/protocol/waku_filter, ../../waku/v2/node/[wakunode2, waku_payload], ../../waku/v2/utils/peers, + ../../apps/wakubridge/wakubridge, ../test_helpers procSuite "WakuBridge": @@ -139,12 +138,12 @@ procSuite "WakuBridge": v2Node.subscribe(DefaultBridgeTopic, relayHandler) - await sleepAsync(2000.millis) + await sleepAsync(250.millis) # Test bridging from V2 to V1 await v2Node.publish(DefaultBridgeTopic, message) - await sleepAsync(2000.millis) + await sleepAsync(250.millis) check: # v1Node received message published by v2Node @@ -173,7 +172,7 @@ procSuite "WakuBridge": await v2Node.publish(DefaultBridgeTopic, message) - await sleepAsync(2000.millis) + await sleepAsync(250.millis) check: # v1Node did not receive duplicate of previous message @@ -211,7 +210,7 @@ procSuite "WakuBridge": # When waitFor v1Bridge.start() - await sleepAsync(2000.millis) # Give peers some time to connect + await sleepAsync(250.millis) # Give peers some time to connect # Then check: @@ -228,7 +227,7 @@ procSuite "WakuBridge": # When discard v1Bridge.maintenanceLoop() # Forces one more run of the maintenance loop - await sleepAsync(2000.millis) # Give peers some time to connect + await sleepAsync(250.millis) # Give peers some time to connect # Then check: diff --git a/waku/v2/node/scripts/rpc_info.nim b/tools/scripts/rpc_info.nim similarity index 70% rename from waku/v2/node/scripts/rpc_info.nim rename to tools/scripts/rpc_info.nim index 8de0ccae6..f8ff46760 100644 --- a/waku/v2/node/scripts/rpc_info.nim +++ b/tools/scripts/rpc_info.nim @@ -4,13 +4,14 @@ import libp2p/[peerinfo, multiaddress], eth/common as eth_common, eth/keys, system, - options, - ../wakunode2, - ../waku_payload, - ../jsonrpc/jsonrpc_types, - ../../protocol/waku_filter, - ../../protocol/waku_store, - ../../../v1/node/rpc/hexstrings + options +import + ../../waku/v2/node/wakunode2, + ../../waku/v2/node/waku_payload, + ../../waku/v2/node/jsonrpc/jsonrpc_types, + ../../waku/v2/protocol/waku_filter, + ../../waku/v2/protocol/waku_store, + ../../waku/v1/node/rpc/hexstrings from strutils import rsplit template sourceDir: string = currentSourcePath.rsplit(DirSep, 1)[0] diff --git a/waku/v2/node/scripts/rpc_publish.nim b/tools/scripts/rpc_publish.nim similarity index 81% rename from waku/v2/node/scripts/rpc_publish.nim rename to tools/scripts/rpc_publish.nim index a8e75eb2e..32390e1b8 100644 --- a/waku/v2/node/scripts/rpc_publish.nim +++ b/tools/scripts/rpc_publish.nim @@ -4,13 +4,14 @@ import libp2p/protobuf/minprotobuf, eth/common as eth_common, eth/keys, system, - options, - ../wakunode2, - ../waku_payload, - ../jsonrpc/jsonrpc_types, - ../../protocol/waku_filter, - ../../protocol/waku_store, - ../../../v1/node/rpc/hexstrings + options +import + ../../waku/v2/node/wakunode2, + ../../waku/v2/node/waku_payload, + ../../waku/v2/node/jsonrpc/jsonrpc_types, + ../../waku/v2/protocol/waku_filter, + ../../waku/v2/protocol/waku_store, + ../../waku/v1/node/rpc/hexstrings from strutils import rsplit template sourceDir: string = currentSourcePath.rsplit(DirSep, 1)[0] diff --git a/waku/v2/node/scripts/rpc_query.nim b/tools/scripts/rpc_query.nim similarity index 81% rename from waku/v2/node/scripts/rpc_query.nim rename to tools/scripts/rpc_query.nim index dc62a31d6..106f57b2b 100644 --- a/waku/v2/node/scripts/rpc_query.nim +++ b/tools/scripts/rpc_query.nim @@ -4,13 +4,15 @@ import libp2p/[peerinfo, multiaddress], eth/common as eth_common, eth/keys, system, - options, - ../wakunode2, - ../waku_payload, - ../jsonrpc/jsonrpc_types, - ../../protocol/waku_filter, - ../../protocol/waku_store, - ../../../v1/node/rpc/hexstrings + options +import + ../../waku/v2/node/wakunode2, + ../../waku/v2/node/waku_payload, + ../../waku/v2/node/jsonrpc/jsonrpc_types, + ../../waku/v2/protocol/waku_filter, + ../../waku/v2/protocol/waku_store, + ../../waku/v1/node/rpc/hexstrings + from strutils import rsplit template sourceDir: string = currentSourcePath.rsplit(DirSep, 1)[0] diff --git a/waku/v2/node/scripts/rpc_subscribe.nim b/tools/scripts/rpc_subscribe.nim similarity index 74% rename from waku/v2/node/scripts/rpc_subscribe.nim rename to tools/scripts/rpc_subscribe.nim index 50b6b4788..93abc0ff2 100644 --- a/waku/v2/node/scripts/rpc_subscribe.nim +++ b/tools/scripts/rpc_subscribe.nim @@ -3,13 +3,16 @@ import libp2p/protobuf/minprotobuf, eth/common as eth_common, eth/keys, system, - options, - ../wakunode2, - ../waku_payload, - ../jsonrpc/jsonrpc_types, - ../../protocol/waku_filter, - ../../protocol/waku_store, - ../../../v1/node/rpc/hexstrings + options +import + ../../waku/v2/node/wakunode2, + ../../waku/v2/node/waku_payload, + ../../waku/v2/node/jsonrpc/jsonrpc_types, + ../../waku/v2/protocol/waku_filter, + ../../waku/v2/protocol/waku_store, + ../../waku/v1/node/rpc/hexstrings + + from strutils import rsplit template sourceDir: string = currentSourcePath.rsplit(DirSep, 1)[0] diff --git a/waku/v2/node/scripts/rpc_subscribe_filter.nim b/tools/scripts/rpc_subscribe_filter.nim similarity index 80% rename from waku/v2/node/scripts/rpc_subscribe_filter.nim rename to tools/scripts/rpc_subscribe_filter.nim index c3ed55cad..90c1b4360 100644 --- a/waku/v2/node/scripts/rpc_subscribe_filter.nim +++ b/tools/scripts/rpc_subscribe_filter.nim @@ -4,13 +4,14 @@ import libp2p/[peerinfo, multiaddress], eth/common as eth_common, eth/keys, system, - options, - ../wakunode2, - ../waku_payload, - ../jsonrpc/jsonrpc_types, - ../../protocol/waku_filter, - ../../protocol/waku_store, - ../../../v1/node/rpc/hexstrings + options +import + ../../waku/v2/node/wakunode2, + ../../waku/v2/node/waku_payload, + ../../waku/v2/node/jsonrpc/jsonrpc_types, + ../../waku/v2/protocol/waku_filter, + ../../waku/v2/protocol/waku_store, + ../../waku/v1/node/rpc/hexstrings from strutils import rsplit template sourceDir: string = currentSourcePath.rsplit(DirSep, 1)[0] diff --git a/waku/v2/node/quicksim2.nim b/tools/simulation/quicksim2.nim similarity index 93% rename from waku/v2/node/quicksim2.nim rename to tools/simulation/quicksim2.nim index ab103bcd1..1159e4ae5 100644 --- a/waku/v2/node/quicksim2.nim +++ b/tools/simulation/quicksim2.nim @@ -6,19 +6,19 @@ import json_rpc/[rpcclient, rpcserver], libp2p/protobuf/minprotobuf import - ../protocol/waku_filter, - ../protocol/waku_store, - ../protocol/waku_message, - ../utils/time, - ./wakunode2, - ./waku_payload, - ./jsonrpc/[jsonrpc_types,jsonrpc_utils] + ../../waku/v2/protocol/waku_filter, + ../../waku/v2/protocol/waku_store, + ../../waku/v2/protocol/waku_message, + ../../waku/v2/utils/time, + ../../waku/v2/node/wakunode2, + ../../waku/v2/node/waku_payload, + ../../waku/v2/node/jsonrpc/[jsonrpc_types,jsonrpc_utils] from strutils import rsplit template sourceDir: string = currentSourcePath.rsplit(DirSep, 1)[0] -const sigWakuPath = sourceDir / "jsonrpc" / "jsonrpc_callsigs.nim" +const sigWakuPath = sourceDir / ".." / ".." / "waku" / "v2" / "node" / "jsonrpc" / "jsonrpc_callsigs.nim" createRpcSigs(RpcHttpClient, sigWakuPath) const defaultTopic = "/waku/2/default-waku/proto" diff --git a/waku/v2/node/start_network2.nim b/tools/simulation/start_network2.nim similarity index 100% rename from waku/v2/node/start_network2.nim rename to tools/simulation/start_network2.nim diff --git a/waku.nimble b/waku.nimble index bfc8379e6..aa9b260be 100644 --- a/waku.nimble +++ b/waku.nimble @@ -64,42 +64,46 @@ task test1, "Build & run Waku v1 tests": ### Waku v2 tasks task wakunode2, "Build Waku v2 (experimental) cli node": - buildBinary "wakunode2", "waku/v2/node/", "-d:chronicles_log_level=DEBUG" + let name = "wakunode2" + buildBinary name, "waku/v2/node/", "-d:chronicles_log_level=DEBUG" + +task bridge, "Build Waku v1 - v2 bridge": + let name = "wakubridge" + buildBinary name, "apps/wakubridge/", "-d:chronicles_log_level=DEBUG" + +task test2, "Build & run Waku v2 tests": + test "all_tests_v2" + task sim2, "Build Waku v2 simulation tools": - buildBinary "quicksim2", "waku/v2/node/", "-d:chronicles_log_level=DEBUG" - buildBinary "start_network2", "waku/v2/node/", "-d:chronicles_log_level=TRACE" + buildBinary "quicksim2", "tools/simulation/", "-d:chronicles_log_level=DEBUG" + buildBinary "start_network2", "tools/simulation/", "-d:chronicles_log_level=TRACE" task example2, "Build Waku v2 example": let name = "basic2" buildBinary name, "examples/v2/", "-d:chronicles_log_level=DEBUG" -task test2, "Build & run Waku v2 tests": - test "all_tests_v2" - task scripts2, "Build Waku v2 scripts": - buildBinary "rpc_publish", "waku/v2/node/scripts/", "-d:chronicles_log_level=DEBUG" - buildBinary "rpc_subscribe", "waku/v2/node/scripts/", "-d:chronicles_log_level=DEBUG" - buildBinary "rpc_subscribe_filter", "waku/v2/node/scripts/", "-d:chronicles_log_level=DEBUG" - buildBinary "rpc_query", "waku/v2/node/scripts/", "-d:chronicles_log_level=DEBUG" - buildBinary "rpc_info", "waku/v2/node/scripts/", "-d:chronicles_log_level=DEBUG" + buildBinary "rpc_publish", "tools/scripts/", "-d:chronicles_log_level=DEBUG" + buildBinary "rpc_subscribe", "tools/scripts/", "-d:chronicles_log_level=DEBUG" + buildBinary "rpc_subscribe_filter", "tools/scripts/", "-d:chronicles_log_level=DEBUG" + buildBinary "rpc_query", "tools/scripts/", "-d:chronicles_log_level=DEBUG" + buildBinary "rpc_info", "tools/scripts/", "-d:chronicles_log_level=DEBUG" task chat2, "Build example Waku v2 chat usage": - let name = "chat2" # NOTE For debugging, set debug level. For chat usage we want minimal log # output to STDOUT. Can be fixed by redirecting logs to file (e.g.) #buildBinary name, "examples/v2/", "-d:chronicles_log_level=WARN" - buildBinary name, "examples/v2/", "-d:chronicles_log_level=DEBUG -d:chronicles_sinks=textlines[file] -d:ssl" -task bridge, "Build Waku v1 - v2 bridge": - buildBinary "wakubridge", "waku/common/", "-d:chronicles_log_level=DEBUG" + let name = "chat2" + buildBinary name, "apps/chat2/", "-d:chronicles_log_level=DEBUG -d:chronicles_sinks=textlines[file] -d:ssl" -task chat2bridge, "Build chat2-matterbridge": +task chat2bridge, "Build chat2bridge": let name = "chat2bridge" + buildBinary name, "apps/chat2bridge/", "-d:chronicles_log_level=DEBUG" - buildBinary name, "examples/v2/matterbridge/", "-d:chronicles_log_level=DEBUG" ### Waku Tooling task wakucanary, "Build waku-canary tool": let name = "wakucanary" - buildBinary name, "tools/wakucanary/", "-d:chronicles_log_level=DEBUG -d:chronicles_runtime_filtering:on" \ No newline at end of file + buildBinary name, "tools/wakucanary/", "-d:chronicles_log_level=DEBUG -d:chronicles_runtime_filtering:on" diff --git a/waku/v2/node/scripts/rpc_query b/waku/v2/node/scripts/rpc_query deleted file mode 100755 index 6efa97bff..000000000 Binary files a/waku/v2/node/scripts/rpc_query and /dev/null differ diff --git a/waku/v2/protocol/waku_rln_relay/waku_rln_relay_utils.nim b/waku/v2/protocol/waku_rln_relay/waku_rln_relay_utils.nim index 0204a23e4..8de2866e1 100644 --- a/waku/v2/protocol/waku_rln_relay/waku_rln_relay_utils.nim +++ b/waku/v2/protocol/waku_rln_relay/waku_rln_relay_utils.nim @@ -17,7 +17,7 @@ import waku_rln_relay_metrics, ../../utils/time, ../../node/[wakunode2_types,config], - ../../../../../examples/v2/config_chat2, + ../../../../../apps/chat2/config_chat2, ../waku_message logScope: