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

codegen and proving fails on oob mem access with 10+ depth tree for compute_merkle_root #2667

Closed
n4ru opened this issue Sep 12, 2023 · 5 comments · Fixed by AztecProtocol/aztec-packages#6320
Labels
bug Something isn't working
Milestone

Comments

@n4ru
Copy link
Contributor

n4ru commented Sep 12, 2023

Aim

I am attempting to compute the root for a large merkle tree. Ideally, for near-arbitrary depths (2^32 or more). This needs to be done in-circuit.

Expected Behavior

A solidity verifier should be generated. The circuit should be provable with nargo, bb.js, or whatever library ends up being used in browsers.

Bug

     Error: Command failed: nargo codegen-verifier
Error: Trying to call acir_proofs_init_proving_key resulted in an error

Caused by:
   0: RuntimeError: out of bounds memory access
   0:     at <unnamed> (<module>[294]:0xae003)
   0:     at <unnamed> (<module>[1003]:0x37ce6b)
   1: heap_get_oob

When trying to generate a solidity verifier or proof using a circuit that runs compute_merkle_root and takes a hash_path for a tree that is too deep (in this case 10+ levels), it fails with the above error.

Since compute_merkle_root just does a bunch of pedersen hashes, this issue seems to occur whenever you nest a large amount of loops. The gate count in my misbehaving circuit is sub-150k, so it is not a gate issue.

I was told the issue is resolved in newer nargo builds, but not inside the wasm proving build. I explicitly need this to work inside a browser for production, which means it has to run inside the wasm build.

To Reproduce

  1. Use compute_merkle_tree on a big hashpath.
  2. Attempt to generate a Solidity verifier or attempt to prove the circuit.

Installation Method

None

Nargo Version

nargo 0.10.3 (git version hash: 2db759f, is dirty: false)

Additional Context

No response

Would you like to submit a PR for this Issue?

No

Support Needs

No response

@n4ru n4ru added the bug Something isn't working label Sep 12, 2023
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Sep 12, 2023
@Savio-Sou
Copy link
Collaborator

Savio-Sou commented Sep 13, 2023

Thanks for creating the issue!

I was told the issue is resolved in newer nargo builds, but not inside the wasm proving build. I explicitly need this to work inside a browser for production, which means it has to run inside the wasm build.

Just to clarify, were you generating the Solidity verifier with nargo codegen-verifier or through the noir_wasm JavaScript package?

(Or was the "wasm build" referring to the WASM-based Nargo releases?)

Would be very helpful if you could link to a code snippet for reproducing the issue too! 🙌

@n4ru
Copy link
Contributor Author

n4ru commented Sep 13, 2023

I am using nargo codegen-verifier and nargo prove on 0.10.3.

The code is simply any circuit with a compute_merkle_root call which takes a hash_path for a deep tree. Can post a minimally reproducible circuit/prover.toml in a bit.

@Savio-Sou
Copy link
Collaborator

Thanks!

To confirm nargo prove was failing as well? What was the error you were prompted with?

@Savio-Sou
Copy link
Collaborator

Savio-Sou commented May 17, 2024

With the #4960 initiative, nargo codegen-verifier and nargo prove would be deprecated. Proving backends (e.g. Barretenberg) would be providing such utilities directly.

If the Issue here exists still with latest Barretenberg versions, creating an Issue on https://github.com/AztecProtocol/barretenberg is recommended 🤝 thanks!

@n4ru
Copy link
Contributor Author

n4ru commented May 18, 2024

I believe at some point a few versions ago this issue was resolved. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants