noir-lang / noir

Noir is a domain specific language for zero knowledge proofs
https://noir-lang.org
Apache License 2.0
905 stars 206 forks source link

Some acir functions blow up 20x in size after `Fix poor handling of aliased references in flattening pass` #6574

Open sirasistant opened 4 days ago

sirasistant commented 4 days ago

Aim

-

Expected Behavior

-

Bug

After this PR https://github.com/noir-lang/noir/pull/6434 some private functions in aztec have grown 20x in the size of ACIR bytecode.

To Reproduce

use dep::aztec::macros::aztec;

#[aztec]
contract StatefulTest {
    use dep::aztec::{
        initializer::assert_is_initialized_private,
        macros::{functions::{initializer, noinitcheck, private, public, view}, storage::storage},
    };
    use dep::aztec::prelude::{AztecAddress, FunctionSelector, Map, PrivateSet, PublicMutable};
    use dep::value_note::{balance_utils, utils::{decrement, increment}, value_note::ValueNote};

    #[storage]
    struct Storage<Context> {
        notes: Map<AztecAddress, PrivateSet<ValueNote, Context>, Context>,
        public_values: Map<AztecAddress, PublicMutable<Field, Context>, Context>,
    }

    #[private]
    fn create_note(owner: AztecAddress, outgoing_viewer: AztecAddress, value: Field) {
        if (value != 0) {
            let loc = storage.notes.at(owner);
            increment(loc, value, owner, outgoing_viewer, outgoing_viewer);
        }
    }

}

Nargo.toml

[package]
name = "test"
type = "contract"
authors = [""]
compiler_version = ">=0.18.0"

[dependencies]
aztec = { path = "PATH_TO_AZTEC_PACKAGES/noir-projects/aztec-nr/aztec" }
value_note = { path = "PATH_TO_AZTEC_PACKAGES/noir-projects/aztec-nr/value-note" }

Workaround

None

Workaround Description

No response

Additional Context

No response

Project Impact

Blocker

Blocker Context

Blocking build

Nargo Version

No response

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