-
Notifications
You must be signed in to change notification settings - Fork 212
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
fix: optimizer to keep track of changing opcode locations #6781
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aakoshh
changed the title
Fix optimizer to keep track of changing opcode locations
fix: optimizer to keep track of changing opcode locations
Dec 12, 2024
Peak Memory Sample
|
Compilation Sample
|
…/noir into fix-optimizer-opcode-locations
asterite
approved these changes
Dec 12, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
AztecBot
added a commit
to AztecProtocol/aztec-packages
that referenced
this pull request
Dec 13, 2024
…iant code motion (noir-lang/noir#6782) feat: add `(x | 1)` optimization for booleans (noir-lang/noir#6795) feat: `nargo test -q` (or `nargo test --format terse`) (noir-lang/noir#6776) fix: disable failure persistance in nargo test fuzzing (noir-lang/noir#6777) feat(cli): Verify `return` against ABI and `Prover.toml` (noir-lang/noir#6765) chore(ssa): Activate loop invariant code motion on ACIR functions (noir-lang/noir#6785) fix: use extension in docs link so it also works on GitHub (noir-lang/noir#6787) fix: optimizer to keep track of changing opcode locations (noir-lang/noir#6781) fix: Minimal change to avoid reverting entire PR #6685 (noir-lang/noir#6778)
AztecBot
added a commit
to AztecProtocol/aztec-packages
that referenced
this pull request
Dec 13, 2024
…tion (noir-lang/noir#6782) feat: add `(x | 1)` optimization for booleans (noir-lang/noir#6795) feat: `nargo test -q` (or `nargo test --format terse`) (noir-lang/noir#6776) fix: disable failure persistance in nargo test fuzzing (noir-lang/noir#6777) feat(cli): Verify `return` against ABI and `Prover.toml` (noir-lang/noir#6765) chore(ssa): Activate loop invariant code motion on ACIR functions (noir-lang/noir#6785) fix: use extension in docs link so it also works on GitHub (noir-lang/noir#6787) fix: optimizer to keep track of changing opcode locations (noir-lang/noir#6781) fix: Minimal change to avoid reverting entire PR #6685 (noir-lang/noir#6778)
This was referenced Dec 13, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Problem*
Resolves the issue found trying to merge AztecProtocol/aztec-packages#10483
Mirroring the commits added to that PR.
Summary*
Unlike
transform_internal
,optimize_internal
did not take anacir_opcode_positions
which would have allowed it to be chained. This caused the second iteration of the loop to resetacir_opcode_positions
to the default values, which indicated no change when theAcirTransformationMap
was derived from it. The consequence was that theassert_messages
anddebug
information did not align with the new opcode locations, which changed in the first iteration.Also changed
test_cmd
to apply thenargo::ops::transform
optimisations, so we get to see any problems introduced there come up in tests. This actually brought out this regression invecdequeue
test, where an unexpected assertion message was returned.Added an integration test to provoke the error fixed by the PR. In order for the ACIR not to eliminate all operations due to them working with constants known in the test code, I am calling it through the fuzzer, which makes the test look silly. To make it work required an update to the fuzz tester to anticipate tests that expect failures.
Additional Context
The way to debug this on
aztec-packages
went like this.First build everything with
./bootstrap.sh
, then in one terminal start an oracle:In another terminal run a test (one of the failing ones):
Then change something in the Noir codebase and recompile:
cd aztec-packages/noir ./bootstrap.sh
With
const MAX_OPTIMIZER_PASSES: usize = 1;
the test passed, otherwise failed. TheLOG_LEVEL=debug
showed the index of the failing opcode. Curiously it was the same in both tests (the oracle is expected to fail, the test verifies it fails with the right message).One of the things I tried was to print the ACIR opcodes with, with a change in the code so it prints the optimised version, after transformations:
Comparing the ACIR indicated that 1 or 3 passes doesn't make any difference. Since it was also the same opcode, I started to suspect that it is actually the assertion message that gets lost.
With this fix the contract tests pass.
Documentation*
Check one:
PR Checklist*
cargo fmt
on default settings.