Skip to content

Commit 5f0ebd6

Browse files
authored
feat: a script which runs nargo fmt in all packages + running it (AztecProtocol#3803)
Added a `run_nargo_fmt.sh` script which formats all noir packages found in `yarn-packages`. Formatted it.
1 parent c415393 commit 5f0ebd6

File tree

84 files changed

+766
-482
lines changed

Some content is hidden

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

84 files changed

+766
-482
lines changed

yarn-project/aztec-nr/aztec/src/history.nr

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ mod note_inclusion;
33
mod note_validity;
44
mod nullifier_inclusion;
55
mod nullifier_non_inclusion;
6-
mod public_value_inclusion;
6+
mod public_value_inclusion;

yarn-project/aztec-nr/aztec/src/history/note_inclusion.nr

+3-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ pub fn prove_note_commitment_inclusion(
2323

2424
// 3) Prove that the commitment is in the note hash tree
2525
assert(
26-
block_header.note_hash_tree_root == compute_merkle_root(note_commitment, witness.index, witness.path),
27-
"Proving note inclusion failed"
26+
block_header.note_hash_tree_root
27+
== compute_merkle_root(note_commitment, witness.index, witness.path), "Proving note inclusion failed"
2828
);
29-
3029
// --> Now we have traversed the trees all the way up to archive root.
3130
}
3231

@@ -39,4 +38,4 @@ pub fn prove_note_inclusion<Note, N>(
3938
let note_commitment = compute_unique_siloed_note_hash(note_interface, note_with_header);
4039

4140
prove_note_commitment_inclusion(note_commitment, block_number, context);
42-
}
41+
}

yarn-project/aztec-nr/aztec/src/history/note_validity.nr

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ pub fn prove_note_validity<Note, N>(
1616
) {
1717
prove_note_inclusion(note_interface, note_with_header, block_number, context);
1818
prove_note_not_nullified(note_interface, note_with_header, block_number, context);
19-
}
19+
}

yarn-project/aztec-nr/aztec/src/messaging/l1_to_l2_message_getter_data.nr

+13-5
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,23 @@ pub fn l1_to_l2_message_getter_len() -> Field {
1616
L1_TO_L2_MESSAGE_LENGTH + 1 + L1_TO_L2_MSG_TREE_HEIGHT + 1
1717
}
1818

