-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: disable side-effects for no_predicates functions (#6027)
# Description ## Problem\* Brillig output is nullified if the call is with a predicate, however, functions with no_predicates attribute expect valid values from their brillig calls because when they constrain the values , it will not have a predicate. Resolves e-2-e test failing on PR AztecProtocol/aztec-packages#4571 ## Summary\* Disable side-effects when calling a function with no_predicates ## Additional Context The dedicated inlining pass for no_predicates functions can be removed after this fix. ## Documentation\* Check one: - [X] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** 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.
- Loading branch information
Showing
4 changed files
with
77 additions
and
8 deletions.
There are no files selected for viewing
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
5 changes: 5 additions & 0 deletions
5
test_programs/execution_success/regression_unsafe_no_predicates/Nargo.toml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[package] | ||
name = "regression_unsafe_no_predicates" | ||
type = "bin" | ||
authors = [""] | ||
[dependencies] |
2 changes: 2 additions & 0 deletions
2
test_programs/execution_success/regression_unsafe_no_predicates/Prover.toml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
x = 239 | ||
nest = false |
25 changes: 25 additions & 0 deletions
25
test_programs/execution_success/regression_unsafe_no_predicates/src/main.nr
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
fn main(x: u8, nest: bool) { | ||
if nest { | ||
let foo = unsafe_assert([x]); | ||
assert(foo != 0); | ||
} | ||
} | ||
|
||
#[no_predicates] | ||
pub fn unsafe_assert<let N: u32>(msg: [u8; N]) -> u8 { | ||
let block = unsafe { | ||
get_block(msg) | ||
}; | ||
verify_block(msg, block); | ||
block[0] | ||
} | ||
|
||
unconstrained fn get_block<let N: u32>(msg: [u8; N]) -> [u8; 2] { | ||
let mut block: [u8; 2] = [0; 2]; | ||
block[0] = msg[0]; | ||
block | ||
} | ||
|
||
fn verify_block<let N: u32>(msg: [u8; N], block: [u8; 2]) { | ||
assert_eq(block[0], msg[0]); | ||
} |