-
Notifications
You must be signed in to change notification settings - Fork 229
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
Passing by value into unconstrained function generates constraints #4244
Comments
Interesting, can you post the output if you compile with the |
Just showing the difference between the final SSA for insert_cheap:
insert_expensive:
|
The reason for the additional constraints is that in Meanwhile for There are a couple of issues in how we're compiling this program however.
If we fix the first bullet point then we'll end up with the program as so which should be optimal.
|
@TomAFrench I would like to validate whether the items you listed address the core of the problem. I have a more developed program where the constraint cost of performing reads/writes into the array scales with the size of the array - this should not happen and from what I can understand, the two points you listed would not cause that behaviour? |
@TomAFrench to explain in more detail - here is the full program I was writing when I encounter this bug: https://gist.github.com/zac-williamson/4bee81b912471395b4e3c9b6029bad81 The cost of the I would expect that increasing the size of the map would increase the number of constraints by a constant, but every |
Copying across from DMs:
This issue is stemming from the fact that we want to pass values in memory to the brillig VM however the only method we have to do this is by reading every single value out of memory and into the witness map which ends up creating a boatload of constraints. |
Aim
I have a Struct that contains arrays. I iterate over the arrays in an unconstrained function. Many constraints generated. Sad face.
Expected Behavior
6 constraints. Not 2000+
Bug
Passing by value into unconstrained fn should not generate constraints
To Reproduce
find_previous_key_location
withfind_previous_key_location_nocopy
Installation Method
Binary
Nargo Version
0.23.0
Additional Context
No response
Would you like to submit a PR for this Issue?
No
Support Needs
No response
The text was updated successfully, but these errors were encountered: