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

@ -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)
@ -475,9 +475,7 @@ procSuite "WakuNode - RLN relay":
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
@ -486,8 +484,10 @@ procSuite "WakuNode - RLN relay":
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