Skip to content

Commit

Permalink
feat: Sync from noir (#11196)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
4 people committed Jan 16, 2025
1 parent ed3a63c commit aa7f24c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
3 changes: 2 additions & 1 deletion aztec/src/macros/dispatch/mod.nr
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,9 @@ comptime fn str_size_in_fields(typ: Type) -> Option<u32> {
comptime fn struct_size_in_fields(typ: Type) -> Option<u32> {
typ.as_struct().map(|typ: (StructDefinition, [Type])| {
let struct_type = typ.0;
let generics = typ.1;
let mut size = 0;
for field in struct_type.fields() {
for field in struct_type.fields(generics) {
size += size_in_fields(field.1);
}
size
Expand Down
10 changes: 6 additions & 4 deletions aztec/src/macros/notes/mod.nr
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ comptime fn generate_note_properties(s: StructDefinition) -> Quoted {
let property_selector_type = type_of(PropertySelector { index: 0, offset: 0, length: 0 });
let note_header_type: Type = type_of(NoteHeader::empty());

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

let properties_types = non_header_fields
.map(|(name, _): (Quoted, Type)| quote { pub $name: $property_selector_type })
Expand Down Expand Up @@ -827,7 +828,7 @@ comptime fn index_note_fields(
let mut indexed_fixed_fields: [(Quoted, Type, u32)] = &[];
let mut indexed_nullable_fields = &[];
let mut counter: u32 = 0;
for field in s.fields() {
for field in s.fields_as_written() {
let (name, typ) = field;
if (typ != NOTE_HEADER_TYPE) {
if nullable_fields.all(|field| field != name) {
Expand All @@ -845,9 +846,10 @@ comptime fn index_note_fields(

/// Injects `NoteHeader` to the note struct if not present.
comptime fn inject_note_header(s: StructDefinition) {
let filtered_header = s.fields().filter(|(_, typ): (Quoted, Type)| typ == NOTE_HEADER_TYPE);
let filtered_header =
s.fields_as_written().filter(|(_, typ): (Quoted, Type)| typ == NOTE_HEADER_TYPE);
if (filtered_header.len() == 0) {
let new_fields = s.fields().push_back((quote { header }, NOTE_HEADER_TYPE));
let new_fields = s.fields_as_written().push_back((quote { header }, NOTE_HEADER_TYPE));
s.set_fields(new_fields);
}
}
Expand Down
3 changes: 2 additions & 1 deletion aztec/src/macros/storage/mod.nr
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ pub comptime fn storage(s: StructDefinition) -> Quoted {
// TODO(#8658): uncomment the code below to inject the Context type parameter.
//let mut new_storage_fields = &[];
//let context_generic = s.add_generic("Context");
for field in s.fields() {
for field in s.fields_as_written() {
// FIXME: This doesn't handle field types with generics
let (name, typ) = field;
let (storage_field_constructor, serialized_size) =
generate_storage_field_constructor(typ, quote { $slot }, false);
Expand Down
14 changes: 9 additions & 5 deletions aztec/src/macros/utils.nr
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,11 @@ comptime fn signature_of_type(typ: Type) -> Quoted {
let element_typ_quote = signature_of_type(element_type);
f"[{element_typ_quote};{array_len}]".quoted_contents()
} else if typ.as_struct().is_some() {
let (s, _) = typ.as_struct().unwrap();
let field_signatures =
s.fields().map(|(_, typ): (Quoted, Type)| signature_of_type(typ)).join(quote {,});
let (s, generics) = typ.as_struct().unwrap();
let field_signatures = s
.fields(generics)
.map(|(_, typ): (Quoted, Type)| signature_of_type(typ))
.join(quote {,});
f"({field_signatures})".quoted_contents()
} else if typ.as_tuple().is_some() {
// Note that tuples are handled the same way as structs
Expand Down Expand Up @@ -201,9 +203,11 @@ pub(crate) comptime fn compute_event_selector(s: StructDefinition) -> Field {
// The signature will be "Foo(Field,AztecAddress)".
let event_name = s.name();
let args_signatures = s
.fields()
.fields_as_written()
.map(|(_, typ): (Quoted, Type)| {
signature_of_type(typ) // signature_of_type can handle structs, so this supports nested structs
// signature_of_type can handle structs, so this supports nested structs
// FIXME: Field generics are not handled here!
signature_of_type(typ)
})
.join(quote {,});
let signature_quote = quote { $event_name($args_signatures) };
Expand Down

0 comments on commit aa7f24c

Please sign in to comment.