19-
pub fn make_l1_to_l2_message_getter_data<N>(fields: [Field; N], start: Field, secret: Field) -> L1ToL2MessageGetterData {
19+
pub fn make_l1_to_l2_message_getter_data<N>(
20+
fields: [Field; N],
21+
start: Field,
22+
secret: Field
23+
) -> L1ToL2MessageGetterData {
2024
L1ToL2MessageGetterData {
21-
message: L1ToL2Message::deserialize(arr_copy_slice(fields, [0; L1_TO_L2_MESSAGE_LENGTH], start),
25+
message: L1ToL2Message::deserialize(
26+
arr_copy_slice(fields, [0; L1_TO_L2_MESSAGE_LENGTH], start),
2227
secret,
23-
fields[start + L1_TO_L2_MESSAGE_LENGTH]),
28+
fields[start + L1_TO_L2_MESSAGE_LENGTH]
29+
),
2430
leaf_index: fields[start + L1_TO_L2_MESSAGE_LENGTH],
25-
sibling_path: arr_copy_slice(fields,
31+
sibling_path: arr_copy_slice(
32+
fields,
2633
[0; L1_TO_L2_MSG_TREE_HEIGHT],
27-
L1_TO_L2_MESSAGE_LENGTH + 1),
34+
L1_TO_L2_MESSAGE_LENGTH + 1
35+
),
2836
root: fields[start + L1_TO_L2_MESSAGE_LENGTH + L1_TO_L2_MSG_TREE_HEIGHT + 1]
2937
}
3038
}

yarn-project/aztec-nr/aztec/src/note/note_getter.nr

+37-11
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ use crate::note::{
1616
use crate::oracle;
1717
use crate::types::vec::BoundedVec;
1818

19-
fn check_note_header<Note, N>(context: PrivateContext, storage_slot: Field, note_interface: NoteInterface<Note, N>, note: Note) {
19+
fn check_note_header<Note, N>(
20+
context: PrivateContext,
21+
storage_slot: Field,
22+
note_interface: NoteInterface<Note, N>,
23+
note: Note
24+
) {
2025
let get_header = note_interface.get_header;
2126
let header = get_header(note);
2227
let contract_address = context.this_address();
@@ -31,7 +36,11 @@ fn check_note_fields<N>(fields: [Field; N], selects: BoundedVec<Option<Select>,
3136
}
3237
}
3338

34-
fn check_notes_order<N>(fields_0: [Field; N], fields_1: [Field; N], sorts: BoundedVec<Option<Sort>, N>) {
39+
fn check_notes_order<N>(
40+
fields_0: [Field; N],
41+
fields_1: [Field; N],
42+
sorts: BoundedVec<Option<Sort>, N>
43+
) {
3544
for i in 0..sorts.len {
3645
let sort = sorts.get_unchecked(i).unwrap_unchecked();
3746
let eq = fields_0[sort.field_index] == fields_1[sort.field_index];
@@ -44,7 +53,11 @@ fn check_notes_order<N>(fields_0: [Field; N], fields_1: [Field; N], sorts: Bound
4453
}
4554
}
4655

47-
pub fn get_note<Note, N>(context: &mut PrivateContext, storage_slot: Field, note_interface: NoteInterface<Note, N>) -> Note {
56+
pub fn get_note<Note, N>(
57+
context: &mut PrivateContext,
58+
storage_slot: Field,
59+
note_interface: NoteInterface<Note, N>
60+
) -> Note {
4861
let note = get_note_internal(storage_slot, note_interface);
4962

5063
check_note_header(*context, storage_slot, note_interface, note);
@@ -94,7 +107,8 @@ pub fn get_notes<Note, N, FILTER_ARGS>(
94107
unconstrained fn get_note_internal<Note, N>(storage_slot: Field, note_interface: NoteInterface<Note, N>) -> Note {
95108
let placeholder_note = [Option::none()];
96109
let placeholder_fields = [0; GET_NOTE_ORACLE_RETURN_LENGTH];
97-
oracle::notes::get_notes(storage_slot,
110+
oracle::notes::get_notes(
111+
storage_slot,
98112
note_interface,
99113
0,
100114
[],
@@ -104,7 +118,8 @@ unconstrained fn get_note_internal<Note, N>(storage_slot: Field, note_interface:
104118
1, // limit
105119
0, // offset
106120
placeholder_note,
107-
placeholder_fields)[0].unwrap() // Notice: we don't allow dummies to be returned from get_note (singular).
121+
placeholder_fields
122+
)[0].unwrap() // Notice: we don't allow dummies to be returned from get_note (singular).
108123
}
109124

110125
unconstrained fn get_notes_internal<Note, N, FILTER_ARGS>(
@@ -115,7 +130,8 @@ unconstrained fn get_notes_internal<Note, N, FILTER_ARGS>(
115130
let (num_selects, select_by, select_values, sort_by, sort_order) = flatten_options(options.selects, options.sorts);
116131
let placeholder_opt_notes = [Option::none(); MAX_READ_REQUESTS_PER_CALL];
117132
let placeholder_fields = [0; GET_NOTES_ORACLE_RETURN_LENGTH];
118-
let opt_notes = oracle::notes::get_notes(storage_slot,
133+
let opt_notes = oracle::notes::get_notes(
134+
storage_slot,
119135
note_interface,
120136
num_selects,
121137
select_by,
@@ -125,18 +141,24 @@ unconstrained fn get_notes_internal<Note, N, FILTER_ARGS>(
125141
options.limit,
126142
options.offset,
127143
placeholder_opt_notes,
128-
placeholder_fields);
144+
placeholder_fields
145+
);
129146

130147
let filter = options.filter;
131148
let filter_args = options.filter_args;
132149
filter(opt_notes, filter_args)
133150
}
134151

135-
unconstrained pub fn view_notes<Note, N>(storage_slot: Field, note_interface: NoteInterface<Note, N>, options: NoteViewerOptions<Note, N>) -> [Option<Note>; MAX_NOTES_PER_PAGE] {
152+
unconstrained pub fn view_notes<Note, N>(
153+
storage_slot: Field,
154+
note_interface: NoteInterface<Note, N>,
155+
options: NoteViewerOptions<Note, N>
156+
) -> [Option<Note>; MAX_NOTES_PER_PAGE] {
136157
let (num_selects, select_by, select_values, sort_by, sort_order) = flatten_options(options.selects, options.sorts);
137158
let placeholder_opt_notes = [Option::none(); MAX_NOTES_PER_PAGE];
138159
let placeholder_fields = [0; VIEW_NOTE_ORACLE_RETURN_LENGTH];
139-
oracle::notes::get_notes(storage_slot,
160+
oracle::notes::get_notes(
161+
storage_slot,
140162
note_interface,
141163
num_selects,
142164
select_by,
@@ -146,10 +168,14 @@ unconstrained pub fn view_notes<Note, N>(storage_slot: Field, note_interface: No
146168
options.limit,
147169
options.offset,
148170
placeholder_opt_notes,
149-
placeholder_fields)
171+
placeholder_fields
172+
)
150173
}
151174

152-
unconstrained fn flatten_options<Note, N>(selects: BoundedVec<Option<Select>, N>, sorts: BoundedVec<Option<Sort>, N>) -> (u8, [u8; N], [Field; N], [u8; N], [u2; N]) {
175+
unconstrained fn flatten_options<Note, N>(
176+
selects: BoundedVec<Option<Select>, N>,
177+
sorts: BoundedVec<Option<Sort>, N>
178+
) -> (u8, [u8; N], [Field; N], [u8; N], [u2; N]) {
153179
let mut num_selects = 0;
154180
let mut select_by = [0; N];
155181
let mut select_values = [0; N];

yarn-project/aztec-nr/aztec/src/note/note_getter_options.nr

+4-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ impl Sort {
3434
}
3535
}
3636

37-
fn return_all_notes<Note, N>(notes: [Option<Note>; MAX_READ_REQUESTS_PER_CALL], _p: Field) -> [Option<Note>; MAX_READ_REQUESTS_PER_CALL] {
37+
fn return_all_notes<Note, N>(
38+
notes: [Option<Note>; MAX_READ_REQUESTS_PER_CALL],
39+
_p: Field
40+
) -> [Option<Note>; MAX_READ_REQUESTS_PER_CALL] {
3841
notes
3942
}
4043

yarn-project/aztec-nr/aztec/src/note/utils.nr

+5-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ pub fn compute_note_hash_for_read_or_nullify<Note, N>(note_interface: NoteInterf
7070
}
7171
}
7272

73-
pub fn compute_note_hash_and_nullifier<Note, N, S>(note_interface: NoteInterface<Note, N>, note_header: NoteHeader, serialized_note: [Field; S]) -> [Field; 4] {
73+
pub fn compute_note_hash_and_nullifier<Note, N, S>(
74+
note_interface: NoteInterface<Note, N>,
75+
note_header: NoteHeader,
76+
serialized_note: [Field; S]
77+
) -> [Field; 4] {
7478
let deserialize = note_interface.deserialize;
7579
let set_header = note_interface.set_header;
7680
let mut note = deserialize(arr_copy_slice(serialized_note, [0; N], 0));

yarn-project/aztec-nr/aztec/src/oracle/call_private_function.nr

+10-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,16 @@ use dep::protocol_types::{
55
};
66

77
#[oracle(callPrivateFunction)]
8-
fn call_private_function_oracle(_contract_address: AztecAddress, _function_selector: FunctionSelector, _args_hash: Field) -> [Field; CALL_PRIVATE_FUNCTION_RETURN_SIZE] {}
8+
fn call_private_function_oracle(
9+
_contract_address: AztecAddress,
10+
_function_selector: FunctionSelector,
11+
_args_hash: Field
12+
) -> [Field; CALL_PRIVATE_FUNCTION_RETURN_SIZE] {}
913

10-
unconstrained pub fn call_private_function_internal(contract_address: AztecAddress, function_selector: FunctionSelector, args_hash: Field) -> [Field; CALL_PRIVATE_FUNCTION_RETURN_SIZE] {
14+
unconstrained pub fn call_private_function_internal(
15+
contract_address: AztecAddress,
16+
function_selector: FunctionSelector,
17+
args_hash: Field
18+
) -> [Field; CALL_PRIVATE_FUNCTION_RETURN_SIZE] {
1119
call_private_function_oracle(contract_address, function_selector, args_hash)
1220
}

yarn-project/aztec-nr/aztec/src/oracle/debug_log.nr

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ fn debug_log_format_oracle<T, N>(_msg: T, _args: [Field; N], _num_args: Field) -
88
#[oracle(debugLog)]
99
fn debug_log_field_oracle(_field: Field) -> Field {}
1010
#[oracle(debugLog)]
11-
fn debug_log_array_oracle<T, N>(_arbitrary_array: [T;N]) -> Field {}
11+
fn debug_log_array_oracle<T, N>(_arbitrary_array: [T; N]) -> Field {}
1212
#[oracle(debugLogWithPrefix)]
13-
fn debug_log_array_with_prefix_oracle<S, T, N>(_prefix: S, _arbitrary_array: [T;N]) -> Field {}
13+
fn debug_log_array_with_prefix_oracle<S, T, N>(_prefix: S, _arbitrary_array: [T; N]) -> Field {}
1414

1515
/// NOTE: call this with a str<N> msg of length > 1
1616
/// Example:

yarn-project/aztec-nr/aztec/src/oracle/enqueue_public_function_call.nr

+10-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,16 @@ use dep::protocol_types::{
1111
global ENQUEUE_PUBLIC_FUNCTION_CALL_RETURN_SIZE: Field = 14;
1212

1313
#[oracle(enqueuePublicFunctionCall)]
14-
fn enqueue_public_function_call_oracle(_contract_address: AztecAddress, _function_selector: FunctionSelector, _args_hash: Field) -> [Field; ENQUEUE_PUBLIC_FUNCTION_CALL_RETURN_SIZE] {}
14+
fn enqueue_public_function_call_oracle(
15+
_contract_address: AztecAddress,
16+
_function_selector: FunctionSelector,
17+
_args_hash: Field
18+
) -> [Field; ENQUEUE_PUBLIC_FUNCTION_CALL_RETURN_SIZE] {}
1519

16-
unconstrained pub fn enqueue_public_function_call_internal(contract_address: AztecAddress, function_selector: FunctionSelector, args_hash: Field) -> [Field; ENQUEUE_PUBLIC_FUNCTION_CALL_RETURN_SIZE] {
20+
unconstrained pub fn enqueue_public_function_call_internal(
21+
contract_address: AztecAddress,
22+
function_selector: FunctionSelector,
23+
args_hash: Field
24+
) -> [Field; ENQUEUE_PUBLIC_FUNCTION_CALL_RETURN_SIZE] {
1725
enqueue_public_function_call_oracle(contract_address, function_selector, args_hash)
1826
}

yarn-project/aztec-nr/aztec/src/oracle/get_block_header.nr

+7-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ pub fn get_block_header(block_number: u32, context: PrivateContext) -> BlockHead
3232

3333
// 2) Check that the block header block number is more than or equal to the block number we want to prove against
3434
// We could not perform the proof otherwise because the archive root from the header would not "contain" the block we want to prove against
35-
assert(block_header_block_number >= block_number, "Block header block number is smaller than the block number we want to prove against");
35+
assert(
36+
block_header_block_number >= block_number, "Block header block number is smaller than the block number we want to prove against"
37+
);
3638

3739
// 3) Get block header of a given block from oracle
3840
let block_header = get_block_header_internal(block_number);
@@ -44,7 +46,10 @@ pub fn get_block_header(block_number: u32, context: PrivateContext) -> BlockHead
4446
let witness = get_archive_membership_witness(block_header_block_number, block_hash);
4547

4648
// 6) Check that the block is in the archive (i.e. the witness is valid)
47-
assert(context.block_header.archive_root == compute_merkle_root(block_hash, witness.index, witness.path), "Proving membership of a block in archive failed");
49+
assert(
50+
context.block_header.archive_root
51+
== compute_merkle_root(block_hash, witness.index, witness.path), "Proving membership of a block in archive failed"
52+
);
4853

4954
// 7) Return the block header
5055
block_header

yarn-project/aztec-nr/aztec/src/oracle/get_membership_witness.nr

+12-3
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,28 @@ unconstrained pub fn get_membership_witness<N, M>(block_number: u32, tree_id: Fi
2929
MembershipWitness { index: fields[0], path: arr_copy_slice(fields, [0; N], 1) }
3030
}
3131

32-
unconstrained pub fn get_contract_membership_witness(block_number: u32, leaf_value: Field) -> MembershipWitness<CONTRACT_TREE_HEIGHT, CONTRACT_TREE_HEIGHT + 1> {
32+
unconstrained pub fn get_contract_membership_witness(
33+
block_number: u32,
34+
leaf_value: Field
35+
) -> MembershipWitness<CONTRACT_TREE_HEIGHT, CONTRACT_TREE_HEIGHT + 1> {
3336
get_membership_witness(block_number, CONTRACT_TREE_ID, leaf_value)
3437
}
3538

3639
// Note: get_nullifier_membership_witness function is implemented in get_nullifier_membership_witness.nr
3740

38-
unconstrained pub fn get_note_hash_membership_witness<N, M>(block_number: u32, leaf_value: Field) -> MembershipWitness<NOTE_HASH_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT + 1> {
41+
unconstrained pub fn get_note_hash_membership_witness<N, M>(
42+
block_number: u32,
43+
leaf_value: Field
44+
) -> MembershipWitness<NOTE_HASH_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT + 1> {
3945
get_membership_witness(block_number, NOTE_HASH_TREE_ID, leaf_value)
4046
}
4147

4248
// There is no `get_public_data_membership_witness` function because it doesn't make sense to be getting a membership
4349
// witness for a value in the public data tree.
4450

45-
unconstrained pub fn get_archive_membership_witness(block_number: u32, leaf_value: Field) -> MembershipWitness<ARCHIVE_HEIGHT, ARCHIVE_HEIGHT + 1> {
51+
unconstrained pub fn get_archive_membership_witness(
52+
block_number: u32,
53+
leaf_value: Field
54+
) -> MembershipWitness<ARCHIVE_HEIGHT, ARCHIVE_HEIGHT + 1> {
4655
get_membership_witness(block_number, ARCHIVE_TREE_ID, leaf_value)
4756
}

yarn-project/aztec-nr/aztec/src/oracle/notes.nr

+8-4
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ unconstrained fn get_notes_oracle_wrapper<N, S>(
4747
mut placeholder_fields: [Field; S]
4848
) -> [Field; S] {
4949
let return_size = placeholder_fields.len() as u32;
50-
get_notes_oracle(storage_slot,
50+
get_notes_oracle(
51+
storage_slot,
5152
num_selects,
5253
select_by,
5354
select_values,
@@ -56,7 +57,8 @@ unconstrained fn get_notes_oracle_wrapper<N, S>(
5657
limit,
5758
offset,
5859
return_size,
59-
placeholder_fields)
60+
placeholder_fields
61+
)
6062
}
6163

6264
unconstrained pub fn get_notes<Note, N, M, S, NS>(
@@ -72,15 +74,17 @@ unconstrained pub fn get_notes<Note, N, M, S, NS>(
7274
mut placeholder_opt_notes: [Option<Note>; S], // TODO: Remove it and use `limit` to initialize the note array.
7375
placeholder_fields: [Field; NS] // TODO: Remove it and use `limit` to initialize the note array.
7476
) -> [Option<Note>; S] {
75-
let fields = get_notes_oracle_wrapper(storage_slot,
77+
let fields = get_notes_oracle_wrapper(
78+
storage_slot,
7679
num_selects,
7780
select_by,
7881
select_values,
7982
sort_by,
8083
sort_order,
8184
limit,
8285
offset,
83-
placeholder_fields);
86+
placeholder_fields
87+
);
8488
let num_notes = fields[0] as u32;
8589
let contract_address = AztecAddress::from_field(fields[1]);
8690
let deserialize = note_interface.deserialize;

yarn-project/aztec-nr/aztec/src/oracle/public_call.nr

+10-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,16 @@ use dep::protocol_types::{
55
};
66

77
#[oracle(callPublicFunction)]
8-
fn call_public_function_oracle(_contract_address: AztecAddress, _function_selector: FunctionSelector, _args_hash: Field) -> [Field; RETURN_VALUES_LENGTH] {}
8+
fn call_public_function_oracle(
9+
_contract_address: AztecAddress,
10+
_function_selector: FunctionSelector,
11+
_args_hash: Field
12+
) -> [Field; RETURN_VALUES_LENGTH] {}
913

10-
unconstrained pub fn call_public_function_internal(contract_address: AztecAddress, function_selector: FunctionSelector, args_hash: Field) -> [Field; RETURN_VALUES_LENGTH] {
14+
unconstrained pub fn call_public_function_internal(
15+
contract_address: AztecAddress,
16+
function_selector: FunctionSelector,
17+
args_hash: Field
18+
) -> [Field; RETURN_VALUES_LENGTH] {
1119
call_public_function_oracle(contract_address, function_selector, args_hash)
1220
}

yarn-project/aztec-nr/aztec/src/oracle/storage.nr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ unconstrained fn storage_read_oracle_wrapper<N>(_storage_slot: Field) -> [Field;
55
storage_read_oracle(_storage_slot, N)
66
}
77

8-
pub fn storage_read<T, N>(storage_slot: Field, deserialize: fn ([Field; N]) -> T) -> T {
8+
pub fn storage_read<T, N>(storage_slot: Field, deserialize: fn([Field; N]) -> T) -> T {
99
let fields = storage_read_oracle_wrapper(storage_slot);
1010
deserialize(fields)
1111
}

yarn-project/aztec-nr/aztec/src/state_vars/immutable_singleton.nr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use dep::std::option::Option;
22
use dep::protocol_types::{
33
address::AztecAddress,
44
};
5-
5+
66
use crate::context::{PrivateContext, Context};
77
use crate::note::{
88
lifecycle::create_note,

yarn-project/aztec-nr/aztec/src/types/type_serialization/address_serialization.nr

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ fn serialize(value: AztecAddress) -> [Field; AZTEC_ADDRESS_SERIALIZED_LEN] {
1919
global AddressSerializationMethods = TypeSerializationInterface {
2020
deserialize,
2121
serialize,
22-
};
22+
};

0 commit comments

Comments
 (0)