snarkVM
snarkVM copied to clipboard
[Feat]: Add an 'in' instruction in the VM.
Motivation
for this issue in leo https://github.com/ProvableHQ/leo/issues/28721
This PR adds a new 'in' instruction support at the synthesizer level. Without this developers would have to do a verbose unroll of the entire array and also instruction costs would increase for contracts for multiple checks, so this saves that.
Some notes:
- The tests currently only checks for single dimensional literal arrays as for multi dimensional arrays and struct struct arrays, it would require a slight different infrastructure then the rest of the tests. But also there's no reason implementation won't work for all kinds of arrays.
- Maybe the cost function can be optimized more, for e.g. rather than a constant, some heuristic approximation or maybe even linear multiple of the recursive array length, considering all the the inner members in structs etc.
If this PR is approved, I would also add the support in leo as well.
Test Plan
Added new tests