From 9fdb9291b12c178b7cff432fb79ad59f38efaa8a Mon Sep 17 00:00:00 2001 From: Ivan Folgueira Bande Date: Mon, 15 Apr 2024 09:14:29 +0200 Subject: [PATCH 1/6] Start moving discovery modules to waku/node/discovery_manager/ --- apps/networkmonitor/networkmonitor.nim | 10 ++--- apps/wakunode2/app.nim | 8 ++-- tests/node/test_wakunode_peer_exchange.nim | 2 +- tests/test_waku_dnsdisc.nim | 2 +- tests/testlib/wakunode.nim | 2 +- tests/waku_peer_exchange/test_protocol.nim | 2 +- tests/waku_peer_exchange/test_rpc_codec.nim | 13 +++---- tests/waku_peer_exchange/utils.nim | 2 +- waku/factory/builder.nim | 3 +- waku/factory/node_factory.nim | 2 +- .../discovery_manager/discovery_manager.nim | 37 +++++++++++++++++++ .../discovery_manager}/waku_discv5.nim | 2 +- .../discovery_manager}/waku_dnsdisc.nim | 2 +- waku/node/waku_node.nim | 7 ++-- waku/waku_api/handlers.nim | 3 +- waku/waku_peer_exchange/protocol.nim | 2 +- 16 files changed, 67 insertions(+), 32 deletions(-) create mode 100644 waku/node/discovery_manager/discovery_manager.nim rename waku/{ => node/discovery_manager}/waku_discv5.nim (99%) rename waku/{ => node/discovery_manager}/waku_dnsdisc.nim (99%) diff --git a/apps/networkmonitor/networkmonitor.nim b/apps/networkmonitor/networkmonitor.nim index 52c5736a0c..7670b94847 100644 --- a/apps/networkmonitor/networkmonitor.nim +++ b/apps/networkmonitor/networkmonitor.nim @@ -25,8 +25,8 @@ import ../../waku/node/peer_manager, ../../waku/waku_node, ../../waku/waku_enr, - ../../waku/waku_discv5, - ../../waku/waku_dnsdisc, + ../../waku/node/discovery_manager/waku_discv5, + ../../waku/node/discovery_manager/waku_dnsdisc, ../../waku/waku_relay, ../../waku/waku_rln_relay, ../../waku/factory/builder, @@ -131,12 +131,12 @@ proc setConnectedPeersMetrics( var analyzeFuts: seq[Future[Result[string, string]]] var (inConns, outConns) = node.peer_manager.connectedPeers(WakuRelayCodec) - info "connected peers", inConns=inConns.len, outConns=outConns.len + info "connected peers", inConns = inConns.len, outConns = outConns.len shuffle(outConns) - if outConns.len >= toInt(MaxConnectedPeers/2): - for p in outConns[0 ..< toInt(outConns.len/2)]: + if outConns.len >= toInt(MaxConnectedPeers / 2): + for p in outConns[0 ..< toInt(outConns.len / 2)]: trace "Pruning Peer", Peer = $p asyncSpawn(node.switch.disconnect(p)) diff --git a/apps/wakunode2/app.nim b/apps/wakunode2/app.nim index 5f16b5198c..90c79c279b 100644 --- a/apps/wakunode2/app.nim +++ b/apps/wakunode2/app.nim @@ -40,9 +40,9 @@ import ../../waku/waku_api/rest/health/handlers as rest_health_api, ../../waku/waku_api/rest/admin/handlers as rest_admin_api, ../../waku/waku_archive, - ../../waku/waku_dnsdisc, + ../../waku/node/discovery_manager/waku_dnsdisc, + ../../waku/node/discovery_manager/waku_discv5, ../../waku/waku_enr/sharding, - ../../waku/waku_discv5, ../../waku/waku_peer_exchange, ../../waku/waku_rln_relay, ../../waku/waku_store, @@ -366,9 +366,7 @@ proc startRestServer( "/relay endpoints are not available. Please check your configuration: --relay" ## Filter REST API - if conf.filternode != "" and - app.node.wakuFilterClient != nil: - + if conf.filternode != "" and app.node.wakuFilterClient != nil: let filterCache = MessageCache.init() let filterDiscoHandler = diff --git a/tests/node/test_wakunode_peer_exchange.nim b/tests/node/test_wakunode_peer_exchange.nim index f4dc516c4c..dd004cf990 100644 --- a/tests/node/test_wakunode_peer_exchange.nim +++ b/tests/node/test_wakunode_peer_exchange.nim @@ -15,7 +15,7 @@ import import ../../../waku/[ waku_node, - waku_discv5, + node/discovery_manager/waku_discv5, waku_peer_exchange, node/peer_manager, waku_relay/protocol, diff --git a/tests/test_waku_dnsdisc.nim b/tests/test_waku_dnsdisc.nim index ceec17e437..edeffa215a 100644 --- a/tests/test_waku_dnsdisc.nim +++ b/tests/test_waku_dnsdisc.nim @@ -13,7 +13,7 @@ import import ../../waku/node/peer_manager, ../../waku/waku_node, - ../../waku/waku_dnsdisc, + ../../waku/node/discovery_manager/waku_dnsdisc, ./testlib/common, ./testlib/wakucore, ./testlib/wakunode diff --git a/tests/testlib/wakunode.nim b/tests/testlib/wakunode.nim index 732256ee23..8900cc2500 100644 --- a/tests/testlib/wakunode.nim +++ b/tests/testlib/wakunode.nim @@ -12,7 +12,7 @@ import ../../../waku/waku_node, ../../../waku/node/peer_manager, ../../../waku/waku_enr, - ../../../waku/waku_discv5, + ../../../waku/node/discovery_manager/waku_discv5, ../../../waku/factory/external_config, ../../../waku/factory/internal_config, ../../../waku/factory/builder, diff --git a/tests/waku_peer_exchange/test_protocol.nim b/tests/waku_peer_exchange/test_protocol.nim index ab4725a29e..4337d309d5 100644 --- a/tests/waku_peer_exchange/test_protocol.nim +++ b/tests/waku_peer_exchange/test_protocol.nim @@ -13,7 +13,7 @@ import ../../../waku/[ waku_node, node/peer_manager, - waku_discv5, + node/discovery_manager/waku_discv5, waku_peer_exchange, waku_peer_exchange/rpc, waku_peer_exchange/rpc_codec, diff --git a/tests/waku_peer_exchange/test_rpc_codec.nim b/tests/waku_peer_exchange/test_rpc_codec.nim index 2b44a12f6f..1ef3386a9f 100644 --- a/tests/waku_peer_exchange/test_rpc_codec.nim +++ b/tests/waku_peer_exchange/test_rpc_codec.nim @@ -12,13 +12,12 @@ import eth/p2p/discoveryv5/enr import - ../../../waku/ - [ - node/peer_manager, - waku_discv5, - waku_peer_exchange/rpc, - waku_peer_exchange/rpc_codec, - ], + ../../../waku/[ + node/peer_manager, + node/discovery_manager/waku_discv5, + waku_peer_exchange/rpc, + waku_peer_exchange/rpc_codec, + ], ../testlib/[wakucore] suite "Peer Exchange RPC": diff --git a/tests/waku_peer_exchange/utils.nim b/tests/waku_peer_exchange/utils.nim index 3e82e1d933..23c0a6f94e 100644 --- a/tests/waku_peer_exchange/utils.nim +++ b/tests/waku_peer_exchange/utils.nim @@ -13,7 +13,7 @@ import import ../../../waku/[ waku_node, - waku_discv5, + node/discovery_manager/waku_discv5, waku_peer_exchange, waku_peer_exchange/rpc, waku_peer_exchange/protocol, diff --git a/waku/factory/builder.nim b/waku/factory/builder.nim index d07f7277ef..943996f6eb 100644 --- a/waku/factory/builder.nim +++ b/waku/factory/builder.nim @@ -12,7 +12,8 @@ import libp2p/builders, libp2p/nameresolving/nameresolver, libp2p/transports/wstransport -import ../waku_enr, ../waku_discv5, ../waku_node, ../node/peer_manager +import + ../waku_enr, ../node/discovery_manager/waku_discv5, ../waku_node, ../node/peer_manager type WakuNodeBuilder* = object # General diff --git a/waku/factory/node_factory.nim b/waku/factory/node_factory.nim index 68d2fa7732..c952423567 100644 --- a/waku/factory/node_factory.nim +++ b/waku/factory/node_factory.nim @@ -16,7 +16,7 @@ import ../waku_node, ../waku_core, ../waku_rln_relay, - ../waku_dnsdisc, + ../node/discovery_manager/waku_dnsdisc, ../waku_archive, ../waku_store, ../waku_filter_v2, diff --git a/waku/node/discovery_manager/discovery_manager.nim b/waku/node/discovery_manager/discovery_manager.nim new file mode 100644 index 0000000000..2e749d3c49 --- /dev/null +++ b/waku/node/discovery_manager/discovery_manager.nim @@ -0,0 +1,37 @@ +when (NimMajor, NimMinor) < (1, 4): + {.push raises: [Defect].} +else: + {.push raises: [].} + +import waku_discv5, ../../waku_core + +## This module contains the logic needed to discover other peers and +## also to make the "self" node discoverable by other peers. + +type DiscoveryManager* = object + wakuDiscv5*: Option[WakuDiscoveryV5] + dynamicBootstrapNodes*: seq[RemotePeerInfo] + +#[ + TODO: in future PRs we will have: + + WakuNode* = ref object + peerManager*: PeerManager + discManager*: DiscoveryManager <-- we will add this + ... + + App* = object + version: string + conf: WakuNodeConf + rng: ref HmacDrbgContext + key: crypto.PrivateKey + + wakuDiscv5: Option[WakuDiscoveryV5] <-- this will get removed + dynamicBootstrapNodes: seq[RemotePeerInfo] <-- this will get removed + + node: WakuNode <-- this will contain a discManager instance + + restServer: Option[WakuRestServerRef] + metricsServer: Option[MetricsHttpServerRef] + + ]# diff --git a/waku/waku_discv5.nim b/waku/node/discovery_manager/waku_discv5.nim similarity index 99% rename from waku/waku_discv5.nim rename to waku/node/discovery_manager/waku_discv5.nim index 319ce824b7..11e9874b5c 100644 --- a/waku/waku_discv5.nim +++ b/waku/node/discovery_manager/waku_discv5.nim @@ -14,7 +14,7 @@ import eth/keys as eth_keys, eth/p2p/discoveryv5/node, eth/p2p/discoveryv5/protocol -import ./node/peer_manager/peer_manager, ./waku_core, ./waku_enr +import ../peer_manager/peer_manager, ../../waku_core, ../../waku_enr export protocol, waku_enr diff --git a/waku/waku_dnsdisc.nim b/waku/node/discovery_manager/waku_dnsdisc.nim similarity index 99% rename from waku/waku_dnsdisc.nim rename to waku/node/discovery_manager/waku_dnsdisc.nim index 639289d1cc..c51318d60c 100644 --- a/waku/waku_dnsdisc.nim +++ b/waku/node/discovery_manager/waku_dnsdisc.nim @@ -21,7 +21,7 @@ import libp2p/multiaddress, libp2p/peerid, dnsdisc/client -import ./waku_core +import ../../waku_core export client diff --git a/waku/node/waku_node.nim b/waku/node/waku_node.nim index bec396e2a9..3c78064da3 100644 --- a/waku/node/waku_node.nim +++ b/waku/node/waku_node.nim @@ -41,11 +41,11 @@ import ../waku_lightpush/common, ../waku_lightpush/protocol, ../waku_enr, - ../waku_dnsdisc, ../waku_peer_exchange, ../waku_rln_relay, ./config, ./peer_manager, + ./discovery_manager/waku_dnsdisc, ../common/ratelimit declarePublicCounter waku_node_messages, "number of messages received", ["type"] @@ -446,8 +446,7 @@ proc filterHandleMessage*( node: WakuNode, pubsubTopic: PubsubTopic, message: WakuMessage ) {.async.} = if node.wakuFilter.isNil(): - error "cannot handle filter message", - error = "waku filter is required" + error "cannot handle filter message", error = "waku filter is required" return await node.wakuFilter.handleMessage(pubsubTopic, message) @@ -546,7 +545,7 @@ proc filterSubscribe*( proc filterUnsubscribe*( node: WakuNode, pubsubTopic: Option[PubsubTopic], - contentTopics: ContentTopic|seq[ContentTopic], + contentTopics: ContentTopic | seq[ContentTopic], peer: RemotePeerInfo | string, ): Future[FilterSubscribeResult] {.async, gcsafe, raises: [Defect, ValueError].} = ## Unsubscribe from a content filter V2". diff --git a/waku/waku_api/handlers.nim b/waku/waku_api/handlers.nim index 16c99998a5..0d0adfa848 100644 --- a/waku/waku_api/handlers.nim +++ b/waku/waku_api/handlers.nim @@ -4,7 +4,8 @@ else: {.push raises: [].} import chronos, chronicles, std/[options, sequtils], stew/results -import ../waku_discv5, ../waku_relay, ../waku_core, ./message_cache +import + ../node/discovery_manager/waku_discv5, ../waku_relay, ../waku_core, ./message_cache ### Discovery diff --git a/waku/waku_peer_exchange/protocol.nim b/waku/waku_peer_exchange/protocol.nim index 0bedbd7874..1a4a547517 100644 --- a/waku/waku_peer_exchange/protocol.nim +++ b/waku/waku_peer_exchange/protocol.nim @@ -11,7 +11,7 @@ import ../common/nimchronos, ../node/peer_manager, ../waku_core, - ../waku_discv5, + ../node/discovery_manager/waku_discv5, ./rpc, ./rpc_codec From 35d85d8cd795d4a1da17ec1b18ce89b8933f0067 Mon Sep 17 00:00:00 2001 From: Ivan Folgueira Bande Date: Mon, 15 Apr 2024 09:55:11 +0200 Subject: [PATCH 2/6] update leftovers imports --- examples/publisher.nim | 2 +- examples/subscriber.nim | 2 +- tests/test_waku_metadata.nim | 2 +- tests/waku_discv5/test_waku_discv5.nim | 3 ++- tests/waku_discv5/utils.nim | 3 ++- tests/waku_enr/test_sharding.nim | 2 +- tests/waku_enr/utils.nim | 3 ++- 7 files changed, 10 insertions(+), 7 deletions(-) diff --git a/examples/publisher.nim b/examples/publisher.nim index bc13189f84..d0231f574e 100644 --- a/examples/publisher.nim +++ b/examples/publisher.nim @@ -15,7 +15,7 @@ import ../../../waku/waku_core, ../../../waku/waku_node, ../../../waku/waku_enr, - ../../../waku/waku_discv5, + ../../../waku/node/discovery_manager/waku_discv5, ../../../waku/factory/builder proc now*(): Timestamp = diff --git a/examples/subscriber.nim b/examples/subscriber.nim index 87b52dc8d7..b9ffe790fb 100644 --- a/examples/subscriber.nim +++ b/examples/subscriber.nim @@ -15,7 +15,7 @@ import ../../../waku/waku_core, ../../../waku/waku_node, ../../../waku/waku_enr, - ../../../waku/waku_discv5, + ../../../waku/node/discovery_manager/waku_discv5, ../../../waku/factory/builder, ../../../waku/waku_relay diff --git a/tests/test_waku_metadata.nim b/tests/test_waku_metadata.nim index 0ae873cc09..b0bf389d7a 100644 --- a/tests/test_waku_metadata.nim +++ b/tests/test_waku_metadata.nim @@ -17,7 +17,7 @@ import ../../waku/waku_node, ../../waku/waku_core/topics, ../../waku/node/peer_manager, - ../../waku/waku_discv5, + ../../waku/node/discovery_manager/waku_discv5, ../../waku/waku_metadata, ./testlib/wakucore, ./testlib/wakunode diff --git a/tests/waku_discv5/test_waku_discv5.nim b/tests/waku_discv5/test_waku_discv5.nim index 2220646c89..5248199b68 100644 --- a/tests/waku_discv5/test_waku_discv5.nim +++ b/tests/waku_discv5/test_waku_discv5.nim @@ -11,7 +11,8 @@ import eth/keys as eth_keys import - ../../../waku/[waku_core/topics, waku_enr, waku_discv5, common/enr], + ../../../waku/ + [waku_core/topics, waku_enr, node/discovery_manager/waku_discv5, common/enr], ../testlib/[wakucore, testasync, assertions, futures], ../waku_enr/utils, ./utils diff --git a/tests/waku_discv5/utils.nim b/tests/waku_discv5/utils.nim index e2fd5a3bd5..3eac021b29 100644 --- a/tests/waku_discv5/utils.nim +++ b/tests/waku_discv5/utils.nim @@ -6,7 +6,8 @@ import eth/keys as eth_keys import - ../../../waku/[waku_core/topics, waku_enr, waku_discv5], ../testlib/[common, wakucore] + ../../../waku/[waku_core/topics, waku_enr, node/discovery_manager/waku_discv5], + ../testlib/[common, wakucore] proc newTestDiscv5*( privKey: libp2p_keys.PrivateKey, diff --git a/tests/waku_enr/test_sharding.nim b/tests/waku_enr/test_sharding.nim index 0c7b79f4c0..a405f383d8 100644 --- a/tests/waku_enr/test_sharding.nim +++ b/tests/waku_enr/test_sharding.nim @@ -9,7 +9,7 @@ import eth/keys as eth_keys import - ../../../waku/[waku_enr, waku_discv5, waku_core], + ../../../waku/[waku_enr, node/discovery_manager/waku_discv5, waku_core], ../testlib/wakucore, ../waku_discv5/utils, ./utils diff --git a/tests/waku_enr/utils.nim b/tests/waku_enr/utils.nim index 469e0d95ce..b9718e8899 100644 --- a/tests/waku_enr/utils.nim +++ b/tests/waku_enr/utils.nim @@ -7,7 +7,8 @@ import eth/keys as eth_keys import - ../../../waku/[waku_core/topics, waku_enr, waku_discv5, waku_enr/sharding], + ../../../waku/ + [waku_core/topics, waku_enr, node/discovery_manager/waku_discv5, waku_enr/sharding], ../testlib/[common, wakucore] proc newTestEnrRecord*( From a43a4b7d5a2904a077c72435e5fb581d0dfae6ae Mon Sep 17 00:00:00 2001 From: Ivan Folgueira Bande Date: Mon, 15 Apr 2024 13:19:52 +0200 Subject: [PATCH 3/6] apps/char2/chat2.nim update leftover import --- apps/chat2/chat2.nim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/chat2/chat2.nim b/apps/chat2/chat2.nim index d27357633c..08b8bf72b2 100644 --- a/apps/chat2/chat2.nim +++ b/apps/chat2/chat2.nim @@ -39,7 +39,7 @@ import ../../waku/waku_lightpush/rpc, ../../waku/waku_enr, ../../waku/waku_store, - ../../waku/waku_dnsdisc, + ../../waku/node/discovery_manager/waku_dnsdisc, ../../waku/waku_node, ../../waku/node/waku_metrics, ../../waku/node/peer_manager, @@ -523,7 +523,9 @@ proc processInput(rfd: AsyncFD, rng: ref HmacDrbgContext) {.async.} = if msg.contentTopic == chat.contentTopic: chat.printReceivedMessage(msg) - node.subscribe((kind: PubsubSub, topic: DefaultPubsubTopic), some(WakuRelayHandler(handler))) + node.subscribe( + (kind: PubsubSub, topic: DefaultPubsubTopic), some(WakuRelayHandler(handler)) + ) if conf.rlnRelay: info "WakuRLNRelay is enabled" From a0b29a9aeb356e9a510b0eb348b902a0c9256160 Mon Sep 17 00:00:00 2001 From: Ivan Folgueira Bande Date: Wed, 17 Apr 2024 14:47:12 +0200 Subject: [PATCH 4/6] readjust discovery refactor to latest PR comments --- apps/networkmonitor/networkmonitor.nim | 4 ++-- apps/wakunode2/app.nim | 4 ++-- tests/node/test_wakunode_peer_exchange.nim | 2 +- tests/test_waku_dnsdisc.nim | 2 +- tests/test_waku_metadata.nim | 2 +- tests/testlib/wakunode.nim | 2 +- tests/waku_discv5/test_waku_discv5.nim | 3 +-- tests/waku_enr/test_sharding.nim | 2 +- tests/waku_peer_exchange/test_protocol.nim | 2 +- tests/waku_peer_exchange/test_rpc_codec.nim | 2 +- tests/waku_peer_exchange/utils.nim | 2 +- .../discovery_manager => discovery}/discovery_manager.nim | 6 +----- waku/{node/discovery_manager => discovery}/waku_discv5.nim | 2 +- waku/{node/discovery_manager => discovery}/waku_dnsdisc.nim | 2 +- waku/factory/builder.nim | 3 +-- waku/factory/node_factory.nim | 2 +- waku/node/waku_node.nim | 2 +- waku/waku_api/handlers.nim | 3 +-- waku/waku_peer_exchange/protocol.nim | 2 +- 19 files changed, 21 insertions(+), 28 deletions(-) rename waku/{node/discovery_manager => discovery}/discovery_manager.nim (86%) rename waku/{node/discovery_manager => discovery}/waku_discv5.nim (99%) rename waku/{node/discovery_manager => discovery}/waku_dnsdisc.nim (99%) diff --git a/apps/networkmonitor/networkmonitor.nim b/apps/networkmonitor/networkmonitor.nim index 7670b94847..f113b2e939 100644 --- a/apps/networkmonitor/networkmonitor.nim +++ b/apps/networkmonitor/networkmonitor.nim @@ -25,8 +25,8 @@ import ../../waku/node/peer_manager, ../../waku/waku_node, ../../waku/waku_enr, - ../../waku/node/discovery_manager/waku_discv5, - ../../waku/node/discovery_manager/waku_dnsdisc, + ../../waku/discovery/waku_discv5, + ../../waku/discovery/waku_dnsdisc, ../../waku/waku_relay, ../../waku/waku_rln_relay, ../../waku/factory/builder, diff --git a/apps/wakunode2/app.nim b/apps/wakunode2/app.nim index 90c79c279b..c6ca66ff52 100644 --- a/apps/wakunode2/app.nim +++ b/apps/wakunode2/app.nim @@ -40,8 +40,8 @@ import ../../waku/waku_api/rest/health/handlers as rest_health_api, ../../waku/waku_api/rest/admin/handlers as rest_admin_api, ../../waku/waku_archive, - ../../waku/node/discovery_manager/waku_dnsdisc, - ../../waku/node/discovery_manager/waku_discv5, + ../../waku/discovery/waku_dnsdisc, + ../../waku/discovery/waku_discv5, ../../waku/waku_enr/sharding, ../../waku/waku_peer_exchange, ../../waku/waku_rln_relay, diff --git a/tests/node/test_wakunode_peer_exchange.nim b/tests/node/test_wakunode_peer_exchange.nim index dd004cf990..a9d18af6af 100644 --- a/tests/node/test_wakunode_peer_exchange.nim +++ b/tests/node/test_wakunode_peer_exchange.nim @@ -15,7 +15,7 @@ import import ../../../waku/[ waku_node, - node/discovery_manager/waku_discv5, + discovery/waku_discv5, waku_peer_exchange, node/peer_manager, waku_relay/protocol, diff --git a/tests/test_waku_dnsdisc.nim b/tests/test_waku_dnsdisc.nim index edeffa215a..55181b5c34 100644 --- a/tests/test_waku_dnsdisc.nim +++ b/tests/test_waku_dnsdisc.nim @@ -13,7 +13,7 @@ import import ../../waku/node/peer_manager, ../../waku/waku_node, - ../../waku/node/discovery_manager/waku_dnsdisc, + ../../waku/discovery/waku_dnsdisc, ./testlib/common, ./testlib/wakucore, ./testlib/wakunode diff --git a/tests/test_waku_metadata.nim b/tests/test_waku_metadata.nim index b0bf389d7a..3c0810581d 100644 --- a/tests/test_waku_metadata.nim +++ b/tests/test_waku_metadata.nim @@ -17,7 +17,7 @@ import ../../waku/waku_node, ../../waku/waku_core/topics, ../../waku/node/peer_manager, - ../../waku/node/discovery_manager/waku_discv5, + ../../waku/discovery/waku_discv5, ../../waku/waku_metadata, ./testlib/wakucore, ./testlib/wakunode diff --git a/tests/testlib/wakunode.nim b/tests/testlib/wakunode.nim index 8900cc2500..4bcf353268 100644 --- a/tests/testlib/wakunode.nim +++ b/tests/testlib/wakunode.nim @@ -12,7 +12,7 @@ import ../../../waku/waku_node, ../../../waku/node/peer_manager, ../../../waku/waku_enr, - ../../../waku/node/discovery_manager/waku_discv5, + ../../../waku/discovery/waku_discv5, ../../../waku/factory/external_config, ../../../waku/factory/internal_config, ../../../waku/factory/builder, diff --git a/tests/waku_discv5/test_waku_discv5.nim b/tests/waku_discv5/test_waku_discv5.nim index 5248199b68..c454abaeee 100644 --- a/tests/waku_discv5/test_waku_discv5.nim +++ b/tests/waku_discv5/test_waku_discv5.nim @@ -11,8 +11,7 @@ import eth/keys as eth_keys import - ../../../waku/ - [waku_core/topics, waku_enr, node/discovery_manager/waku_discv5, common/enr], + ../../../waku/[waku_core/topics, waku_enr, discovery/waku_discv5, common/enr], ../testlib/[wakucore, testasync, assertions, futures], ../waku_enr/utils, ./utils diff --git a/tests/waku_enr/test_sharding.nim b/tests/waku_enr/test_sharding.nim index a405f383d8..0417da88a5 100644 --- a/tests/waku_enr/test_sharding.nim +++ b/tests/waku_enr/test_sharding.nim @@ -9,7 +9,7 @@ import eth/keys as eth_keys import - ../../../waku/[waku_enr, node/discovery_manager/waku_discv5, waku_core], + ../../../waku/[waku_enr, discovery/waku_discv5, waku_core], ../testlib/wakucore, ../waku_discv5/utils, ./utils diff --git a/tests/waku_peer_exchange/test_protocol.nim b/tests/waku_peer_exchange/test_protocol.nim index 4337d309d5..db2f441f57 100644 --- a/tests/waku_peer_exchange/test_protocol.nim +++ b/tests/waku_peer_exchange/test_protocol.nim @@ -13,7 +13,7 @@ import ../../../waku/[ waku_node, node/peer_manager, - node/discovery_manager/waku_discv5, + discovery/waku_discv5, waku_peer_exchange, waku_peer_exchange/rpc, waku_peer_exchange/rpc_codec, diff --git a/tests/waku_peer_exchange/test_rpc_codec.nim b/tests/waku_peer_exchange/test_rpc_codec.nim index 1ef3386a9f..b07aa6916b 100644 --- a/tests/waku_peer_exchange/test_rpc_codec.nim +++ b/tests/waku_peer_exchange/test_rpc_codec.nim @@ -14,7 +14,7 @@ import import ../../../waku/[ node/peer_manager, - node/discovery_manager/waku_discv5, + discovery/waku_discv5, waku_peer_exchange/rpc, waku_peer_exchange/rpc_codec, ], diff --git a/tests/waku_peer_exchange/utils.nim b/tests/waku_peer_exchange/utils.nim index 23c0a6f94e..dddb077696 100644 --- a/tests/waku_peer_exchange/utils.nim +++ b/tests/waku_peer_exchange/utils.nim @@ -13,7 +13,7 @@ import import ../../../waku/[ waku_node, - node/discovery_manager/waku_discv5, + discovery/waku_discv5, waku_peer_exchange, waku_peer_exchange/rpc, waku_peer_exchange/protocol, diff --git a/waku/node/discovery_manager/discovery_manager.nim b/waku/discovery/discovery_manager.nim similarity index 86% rename from waku/node/discovery_manager/discovery_manager.nim rename to waku/discovery/discovery_manager.nim index 2e749d3c49..9fd239598a 100644 --- a/waku/node/discovery_manager/discovery_manager.nim +++ b/waku/discovery/discovery_manager.nim @@ -15,17 +15,13 @@ type DiscoveryManager* = object #[ TODO: in future PRs we will have: - WakuNode* = ref object - peerManager*: PeerManager - discManager*: DiscoveryManager <-- we will add this - ... - App* = object version: string conf: WakuNodeConf rng: ref HmacDrbgContext key: crypto.PrivateKey + ## in future PRs, the following two items will be encapsulated by 'DiscoveryManager' wakuDiscv5: Option[WakuDiscoveryV5] <-- this will get removed dynamicBootstrapNodes: seq[RemotePeerInfo] <-- this will get removed diff --git a/waku/node/discovery_manager/waku_discv5.nim b/waku/discovery/waku_discv5.nim similarity index 99% rename from waku/node/discovery_manager/waku_discv5.nim rename to waku/discovery/waku_discv5.nim index 11e9874b5c..1637c35049 100644 --- a/waku/node/discovery_manager/waku_discv5.nim +++ b/waku/discovery/waku_discv5.nim @@ -14,7 +14,7 @@ import eth/keys as eth_keys, eth/p2p/discoveryv5/node, eth/p2p/discoveryv5/protocol -import ../peer_manager/peer_manager, ../../waku_core, ../../waku_enr +import ../node/peer_manager/peer_manager, ../waku_core, ../waku_enr export protocol, waku_enr diff --git a/waku/node/discovery_manager/waku_dnsdisc.nim b/waku/discovery/waku_dnsdisc.nim similarity index 99% rename from waku/node/discovery_manager/waku_dnsdisc.nim rename to waku/discovery/waku_dnsdisc.nim index c51318d60c..921daff499 100644 --- a/waku/node/discovery_manager/waku_dnsdisc.nim +++ b/waku/discovery/waku_dnsdisc.nim @@ -21,7 +21,7 @@ import libp2p/multiaddress, libp2p/peerid, dnsdisc/client -import ../../waku_core +import ../waku_core export client diff --git a/waku/factory/builder.nim b/waku/factory/builder.nim index 943996f6eb..af68501594 100644 --- a/waku/factory/builder.nim +++ b/waku/factory/builder.nim @@ -12,8 +12,7 @@ import libp2p/builders, libp2p/nameresolving/nameresolver, libp2p/transports/wstransport -import - ../waku_enr, ../node/discovery_manager/waku_discv5, ../waku_node, ../node/peer_manager +import ../waku_enr, ../discovery/waku_discv5, ../waku_node, ../node/peer_manager type WakuNodeBuilder* = object # General diff --git a/waku/factory/node_factory.nim b/waku/factory/node_factory.nim index c952423567..1dfbbf9da9 100644 --- a/waku/factory/node_factory.nim +++ b/waku/factory/node_factory.nim @@ -16,7 +16,7 @@ import ../waku_node, ../waku_core, ../waku_rln_relay, - ../node/discovery_manager/waku_dnsdisc, + ../discovery/waku_dnsdisc, ../waku_archive, ../waku_store, ../waku_filter_v2, diff --git a/waku/node/waku_node.nim b/waku/node/waku_node.nim index 3c78064da3..e132eb8de1 100644 --- a/waku/node/waku_node.nim +++ b/waku/node/waku_node.nim @@ -45,7 +45,7 @@ import ../waku_rln_relay, ./config, ./peer_manager, - ./discovery_manager/waku_dnsdisc, + ../discovery/waku_dnsdisc, ../common/ratelimit declarePublicCounter waku_node_messages, "number of messages received", ["type"] diff --git a/waku/waku_api/handlers.nim b/waku/waku_api/handlers.nim index 0d0adfa848..26338f8cf3 100644 --- a/waku/waku_api/handlers.nim +++ b/waku/waku_api/handlers.nim @@ -4,8 +4,7 @@ else: {.push raises: [].} import chronos, chronicles, std/[options, sequtils], stew/results -import - ../node/discovery_manager/waku_discv5, ../waku_relay, ../waku_core, ./message_cache +import ../discovery/waku_discv5, ../waku_relay, ../waku_core, ./message_cache ### Discovery diff --git a/waku/waku_peer_exchange/protocol.nim b/waku/waku_peer_exchange/protocol.nim index 1a4a547517..3f26eb7a7c 100644 --- a/waku/waku_peer_exchange/protocol.nim +++ b/waku/waku_peer_exchange/protocol.nim @@ -11,7 +11,7 @@ import ../common/nimchronos, ../node/peer_manager, ../waku_core, - ../node/discovery_manager/waku_discv5, + ../discovery/waku_discv5, ./rpc, ./rpc_codec From dd8a6cb96c7cd65bed8c491ad113c644b3e51d0d Mon Sep 17 00:00:00 2001 From: Ivan Folgueira Bande Date: Wed, 17 Apr 2024 15:02:18 +0200 Subject: [PATCH 5/6] I missed to adjust some imports --- examples/publisher.nim | 2 +- examples/subscriber.nim | 2 +- tests/waku_discv5/utils.nim | 2 +- tests/waku_enr/utils.nim | 3 +-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/examples/publisher.nim b/examples/publisher.nim index d0231f574e..2a95c68e2d 100644 --- a/examples/publisher.nim +++ b/examples/publisher.nim @@ -15,7 +15,7 @@ import ../../../waku/waku_core, ../../../waku/waku_node, ../../../waku/waku_enr, - ../../../waku/node/discovery_manager/waku_discv5, + ../../../waku/discovery/waku_discv5, ../../../waku/factory/builder proc now*(): Timestamp = diff --git a/examples/subscriber.nim b/examples/subscriber.nim index b9ffe790fb..842a3a02de 100644 --- a/examples/subscriber.nim +++ b/examples/subscriber.nim @@ -15,7 +15,7 @@ import ../../../waku/waku_core, ../../../waku/waku_node, ../../../waku/waku_enr, - ../../../waku/node/discovery_manager/waku_discv5, + ../../../waku/discovery/waku_discv5, ../../../waku/factory/builder, ../../../waku/waku_relay diff --git a/tests/waku_discv5/utils.nim b/tests/waku_discv5/utils.nim index 3eac021b29..5dd04e6e7d 100644 --- a/tests/waku_discv5/utils.nim +++ b/tests/waku_discv5/utils.nim @@ -6,7 +6,7 @@ import eth/keys as eth_keys import - ../../../waku/[waku_core/topics, waku_enr, node/discovery_manager/waku_discv5], + ../../../waku/[waku_core/topics, waku_enr, discovery/waku_discv5], ../testlib/[common, wakucore] proc newTestDiscv5*( diff --git a/tests/waku_enr/utils.nim b/tests/waku_enr/utils.nim index b9718e8899..2682e0ec44 100644 --- a/tests/waku_enr/utils.nim +++ b/tests/waku_enr/utils.nim @@ -7,8 +7,7 @@ import eth/keys as eth_keys import - ../../../waku/ - [waku_core/topics, waku_enr, node/discovery_manager/waku_discv5, waku_enr/sharding], + ../../../waku/[waku_core/topics, waku_enr, discovery/waku_discv5, waku_enr/sharding], ../testlib/[common, wakucore] proc newTestEnrRecord*( From 77b2e463a9e7cdaae21d47d34885ce7a7b91c7b1 Mon Sep 17 00:00:00 2001 From: Ivan Folgueira Bande Date: Wed, 17 Apr 2024 15:27:42 +0200 Subject: [PATCH 6/6] chat2.nim: missed to add file --- apps/chat2/chat2.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/chat2/chat2.nim b/apps/chat2/chat2.nim index 08b8bf72b2..1edfe24cec 100644 --- a/apps/chat2/chat2.nim +++ b/apps/chat2/chat2.nim @@ -39,7 +39,7 @@ import ../../waku/waku_lightpush/rpc, ../../waku/waku_enr, ../../waku/waku_store, - ../../waku/node/discovery_manager/waku_dnsdisc, + ../../waku/discovery/waku_dnsdisc, ../../waku/waku_node, ../../waku/node/waku_metrics, ../../waku/node/peer_manager,