AztecProtocol / noir-starter

MIT License
168 stars 40 forks source link

foundry-voting: improve devx of merkle tree recalculation #28

Closed sambarnes closed 1 year ago

sambarnes commented 1 year ago

Description

Problem*

In the foundry-voting example, a lot of the merkle tree related fields are hardcoded, and a solid chunk of the README is dedicated to walking through how a dev might go about recalculating them.

The commented out functions in the circuit were a good starting point, but still kinda clunky to change the whole set.

Summary*

This PR sets out to make it easier for a beginner to recalculate the merkle tree in a single command. While also demonstrating noir's testing functionality.

$ nargo test --show-output

Running 1 test functions...
Testing test_build_merkle_tree...
Merkle Tree:
0x20c77d6d51119d86868b3a37a64cd4510abd7bdb7f62a9e78e51fe8ca615a194
[0x0fcf7577aeb374ed0a19b942e0470521d46bde86f01d3138239ccc4b995c00ae, 0x1e8e7c1e1f6f65d0d3553e0f715c335f0ccdcc21cda1df7355e6c6e851bccf54]
[0x0ae5f55a6f2c82f74bba34d9e23c7cd69d41c183c8ddbd9a440ee3de5bf1c649, 0x1053e87bed5f2a4f5144b386c5403701212f4b3c21cb14683b6ebdfed16c854d, 0x1eff4379fbc748b53a07ce5961c24eccdfeb8f17154490d2e41c6096a9519329, 0x0e0adf2416341b3d868d88043127be8e6965f3758ce6a80d11a494fe21b0cdff]
ok
All tests passed

Feel free to close if ya don't think this is a worthwhile change! Just trying to help out the next noob after me :)

PR Checklist*

netlify[bot] commented 1 year ago

Deploy Preview for noir-next-hardhat canceled.

Name Link
Latest commit 0ab357ca82b9308fa0e564393c566f099f49bb46
Latest deploy log https://app.netlify.com/sites/noir-next-hardhat/deploys/647dff083bbaf10008c20ee6
critesjosh commented 1 year ago

this is a great addition, happy to merge. Thank you! :pray: