-
Notifications
You must be signed in to change notification settings - Fork 57
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
fix(rln-relay): make nullifier log abide by epoch ordering #2508
Conversation
You can find the image built from this PR at
Built from a06cd42 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a test to protect the code from future modifications and understand that
This could lead to a node only accepting one valid message sent during an epoch e, and reject all other messages sent during epoch e.
can indeed happen?
# check if the epoch exists | ||
if not rlnPeer.nullifierLog.hasKey(externalNullifier): | ||
let nullifier = proofMetadata.nullifier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe all this can be replace by something like (disregard types). getOrDefault
might be useful.
return defaultTable.getOrDefault("epoch1", initTable[string, int]()).hasKey("key1")
A quick example would be something like this.
import tables
var defaultTable: Table[string, Table[string, int]] = {"epoch1":{"key1": 3, "key2": 3}.toTable,
"epoch2": {"key3": 3, "key4": 3}.toTable}.toTable
echo defaultTable.getOrDefault("epoch1", initTable[string, int]()).hasKey("key1")
# true
echo defaultTable.getOrDefault("epoch1", initTable[string, int]()).hasKey("key200")
# false
echo defaultTable.getOrDefault("epoch5", initTable[string, int]()).hasKey("key1")
# false
just an idea though, at your discretion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed in 6d20aef
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure thats addressed there. in any case not blocking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't actually need to get the value from the nullifierLog table, just check if it exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Just minor comments on the surface
# check if the epoch exists | ||
if not rlnPeer.nullifierLog.hasKey(externalNullifier): | ||
let nullifier = proofMetadata.nullifier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure thats addressed there. in any case not blocking.
Co-authored-by: Ivan FB <128452529+Ivansete-status@users.noreply.github.com>
378100a
to
c8bc4a6
Compare
Description
Instead of using theepoch
as the key for the nullifierLog,externalNullifier
was being used. This could lead to a node only accepting one valid message sent during an epoche
, and reject all other messages sent during epoche
.Made the NullifierLog properly map from Epoch to Nullifiers instead of ExternalNullifier to ProofMetadata.
Optimized by nesting the hashmap to locate duplicates faster instead of searching an array.
Changes
OrderedTable[Epoch, Table[Nullifier, ProofMetadata]]