diff --git a/apps/chat2/chat2.nim b/apps/chat2/chat2.nim index 8fee78ae4..3f02eefe6 100644 --- a/apps/chat2/chat2.nim +++ b/apps/chat2/chat2.nim @@ -38,7 +38,7 @@ when defined(rln): import libp2p/protocols/pubsub/rpc/messages, libp2p/protocols/pubsub/pubsub, - ../../waku/v2/protocol/waku_rln_relay/waku_rln_relay_utils + ../../waku/v2/protocol/waku_rln_relay const Help = """ Commands: /[?|help|connect|nick|exit] diff --git a/apps/wakunode2/wakunode2.nim b/apps/wakunode2/wakunode2.nim index 3f9edff8b..ad0d71b76 100644 --- a/apps/wakunode2/wakunode2.nim +++ b/apps/wakunode2/wakunode2.nim @@ -47,8 +47,7 @@ import when defined(rln): import - ../../waku/v2/protocol/waku_rln_relay/waku_rln_relay_types, - ../../waku/v2/protocol/waku_rln_relay/waku_rln_relay_utils + ../../waku/v2/protocol/waku_rln_relay logScope: diff --git a/docs/tutorial/onchain-rln-relay-chat2.md b/docs/tutorial/onchain-rln-relay-chat2.md index 857c379c6..18dd61b8d 100644 --- a/docs/tutorial/onchain-rln-relay-chat2.md +++ b/docs/tutorial/onchain-rln-relay-chat2.md @@ -133,7 +133,7 @@ The numerical value `165886530` indicates the epoch of the message `Hi`. You will see a different value than `165886530` on your screen. If two messages sent by the same chat2 client happen to have the same RLN epoch value, then one of them will be detected as spam and won't be routed (by test fleets in this test setting). At the time of this tutorial, the epoch duration is set to `10` seconds. -You can inspect the current epoch value by checking the following [constant variable](https://github.com/status-im/nim-waku/blob/21cac6d491a6d995a7a8ba84c85fecc7817b3d8b/waku/v2/protocol/waku_rln_relay/waku_rln_relay_types.nim#L119) in the nim-waku codebase. +You can inspect the current epoch value by checking the following [constant variable](https://github.com/status-im/nim-waku/blob/21cac6d491a6d995a7a8ba84c85fecc7817b3d8b/waku/v2/protocol/waku_rln_relay/constants.nim#L245) in the nim-waku codebase. Thus, if you send two messages less than `10` seconds apart, they are likely to get the same `rln epoch` values. After sending a chat message, you may experience some delay before the next chat prompt appears. diff --git a/docs/tutorial/rln-chat2-live-testnet.md b/docs/tutorial/rln-chat2-live-testnet.md index f3b164881..2c9d0f5e6 100644 --- a/docs/tutorial/rln-chat2-live-testnet.md +++ b/docs/tutorial/rln-chat2-live-testnet.md @@ -7,7 +7,7 @@ Spam detection takes place at the chat2 users end. In this setting, you should try to spam the network by violating the message rate limit i.e., sending more than one message per epoch. At the time of this tutorial, the epoch duration is set to `10` seconds. -You can inspect the current epoch value by checking the following [constant variable](https://github.com/status-im/nim-waku/blob/21cac6d491a6d995a7a8ba84c85fecc7817b3d8b/waku/v2/protocol/waku_rln_relay/waku_rln_relay_types.nim#L119) in the nim-waku codebase. +You can inspect the current epoch value by checking the following [constant variable](https://github.com/status-im/nim-waku/blob/21cac6d491a6d995a7a8ba84c85fecc7817b3d8b/waku/v2/protocol/waku_rln_relay/constants.nim#L245) in the nim-waku codebase. Your messages will be routed via test fleets and will arrive at other live chat2 clients that are running in rate-limited mode over the same content topic i.e., `/toy-chat/2/luzhou/proto`. Your samp activity will be detected by them and a proper message will be shown on their console. diff --git a/docs/tutorial/rln-chat2-local-test.md b/docs/tutorial/rln-chat2-local-test.md index 677db2ff7..23a854368 100644 --- a/docs/tutorial/rln-chat2-local-test.md +++ b/docs/tutorial/rln-chat2-local-test.md @@ -7,7 +7,7 @@ For ease of explanation, we will refer to them as `Alice`, `Bob`, and `Carol`. In this setting, if `Bob` or `Carol` attempts to spam the network by violating the message rate limit then `Alice` will detect their spamming activity, and does not relay the spam messages. The message rate is one per epoch. At the time of this tutorial, the epoch duration is set to `10` seconds. -You can inspect its current value by checking the following [constant variable](https://github.com/status-im/nim-waku/blob/21cac6d491a6d995a7a8ba84c85fecc7817b3d8b/waku/v2/protocol/waku_rln_relay/waku_rln_relay_types.nim#L119) in the nim-waku codebase. +You can inspect its current value by checking the following [constant variable](https://github.com/status-im/nim-waku/blob/21cac6d491a6d995a7a8ba84c85fecc7817b3d8b/waku/v2/protocol/waku_rln_relay/constants.nim#L245) in the nim-waku codebase. # Set up diff --git a/tests/v2/test_waku_rln_relay.nim b/tests/v2/test_waku_rln_relay.nim index 9c8b668fb..29835e39c 100644 --- a/tests/v2/test_waku_rln_relay.nim +++ b/tests/v2/test_waku_rln_relay.nim @@ -13,11 +13,7 @@ import import ../../waku/v2/node/waku_node, ../../waku/v2/protocol/waku_message, - ../../waku/v2/protocol/waku_rln_relay/rln, - ../../waku/v2/protocol/waku_rln_relay/waku_rln_relay_utils, - ../../waku/v2/protocol/waku_rln_relay/waku_rln_relay_types, - ../../waku/v2/protocol/waku_rln_relay/waku_rln_relay_constants, - ../../waku/v2/protocol/waku_rln_relay/waku_rln_relay_metrics, + ../../waku/v2/protocol/waku_rln_relay, ../test_helpers const RlnRelayPubsubTopic = "waku/2/rlnrelay/proto" diff --git a/tests/v2/test_waku_rln_relay_onchain.nim b/tests/v2/test_waku_rln_relay_onchain.nim index 79061d862..43b31d37b 100644 --- a/tests/v2/test_waku_rln_relay_onchain.nim +++ b/tests/v2/test_waku_rln_relay_onchain.nim @@ -8,9 +8,9 @@ import stew/byteutils, stew/shims/net as stewNet, libp2p/crypto/crypto, eth/keys, - ../../waku/v2/protocol/waku_rln_relay/[waku_rln_relay_utils, - waku_rln_relay_constants, - waku_rln_relay_types, + ../../waku/v2/protocol/waku_rln_relay/[utils, + constants, + protocol_types, rln_relay_contract], ../../waku/v2/node/waku_node, ../test_helpers, diff --git a/tests/v2/test_wakunode_rln_relay.nim b/tests/v2/test_wakunode_rln_relay.nim index 17db361c6..7e76244f8 100644 --- a/tests/v2/test_wakunode_rln_relay.nim +++ b/tests/v2/test_wakunode_rln_relay.nim @@ -17,9 +17,7 @@ import import ../../waku/v2/node/waku_node, ../../waku/v2/protocol/waku_message, - ../../waku/v2/protocol/waku_rln_relay/waku_rln_relay_utils, - ../../waku/v2/protocol/waku_rln_relay/waku_rln_relay_types, - ../../waku/v2/protocol/waku_rln_relay/waku_rln_relay_constants, + ../../waku/v2/protocol/waku_rln_relay, ../../waku/v2/utils/peers from std/times import epochTime diff --git a/waku/v2/node/waku_metrics.nim b/waku/v2/node/waku_metrics.nim index 6e4cbd18b..d1acf0b3e 100644 --- a/waku/v2/node/waku_metrics.nim +++ b/waku/v2/node/waku_metrics.nim @@ -17,7 +17,7 @@ import ./waku_node when defined(rln): - import ../protocol/waku_rln_relay/waku_rln_relay_metrics + import ../protocol/waku_rln_relay/protocol_metrics as rln_metrics const LogInterval = 30.seconds diff --git a/waku/v2/node/waku_node.nim b/waku/v2/node/waku_node.nim index 5d27d1cac..76fda8341 100644 --- a/waku/v2/node/waku_node.nim +++ b/waku/v2/node/waku_node.nim @@ -44,7 +44,7 @@ import when defined(rln): import - ../protocol/waku_rln_relay/waku_rln_relay_types + ../protocol/waku_rln_relay/protocol_types declarePublicGauge waku_version, "Waku version info (in git describe format)", ["version"] declarePublicCounter waku_node_messages, "number of messages received", ["type"] diff --git a/waku/v2/protocol/waku_message.nim b/waku/v2/protocol/waku_message.nim index 5f4273437..bbe4b1183 100644 --- a/waku/v2/protocol/waku_message.nim +++ b/waku/v2/protocol/waku_message.nim @@ -17,7 +17,7 @@ import when defined(rln): import - ./waku_rln_relay/waku_rln_relay_types + ./waku_rln_relay/protocol_types const MaxWakuMessageSize* = 1024 * 1024 # In bytes. Corresponds to PubSub default diff --git a/waku/v2/protocol/waku_rln_relay.nim b/waku/v2/protocol/waku_rln_relay.nim new file mode 100644 index 000000000..55565ad14 --- /dev/null +++ b/waku/v2/protocol/waku_rln_relay.nim @@ -0,0 +1,13 @@ +import + ./waku_rln_relay/rln, + ./waku_rln_relay/constants, + ./waku_rln_relay/protocol_types, + ./waku_rln_relay/protocol_metrics, + ./waku_rln_relay/utils + +export + rln, + constants, + protocol_types, + protocol_metrics, + utils diff --git a/waku/v2/protocol/waku_rln_relay/waku_rln_relay_constants.nim b/waku/v2/protocol/waku_rln_relay/constants.nim similarity index 100% rename from waku/v2/protocol/waku_rln_relay/waku_rln_relay_constants.nim rename to waku/v2/protocol/waku_rln_relay/constants.nim diff --git a/waku/v2/protocol/waku_rln_relay/waku_rln_relay_metrics.nim b/waku/v2/protocol/waku_rln_relay/protocol_metrics.nim similarity index 99% rename from waku/v2/protocol/waku_rln_relay/waku_rln_relay_metrics.nim rename to waku/v2/protocol/waku_rln_relay/protocol_metrics.nim index 4c1b60fd8..bacb6a3c0 100644 --- a/waku/v2/protocol/waku_rln_relay/waku_rln_relay_metrics.nim +++ b/waku/v2/protocol/waku_rln_relay/protocol_metrics.nim @@ -8,7 +8,7 @@ import chronos, metrics, metrics/chronos_httpserver, - waku_rln_relay_constants, + ./constants, ../../utils/collector export metrics diff --git a/waku/v2/protocol/waku_rln_relay/waku_rln_relay_types.nim b/waku/v2/protocol/waku_rln_relay/protocol_types.nim similarity index 100% rename from waku/v2/protocol/waku_rln_relay/waku_rln_relay_types.nim rename to waku/v2/protocol/waku_rln_relay/protocol_types.nim diff --git a/waku/v2/protocol/waku_rln_relay/rln.nim b/waku/v2/protocol/waku_rln_relay/rln.nim index 1528cc163..6ca296a84 100644 --- a/waku/v2/protocol/waku_rln_relay/rln.nim +++ b/waku/v2/protocol/waku_rln_relay/rln.nim @@ -7,7 +7,7 @@ else: import os, - waku_rln_relay_types + ./protocol_types const libPath = "vendor/zerokit/target/release/" diff --git a/waku/v2/protocol/waku_rln_relay/waku_rln_relay_utils.nim b/waku/v2/protocol/waku_rln_relay/utils.nim similarity index 99% rename from waku/v2/protocol/waku_rln_relay/waku_rln_relay_utils.nim rename to waku/v2/protocol/waku_rln_relay/utils.nim index 5903d8132..16bf2c9d6 100644 --- a/waku/v2/protocol/waku_rln_relay/waku_rln_relay_utils.nim +++ b/waku/v2/protocol/waku_rln_relay/utils.nim @@ -14,11 +14,13 @@ import libp2p/protocols/pubsub/rpc/messages, libp2p/protocols/pubsub/pubsub, stew/results, - stew/[byteutils, arrayops, endians2], - rln, - waku_rln_relay_constants, - waku_rln_relay_types, - waku_rln_relay_metrics, + stew/[byteutils, arrayops, endians2] +import + ./rln, + ./constants, + ./protocol_types, + ./protocol_metrics +import ../../utils/time, ../../utils/keyfile, ../../node/waku_node,