diff --git a/apps/chat2/chat2.nim b/apps/chat2/chat2.nim index bfc45fca4..2e57fc015 100644 --- a/apps/chat2/chat2.nim +++ b/apps/chat2/chat2.nim @@ -48,7 +48,7 @@ import ./config_chat2 import libp2p/protocols/pubsub/rpc/messages, libp2p/protocols/pubsub/pubsub -import ../../logos_delivery/waku/rln +import logos_delivery/waku/rln const Help = """ Commands: /[?|help|connect|nick|exit] @@ -193,12 +193,7 @@ proc publish(c: Chat, line: string) = # for future version when we support more than one rln protected content topic, # we should check the message content topic as well let proofRes = - try: - waitFor c.node.rln.generateRLNProof(message.toRLNSignal(), float64(time)) - except CatchableError: - Result[seq[byte], string].err( - "exception generating rln proof: " & getCurrentExceptionMsg() - ) + waitFor c.node.rln.generateRLNProof(message.toRLNSignal(), float64(time)) if proofRes.isErr(): info "could not append rate limit proof to the message" else: diff --git a/library/liblogosdelivery.nim b/library/liblogosdelivery.nim index 8f1fd1180..57279c189 100644 --- a/library/liblogosdelivery.nim +++ b/library/liblogosdelivery.nim @@ -1,4 +1,5 @@ -import std/[atomics, macros], chronicles, chronos, chronos/threadsync, ffi +import std/[atomics, macros] +import chronicles, chronos, chronos/threadsync, ffi import logos_delivery/waku/waku_core/message/message, logos_delivery/waku/waku_core/topics/pubsub_topic, diff --git a/logos_delivery/waku/incentivization/eligibility_manager.nim b/logos_delivery/waku/incentivization/eligibility_manager.nim index 21d119769..298d52ccf 100644 --- a/logos_delivery/waku/incentivization/eligibility_manager.nim +++ b/logos_delivery/waku/incentivization/eligibility_manager.nim @@ -1,13 +1,8 @@ -import - std/sets, - chronos, - web3, - stew/byteutils, - stint, - results, - chronicles, - logos_delivery/waku/incentivization/rpc, - tests/waku_rln_relay/utils_onchain +import std/sets, chronos, web3, stew/byteutils, stint, results + +import chronicles + +import logos_delivery/waku/incentivization/rpc, tests/waku_rln_relay/utils_onchain const SimpleTransferGasUsed = Quantity(21000) const TxReceiptQueryTimeout = 3.seconds diff --git a/logos_delivery/waku/node/subscription_manager.nim b/logos_delivery/waku/node/subscription_manager.nim index d852a8c68..2a0d5cbac 100644 --- a/logos_delivery/waku/node/subscription_manager.nim +++ b/logos_delivery/waku/node/subscription_manager.nim @@ -1,10 +1,6 @@ -import - std/[sequtils, sets, tables], - chronos, - chronicles, - metrics, - results, - libp2p/[peerid, peerinfo] +import std/[sequtils, sets, tables], chronos, chronicles, metrics, results + +import libp2p/[peerid, peerinfo] import brokers/broker_context import diff --git a/logos_delivery/waku/persistency/backend_comm.nim b/logos_delivery/waku/persistency/backend_comm.nim index ad8a11106..d680cc282 100644 --- a/logos_delivery/waku/persistency/backend_comm.nim +++ b/logos_delivery/waku/persistency/backend_comm.nim @@ -81,9 +81,10 @@ proc mtMarshalSizeValue*[T](value: Opt[T]): int {.gcsafe.} = # Opt[T] is generic: for a copyMem-able T the generic size pass takes the # sizeof() branch (padding included) while our marshal writes flag+payload. mixin mtMarshalSizeValue - result = sizeof(uint8) + var size = sizeof(uint8) if value.isSome(): - result += mtMarshalSizeValue(value.get()) + size += mtMarshalSizeValue(value.get()) + return size proc mtMarshalValue*( buf: ptr UncheckedArray[byte], cap: int, value: TxOp, pos: var int diff --git a/logos_delivery/waku/rest_api/endpoint/origin_handler.nim b/logos_delivery/waku/rest_api/endpoint/origin_handler.nim index b45612228..0a8fa9ec2 100644 --- a/logos_delivery/waku/rest_api/endpoint/origin_handler.nim +++ b/logos_delivery/waku/rest_api/endpoint/origin_handler.nim @@ -1,7 +1,7 @@ {.push raises: [].} -import - std/[strutils, net], regex, results, chronicles, chronos, chronos/apps/http/httpserver +import std/[strutils, net], regex, results +import chronicles, chronos, chronos/apps/http/httpserver type OriginHandlerMiddlewareRef* = ref object of HttpServerMiddlewareRef allowedOriginMatcher: Opt[Regex2] diff --git a/logos_delivery/waku/rest_api/endpoint/store/handlers.nim b/logos_delivery/waku/rest_api/endpoint/store/handlers.nim index 396de13bd..aa0136922 100644 --- a/logos_delivery/waku/rest_api/endpoint/store/handlers.nim +++ b/logos_delivery/waku/rest_api/endpoint/store/handlers.nim @@ -1,24 +1,21 @@ {.push raises: [].} +import std/options, std/[strformat, sugar], results + +import chronicles, uri, json_serialization, presto/route import - std/options, - std/[strformat, sugar], - results, - chronicles, - uri, - json_serialization, - presto/route -import - ../../../waku_core, - ../../../waku_store/common, - ../../../waku_store/self_req_handler, - ../../../waku_node, - ../../../node/peer_manager, - ../../../common/paging, - ../../handlers, - ../responses, - ../serdes, - ./types + logos_delivery/waku/[ + waku_core, + waku_store/common, + waku_store/self_req_handler, + waku_node, + node/peer_manager, + common/paging, + rest_api/handlers, + rest_api/endpoint/responses, + rest_api/endpoint/serdes, + rest_api/endpoint/store/types, + ] export types diff --git a/logos_delivery/waku/rln/proof.nim b/logos_delivery/waku/rln/proof.nim index 9f9f9abc7..ba4b0361a 100644 --- a/logos_delivery/waku/rln/proof.nim +++ b/logos_delivery/waku/rln/proof.nim @@ -3,9 +3,15 @@ import std/[times, sequtils] import chronos, chronicles, results, stew/byteutils -import ./types, ./protocol_types, ./conversion_utils, ./group_manager, ./nonce_manager - -import logos_delivery/waku/waku_core +import + logos_delivery/waku/[ + rln/types, + rln/protocol_types, + rln/conversion_utils, + rln/group_manager, + rln/nonce_manager, + waku_core, + ] proc calcEpoch*(rln: Rln, t: float64): Epoch = ## gets time `t` as `flaot64` with subseconds resolution in the fractional part @@ -56,13 +62,16 @@ proc toRLNSignal*(wakumessage: WakuMessage): seq[byte] = proc generateRLNProof*( rln: Rln, input: seq[byte], senderEpochTime: float64 -): Future[Result[seq[byte], string]] {.async.} = +): Future[Result[seq[byte], string]] {.async: (raises: []).} = let epoch = rln.calcEpoch(senderEpochTime) let nonce = rln.nonceManager.getNonce().valueOr: return err("could not get new message id to generate an rln proof: " & $error) - let proof = (await rln.groupManager.generateProof(input, epoch, nonce)).valueOr: - return err("could not generate rln-v2 proof: " & $error) - return ok(proof.encode().buffer) + try: + let proof = (await rln.groupManager.generateProof(input, epoch, nonce)).valueOr: + return err("could not generate rln-v2 proof: " & $error) + return ok(proof.encode().buffer) + except CatchableError as e: + return err("exception generating rln proof: " & e.msg) proc generateRLNProofWithRootRefresh*( rln: Rln, input: seq[byte], senderEpochTime: float64 diff --git a/logos_delivery/waku/rln/rln/wrappers.nim b/logos_delivery/waku/rln/rln/wrappers.nim index a669e035d..e02ee2e2e 100644 --- a/logos_delivery/waku/rln/rln/wrappers.nim +++ b/logos_delivery/waku/rln/rln/wrappers.nim @@ -1,14 +1,16 @@ +import stew/[arrayops, endians2], stint, results + +import chronicles, eth/keys + import - chronicles, - eth/keys, - stew/[arrayops, endians2], - stint, - results, - ./rln_interface, - ../conversion_utils, - ../protocol_types, - ../protocol_metrics -import ../../waku_core, ../../waku_keystore + logos_delivery/waku/[ + rln/rln/rln_interface, + rln/conversion_utils, + rln/protocol_types, + rln/protocol_metrics, + waku_core, + waku_keystore, + ] {.push raises: [], gcsafe.} diff --git a/logos_delivery/waku/waku_peer_exchange/client.nim b/logos_delivery/waku/waku_peer_exchange/client.nim index d51d65b82..f2ceb67c4 100644 --- a/logos_delivery/waku/waku_peer_exchange/client.nim +++ b/logos_delivery/waku/waku_peer_exchange/client.nim @@ -1,14 +1,14 @@ +import results +import chronicles, chronos, metrics import - results, - chronicles, - chronos, - metrics, - ./common, - ./rpc, - ./rpc_codec, - ../node/peer_manager + logos_delivery/waku/[ + waku_peer_exchange/common, + waku_peer_exchange/rpc, + waku_peer_exchange/rpc_codec, + node/peer_manager, + ] -from ../waku_core/codecs import WakuPeerExchangeCodec +from logos_delivery/waku/waku_core/codecs import WakuPeerExchangeCodec declarePublicGauge waku_px_peers_received_total, "number of ENRs received via peer exchange"