fix: make rln rate limit spec compliant (#2294)

This commit is contained in:
Alvaro Revuelta 2023-12-15 10:26:17 +01:00 committed by GitHub
parent 0fc617ff69
commit 5847f49d3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View File

@ -398,7 +398,7 @@ procSuite "WakuNode - RLN relay":
await node3.stop()
asyncTest "clearNullifierLog: should clear epochs > MaxEpochGap":
let
# publisher node
nodeKey1 = generateSecp256k1Key()
@ -445,7 +445,7 @@ procSuite "WakuNode - RLN relay":
proofAdded1 = node1.wakuRlnRelay.appendRLNProof(wm1, time)
# another message in the same epoch as wm1, it will break the messaging rate limit
wm2 = WakuMessage(payload: "message 2".toBytes(), contentTopic: contentTopic)
proofAdded2 = node1.wakuRlnRelay.appendRLNProof(wm2, time + EpochUnitSeconds)
proofAdded2 = node1.wakuRlnRelay.appendRLNProof(wm2, time)
# wm3 points to the next epoch
wm3 = WakuMessage(payload: "message 3".toBytes(), contentTopic: contentTopic)
proofAdded3 = node1.wakuRlnRelay.appendRLNProof(wm3, time + EpochUnitSeconds * 2)
@ -455,7 +455,7 @@ procSuite "WakuNode - RLN relay":
proofAdded1
proofAdded2
proofAdded3
# relay handler for node2
var completionFut1 = newFuture[bool]()
var completionFut2 = newFuture[bool]()
@ -469,25 +469,25 @@ procSuite "WakuNode - RLN relay":
completionFut2.complete(true)
if msg == wm3:
completionFut3.complete(true)
# mount the relay handler for node2
node2.subscribe((kind: PubsubSub, topic: DefaultPubsubTopic), some(relayHandler))
await sleepAsync(2000.millis)
await node1.publish(some(DefaultPubsubTopic), wm1)
await sleepAsync(10.seconds)
await node1.publish(some(DefaultPubsubTopic), wm2)
await sleepAsync(10.seconds)
await node1.publish(some(DefaultPubsubTopic), wm3)
let
res1 = await completionFut1.withTimeout(10.seconds)
res2 = await completionFut2.withTimeout(10.seconds)
res3 = await completionFut3.withTimeout(10.seconds)
check:
(res1 and res2 and res3) == true # all 3 are valid
node2.wakuRlnRelay.nullifierLog.len() == 1 # after clearing, only 1 is stored
res1 == true
res2 == false
res3 == true
node2.wakuRlnRelay.nullifierLog.len() == 2
await node1.stop()
await node2.stop()

View File

@ -47,7 +47,7 @@ const
# the root is created locally, using createMembershipList proc from waku_rln_relay_utils module, and the result is hardcoded in here
StaticGroupMerkleRoot* = "1e534adab58f7d300aaeecae57a25e0a0b18c368a09f720280da92b288950901"
const EpochUnitSeconds* = float64(10) # the rln-relay epoch length in seconds
const EpochUnitSeconds* = float64(1) # the rln-relay epoch length in seconds
const MaxClockGapSeconds* = 20.0 # the maximum clock difference between peers in seconds
# maximum allowed gap between the epochs of messages' RateLimitProofs