-
Notifications
You must be signed in to change notification settings - Fork 199
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
feat: Handle no_predicates
attribute
#4942
Conversation
…ke more granular for inlining
Look to be getting some panics still so can hold off on a review |
I was thinking to perhaps change the name of the attribute to something more specific to the Noir codegen. Like |
…' into mv/handle-inline-never-attribute
Is this PR ready for review now?
I definitely think that we shouldn't call it Also, can you elaborate more on why inlining after flattening fixes #4688? It seems somewhat odd to me - like we're missing a more direct optimization or fix instead. |
Yeah it is |
We can discuss further during scrum and I can change it as part of this PR or a follow-up. I was leaning towards the more verbose
We are getting a big blow-up for poseidon due to how predicates need to be handled when working with large arrays and complex logic. Each call to poseidon is inlined before flattening thus causing everything inside of poseidon also needing to be flattened. In some cases (such as finding a hash) we don't need to worry about handling a predicate appropriately in the failure case and just want the result from the passing case. Our black box functions like For this program using pub fn pedersen_hash<N>(inputs: [Field; N], hash_index: u32) -> Field {
dep::std::hash::pedersen_hash_with_separator(inputs, hash_index)
}
fn main(
to_hash: [[Field; HASH_LENGTH]; NUM_HASHES],
enable: [bool; NUM_HASHES]
) -> pub [Field; NUM_HASHES + 1] {
let mut result = [0; NUM_HASHES + 1];
for i in 0..NUM_HASHES {
let enable = enable[i];
let to_hash = to_hash[i];
if enable {
result[i] = pedersen_hash(to_hash, 0);
// result[i] = poseidon_hash(to_hash);
}
}
result
} We have the following SSA:
Replacing pedersen with
I definitely think it would still be good to optimize array merges either way. However, this felt like it could be its own issue and I'm not sure if it would still provide as meaningful optimization that this inlining attribute provides. It actually felt kind of natural to me that Noir would start to adopt codegen attributes that can provide optimizations to the user. |
The tradeoff of this would be if there are failing constraints or similar inside the function call then they'd still fail even if the call was wrapped by an
Right, that comment wasn't in reference to array merges which barely affected the original issue constraint count wise. I also don't disagree with adding more compilation/optimization annotations. I was just thinking that this particular solution seemed indirect and I was wondering if there was a more direct way to optimize out predicates we're missing in general. Assuming my |
I wonder if we can have an optimization or change semantics in a way that we can only apply predicates to results in general instead of every intermediate step. Maybe we'd need to check for side-effect boundaries and delay it until then? Or group up side effects to perform all at once later somehow? Not sure. |
Looks like: fn main(x: bool) {
if x {
foo();
}
}
#[inline(never)]
fn foo() {
assert(false);
} with x = false fails |
Discussed in standup:
|
no_predicates
attribute
I ended up going with |
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.
no_predicates_is_entry_point
is a bit of an awkward name but I've no better suggestions at this point and it's not worth blocking over
👍
Yeah I thought the same but was unsure about a better one and didn't feel the need to make some context struct for one flag. |
…eturn (noir-lang/noir#4949) feat!: use `distinct` return value witnesses by default (noir-lang/noir#4951) chore(docs): adding matomo tracking (noir-lang/noir#4898) chore: fix typo in `ResolverError::AbiAttributeOutsideContract` (noir-lang/noir#4933) chore: Add test for recursing a foldable function (noir-lang/noir#4948) feat: Handle `no_predicates` attribute (noir-lang/noir#4942) fix: ensure where clauses propagated to trait default definitions (noir-lang/noir#4894) chore: Remove unnecessary `pub(super)` in interpreter (noir-lang/noir#4939)
Automated pull of development from the [noir](https://github.com/noir-lang/noir) programming language, a dependency of Aztec. BEGIN_COMMIT_OVERRIDE fix: Require for all foldable functions to use distinct return (noir-lang/noir#4949) feat!: use `distinct` return value witnesses by default (noir-lang/noir#4951) chore(docs): adding matomo tracking (noir-lang/noir#4898) chore: fix typo in `ResolverError::AbiAttributeOutsideContract` (noir-lang/noir#4933) chore: Add test for recursing a foldable function (noir-lang/noir#4948) feat: Handle `no_predicates` attribute (noir-lang/noir#4942) fix: ensure where clauses propagated to trait default definitions (noir-lang/noir#4894) chore: Remove unnecessary `pub(super)` in interpreter (noir-lang/noir#4939) END_COMMIT_OVERRIDE --------- Co-authored-by: Tom French <tom@tomfren.ch> Co-authored-by: Maxim Vezenov <mvezenov@gmail.com>
* master: (25 commits) feat: Complex outputs from acir call (#4952) fix: Require for all foldable functions to use distinct return (#4949) feat!: use `distinct` return value witnesses by default (#4951) chore(docs): adding matomo tracking (#4898) chore: fix typo in `ResolverError::AbiAttributeOutsideContract` (#4933) chore: Add test for recursing a foldable function (#4948) feat: Handle `no_predicates` attribute (#4942) fix: ensure where clauses propagated to trait default definitions (#4894) chore: Remove unnecessary `pub(super)` in interpreter (#4939) feat: add de-sugaring for `impl Trait` in function parameters (#4919) feat(experimental): `comptime` globals (#4918) chore: update error conversion traits to act on references (#4936) fix: ban self-referential structs (#4883) chore: add regression test for #3051 (#4815) fix: discard ref counts during unrolling (#4923) feat!: Bit shift is restricted to u8 right operand (#4907) feat: Add `#[inline(tag)]` attribute and codegen (#4913) chore: rework workspace structure for utils crates (#4886) feat: add variable size sha256 (#4920) chore: delete flake.lock (#4855) ...
* master: (25 commits) feat: Complex outputs from acir call (#4952) fix: Require for all foldable functions to use distinct return (#4949) feat!: use `distinct` return value witnesses by default (#4951) chore(docs): adding matomo tracking (#4898) chore: fix typo in `ResolverError::AbiAttributeOutsideContract` (#4933) chore: Add test for recursing a foldable function (#4948) feat: Handle `no_predicates` attribute (#4942) fix: ensure where clauses propagated to trait default definitions (#4894) chore: Remove unnecessary `pub(super)` in interpreter (#4939) feat: add de-sugaring for `impl Trait` in function parameters (#4919) feat(experimental): `comptime` globals (#4918) chore: update error conversion traits to act on references (#4936) fix: ban self-referential structs (#4883) chore: add regression test for #3051 (#4815) fix: discard ref counts during unrolling (#4923) feat!: Bit shift is restricted to u8 right operand (#4907) feat: Add `#[inline(tag)]` attribute and codegen (#4913) chore: rework workspace structure for utils crates (#4886) feat: add variable size sha256 (#4920) chore: delete flake.lock (#4855) ...
Automated pull of development from the [noir](https://github.com/noir-lang/noir) programming language, a dependency of Aztec. BEGIN_COMMIT_OVERRIDE fix: Require for all foldable functions to use distinct return (noir-lang/noir#4949) feat!: use `distinct` return value witnesses by default (noir-lang/noir#4951) chore(docs): adding matomo tracking (noir-lang/noir#4898) chore: fix typo in `ResolverError::AbiAttributeOutsideContract` (noir-lang/noir#4933) chore: Add test for recursing a foldable function (noir-lang/noir#4948) feat: Handle `no_predicates` attribute (noir-lang/noir#4942) fix: ensure where clauses propagated to trait default definitions (noir-lang/noir#4894) chore: Remove unnecessary `pub(super)` in interpreter (noir-lang/noir#4939) END_COMMIT_OVERRIDE --------- Co-authored-by: Tom French <tom@tomfren.ch> Co-authored-by: Maxim Vezenov <mvezenov@gmail.com>
🤖 I have created a release *beep* *boop* --- <details><summary>aztec-package: 0.37.0</summary> ## [0.37.0](aztec-package-v0.36.0...aztec-package-v0.37.0) (2024-05-02) ### Miscellaneous * **aztec-package:** Synchronize aztec-packages versions </details> <details><summary>barretenberg.js: 0.37.0</summary> ## [0.37.0](barretenberg.js-v0.36.0...barretenberg.js-v0.37.0) (2024-05-02) ### Features * Devbox ([#5772](#5772)) ([72321f9](72321f9)) </details> <details><summary>aztec-packages: 0.37.0</summary> ## [0.37.0](aztec-packages-v0.36.0...aztec-packages-v0.37.0) (2024-05-02) ### ⚠ BREAKING CHANGES * use `distinct` return value witnesses by default (noir-lang/noir#4951) * Bit shift is restricted to u8 right operand (noir-lang/noir#4907) ### Features * Abort ongoing proving jobs ([#6049](#6049)) ([0aa352d](0aa352d)) * Add aztecprotocol/aztec-builder ([#6116](#6116)) ([30899d0](30899d0)) * Add de-sugaring for `impl Trait` in function parameters (noir-lang/noir#4919) ([f060fa6](f060fa6)) * Aztec nr lib constraining nullifier key is fresh ([#5939](#5939)) ([f95de6b](f95de6b)) * Bit shift is restricted to u8 right operand (noir-lang/noir#4907) ([f060fa6](f060fa6)) * Count Bb lines weighted by complexity ([#6090](#6090)) ([705177f](705177f)) * Devbox ([#5772](#5772)) ([72321f9](72321f9)) * Enforce gas limits from private kernels ([#6105](#6105)) ([4395855](4395855)) * **experimental:** `comptime` globals (noir-lang/noir#4918) ([f060fa6](f060fa6)) * Handle `no_predicates` attribute (noir-lang/noir#4942) ([4dc5efb](4dc5efb)) * Migrate boxes to GA and Earthly ([#6076](#6076)) ([4a49f9d](4a49f9d)) * Pippenger benchmarks compatible with wasmtime ([#6095](#6095)) ([5297b5b](5297b5b)) * Private da gas metering ([#6103](#6103)) ([1a8f372](1a8f372)) * Prover metrics ([#6050](#6050)) ([5b133f2](5b133f2)) * Use `distinct` return value witnesses by default (noir-lang/noir#4951) ([4dc5efb](4dc5efb)) ### Bug Fixes * Ban self-referential structs (noir-lang/noir#4883) ([f060fa6](f060fa6)) * **ci:** Build-key hotfix ([#6123](#6123)) ([5791004](5791004)) * **ci:** Ssh'ing into instances ([#6136](#6136)) ([af3192d](af3192d)) * Discard ref counts during unrolling (noir-lang/noir#4923) ([f060fa6](f060fa6)) * **docs:** Add codegen to `aztec-builder` command ([#6098](#6098)) ([4839ed9](4839ed9)) * Ensure where clauses propagated to trait default definitions (noir-lang/noir#4894) ([4dc5efb](4dc5efb)) * Require for all foldable functions to use distinct return (noir-lang/noir#4949) ([4dc5efb](4dc5efb)) ### Miscellaneous * Add regression test for [#3051](#3051) (noir-lang/noir#4815) ([f060fa6](f060fa6)) * Add test for recursing a foldable function (noir-lang/noir#4948) ([4dc5efb](4dc5efb)) * Adding devcontainer with create aztec app ([#5960](#5960)) ([ae5cb21](ae5cb21)) * Build docs in earthly ([#6038](#6038)) ([784d542](784d542)) * Bump bench-tx-size timeout ([#6109](#6109)) ([aa3eefa](aa3eefa)) * **ci:** Fix spot runner build key ([#6119](#6119)) ([f332bc9](f332bc9)) * **ci:** Hotfix ([#6124](#6124)) ([f60dfcd](f60dfcd)) * **ci:** Run benchmarks on Earthly ([#6089](#6089)) ([c985c73](c985c73)) * **ci:** Turn off ARM build for now ([#6135](#6135)) ([853913f](853913f)) * Disable bench-summary for now ([67485f1](67485f1)) * Disable doc builds ([#6107](#6107)) ([7933f0f](7933f0f)) * **docs:** Adding matomo tracking (noir-lang/noir#4898) ([4dc5efb](4dc5efb)) * Ebs attach robustness ([#6108](#6108)) ([c702688](c702688)) * Fix typo in `ResolverError::AbiAttributeOutsideContract` (noir-lang/noir#4933) ([4dc5efb](4dc5efb)) * Migrate the prover client test to earthly ([#6118](#6118)) ([a59a6c0](a59a6c0)) * Redo typo PR by stayweek ([#6080](#6080)) ([0869452](0869452)) * Redo typo PR by vitalmotif ([#6081](#6081)) ([1a89d1a](1a89d1a)) * Refactor nested contract test for speed ([#6117](#6117)) ([b346a2f](b346a2f)) * Remove unnecessary `pub(super)` in interpreter (noir-lang/noir#4939) ([4dc5efb](4dc5efb)) * Replace relative paths to noir-protocol-circuits ([47592a2](47592a2)) * Replace relative paths to noir-protocol-circuits ([f0d95f5](f0d95f5)) * Update error conversion traits to act on references (noir-lang/noir#4936) ([f060fa6](f060fa6)) ### Documentation * Tweaks for release ([#6129](#6129)) ([77b45b9](77b45b9)) * Update @aztec/builder readme ([#6115](#6115)) ([248761e](248761e)) * Yellow paper updates for the parity circuits ([#6048](#6048)) ([cfe1b05](cfe1b05)) </details> <details><summary>barretenberg: 0.37.0</summary> ## [0.37.0](barretenberg-v0.36.0...barretenberg-v0.37.0) (2024-05-02) ### ⚠ BREAKING CHANGES * use `distinct` return value witnesses by default (noir-lang/noir#4951) ### Features * Count Bb lines weighted by complexity ([#6090](#6090)) ([705177f](705177f)) * Devbox ([#5772](#5772)) ([72321f9](72321f9)) * Handle `no_predicates` attribute (noir-lang/noir#4942) ([4dc5efb](4dc5efb)) * Pippenger benchmarks compatible with wasmtime ([#6095](#6095)) ([5297b5b](5297b5b)) * Use `distinct` return value witnesses by default (noir-lang/noir#4951) ([4dc5efb](4dc5efb)) ### Bug Fixes * Ensure where clauses propagated to trait default definitions (noir-lang/noir#4894) ([4dc5efb](4dc5efb)) * Require for all foldable functions to use distinct return (noir-lang/noir#4949) ([4dc5efb](4dc5efb)) ### Miscellaneous * Add test for recursing a foldable function (noir-lang/noir#4948) ([4dc5efb](4dc5efb)) * **docs:** Adding matomo tracking (noir-lang/noir#4898) ([4dc5efb](4dc5efb)) * Fix typo in `ResolverError::AbiAttributeOutsideContract` (noir-lang/noir#4933) ([4dc5efb](4dc5efb)) * Redo typo PR by stayweek ([#6080](#6080)) ([0869452](0869452)) * Remove unnecessary `pub(super)` in interpreter (noir-lang/noir#4939) ([4dc5efb](4dc5efb)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
🤖 I have created a release *beep* *boop* --- <details><summary>aztec-package: 0.37.0</summary> ## [0.37.0](AztecProtocol/aztec-packages@aztec-package-v0.36.0...aztec-package-v0.37.0) (2024-05-02) ### Miscellaneous * **aztec-package:** Synchronize aztec-packages versions </details> <details><summary>barretenberg.js: 0.37.0</summary> ## [0.37.0](AztecProtocol/aztec-packages@barretenberg.js-v0.36.0...barretenberg.js-v0.37.0) (2024-05-02) ### Features * Devbox ([#5772](AztecProtocol/aztec-packages#5772)) ([72321f9](AztecProtocol/aztec-packages@72321f9)) </details> <details><summary>aztec-packages: 0.37.0</summary> ## [0.37.0](AztecProtocol/aztec-packages@aztec-packages-v0.36.0...aztec-packages-v0.37.0) (2024-05-02) ### ⚠ BREAKING CHANGES * use `distinct` return value witnesses by default (noir-lang/noir#4951) * Bit shift is restricted to u8 right operand (noir-lang/noir#4907) ### Features * Abort ongoing proving jobs ([#6049](AztecProtocol/aztec-packages#6049)) ([0aa352d](AztecProtocol/aztec-packages@0aa352d)) * Add aztecprotocol/aztec-builder ([#6116](AztecProtocol/aztec-packages#6116)) ([30899d0](AztecProtocol/aztec-packages@30899d0)) * Add de-sugaring for `impl Trait` in function parameters (noir-lang/noir#4919) ([f060fa6](AztecProtocol/aztec-packages@f060fa6)) * Aztec nr lib constraining nullifier key is fresh ([#5939](AztecProtocol/aztec-packages#5939)) ([f95de6b](AztecProtocol/aztec-packages@f95de6b)) * Bit shift is restricted to u8 right operand (noir-lang/noir#4907) ([f060fa6](AztecProtocol/aztec-packages@f060fa6)) * Count Bb lines weighted by complexity ([#6090](AztecProtocol/aztec-packages#6090)) ([705177f](AztecProtocol/aztec-packages@705177f)) * Devbox ([#5772](AztecProtocol/aztec-packages#5772)) ([72321f9](AztecProtocol/aztec-packages@72321f9)) * Enforce gas limits from private kernels ([#6105](AztecProtocol/aztec-packages#6105)) ([4395855](AztecProtocol/aztec-packages@4395855)) * **experimental:** `comptime` globals (noir-lang/noir#4918) ([f060fa6](AztecProtocol/aztec-packages@f060fa6)) * Handle `no_predicates` attribute (noir-lang/noir#4942) ([4dc5efb](AztecProtocol/aztec-packages@4dc5efb)) * Migrate boxes to GA and Earthly ([#6076](AztecProtocol/aztec-packages#6076)) ([4a49f9d](AztecProtocol/aztec-packages@4a49f9d)) * Pippenger benchmarks compatible with wasmtime ([#6095](AztecProtocol/aztec-packages#6095)) ([5297b5b](AztecProtocol/aztec-packages@5297b5b)) * Private da gas metering ([#6103](AztecProtocol/aztec-packages#6103)) ([1a8f372](AztecProtocol/aztec-packages@1a8f372)) * Prover metrics ([#6050](AztecProtocol/aztec-packages#6050)) ([5b133f2](AztecProtocol/aztec-packages@5b133f2)) * Use `distinct` return value witnesses by default (noir-lang/noir#4951) ([4dc5efb](AztecProtocol/aztec-packages@4dc5efb)) ### Bug Fixes * Ban self-referential structs (noir-lang/noir#4883) ([f060fa6](AztecProtocol/aztec-packages@f060fa6)) * **ci:** Build-key hotfix ([#6123](AztecProtocol/aztec-packages#6123)) ([5791004](AztecProtocol/aztec-packages@5791004)) * **ci:** Ssh'ing into instances ([#6136](AztecProtocol/aztec-packages#6136)) ([af3192d](AztecProtocol/aztec-packages@af3192d)) * Discard ref counts during unrolling (noir-lang/noir#4923) ([f060fa6](AztecProtocol/aztec-packages@f060fa6)) * **docs:** Add codegen to `aztec-builder` command ([#6098](AztecProtocol/aztec-packages#6098)) ([4839ed9](AztecProtocol/aztec-packages@4839ed9)) * Ensure where clauses propagated to trait default definitions (noir-lang/noir#4894) ([4dc5efb](AztecProtocol/aztec-packages@4dc5efb)) * Require for all foldable functions to use distinct return (noir-lang/noir#4949) ([4dc5efb](AztecProtocol/aztec-packages@4dc5efb)) ### Miscellaneous * Add regression test for [#3051](AztecProtocol/aztec-packages#3051) (noir-lang/noir#4815) ([f060fa6](AztecProtocol/aztec-packages@f060fa6)) * Add test for recursing a foldable function (noir-lang/noir#4948) ([4dc5efb](AztecProtocol/aztec-packages@4dc5efb)) * Adding devcontainer with create aztec app ([#5960](AztecProtocol/aztec-packages#5960)) ([ae5cb21](AztecProtocol/aztec-packages@ae5cb21)) * Build docs in earthly ([#6038](AztecProtocol/aztec-packages#6038)) ([784d542](AztecProtocol/aztec-packages@784d542)) * Bump bench-tx-size timeout ([#6109](AztecProtocol/aztec-packages#6109)) ([aa3eefa](AztecProtocol/aztec-packages@aa3eefa)) * **ci:** Fix spot runner build key ([#6119](AztecProtocol/aztec-packages#6119)) ([f332bc9](AztecProtocol/aztec-packages@f332bc9)) * **ci:** Hotfix ([#6124](AztecProtocol/aztec-packages#6124)) ([f60dfcd](AztecProtocol/aztec-packages@f60dfcd)) * **ci:** Run benchmarks on Earthly ([#6089](AztecProtocol/aztec-packages#6089)) ([c985c73](AztecProtocol/aztec-packages@c985c73)) * **ci:** Turn off ARM build for now ([#6135](AztecProtocol/aztec-packages#6135)) ([853913f](AztecProtocol/aztec-packages@853913f)) * Disable bench-summary for now ([67485f1](AztecProtocol/aztec-packages@67485f1)) * Disable doc builds ([#6107](AztecProtocol/aztec-packages#6107)) ([7933f0f](AztecProtocol/aztec-packages@7933f0f)) * **docs:** Adding matomo tracking (noir-lang/noir#4898) ([4dc5efb](AztecProtocol/aztec-packages@4dc5efb)) * Ebs attach robustness ([#6108](AztecProtocol/aztec-packages#6108)) ([c702688](AztecProtocol/aztec-packages@c702688)) * Fix typo in `ResolverError::AbiAttributeOutsideContract` (noir-lang/noir#4933) ([4dc5efb](AztecProtocol/aztec-packages@4dc5efb)) * Migrate the prover client test to earthly ([#6118](AztecProtocol/aztec-packages#6118)) ([a59a6c0](AztecProtocol/aztec-packages@a59a6c0)) * Redo typo PR by stayweek ([#6080](AztecProtocol/aztec-packages#6080)) ([0869452](AztecProtocol/aztec-packages@0869452)) * Redo typo PR by vitalmotif ([#6081](AztecProtocol/aztec-packages#6081)) ([1a89d1a](AztecProtocol/aztec-packages@1a89d1a)) * Refactor nested contract test for speed ([#6117](AztecProtocol/aztec-packages#6117)) ([b346a2f](AztecProtocol/aztec-packages@b346a2f)) * Remove unnecessary `pub(super)` in interpreter (noir-lang/noir#4939) ([4dc5efb](AztecProtocol/aztec-packages@4dc5efb)) * Replace relative paths to noir-protocol-circuits ([47592a2](AztecProtocol/aztec-packages@47592a2)) * Replace relative paths to noir-protocol-circuits ([f0d95f5](AztecProtocol/aztec-packages@f0d95f5)) * Update error conversion traits to act on references (noir-lang/noir#4936) ([f060fa6](AztecProtocol/aztec-packages@f060fa6)) ### Documentation * Tweaks for release ([#6129](AztecProtocol/aztec-packages#6129)) ([77b45b9](AztecProtocol/aztec-packages@77b45b9)) * Update @aztec/builder readme ([#6115](AztecProtocol/aztec-packages#6115)) ([248761e](AztecProtocol/aztec-packages@248761e)) * Yellow paper updates for the parity circuits ([#6048](AztecProtocol/aztec-packages#6048)) ([cfe1b05](AztecProtocol/aztec-packages@cfe1b05)) </details> <details><summary>barretenberg: 0.37.0</summary> ## [0.37.0](AztecProtocol/aztec-packages@barretenberg-v0.36.0...barretenberg-v0.37.0) (2024-05-02) ### ⚠ BREAKING CHANGES * use `distinct` return value witnesses by default (noir-lang/noir#4951) ### Features * Count Bb lines weighted by complexity ([#6090](AztecProtocol/aztec-packages#6090)) ([705177f](AztecProtocol/aztec-packages@705177f)) * Devbox ([#5772](AztecProtocol/aztec-packages#5772)) ([72321f9](AztecProtocol/aztec-packages@72321f9)) * Handle `no_predicates` attribute (noir-lang/noir#4942) ([4dc5efb](AztecProtocol/aztec-packages@4dc5efb)) * Pippenger benchmarks compatible with wasmtime ([#6095](AztecProtocol/aztec-packages#6095)) ([5297b5b](AztecProtocol/aztec-packages@5297b5b)) * Use `distinct` return value witnesses by default (noir-lang/noir#4951) ([4dc5efb](AztecProtocol/aztec-packages@4dc5efb)) ### Bug Fixes * Ensure where clauses propagated to trait default definitions (noir-lang/noir#4894) ([4dc5efb](AztecProtocol/aztec-packages@4dc5efb)) * Require for all foldable functions to use distinct return (noir-lang/noir#4949) ([4dc5efb](AztecProtocol/aztec-packages@4dc5efb)) ### Miscellaneous * Add test for recursing a foldable function (noir-lang/noir#4948) ([4dc5efb](AztecProtocol/aztec-packages@4dc5efb)) * **docs:** Adding matomo tracking (noir-lang/noir#4898) ([4dc5efb](AztecProtocol/aztec-packages@4dc5efb)) * Fix typo in `ResolverError::AbiAttributeOutsideContract` (noir-lang/noir#4933) ([4dc5efb](AztecProtocol/aztec-packages@4dc5efb)) * Redo typo PR by stayweek ([#6080](AztecProtocol/aztec-packages#6080)) ([0869452](AztecProtocol/aztec-packages@0869452)) * Remove unnecessary `pub(super)` in interpreter (noir-lang/noir#4939) ([4dc5efb](AztecProtocol/aztec-packages@4dc5efb)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
🤖 I have created a release *beep* *boop* --- <details><summary>0.29.0</summary> ## [0.29.0](v0.28.0...v0.29.0) (2024-05-03) ### ⚠ BREAKING CHANGES * use `distinct` return value witnesses by default ([#4951](#4951)) * Bit shift is restricted to u8 right operand ([#4907](#4907)) ### Features * Add `#[inline(tag)]` attribute and codegen ([#4913](#4913)) ([1ec9cdc](1ec9cdc)) * Add de-sugaring for `impl Trait` in function parameters ([#4919](#4919)) ([8aad2e4](8aad2e4)) * Add variable size sha256 ([#4920](#4920)) ([dbfca58](dbfca58)) * Bit shift is restricted to u8 right operand ([#4907](#4907)) ([c4b0369](c4b0369)) * Complex outputs from acir call ([#4952](#4952)) ([2e085b9](2e085b9)) * **experimental:** `comptime` globals ([#4918](#4918)) ([8a3c7f1](8a3c7f1)) * Handle `BrilligCall` opcodes in the debugger ([#4897](#4897)) ([b380dc4](b380dc4)) * Handle `no_predicates` attribute ([#4942](#4942)) ([0ce04d3](0ce04d3)) * Handle empty response foreign calls without an external resolver ([#4959](#4959)) ([0154bde](0154bde)) * Optimize array sets in if conditions (alternate version) ([#4716](#4716)) ([a87c655](a87c655)) * Use `distinct` return value witnesses by default ([#4951](#4951)) ([5f1b584](5f1b584)) ### Bug Fixes * Ban self-referential structs ([#4883](#4883)) ([800f670](800f670)) * Discard ref counts during unrolling ([#4923](#4923)) ([91062db](91062db)) * Ensure where clauses propagated to trait default definitions ([#4894](#4894)) ([aaac0f6](aaac0f6)) * Move remove_if_else pass after second inlining ([#4976](#4976)) ([96fb3e9](96fb3e9)) * Nested array equality ([#4903](#4903)) ([0cf2e2a](0cf2e2a)) * Require for all foldable functions to use distinct return ([#4949](#4949)) ([d4c6806](d4c6806)) * Use annotated type when checking declaration ([#4966](#4966)) ([f7fa696](f7fa696)) </details> <details><summary>0.45.0</summary> ## [0.45.0](v0.44.0...v0.45.0) (2024-05-03) ### ⚠ BREAKING CHANGES * Bit shift is restricted to u8 right operand ([#4907](#4907)) * contract interfaces and better function calls (AztecProtocol/aztec-packages#5687) * change backend width to 4 (AztecProtocol/aztec-packages#5374) * Use fixed size arrays in black box functions where sizes are known (AztecProtocol/aztec-packages#5620) * trap with revert data (AztecProtocol/aztec-packages#5732) * **acir:** BrilligCall opcode (AztecProtocol/aztec-packages#5709) * remove fixed-length keccak256 (AztecProtocol/aztec-packages#5617) * storage_layout and `#[aztec(storage)]` (AztecProtocol/aztec-packages#5387) * **acir:** Add predicate to call opcode (AztecProtocol/aztec-packages#5616) * contract_abi-exports (AztecProtocol/aztec-packages#5386) * Brillig typed memory (AztecProtocol/aztec-packages#5395) * **acir:** Program and witness stack structure (AztecProtocol/aztec-packages#5149) * automatic NoteInterface and NoteGetterOptions auto select (AztecProtocol/aztec-packages#4508) * Acir call opcode (AztecProtocol/aztec-packages#4773) * Support contracts with no constructor (AztecProtocol/aztec-packages#5175) * Internal as a macro (AztecProtocol/aztec-packages#4898) * move noir out of yarn-project (AztecProtocol/aztec-packages#4479) * note type ids (AztecProtocol/aztec-packages#4500) * rename bigint_neg into bigint_sub (AztecProtocol/aztec-packages#4420) * Add expression width into acir (AztecProtocol/aztec-packages#4014) * init storage macro (AztecProtocol/aztec-packages#4200) * **acir:** Move `is_recursive` flag to be part of the circuit definition (AztecProtocol/aztec-packages#4221) * Sync commits from `aztec-packages` ([#4144](#4144)) * Breaking changes from aztec-packages ([#3955](#3955)) ### Features * Acir call opcode (AztecProtocol/aztec-packages#4773) ([c3c9e19](c3c9e19)) * **acir_gen:** Brillig stdlib ([#4848](#4848)) ([0c8175c](0c8175c)) * **acir_gen:** Fold attribute at compile-time and initial non inlined ACIR (AztecProtocol/aztec-packages#5341) ([a0f7474](a0f7474)) * **acir:** Add predicate to call opcode (AztecProtocol/aztec-packages#5616) ([2bd006a](2bd006a)) * **acir:** BrilligCall opcode (AztecProtocol/aztec-packages#5709) ([0f9ae0a](0f9ae0a)) * **acir:** Program and witness stack structure (AztecProtocol/aztec-packages#5149) ([13eb71b](13eb71b)) * **acvm_js:** Execute program ([#4694](#4694)) ([386f6d0](386f6d0)) * **acvm:** Execute multiple circuits (AztecProtocol/aztec-packages#5380) ([a0f7474](a0f7474)) * Add bit size to const opcode (AztecProtocol/aztec-packages#4385) ([158c8ce](158c8ce)) * Add CMOV instruction to brillig and brillig gen (AztecProtocol/aztec-packages#5308) ([13eb71b](13eb71b)) * Add expression width into acir (AztecProtocol/aztec-packages#4014) ([158c8ce](158c8ce)) * Add instrumentation for tracking variables in debugging ([#4122](#4122)) ([c58d691](c58d691)) * Add poseidon2 opcode implementation for acvm/brillig, and Noir ([#4398](#4398)) ([10e8292](10e8292)) * Add return values to aztec fns (AztecProtocol/aztec-packages#5389) ([2bd006a](2bd006a)) * Add support for overriding expression width ([#4117](#4117)) ([c8026d5](c8026d5)) * Added cast opcode and cast calldata (AztecProtocol/aztec-packages#4423) ([78ef013](78ef013)) * Allow brillig to read arrays directly from memory (AztecProtocol/aztec-packages#4460) ([158c8ce](158c8ce)) * Allow nested arrays and vectors in Brillig foreign calls (AztecProtocol/aztec-packages#4478) ([158c8ce](158c8ce)) * Allow variables and stack trace inspection in the debugger ([#4184](#4184)) ([bf263fc](bf263fc)) * Automatic NoteInterface and NoteGetterOptions auto select (AztecProtocol/aztec-packages#4508) ([13eb71b](13eb71b)) * **avm:** Back in avm context with macro - refactor context (AztecProtocol/aztec-packages#4438) ([158c8ce](158c8ce)) * **avm:** Brillig CONST of size > u128 (AztecProtocol/aztec-packages#5217) ([c3c9e19](c3c9e19)) * **avm:** Integrate AVM with initializers (AztecProtocol/aztec-packages#5469) ([2bd006a](2bd006a)) * **aztec-nr:** Initial work for aztec public vm macro (AztecProtocol/aztec-packages#4400) ([158c8ce](158c8ce)) * Backpropagate constants in ACIR during optimization ([#3926](#3926)) ([aad0da0](aad0da0)) * Bit shift is restricted to u8 right operand ([#4907](#4907)) ([c4b0369](c4b0369)) * Breaking changes from aztec-packages ([#3955](#3955)) ([5be049e](5be049e)) * Brillig heterogeneous memory cells (AztecProtocol/aztec-packages#5608) ([305bcdc](305bcdc)) * Brillig IR refactor (AztecProtocol/aztec-packages#5233) ([c3c9e19](c3c9e19)) * Brillig pointer codegen and execution (AztecProtocol/aztec-packages#5737) ([0f9ae0a](0f9ae0a)) * Brillig typed memory (AztecProtocol/aztec-packages#5395) ([0bc18c4](0bc18c4)) * Change backend width to 4 (AztecProtocol/aztec-packages#5374) ([0f9ae0a](0f9ae0a)) * Check initializer msg.sender matches deployer from address preimage (AztecProtocol/aztec-packages#5222) ([c3c9e19](c3c9e19)) * Contract interfaces and better function calls (AztecProtocol/aztec-packages#5687) ([0f9ae0a](0f9ae0a)) * Contract_abi-exports (AztecProtocol/aztec-packages#5386) ([2bd006a](2bd006a)) * Evaluation of dynamic assert messages ([#4101](#4101)) ([c284e01](c284e01)) * Handle `BrilligCall` opcodes in the debugger ([#4897](#4897)) ([b380dc4](b380dc4)) * Impl of missing functionality in new key store (AztecProtocol/aztec-packages#5750) ([0f9ae0a](0f9ae0a)) * Init storage macro (AztecProtocol/aztec-packages#4200) ([158c8ce](158c8ce)) * Initial Earthly CI (AztecProtocol/aztec-packages#5069) ([c3c9e19](c3c9e19)) * Internal as a macro (AztecProtocol/aztec-packages#4898) ([5f57ebb](5f57ebb)) * **nargo:** Handle call stacks for multiple Acir calls ([#4711](#4711)) ([5b23171](5b23171)) * New brillig field operations and refactor of binary operations (AztecProtocol/aztec-packages#5208) ([c3c9e19](c3c9e19)) * Note type ids (AztecProtocol/aztec-packages#4500) ([78ef013](78ef013)) * Remove replacement of boolean range opcodes with `AssertZero` opcodes ([#4107](#4107)) ([dac0e87](dac0e87)) * Restore hashing args via slice for performance (AztecProtocol/aztec-packages#5539) ([2bd006a](2bd006a)) * Signed integer division and modulus in brillig gen (AztecProtocol/aztec-packages#5279) ([c3c9e19](c3c9e19)) * **simulator:** Fetch return values at circuit execution (AztecProtocol/aztec-packages#5642) ([305bcdc](305bcdc)) * Storage_layout and `#[aztec(storage)]` (AztecProtocol/aztec-packages#5387) ([2bd006a](2bd006a)) * Support contracts with no constructor (AztecProtocol/aztec-packages#5175) ([c3c9e19](c3c9e19)) * Sync `aztec-packages` ([#4011](#4011)) ([fee2452](fee2452)) * Sync commits from `aztec-packages` ([#4068](#4068)) ([7a8f3a3](7a8f3a3)) * Sync commits from `aztec-packages` ([#4144](#4144)) ([0205d3b](0205d3b)) * Sync from aztec-packages ([#4483](#4483)) ([fe8f277](fe8f277)) * Sync from noir (AztecProtocol/aztec-packages#5234) ([c3c9e19](c3c9e19)) * Sync from noir (AztecProtocol/aztec-packages#5286) ([c3c9e19](c3c9e19)) * Sync from noir (AztecProtocol/aztec-packages#5572) ([2bd006a](2bd006a)) * Sync from noir (AztecProtocol/aztec-packages#5619) ([2bd006a](2bd006a)) * Sync from noir (AztecProtocol/aztec-packages#5697) ([305bcdc](305bcdc)) * Sync from noir (AztecProtocol/aztec-packages#5794) ([0f9ae0a](0f9ae0a)) * Sync from noir (AztecProtocol/aztec-packages#5814) ([0f9ae0a](0f9ae0a)) * Sync from noir (AztecProtocol/aztec-packages#5935) ([1b867b1](1b867b1)) * Sync from noir (AztecProtocol/aztec-packages#5955) ([1b867b1](1b867b1)) * Sync from noir (AztecProtocol/aztec-packages#5999) ([1b867b1](1b867b1)) * Trap with revert data (AztecProtocol/aztec-packages#5732) ([0f9ae0a](0f9ae0a)) * Use fixed size arrays in black box functions where sizes are known (AztecProtocol/aztec-packages#5620) ([0f9ae0a](0f9ae0a)) * Variable length returns (AztecProtocol/aztec-packages#5633) ([305bcdc](305bcdc)) ### Bug Fixes * **acvm:** Mark outputs of Opcode::Call solvable ([#4708](#4708)) ([8fea405](8fea405)) * Avoid huge unrolling in hash_args (AztecProtocol/aztec-packages#5703) ([305bcdc](305bcdc)) * Catch panics from EC point creation (e.g. the point is at infinity) ([#4790](#4790)) ([645dba1](645dba1)) * Don't reuse brillig with slice arguments (AztecProtocol/aztec-packages#5800) ([0f9ae0a](0f9ae0a)) * Issue 4682 and add solver for unconstrained bigintegers ([#4729](#4729)) ([e4d33c1](e4d33c1)) * Noir test incorrect reporting (AztecProtocol/aztec-packages#4925) ([5f57ebb](5f57ebb)) * Proper field inversion for bigints ([#4802](#4802)) ([b46d0e3](b46d0e3)) * Remove panic from `init_log_level` in `acvm_js` ([#4195](#4195)) ([2e26530](2e26530)) * Return error rather instead of panicking on invalid circuit ([#3976](#3976)) ([67201bf](67201bf)) ### Miscellaneous Chores * **acir:** Move `is_recursive` flag to be part of the circuit definition (AztecProtocol/aztec-packages#4221) ([158c8ce](158c8ce)) * Move noir out of yarn-project (AztecProtocol/aztec-packages#4479) ([78ef013](78ef013)) * Remove fixed-length keccak256 (AztecProtocol/aztec-packages#5617) ([305bcdc](305bcdc)) * Rename bigint_neg into bigint_sub (AztecProtocol/aztec-packages#4420) ([158c8ce](158c8ce)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Description
Problem*
Resolves #4911 and #4688
Summary*
We recently included theThis has now been switched to the name#[inline(never)]
attribute to enable developers to optimize codegen.no_predicates
. The main use-case in mind is for circuits in issue #4688 where inlining a function with heavy array operations when dependent upon witnesses is not always ideal. Specifically when the function being inlined does not need to rely on the predicate for correctness.Originally I had in mind to delay inlining all the way to after ACIR gen and inline the ACIR artifacts. However, this feels overly complex now as we have all the infrastructure to inline functions as we wish during SSA, we could just need to delay the inlining of certain functions to happen after flattening. This PR does exactly what was just mentioned.
For example, the new test
no_predicates_numeric_generic_poseidon
gave these results whenposeidon_hash
was not marked with#[no_predicates]
:While when
poseidon_hash
was marked with#[no_predicates]
:Additional Context
Documentation*
Check one:
PR Checklist*
cargo fmt
on default settings.