Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(rln-relay): clean up nullifier table every MaxEpochGap #1994

Merged
merged 1 commit into from
Sep 6, 2023

Conversation

rymnc
Copy link
Contributor

@rymnc rymnc commented Sep 6, 2023

Description

This PR clears the nullifier table every time there are more than MaxEpochGap epochs stored in it

Changes

  • Updated rln-relay validator to clear nullifier log on invocation
  • Added test

Issue

Addresses a part of #1906

@github-actions
Copy link

github-actions bot commented Sep 6, 2023

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:1994

@github-actions
Copy link

github-actions bot commented Sep 6, 2023

You can find the experimental image built from this PR at

quay.io/wakuorg/nwaku-pr:1994-experimental

@@ -1,23 +1,18 @@
{.used.}

import
std/[sequtils, tempfiles],
std/[tempfiles, sequtils],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't s before t in the alphabet?:D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

err, my bad - that change shouldn't be in the diff

@rymnc rymnc marked this pull request as ready for review September 6, 2023 07:07
Copy link
Member

@vpavlin vpavlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Contributor

@alrevuelta alrevuelta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm thanks! left a comment in case you find it relevant.

side questions:

  • so as it was before, we should have a memory leak? if the table was not being emptied, that should grow to infinity? just asking because i didnt saw the leak in the simulations.
  • what would be the napkin math on the worst case size of this table? I assume seq[ProofMetadata] can be as long as the max amount of memberships, since we would only store 1 proof per epoch per membership (if it sent a message). And then if we allow a diff between clocks of 20 seconds and 1 message every 1 second MaxEpochGap=20/1. Having 10k memberhips, is it fair to assume that we can have 10.000 * 20 entries at worse?

@@ -300,13 +299,26 @@ proc appendRLNProof*(rlnPeer: WakuRLNRelay,
msg.proof = proofGenRes.get().encode().buffer
return true

proc clearNullifierLog(rlnPeer: WakuRlnRelay) =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to understand it. what we really want to keep is the seq[ProofMetadata] of the epochs that are no older than MaxEpochGap right?

I mean, in your case you keep MaxEpochGap at max, no matter if they meet this condition. But we would be interested in:

for epoch in rlnPeer.nullifierLog.keys():
  if (epoch + MaxEpochGap) < now_epoch:
    rlnPeer.nullufierLog.del(epoch)

this doesn't require an OrderedTable (unsure if ordered tables impact performance).

not a blocker

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading the RFC for the external nullifiers which are stored in the nullifierLog I wonder if it's the case that they're a hash of an epoch, and not an epoch per se, so maybe that's why the approach from this PR was chosen instead, and the comparison against the current epoch is not possible

@rymnc
Copy link
Contributor Author

rymnc commented Sep 6, 2023

lgtm thanks! left a comment in case you find it relevant.

side questions:

  • so as it was before, we should have a memory leak? if the table was not being emptied, that should grow to infinity? just asking because i didnt saw the leak in the simulations.
  • what would be the napkin math on the worst case size of this table? I assume seq[ProofMetadata] can be as long as the max amount of memberships, since we would only store 1 proof per epoch per membership (if it sent a message). And then if we allow a diff between clocks of 20 seconds and 1 message every 1 second MaxEpochGap=20/1. Having 10k memberhips, is it fair to assume that we can have 10.000 * 20 entries at worse?

depends on how long were your simulations - but yes, it would've grown to infinity

@rymnc rymnc merged commit 483f40c into master Sep 6, 2023
14 checks passed
@rymnc rymnc deleted the clear-nullifier-table branch September 6, 2023 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants