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

Trait inequality test fails for bounded vectors #6340

Closed
aakoshh opened this issue Oct 24, 2024 · 1 comment
Closed

Trait inequality test fails for bounded vectors #6340

aakoshh opened this issue Oct 24, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@aakoshh
Copy link
Contributor

aakoshh commented Oct 24, 2024

Aim

Tried running the stdlib tests with Brillig to see if it makes any difference.

Expected Behavior

All tests should pass.

Bug

collections::bounded_vec::bounded_vec_tests::trait_eq::inequality fails when executed with Brillig.

To Reproduce

  1. Change this line into &CompileOptions { force_brillig: true, ..Default::default() },
  2. Execute cargo test -p nargo_cli --test stdlib-tests -- run_stdlib_tests trait_eq::inequality

The output is:

cargo test -p nargo_cli --test stdlib-tests -- run_stdlib_tests trait_eq::inequality
    Finished test [optimized + debuginfo] target(s) in 0.16s
     Running tests/stdlib-tests.rs (target/debug/deps/stdlib_tests-6b25c223cdb4acdb)

running 1 test
[stdlib] Testing collections::bounded_vec::bounded_vec_tests::trait_eq::inequality... FAIL
Failed to solve program: 'Failed to solve brillig function'

error: Failed to solve program: 'Failed to solve brillig function'
    ┌─ std/collections/bounded_vec.nr:598:20

598 │             assert(bounded_vec1 != bounded_vec2);
    │                    ----------------------------

    = Call stack:
      1. std/collections/bounded_vec.nr:598:20

[stdlib] 1 test failed
test run_stdlib_tests ... FAILED

failures:

---- run_stdlib_tests stdout ----
thread 'run_stdlib_tests' panicked at tooling/nargo_cli/tests/stdlib-tests.rs:91:5:
assertion failed: test_report.iter().all(|(_, status)| !status.failed())
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    run_stdlib_tests

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.09s

error: test failed, to rerun pass `-p nargo_cli --test stdlib-tests`

Workaround

None

Workaround Description

No response

Additional Context

Print the state of the vectors

Printing the value of the vectors, after pushing the value 3 to bounded_vec2 shows that in the tests they seem to be backed by the same storage:

vec1: BoundedVec { storage: [0x02, 0x03, 0x00], len: 1 }
vec2: BoundedVec { storage: [0x02, 0x03, 0x00], len: 2 }

Interestingly removing either pushes leaves the other vector untouched. Overwriting the the other vector only happens if both pushes are present; the last one wins.

Test with Brillig

We should have two tests: add a force_brillig: bool parameter to run_stdlib_tests and call it with true and false from two different #[test] functions.

Done in #6352

Run with CLI

During investigation Tom noticed that if we extract the test into a main.nr and run it with cargo run -p nargo_cli execute --force-brillig then the assertion passes. The only difference in the CompileOptions is that on the CLI inliner_aggressiveness is set to i64::MAX.

Indeed setting this to be the same in the stdlib-tests.rs solves the issue!

Project Impact

None

Blocker Context

No response

Nargo Version

nargo version = 0.36.0 noirc version = 0.36.0+2f0cb3e80f3d93a1dee77fffacc397811e300257 (git version hash: 2f0cb3e, is dirty: false)

NoirJS Version

No response

Proving Backend Tooling & Version

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

@aakoshh
Copy link
Contributor Author

aakoshh commented Oct 25, 2024

Fixed in #6355

@aakoshh aakoshh closed this as completed Oct 25, 2024
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Oct 25, 2024
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

No branches or pull requests

1 participant