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

Can't assert() two arrays when contract compiled via aztec-cli compile #3752

Closed
michaelelliot opened this issue Dec 20, 2023 · 1 comment · Fixed by noir-lang/noir#3936
Closed

Comments

@michaelelliot
Copy link
Contributor

When compiling a simple contract that does an assert(a == b) on two arrays the wasm compiler complains:

$ aztec-cli compile .
Compiling . with wasm backend...
panicked at 'internal error: entered unreachable code: Arrays are invalid in binary operations', compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs:1340:13

Stack:

Error
    at module.exports.__wbg_new_abda76e883ba8a5f (/usr/src/noir/packages/noir_wasm/nodejs/noir_wasm.js:308:17)
    at console_error_panic_hook::hook::h0dc62071592e511d (wasm://wasm/0250a666:wasm-function[2915]:0x684633)
    at core::ops::function::Fn::call::ha4bfd2d1114566d9 (wasm://wasm/0250a666:wasm-function[7449]:0x74ec17)
    at wasm://wasm/0250a666:wasm-function[4741]:0x717375
    at wasm://wasm/0250a666:wasm-function[5151]:0x72a5ba
    at wasm://wasm/0250a666:wasm-function[7443]:0x74ebe4
    at wasm://wasm/0250a666:wasm-function[5859]:0x73f0f2
    at wasm://wasm/0250a666:wasm-function[6266]:0x746aa9
    at noirc_evaluator::brillig::brillig_gen::brillig_block::BrilligBlock::convert_ssa_binary::h6340c18ff460e390 (wasm://wasm/0250a666:wasm-function[1304]:0x545126)
    at noirc_evaluator::brillig::brillig_gen::brillig_block::BrilligBlock::convert_block::h59d45d2728348b39 (wasm://wasm/0250a666:wasm-function[28]:0x6dacf)

Error in command execution
RuntimeError: unreachable
    at wasm://wasm/0250a666:wasm-function[7570]:0x74efcd
    at wasm://wasm/0250a666:wasm-function[7038]:0x74d87b
    at wasm://wasm/0250a666:wasm-function[4741]:0x7173a5
    at wasm://wasm/0250a666:wasm-function[5151]:0x72a5ba
    at wasm://wasm/0250a666:wasm-function[7443]:0x74ebe4
    at wasm://wasm/0250a666:wasm-function[5859]:0x73f0f2
    at wasm://wasm/0250a666:wasm-function[6266]:0x746aa9
    at noirc_evaluator::brillig::brillig_gen::brillig_block::BrilligBlock::convert_ssa_binary::h6340c18ff460e390 (wasm://wasm/0250a666:wasm-function[1304]:0x545126)
    at noirc_evaluator::brillig::brillig_gen::brillig_block::BrilligBlock::convert_block::h59d45d2728348b39 (wasm://wasm/0250a666:wasm-function[28]:0x6dacf)
    at noirc_evaluator::brillig::brillig_gen::brillig_block::BrilligBlock::compile::h198848e02911a014 (wasm://wasm/0250a666:wasm-function[1150]:0x50d228)

Contract:

contract TestingArrayAssert {
    #[aztec(public)]
    fn test_array_assert(a: [u8; 2], b: [u8; 2]) {
        assert(a == b);
    }
}

Using the latest sandbox and CLI images:

aztecprotocol/cli:latest	    sha256:67325eebfb212404b2660e6d81e79958a08ae1e9f99404574450610f89093e98
aztecprotocol/aztec-sandbox:latest  sha256:7603842a4a3bf1b53bb5e439f754353cc6134fd15bdd5bc35af6c07a928af0a7
$ aztec-cli -V
0.16.9
@rahul-kothari
Copy link
Contributor

rahul-kothari commented Jan 3, 2024

Thanks for flagging this - it is a bug which is fixed in noir-lang/noir#3916

This can be worked around using

let predicate = a == b;
assert(predicate)

until the fix is included in a release!

github-merge-queue bot pushed a commit to noir-lang/noir that referenced this issue Jan 3, 2024
# Description

## Problem\*

Resolves AztecProtocol/aztec-packages#3752

## Summary\*

This PR adds a regression test for
AztecProtocol/aztec-packages#3752 which was
fixed in #3916.

## Additional Context

## Documentation\*

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[Exceptional Case]** Documentation to be submitted in a separate
PR.

# PR Checklist\*

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
@github-project-automation github-project-automation bot moved this from Todo to Done in A3 Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants