-
Notifications
You must be signed in to change notification settings - Fork 0
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
Onchain RLN tree+root: Proof Of Concept #72
Comments
was great working w/ you on this! thanks for the detailed report 🔥 |
Great work, @alrevuelta @rymnc. Very good input and POC to have. |
closing since this has already been researched, implemented and delivered to TheWakuNetwork see: |
tldr: We present a change in the RLN contract to store the whole membership tree on-chain + its Merkle root. This lowers sync time from several minutes to a few seconds, but at a cost of x10 the membership insertion cost. It also makes light clients lighter since proof verification becomes stateless (Merkle root can be accessed onchain, without having to sync the tree). We also present go-waku-light, to showcase the newly introduced features and how they are meant to be used.
Thanks to @rymnc for developing the contract changes and his support with the deployments.
This issue aims to solve the problem of using RLN in resource-restricted devices (aka light clients) stated in #45 with the approach proposed in #56. We propose a proof of concept that solves it, introducing:
Note: This is a proof of concept, and it's yet to decide if we will integrate this into The Waku Network.
The pros:
nwaku
+ there is no need to make any modifications. A client can opt to sync with events (current approach) or via the RPC call to get the leaves (new approach). Of course, the new approach is recomended.The cons:
80k
to700k
.The goal:
js-waku
to become more RLN user friendly.Gas Fees and Layer2
In this proof of concept, we use BinaryIMT (binary incremental Merkle tree) to store both leafs and Merkle root of the tree on chain. While this benefits light clients, it comes at a cost. Membership insertion (adding a new RLN member into the tree) is more expensive in terms of gas. We have deployed two contracts to see the delta.
80k
gas.700k
gas.In Ethereum mainnet, that would be (using 40Gwei as gas price and 1ETH=$2000 ref):
$6.4
$56
In a Layer 2 such as Polygon zkEVM that would be (using 4Gwei and 1ETH=$2000 ref):
$0.64
$5.6
Important notes:
Important takes:
Regarding Layer 2s:
Proof of Concept Playground
We have developed go-waku-light, a proof of concept of a waku light client built in go that interacts with this contract deployed in the Polygon zkEVM containing the changes explained in this issue.
The goal of this tool is to serve as a playground and show the capabilities of this proof of concept. It abstracts away all waku full node capabilities and just focuses on what a light client should know in order to send (generate rln proofs) and received (verify rln proofs) messages.
It allows to easily sync a tree, access the onchain merkle root, register a new membership, generate a proof, verify a proof and listen for changes in the membership set. See instructions inside the repo.
Future work
If we decide to integrate this in The Waku Network, we should:
go-waku-light
injs-waku
nwaku
/go-waku
. Not mandatory since backwards compatibility is kept, but more efficient.The text was updated successfully, but these errors were encountered: