mirror of
https://github.com/logos-messaging/logos-delivery.git
synced 2026-07-19 11:09:26 +00:00
Fixes from Ivan's review
* Change generateRlnProof error handling * Fix imports * Remove result use
This commit is contained in:
parent
2315927043
commit
5d24d41181
@ -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:
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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]
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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.}
|
||||
|
||||
|
||||
@ -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"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user