Apply nph formatting

This commit is contained in:
stubbsta 2026-06-26 16:52:10 +02:00
parent 57032579e0
commit 6f5d993b0d
No known key found for this signature in database
11 changed files with 24 additions and 54 deletions

View File

@ -47,9 +47,7 @@ proc sendThruWaku*(
)
message.proof = (
await self.waku.node.rln.generateRLNProof(
message.toRLNSignal(), float64(time)
)
await self.waku.node.rln.generateRLNProof(message.toRLNSignal(), float64(time))
).valueOr:
return err("could not append rate limit proof to the message: " & error)

View File

@ -186,8 +186,7 @@ proc installRelayApiHandlers*(
logMessageInfo(node.wakuRelay, "rest", pubsubTopic, "none", message, onRecv = true)
# if we reach here its either a non-RLN message or a RLN message with a valid proof
info "Publishing message",
pubSubTopic = pubSubTopic, rln = not node.rln.isNil()
info "Publishing message", pubSubTopic = pubSubTopic, rln = not node.rln.isNil()
if not (waitFor node.publish(some(pubSubTopic), message).withTimeout(futTimeout)):
error "Failed to publish message to topic", pubSubTopic = pubSubTopic
return RestApiResponse.internalServerError("Failed to publish: timedout")

View File

@ -1,7 +1,3 @@
import
./rln/group_manager,
./rln/conversion_utils,
./rln/rln,
./rln/contract
import ./rln/group_manager, ./rln/conversion_utils, ./rln/rln, ./rln/contract
export group_manager, conversion_utils, rln, contract

View File

@ -234,9 +234,7 @@ proc mount(
proc(
msg: WakuMessage, senderEpochTime: float64
): Future[Result[RequestGenerateRlnProof, string]] {.async.} =
let proof = (
await rln.generateRLNProof(msg.toRLNSignal(), senderEpochTime)
).valueOr:
let proof = (await rln.generateRLNProof(msg.toRLNSignal(), senderEpochTime)).valueOr:
return err("Could not create RLN proof: " & error)
return ok(RequestGenerateRlnProof(proof: proof)),
@ -260,9 +258,7 @@ proc isReady*(rlnPeer: Rln): Future[bool] {.async.} =
return false
proc new*(
T: type Rln,
conf: WakuRlnConfig,
registrationHandler = none(RegistrationHandler),
T: type Rln, conf: WakuRlnConfig, registrationHandler = none(RegistrationHandler)
): Future[RlnResult[Rln]] {.async.} =
## Mounts the rln-relay protocol on the node.
## The rln-relay protocol can be mounted in two modes: on-chain and off-chain.

View File

@ -8,8 +8,7 @@ import
libp2p/crypto/crypto
import
logos_delivery/waku/
[waku_core, node/peer_manager, waku_node, waku_lightpush, rln],
logos_delivery/waku/[waku_core, node/peer_manager, waku_node, waku_lightpush, rln],
../testlib/[wakucore, wakunode, testasync, futures],
../resources/payloads,
../waku_rln_relay/[rln/waku_rln_relay_utils, utils_onchain]

View File

@ -142,8 +142,7 @@ suite "Waku RlnRelay - End to End - Static":
check:
server.wakuRelay == nil
server.rln == nil
catchRes.error()[].msg ==
"WakuRelay protocol is not mounted, cannot mount Rln"
catchRes.error()[].msg == "WakuRelay protocol is not mounted, cannot mount Rln"
asyncTest "Pubsub topics subscribed before mounting RlnRelay are added to it":
# Given the node enables Relay and Rln while subscribing to a pubsub topic
@ -279,22 +278,19 @@ suite "Waku RlnRelay - End to End - Static":
message1b.proof = (
await client.rln.generateRLNProof(
message1b.toRLNSignal(),
epoch + float64(client.rln.rlnEpochSizeSec * 0),
message1b.toRLNSignal(), epoch + float64(client.rln.rlnEpochSizeSec * 0)
)
).valueOr:
raiseAssert "generateRLNProof failed: " & error
message1kib.proof = (
await client.rln.generateRLNProof(
message1kib.toRLNSignal(),
epoch + float64(client.rln.rlnEpochSizeSec * 1),
message1kib.toRLNSignal(), epoch + float64(client.rln.rlnEpochSizeSec * 1)
)
).valueOr:
raiseAssert "generateRLNProof failed: " & error
message150kib.proof = (
await client.rln.generateRLNProof(
message150kib.toRLNSignal(),
epoch + float64(client.rln.rlnEpochSizeSec * 2),
message150kib.toRLNSignal(), epoch + float64(client.rln.rlnEpochSizeSec * 2)
)
).valueOr:
raiseAssert "generateRLNProof failed: " & error

View File

@ -3,8 +3,7 @@
import stint
import
logos_delivery/waku/[waku_keystore/protocol_types, rln, rln/protocol_types]
import logos_delivery/waku/[waku_keystore/protocol_types, rln, rln/protocol_types]
func fromStrToBytesLe*(v: string): seq[byte] =
try:

View File

@ -216,9 +216,7 @@ suite "Waku rln relay":
discard rln.updateLog(epoch, proofMetadata2)
# proof3 has the same nullifier as proof1 but different secret shares, it should be detected as duplicate
let isDuplicate3 = rln.hasDuplicate(
epoch, proof3.extractMetadata().tryGet()
).valueOr:
let isDuplicate3 = rln.hasDuplicate(epoch, proof3.extractMetadata().tryGet()).valueOr:
raiseAssert $error
# it is a duplicate
assert isDuplicate3, "duplicate should be found"

View File

@ -136,9 +136,7 @@ procSuite "WakuNode - RLN relay":
WakuMessage(payload: @payload, contentTopic: contentTopic, timestamp: now())
doAssert(
node1.rln
.unsafeAppendRLNProof(
message, node1.rln.getCurrentEpoch(), MessageId(0)
)
.unsafeAppendRLNProof(message, node1.rln.getCurrentEpoch(), MessageId(0))
.isOk()
)
@ -674,18 +672,14 @@ procSuite "WakuNode - RLN relay":
# Given all messages have an rln proof and are published by the node 1
let publishSleepDuration: Duration = 5000.millis
let epoch_1 = node1.rln.calcEpoch(epochTime().float64)
let epoch_2 = node1.rln.calcEpoch(
epochTime().float64 + node1.rln.rlnEpochSizeSec.float64 * 1
)
let epoch_3 = node1.rln.calcEpoch(
epochTime().float64 + node1.rln.rlnEpochSizeSec.float64 * 2
)
let epoch_4 = node1.rln.calcEpoch(
epochTime().float64 + node1.rln.rlnEpochSizeSec.float64 * 3
)
let epoch_5 = node1.rln.calcEpoch(
epochTime().float64 + node1.rln.rlnEpochSizeSec.float64 * 4
)
let epoch_2 =
node1.rln.calcEpoch(epochTime().float64 + node1.rln.rlnEpochSizeSec.float64 * 1)
let epoch_3 =
node1.rln.calcEpoch(epochTime().float64 + node1.rln.rlnEpochSizeSec.float64 * 2)
let epoch_4 =
node1.rln.calcEpoch(epochTime().float64 + node1.rln.rlnEpochSizeSec.float64 * 3)
let epoch_5 =
node1.rln.calcEpoch(epochTime().float64 + node1.rln.rlnEpochSizeSec.float64 * 4)
# Epoch 1
node1.rln.unsafeAppendRLNProof(wm1, epoch_1, MessageId(0)).isOkOr:

View File

@ -20,8 +20,7 @@ import
results
import
logos_delivery/waku/
[rln, rln/protocol_types, rln/constants, rln/bindings],
logos_delivery/waku/[rln, rln/protocol_types, rln/constants, rln/bindings],
../testlib/common
const CHAIN_ID* = 1234'u256

View File

@ -6,12 +6,8 @@ else:
import chronicles, results, std/[tempfiles, sequtils]
import
logos_delivery/waku/[
waku_keystore,
rln/bindings,
rln/conversion_utils,
rln/group_manager/on_chain,
]
logos_delivery/waku/
[waku_keystore, rln/bindings, rln/conversion_utils, rln/group_manager/on_chain]
logScope:
topics = "rln_keystore_generator"