Skip to content

Commit 3ed22ed

Browse files
AztecBotTomAFrenchjfecher
authored
feat: Sync from noir (#11196)
Automated pull of development from the [noir](https://github.com/noir-lang/noir) programming language, a dependency of Aztec. BEGIN_COMMIT_OVERRIDE chore: add end step for formatting workflow (noir-lang/noir#7070) feat(LSP): code action to import trait in a method call (noir-lang/noir#7066) feat!: Handle generic fields in `StructDefinition::fields` and move old functionality to `StructDefinition::fields_as_written` (noir-lang/noir#7067) chore(ci): Check various inliner aggressiveness setttings in Brillig reports (noir-lang/noir#7049) chore: reenable reports on rollup root circuits (noir-lang/noir#7061) fix: don't always select trait impl when verifying trait constraints (noir-lang/noir#7041) chore: mark some critical libraries as good again (noir-lang/noir#7065) fix: Reduce memory usage in mem2reg (noir-lang/noir#7053) feat: Allow associated types to be ellided from trait constraints (noir-lang/noir#7026) chore(perf): try using vec-collections's VecSet in AliasSet (noir-lang/noir#7058) chore: reduce number of iterations of `acvm::compiler::compile` (noir-lang/noir#7050) chore: add `noir_check_shuffle` as a critical library (noir-lang/noir#7056) chore: clippy warning fix (noir-lang/noir#7051) chore(ci): Unify compilation/execution report jobs that take averages with single runs (noir-lang/noir#7048) fix(nargo_fmt): let doc comment could come after regular comment (noir-lang/noir#7046) fix(nargo_fmt): don't consider identifiers the same if they are equal… (noir-lang/noir#7043) feat: auto-import traits when suggesting trait methods (noir-lang/noir#7037) feat: avoid inserting `inc_rc` instructions into ACIR (noir-lang/noir#7036) fix(lsp): suggest all possible trait methods, but only visible ones (noir-lang/noir#7027) chore: add more protocol circuits to reports (noir-lang/noir#6977) feat: avoid generating a new witness when checking if linear expression is zero (noir-lang/noir#7031) feat: skip codegen of zero iteration loops (noir-lang/noir#7030) END_COMMIT_OVERRIDE --------- Co-authored-by: Tom French <[email protected]> Co-authored-by: Tom French <[email protected]> Co-authored-by: Jake Fecher <[email protected]>
1 parent 57da116 commit 3ed22ed

File tree

72 files changed

+1433
-300
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1433
-300
lines changed

.noir-sync-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
db28cb9ffb710c286b54dbfcf57292ae3dffb03d
1+
9471e28ad6f02bf2fae3782c3db68106b615595f

noir-projects/aztec-nr/aztec/src/macros/dispatch/mod.nr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,9 @@ comptime fn str_size_in_fields(typ: Type) -> Option<u32> {
159159
comptime fn struct_size_in_fields(typ: Type) -> Option<u32> {
160160
typ.as_struct().map(|typ: (StructDefinition, [Type])| {
161161
let struct_type = typ.0;
162+
let generics = typ.1;
162163
let mut size = 0;
163-
for field in struct_type.fields() {
164+
for field in struct_type.fields(generics) {
164165
size += size_in_fields(field.1);
165166
}
166167
size

noir-projects/aztec-nr/aztec/src/macros/notes/mod.nr

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ comptime fn generate_note_properties(s: StructDefinition) -> Quoted {
203203
let property_selector_type = type_of(PropertySelector { index: 0, offset: 0, length: 0 });
204204
let note_header_type: Type = type_of(NoteHeader::empty());
205205

206-
let non_header_fields = s.fields().filter(|(_, typ): (Quoted, Type)| typ != note_header_type);
206+
let non_header_fields =
207+
s.fields_as_written().filter(|(_, typ): (Quoted, Type)| typ != note_header_type);
207208

208209
let properties_types = non_header_fields
209210
.map(|(name, _): (Quoted, Type)| quote { pub $name: $property_selector_type })
@@ -827,7 +828,7 @@ comptime fn index_note_fields(
827828
let mut indexed_fixed_fields: [(Quoted, Type, u32)] = &[];
828829
let mut indexed_nullable_fields = &[];
829830
let mut counter: u32 = 0;
830-
for field in s.fields() {
831+
for field in s.fields_as_written() {
831832
let (name, typ) = field;
832833
if (typ != NOTE_HEADER_TYPE) {
833834
if nullable_fields.all(|field| field != name) {
@@ -845,9 +846,10 @@ comptime fn index_note_fields(
845846

846847
/// Injects `NoteHeader` to the note struct if not present.
847848
comptime fn inject_note_header(s: StructDefinition) {
848-
let filtered_header = s.fields().filter(|(_, typ): (Quoted, Type)| typ == NOTE_HEADER_TYPE);
849+
let filtered_header =
850+
s.fields_as_written().filter(|(_, typ): (Quoted, Type)| typ == NOTE_HEADER_TYPE);
849851
if (filtered_header.len() == 0) {
850-
let new_fields = s.fields().push_back((quote { header }, NOTE_HEADER_TYPE));
852+
let new_fields = s.fields_as_written().push_back((quote { header }, NOTE_HEADER_TYPE));
851853
s.set_fields(new_fields);
852854
}
853855
}

noir-projects/aztec-nr/aztec/src/macros/storage/mod.nr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ pub comptime fn storage(s: StructDefinition) -> Quoted {
2727
// TODO(#8658): uncomment the code below to inject the Context type parameter.
2828
//let mut new_storage_fields = &[];
2929
//let context_generic = s.add_generic("Context");
30-
for field in s.fields() {
30+
for field in s.fields_as_written() {
31+
// FIXME: This doesn't handle field types with generics
3132
let (name, typ) = field;
3233
let (storage_field_constructor, serialized_size) =
3334
generate_storage_field_constructor(typ, quote { $slot }, false);

noir-projects/aztec-nr/aztec/src/macros/utils.nr

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,11 @@ comptime fn signature_of_type(typ: Type) -> Quoted {
128128
let element_typ_quote = signature_of_type(element_type);
129129
f"[{element_typ_quote};{array_len}]".quoted_contents()
130130
} else if typ.as_struct().is_some() {
131-
let (s, _) = typ.as_struct().unwrap();
132-
let field_signatures =
133-
s.fields().map(|(_, typ): (Quoted, Type)| signature_of_type(typ)).join(quote {,});
131+
let (s, generics) = typ.as_struct().unwrap();
132+
let field_signatures = s
133+
.fields(generics)
134+
.map(|(_, typ): (Quoted, Type)| signature_of_type(typ))
135+
.join(quote {,});
134136
f"({field_signatures})".quoted_contents()
135137
} else if typ.as_tuple().is_some() {
136138
// Note that tuples are handled the same way as structs
@@ -201,9 +203,11 @@ pub(crate) comptime fn compute_event_selector(s: StructDefinition) -> Field {
201203
// The signature will be "Foo(Field,AztecAddress)".
202204
let event_name = s.name();
203205
let args_signatures = s
204-
.fields()
206+
.fields_as_written()
205207
.map(|(_, typ): (Quoted, Type)| {
206-
signature_of_type(typ) // signature_of_type can handle structs, so this supports nested structs
208+
// signature_of_type can handle structs, so this supports nested structs
209+
// FIXME: Field generics are not handled here!
210+
signature_of_type(typ)
207211
})
208212
.join(quote {,});
209213
let signature_quote = quote { $event_name($args_signatures) };

noir-projects/noir-protocol-circuits/crates/blob/src/blob.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::{
44
unconstrained_config::{compute_roots_of_unity, D_INV, F, LOG_FIELDS_PER_BLOB},
55
};
66

7-
use bigint::BigNum;
7+
use bigint::{BigNum, BigNumTrait};
88
// Fixed hash method:
99
use types::hash::poseidon2_hash_subarray;
1010
// Variable hash method:

noir-projects/noir-protocol-circuits/crates/blob/src/mock_blob_oracle.nr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
use crate::blob_public_inputs::{BlobCommitment, BlockBlobPublicInputs};
2+
use super::blob_public_inputs::Deserialize;
23
use types::{
34
abis::sponge_blob::SpongeBlob,
45
constants::{BLOB_PUBLIC_INPUTS, BLOBS_PER_BLOCK, FIELDS_PER_BLOB},
56
};
7+
68
// TODO(#10323): this was added to save simulation time (~1min in ACVM, ~3mins in wasm -> 500ms).
79
// The use of bignum adds a lot of unconstrained code which overloads limits when simulating.
810
// If/when simulation times of unconstrained are improved, remove this.

noir-projects/noir-protocol-circuits/crates/blob/src/unconstrained_config.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use bigint::{BigNum, fields::bls12_381Fr::BLS12_381_Fr_Params};
1+
use bigint::{bignum::{BigNum, BigNumTrait}, fields::bls12_381Fr::BLS12_381_Fr_Params};
22
use types::constants::FIELDS_PER_BLOB;
33

44
// TODO(#9982): Delete this file and go back to using config.nr - calculating ROOTS in unconstrained is insecure.

noir-projects/noir-protocol-circuits/crates/types/src/meta/mod.nr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ pub comptime fn pack_from_fields<N>(
2323
result = quote { $buffer[$already_consumed] as $typ };
2424
consumed = 1;
2525
} else if typ.as_struct().is_some() {
26-
let (nested_def, _) = typ.as_struct().unwrap();
26+
let (nested_def, generics) = typ.as_struct().unwrap();
2727
let nested_name = nested_def.name();
2828
let mut deserialized_fields_list = &[];
29-
for field in nested_def.fields() {
29+
for field in nested_def.fields(generics) {
3030
let (field_name, field_type) = field;
3131
let (deserialized_field, consumed_by_field) = pack_from_fields(
3232
quote { $field_name },
@@ -106,7 +106,7 @@ pub comptime fn flatten_to_fields(name: Quoted, typ: Type, omit: [Quoted]) -> ([
106106
} else if typ.as_struct().is_some() {
107107
// For struct we pref
108108
let nested_struct = typ.as_struct().unwrap();
109-
let params = nested_struct.0.fields();
109+
let params = nested_struct.0.fields(nested_struct.1);
110110
let struct_flattened = params.map(|(param_name, param_type): (Quoted, Type)| {
111111
let maybe_prefixed_name = if name == quote {} {
112112
// Triggered when the param name is of a value available in the current scope (e.g. a function

noir/bootstrap.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ function build {
1010
if ! cache_download noir-$hash.tar.gz; then
1111
# Fake this so artifacts have a consistent hash in the cache and not git hash dependent
1212
export COMMIT_HASH="$(echo "$hash" | sed 's/-.*//g')"
13-
parallel denoise ::: ./scripts/bootstrap_native.sh ./scripts/bootstrap_packages.sh
13+
denoise ./scripts/bootstrap_native.sh
14+
denoise ./scripts/bootstrap_packages.sh
1415
cache_upload noir-$hash.tar.gz noir-repo/target/release/nargo noir-repo/target/release/acvm packages
1516
fi
1617
github_endgroup

0 commit comments

Comments
 (0)