-
Notifications
You must be signed in to change notification settings - Fork 60
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
Use Zerokit RLN module in nwaku #1030
Conversation
Tests failures are affected by zerokit RLN slow circuit loading, bringing total execution time to exceed 60 minutes: this issue is tracked in vacp2p/zerokit#23. |
Jenkins BuildsClick to see older builds (2)
|
Thanks @s1fr0 for the PR, that's great to see that zerokit is ready! 👍 |
@staheri14 Thank you Sanaz! Adding a compilation flag for zerokit RLN is not a problem, but rather the fact that APIs slightly differ and hence are not fully interchangeable. AFAIK, or either the two waku sources (interfacing, respectively, with Kilic's and zerokit's RLN libs) live in parallel and a compilation flag selects which one will be compiled (but lots of code will be duplicated), or we can have many |
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.
Nice one!
tests/v2/test_waku_rln_relay.nim
Outdated
# and run the following command in the root directory of the cloned project | ||
# cargo run --example export_test_keys | ||
# the file is generated separately and copied here | ||
parameters = readFile("waku/v2/protocol/waku_rln_relay/parameters.key") |
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.
How come this isn't needed anymore?
tests/v2/test_waku_rln_relay.nim
Outdated
@@ -371,7 +357,7 @@ suite "Waku rln relay": | |||
hashSuccess | |||
let outputArr = cast[ptr array[32, byte]](outputBuffer.`ptr`)[] | |||
check: | |||
"efb8ac39dc22eaf377fe85b405b99ba78dbc2f3f32494add4501741df946bd1d" == | |||
"4c6ea217404bd5f10e243bac29dc4f1ec36bf4a41caba7b4c8075c54abb3321e" == |
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.
Any idea why these are different? (Not saying they shouldn't be, just wondering if we understand reason)
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.
I guess the main reason is that Kilic's library is internally using Bn256, while in zerokit RLN I use circom's Bn254.
## index is the position of the id commitment key to be deleted from the tree | ||
## the deleted id commitment key is replaced with a zero leaf | ||
## the return bool value indicates the success or failure of the operation | ||
|
||
proc get_root*(ctx: RLN[Bn256], output_buffer: ptr Buffer): bool {.importc: "get_root".} | ||
proc get_root*(ctx: ptr RLN, output_buffer: ptr Buffer): bool {.importc: "get_root".} |
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.
How come this is difference?
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.
Current RLN object instantiation is not parametrized by the curve equation (it's hardcoded to Bn254), but this will likely change in the future. Passing the pointer rather than the object is much more efficient and makes more sense IMO since its instantiation and processing should be managed by the RLN library and the object should not be copied around by nim implementation (also the pointer is what is returned by the new_circuit call).
## get_root populates the passed pointer output_buffer with the current tree root | ||
## the output_buffer holds the Merkle tree root of size 32 bytes | ||
## the return bool value indicates the success or failure of the operation | ||
## | ||
|
||
proc get_merkle_proof*(ctx: ptr RLN, index: uint, output_buffer: ptr Buffer): bool {.importc: "get_proof".} |
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.
I'd probably keep this as qualified merkle proof, as "get proof" could be a ZK proof
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.
So is fine like this, or you mean changing the zerokit RLN api name to get_merkle_proof too?
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.
get_merkle_proof
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.
This nim wrapper is already named get_merkle_proof
and with this name the API is used internally in nwaku. If you mean to change zerokit RLN public API name, this has to be addressed with an issue in vacp2p/zerokit.
input_buffer: ptr Buffer, | ||
output_buffer: ptr Buffer): bool {.importc: "generate_rln_proof".} | ||
## input_buffer has to be serialized as [ id_key<32> | id_index<8> | epoch<32> | signal_len<8> | signal<var> ] | ||
## output_buffer holds the proof data and should be parsed as [ proof<128> | share_y<32> | nullifier<32> | root<32> | epoch<32> | share_x<32> | rln_identifier<32> ] |
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.
How come proof size is different?I find the order of share_/share_y/nullifier a bit odd, any particular reason for changing this order?
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.
Proof is 128 bytes since it's compressed: 254 bits for each X coordinate of the 3 proof points + 1 bit for the sign of the y coordinate = 32 bytes per coordinate x 4 coordinates (2x1 over G1, 1x2 over G2) = 128 bytes. Compressed proofs are the default returned by ark-circom create_random_proof_with_reduction and verify_proof, so to make the API the same I should have gone through a decompression and re-compression adding useless overhead. There is probably a way to directly process proofs in uncompressed form (to avoid square roots operation to recover the right y coordinate), but here we discussed how we can benchmark if this makes actually sense.
The comment is wrong with respect to the implementation: the current version is
[ proof<128> | root<32> | epoch<32> | share_x<32> | share_y<32> | nullifier<32> | rln_identifier<32> ]
The reason for such order of variables was in order to follow the order of the circuit's variables, cf. https://github.com/privacy-scaling-explorations/rln/blob/616ee9b0b085bdf14e7f39df884496b8e77ddc2f/circuits/rln.circom#L5 and https://github.com/privacy-scaling-explorations/rln/blob/616ee9b0b085bdf14e7f39df884496b8e77ddc2f/circuits/rln-base.circom#L60-L62. For serialization/deserialization purposes, this order makes more sense to me since this is the order parameters should be passed to the verify_proof function. However, ultimately, I didn't want to change too much nwaku code, so I ultimately decided the keep the previously implemented order and add rln_identifier at the end.
Can be easily changed though, since the zerokit witness structure abstracts the fields order: it is just a matter of redefining the serialization/deserialization order.
Comment updated in 80dddff
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.
Yay for compressed proofs!
@@ -55,6 +52,8 @@ type RateLimitProof* = object | |||
## nullifier enables linking two messages published during the same epoch | |||
## see details in https://hackmd.io/tMTLMYmTR5eynw2lwK9n1w?view#Nullifiers | |||
nullifier*: Nullifier | |||
## Application specific RLN Identifier | |||
rlnIdentifier*: RlnIdentifier |
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.
Good call, we should probably add this to RLN relay spec @staheri14
@@ -98,6 +97,9 @@ const | |||
ETH_CLIENT* = "ws://localhost:8540/" | |||
|
|||
const | |||
# The relative folder where the circuit, proving and verification key for RLN can be found | |||
# Note that resources has to be compiled with respect to the above MERKLE_TREE_DEPTH | |||
RLN_RESOURCE_FOLDER* = "vendor/zerokit/rln/resources/tree_height_" & $MERKLE_TREE_DEPTH & "/" |
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.
How come we need this now?
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.
In order to not have duplicates of the circuit in nwaku, I thought that it is better to point to zerokit resource folder directly. Since nwaku is calling zerokit API from a different path than the latter, the resource folders should be passed to correctly locate the circuit (i.e., this string cannot be hardcoded in zerokit)
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.
Hm, I don't know how exactly but I suspect this might fail when we do distribution. In general vendoring and static resources should be kept separate. Perhaps OK for initial integration where we compile stuff ourselves.
cc @jm-clius
@@ -362,6 +368,7 @@ proc encode*(nsp: RateLimitProof): ProtoBuffer = | |||
output.write3(4, nsp.shareX) | |||
output.write3(5, nsp.shareY) | |||
output.write3(6, nsp.nullifier) | |||
output.write3(7, nsp.rlnIdentifier) |
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.
Requires spec change I believe
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.
Tracking issue: vacp2p/rfc#523
|
||
return ok(output) | ||
|
||
proc serialize(proof: RateLimitProof, data: openArray[byte]): seq[byte] = | ||
## a private proc to convert RateLimitProof and data to a byte seq | ||
## this conversion is used in the proof verification proc | ||
## the order of serialization is based on https://github.com/kilic/rln/blob/7ac74183f8b69b399e3bc96c1ae8ab61c026dc43/src/public.rs#L205 | ||
## [ proof<256>| root<32>| epoch<32>| share_x<32>| share_y<32>| nullifier<32> | signal_len<8> | signal<var> ] | ||
## [ proof<128> | root<32> | epoch<32> | share_x<32> | share_y<32> | nullifier<32> | rln_identifier<32> | signal_len<8> | signal<var> ] | ||
let lenPrefMsg = appendLength(@data) | ||
var proofBytes = concat(@(proof.proof), | ||
@(proof.merkleRoot), | ||
@(proof.epoch), | ||
@(proof.shareX), |
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.
This order of share x / y / nullifier makes more sense to me
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.
@jm-clius re gracefully integrating this option Switching between:
Once we know Zerokit RLN works correctly and with OK perf we can replace kilic version |
if (pbytes.len == 0): | ||
debug "error in parameters.key" | ||
return err("error in parameters.key") | ||
resourcesPathBuffer = RLN_RESOURCE_FOLDER.toOpenArrayByte(0, RLN_RESOURCE_FOLDER.high).toBuffer() |
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.
I'd do error handling on this, assume rln resource folder can't be found / is null
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.
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.
This LGTM, but I assume that, as discussed during offsite, you want to maintain both Kilic and Zerokit implementations until after the testnet? My suggestion would be to simply split the relevant RLN modules into the "old" implementation and the "new" implementation using compiler definitions (when defined...
). Should be a simple copy-paste operation - the result will be ugly, but we can mitigate it a bit by clearly separating the two implementations per module using comments/dividers. Hopefully this dual-impl will live only for a short time!
tests/v2/test_wakunode.nim
Outdated
check: | ||
(await completionFut.withTimeout(10.seconds)) == true | ||
(await completionFut.withTimeout(200.seconds)) == true |
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.
Just double checking that 200
is indeed necessary. :) Any idea what the usual successful loading time is, more or less? I know the circom loading takes a long time, but waiting > 3 mins for the test to fail could be frustrating during regular CI.
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 necessary anymore with zerokit rln perfomance fixes.
As commented above, I think separating affected modules between "old" and "new" implementations using compiler definitions seem the fastest, easiest-to-maintain option to me. Only if it's short-lived, of course. :D |
@jm-clius @oskarth @staheri14 what would be the default for CI then? If Kilic's RLN, zerokit integration does not get automatically tested; if, instead, by default we set zerokit, then this might create problems in next stages of RLN testing. For this reason I think the best would be to have a subfolder In this way both implementations can be tested independently. |
@staheri14 would you able to review this PR? It has been awaiting your review for a while now I believe. (I requested a review from Ksr for general code integration, assuming Hanno/Lorenzo won't be back soon) |
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 from an integration point of view. I do not have enough background to give feedback / evaluate details.
Some parts are raw, but as the comments suggest, this will be addressed once the move to zerokit has been completed.
contract(MembershipContract): | ||
proc register(pubkey: Uint256) # external payable | ||
proc MemberRegistered(pubkey: Uint256, index: Uint256) {.event.} | ||
# proc registerBatch(pubkeys: seq[Uint256]) # external payable |
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.
Will these be implemented later?
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.
Thanks! This is a question for @staheri14. I just made test_waku_rln_onchain.nim
to load and correctly process zerokit RLN wrappers.
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.
Yes, but right now, there is no actual use case for them.
Based on the conversation, I was under the impression that the PR is still in progress. Doing review now. |
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.
I left my comments, the major issue is with all the files duplicated from the original rln-relay module which is unnecessary. The only thing that needs to be duplicated (if any) is the rln.lib which contains the binding for a different c lib.
contract(MembershipContract): | ||
proc register(pubkey: Uint256) # external payable | ||
proc MemberRegistered(pubkey: Uint256, index: Uint256) {.event.} | ||
# proc registerBatch(pubkeys: seq[Uint256]) # external payable |
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.
Yes, but right now, there is no actual use case for them.
@@ -790,7 +790,6 @@ procSuite "WakuNode": | |||
await node1.publish(rlnRelayPubSubTopic, message) | |||
await sleepAsync(2000.millis) | |||
|
|||
|
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.
I think this line is removed unintentionally.
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.
The previous extra line doesn't seem to be consistent with the remaining tests.
## TODO: properly address these import once zerokit rln is merged | ||
when defined(rln) or (not defined(rln) and not defined(rlnzerokit)): | ||
import ../protocol/waku_rln_relay/waku_rln_relay_types | ||
|
||
when defined(rlnzerokit): | ||
import ../protocol/waku_rln_relay/rlnzerokit/waku_rln_relay_types | ||
|
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.
## TODO: properly address these import once zerokit rln is merged | |
when defined(rln) or (not defined(rln) and not defined(rlnzerokit)): | |
import ../protocol/waku_rln_relay/waku_rln_relay_types | |
when defined(rlnzerokit): | |
import ../protocol/waku_rln_relay/rlnzerokit/waku_rln_relay_types | |
## TODO: properly address these import once zerokit rln is merged | |
when defined(rln): | |
import ../protocol/waku_rln_relay/waku_rln_relay_types | |
else: | |
when defined(rlnzerokit): | |
import ../protocol/waku_rln_relay/rlnzerokit/waku_rln_relay_types | |
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.
Such separation is not needed when the same file is used.
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.
This won't work, since for example if neither RLN=true
or RLNZEROKIT=true
is set, then https://github.com/status-im/nwaku/blob/311fc253b4074b5c17bc2056b29d6e1d8f32a20e/waku/v2/node/config.nim#L126 would not be defined.
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.
Once we remove duplicate waku-rln-relay-types.nim files, then there is no need for conditional import.
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.
See #1030 (comment)
## TODO: properly address these import once zerokit rln is merged | ||
when defined(rln) or (not defined(rln) and not defined(rlnzerokit)): | ||
import ../protocol/waku_rln_relay/waku_rln_relay_types | ||
|
||
when defined(rlnzerokit): | ||
import ../protocol/waku_rln_relay/rlnzerokit/waku_rln_relay_types |
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.
## TODO: properly address these import once zerokit rln is merged | |
when defined(rln) or (not defined(rln) and not defined(rlnzerokit)): | |
import ../protocol/waku_rln_relay/waku_rln_relay_types | |
when defined(rlnzerokit): | |
import ../protocol/waku_rln_relay/rlnzerokit/waku_rln_relay_types | |
## TODO: properly address these import once zerokit rln is merged | |
when defined(rln): | |
import ../protocol/waku_rln_relay/waku_rln_relay_types | |
else: | |
when defined(rlnzerokit): | |
import ../protocol/waku_rln_relay/rlnzerokit/waku_rln_relay_types |
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.
Such separation is not needed when the same file is used.
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.
This won't work, since for example if neither RLN=true
or RLNZEROKIT=true
is set, then https://github.com/status-im/nwaku/blob/311fc253b4074b5c17bc2056b29d6e1d8f32a20e/waku/v2/node/wakunode2_types.nim#L44 would not be defined.
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.
Once we remove duplicate waku-rln-relay-types.nim files, then there is no need for conditional import.
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.
waku-rln-relay-types.nim
and rlnzerokit/waku-rln-relay-types.nim
are not the same file
## TODO: properly address these import once zerokit rln is merged | ||
when defined(rln) or (not defined(rln) and not defined(rlnzerokit)): | ||
import waku_rln_relay/waku_rln_relay_types | ||
|
||
when defined(rlnzerokit): | ||
import waku_rln_relay/rlnzerokit/waku_rln_relay_types | ||
|
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.
## TODO: properly address these import once zerokit rln is merged | |
when defined(rln) or (not defined(rln) and not defined(rlnzerokit)): | |
import waku_rln_relay/waku_rln_relay_types | |
when defined(rlnzerokit): | |
import waku_rln_relay/rlnzerokit/waku_rln_relay_types | |
```suggestion | |
## TODO: properly address these import once zerokit rln is merged | |
when defined(rln): | |
import ../protocol/waku_rln_relay/waku_rln_relay_types | |
else: | |
when defined(rlnzerokit): | |
import ../protocol/waku_rln_relay/rlnzerokit/waku_rln_relay_types |
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.
Such separation is not needed when the same file is used.
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.
This won't work, since for example if neither RLN=true
or RLNZEROKIT=true
is set, then https://github.com/status-im/nwaku/blob/311fc253b4074b5c17bc2056b29d6e1d8f32a20e/waku/v2/protocol/waku_message.nim#L40 would not be defined.
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.
Ditto, Once we remove duplicate waku-rln-relay-types.nim files, then there is no need for conditional import.
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.
See #1030 (comment)
@@ -0,0 +1,107 @@ | |||
# src: https://github.com/kilic/rlnapp/blob/master/packages/contracts/contracts/RLN.sol |
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.
Why do we have a new file for the contract?
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.
This is not really necessary, but the reasoning behind is described in #1030
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.
Please see #1030 (comment)
@@ -0,0 +1,376 @@ | |||
when defined(rlnzerokit): |
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.
Why do we have a new file for the rln_relay_types?
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.
As for utils, there are minor differences such us rlnInstance is a pointer to RLN, here there is rlnIdentifier, etc.
Having a separate/standalone folder, even with mostly duplicated code, will make easy to just move/replace these files with current ones in order to replace kilic's RLN library.
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.
see #1030 (comment)
@@ -0,0 +1,841 @@ | |||
{.push raises: [Defect].} |
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.
There is no need for a duplicate of waku_rln_relay_utils, you can use the existing one
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.
There are minor differences, e.g. not using Bn256, rlnInstance is a pointer to RLN, new_circuit doesn't use parameters.key, etc.
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.
The RLN construct definition should be moved to the rln.nim module and then all the imports of rln.nim module should be managed under a compiler flag.
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.
As mentioned before, there are unnecessary duplicates of the original waku_rln_relay
module which should be removed. This can be addressed by moving the RLN construct definition to the rln.nim
module and then managing all the imports of rln.nim
module under a compiler flag.
@staheri14 This would not suffice and nonetheless differs from current implementation. Even by moving the new RLN object definition in rln.nim, there are many differences that would require as many |
@s1fr0 |
@staheri14 This PR is based on (my understanding of) the discussion we had here and during the offisite on how to address such integration, and on the assumption that it should result as a temporary fix that can later allow easy removal of Kilic's RLN module. Note that the original goal was to make both Kilic and Zerokit RLN modules be tested one after each other by CI, which partially explains why there are duplicate files in separate folders (essentially because if something is defined alternatively with a kilic/zerokit I agree with and I was aware of all the downsides you mentioned. Indeed, I'm the first one to not like this solution: in my opinion, we should either complete the RLN testing phase using Kilic's RLN module and then integrate zerokit RLN (and probably partially repeat some tests), or switch to zerokit RLN (as soon as reaches some agreed level of maturity) and then start with the testnet. No problem in refactoring this PR so that we don't duplicate files but we have |
From what I can tell the PR has been waiting for reviews since here #1030 (comment)
Agree, this was discussed during the offsite and this is a short-lived change. The only reason not to replace it completely in PR was to not delay the testnet with existing kilic implementation as you suggested @staheri14.
While this is generally true, there are good exceptions.
What are the minimal changes, if any, we can make to this PR to meet the following objectives?
|
We also need an issue toggling on this version of Zerokit by default, and some acceptance criteria such as
The sooner we make the shift the better |
Having all this said, if this is the group's decision, although I disagree, I'll commit to it. |
The commits are still there. It is true it makes it slightly more annoying if you are trying to do
That's fair, but I'd expect:
That's a fair point. I don't have any super strong opinions here and think it is largely an implementation detail, and there are pros and cons for both. When we discussed this during the offsite, I believe the consensus was that a "flatter" compiler flag in one place was less error-prone. This especially true for temporary changes, compared to if we expected the two implementations to run concurrently for an extended period of time, in which case I'd agree with you that the "diff" should be kept to a minimum. Additionally, I believe @jm-clius was also in favor of this flatter approach in terms of integration risk, and as the main code owner of nwaku and I believe this should have extra weight in terms of reducing integration risk (see two questions points) which is important in software engineering and code change management. All that said, if after understanding the above reasoning, you @staheri14 and @s1fr0 have a strong preference for the more granular compiler flag then go for it. I'd rather we work as a team towards the same place here rather than dismissing review. The main thing is that @jm-clius or @LNSD (since Hanno is out) is OK with this approach. |
Honestly, I never had any strong preference for either methods. I implemented this PR since it appeared to me to be the method on which we found some kind of traversal consensus.
This is not necessary and definitely something I would care about: I would copy/paste the zerokit files over the current files in master and resolve conflicts so that changes result as incremental and the commits history remains intact.
This could happen as well with inline compilation flags. However, as long as we don't reach consensus on this and more commits are merged to master, I need to keep updated this and others PRs (and their double kilic/rln versions): this is not always straightforward since with indents/flags/multiple files is not easy to see the diffs quickly.
Definitely not straightforward. As I said multiple times, the differences are not only in few proc definitions, but are many. Also, requiring to align completely the zerokit APIs to Kilic's RLN module, would invalidate some design choices we discussed in zerokit (e.g., delegate everything by using pointers and not touch at all the RLN object in nim/C, hardcode for now the Elliptic curve). However I'd like a bit more pragmatic on this: i pushed the PR #1060 (in alternative to this) implementing the inline compilation flags approach.
Now that #1060 is ready, we can decide better which approach is more appropriate for the integration of zerokit RLN. As I said above, to avoid maintaining the PRs' branches for long with the changes in master, let's just try to agree as soon as we can on one between #1030 and #1060. |
I am ok with both approaches. My concern is that we need to merge these changes as soon as possible to avoid more conflict headaches for @s1fr0. As I commented in @kgrgpg PR, after this month's release, I would like to allocate some time to review the current RLN code. The current nim file division (utils, types, and main module) is causing some problems (e.g. merge/rebase conflicts, cycling imports, etc.) that could be solved with a better code "layout" 😁 |
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.
@oskarth and @s1fr0 Thanks for your comments and clarification, with your suggested solutions regarding the debugging and commit history, I am convinced that we can merge this PR.
@s1fr0 Thanks for opening the other PR, this is exactly what I meant (almost), merge whichever that you think is easier for you.
At the end, we decided to merge the alternative implementation with inline compilation flags from #1060. I then close this PR. |
This PR replaces Kilic's RLN implementation with Zerokit RLN module in nwaku.
Minor changes to the nim wrappers were required, as well us update of constants in tests.
EDIT: we decided to have a compilation flag to switch between the two RLN implementation, at least until RLN-Relay gets extensively tested. Note that Zerokit RLN implementation and the nwaku wrappers/tests contained in this PR implement the application-specific
rlnIdentifier
as described in 17/WAKU2-RLNRELAY, while current master does not (and suchrlnIdentifier
logic is not executed when Kilic's RLN module is selected at compilation time).