Skip to content

Commit 62a17a4

Browse files
authored
feat: update to latest noir and update noir compiler (AztecProtocol#3696)
This PR updates aztec-packages to use latest noir. - Regarding noir_wasm, providing the solved sources directly to `node_wasm` eliminates the need for `source-resolver`, which has been completely removed from the repository. - Added required pub in return values - Updated return_type - Pulled latest noir
1 parent 34e2505 commit 62a17a4

File tree

1,042 files changed

+22103
-19613
lines changed

Some content is hidden

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

1,042 files changed

+22103
-19613
lines changed

.github/workflows/mirror_noir_subrepo.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- name: Push to branch
3535
run: |
3636
SUBREPO_PATH=noir
37-
BRANCH=aztec
37+
BRANCH=aztec-packages
3838
# identify ourselves, needed to commit
3939
git config --global user.name AztecBot
4040
git config --global user.email tech@aztecprotocol.com
@@ -57,4 +57,4 @@ jobs:
5757
pr_title: 'feat: aztec-packages'
5858
pr_body: 'Development from Aztec.'
5959
destination_branch: 'master'
60-
source_branch: 'aztec'
60+
source_branch: 'aztec-packages'

.github/workflows/protocol-circuits-gate-diff.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
uses: TomAFrench/noir-gates-diff@e7cf131b7e7f044c01615f93f0b855f65ddc02d4
5454
with:
5555
report: protocol_circuits_report.json
56-
summaryQuantile: 1 # Display any diff in gate count
56+
summaryQuantile: 0 # Display any diff in gate count
5757

5858
- name: Add gates diff to sticky comment
5959
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'

boxes/blank/src/contracts/src/main.nr

+8-5
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,21 @@ contract Blank {
1010
fn constructor() {}
1111

1212
#[aztec(private)]
13-
fn getPublicKey(
14-
address: Field,
15-
) -> [Field; 2]{
13+
fn getPublicKey(address: Field) -> [Field; 2] {
1614
let pub_key = get_public_key(address);
17-
15+
1816
[pub_key.x, pub_key.y]
1917
}
2018

2119
// A function which needs to be implemented by every contract working with storage. Replace it's content with your
2220
// own logic once you start working with private storage.
2321
// TODO: Remove this placeholder once https://github.com/AztecProtocol/aztec-packages/issues/2918 is implemented.
24-
unconstrained fn compute_note_hash_and_nullifier(contract_address: Field, nonce: Field, storage_slot: Field, serialized_note: [Field; 0]) -> [Field; 4] {
22+
unconstrained fn compute_note_hash_and_nullifier(
23+
contract_address: Field,
24+
nonce: Field,
25+
storage_slot: Field,
26+
serialized_note: [Field; 0]
27+
) -> pub [Field; 4] {
2528
[0, 0, 0, 0]
2629
}
2730
}

boxes/token/src/contracts/src/main.nr

+25-76
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ contract Token {
128128

129129
// docs:start:set_admin
130130
#[aztec(public)]
131-
fn set_admin(
132-
new_admin: AztecAddress,
133-
) {
131+
fn set_admin(new_admin: AztecAddress) {
134132
assert(storage.admin.read().eq(AztecAddress::new(context.msg_sender())), "caller is not admin");
135133
// docs:start:write_admin
136134
storage.admin.write(new_admin);
@@ -140,10 +138,7 @@ contract Token {
140138

141139
// docs:start:set_minter
142140
#[aztec(public)]
143-
fn set_minter(
144-
minter: AztecAddress,
145-
approve: bool,
146-
) {
141+
fn set_minter(minter: AztecAddress, approve: bool) {
147142
// docs:start:read_admin
148143
assert(storage.admin.read().eq(AztecAddress::new(context.msg_sender())), "caller is not admin");
149144
// docs:end:read_admin
@@ -155,10 +150,7 @@ contract Token {
155150

156151
// docs:start:mint_public
157152
#[aztec(public)]
158-
fn mint_public(
159-
to: AztecAddress,
160-
amount: Field,
161-
) -> Field {
153+
fn mint_public(to: AztecAddress, amount: Field) -> Field {
162154
// docs:start:read_minter
163155
assert(storage.minters.at(context.msg_sender()).read(), "caller is not minter");
164156
// docs:end:read_minter
@@ -174,10 +166,7 @@ contract Token {
174166

175167
// docs:start:mint_private
176168
#[aztec(public)]
177-
fn mint_private(
178-
amount: Field,
179-
secret_hash: Field,
180-
) -> Field {
169+
fn mint_private(amount: Field, secret_hash: Field) -> Field {
181170
assert(storage.minters.at(context.msg_sender()).read(), "caller is not minter");
182171
let pending_shields = storage.pending_shields;
183172
let mut note = TransparentNote::new(amount, secret_hash);
@@ -193,12 +182,7 @@ contract Token {
193182

194183
// docs:start:shield
195184
#[aztec(public)]
196-
fn shield(
197-
from: AztecAddress,
198-
amount: Field,
199-
secret_hash: Field,
200-
nonce: Field,
201-
) -> Field {
185+
fn shield(from: AztecAddress, amount: Field, secret_hash: Field, nonce: Field) -> Field {
202186
if (from.address != context.msg_sender()) {
203187
// The redeem is only spendable once, so we need to ensure that you cannot insert multiple shields from the same message.
204188
assert_current_call_valid_authwit_public(&mut context, from);
@@ -220,12 +204,7 @@ contract Token {
220204

221205
// docs:start:transfer_public
222206
#[aztec(public)]
223-
fn transfer_public(
224-
from: AztecAddress,
225-
to: AztecAddress,
226-
amount: Field,
227-
nonce: Field,
228-
) -> Field {
207+
fn transfer_public(from: AztecAddress, to: AztecAddress, amount: Field, nonce: Field) -> Field {
229208
if (from.address != context.msg_sender()) {
230209
assert_current_call_valid_authwit_public(&mut context, from);
231210
} else {
@@ -245,11 +224,7 @@ contract Token {
245224

246225
// docs:start:burn_public
247226
#[aztec(public)]
248-
fn burn_public(
249-
from: AztecAddress,
250-
amount: Field,
251-
nonce: Field,
252-
) -> Field {
227+
fn burn_public(from: AztecAddress, amount: Field, nonce: Field) -> Field {
253228
if (from.address != context.msg_sender()) {
254229
assert_current_call_valid_authwit_public(&mut context, from);
255230
} else {
@@ -269,11 +244,7 @@ contract Token {
269244

270245
// docs:start:redeem_shield
271246
#[aztec(private)]
272-
fn redeem_shield(
273-
to: AztecAddress,
274-
amount: Field,
275-
secret: Field,
276-
) -> Field {
247+
fn redeem_shield(to: AztecAddress, amount: Field, secret: Field) -> Field {
277248
let pending_shields = storage.pending_shields;
278249
let secret_hash = compute_secret_hash(secret);
279250
let options = NoteGetterOptions::new().select(0, amount).select(1, secret_hash).set_limit(1);
@@ -289,12 +260,7 @@ contract Token {
289260

290261
// docs:start:unshield
291262
#[aztec(private)]
292-
fn unshield(
293-
from: AztecAddress,
294-
to: AztecAddress,
295-
amount: Field,
296-
nonce: Field,
297-
) -> Field {
263+
fn unshield(from: AztecAddress, to: AztecAddress, amount: Field, nonce: Field) -> Field {
298264
if (from.address != context.msg_sender()) {
299265
assert_current_call_valid_authwit(&mut context, from);
300266
} else {
@@ -312,12 +278,7 @@ contract Token {
312278

313279
// docs:start:transfer
314280
#[aztec(private)]
315-
fn transfer(
316-
from: AztecAddress,
317-
to: AztecAddress,
318-
amount: Field,
319-
nonce: Field,
320-
) -> Field {
281+
fn transfer(from: AztecAddress, to: AztecAddress, amount: Field, nonce: Field) -> Field {
321282
if (from.address != context.msg_sender()) {
322283
assert_current_call_valid_authwit(&mut context, from);
323284
} else {
@@ -334,11 +295,7 @@ contract Token {
334295

335296
// docs:start:burn
336297
#[aztec(private)]
337-
fn burn(
338-
from: AztecAddress,
339-
amount: Field,
340-
nonce: Field,
341-
) -> Field {
298+
fn burn(from: AztecAddress, amount: Field, nonce: Field) -> Field {
342299
if (from.address != context.msg_sender()) {
343300
assert_current_call_valid_authwit(&mut context, from);
344301
} else {
@@ -356,9 +313,7 @@ contract Token {
356313

357314
// docs:start:initialize
358315
#[aztec(public)]
359-
internal fn _initialize(
360-
new_admin: AztecAddress,
361-
) {
316+
internal fn _initialize(new_admin: AztecAddress) {
362317
storage.admin.write(new_admin);
363318
storage.minters.at(new_admin.address).write(true);
364319
}
@@ -368,20 +323,15 @@ contract Token {
368323

369324
// docs:start:increase_public_balance
370325
#[aztec(public)]
371-
internal fn _increase_public_balance(
372-
to: AztecAddress,
373-
amount: Field,
374-
) {
326+
internal fn _increase_public_balance(to: AztecAddress, amount: Field) {
375327
let new_balance = storage.public_balances.at(to.address).read().add(SafeU120::new(amount));
376328
storage.public_balances.at(to.address).write(new_balance);
377329
}
378330
// docs:end:increase_public_balance
379331

380332
// docs:start:reduce_total_supply
381333
#[aztec(public)]
382-
internal fn _reduce_total_supply(
383-
amount: Field,
384-
) {
334+
internal fn _reduce_total_supply(amount: Field) {
385335
// Only to be called from burn.
386336
let new_supply = storage.total_supply.read().sub(SafeU120::new(amount));
387337
storage.total_supply.write(new_supply);
@@ -391,37 +341,31 @@ contract Token {
391341
/// Unconstrained ///
392342

393343
// docs:start:admin
394-
unconstrained fn admin() -> Field {
344+
unconstrained fn admin() -> pub Field {
395345
storage.admin.read().address
396346
}
397347
// docs:end:admin
398348

399349
// docs:start:is_minter
400-
unconstrained fn is_minter(
401-
minter: AztecAddress,
402-
) -> bool {
350+
unconstrained fn is_minter(minter: AztecAddress) -> pub bool {
403351
storage.minters.at(minter.address).read()
404352
}
405353
// docs:end:is_minter
406354

407355
// docs:start:total_supply
408-
unconstrained fn total_supply() -> u120 {
356+
unconstrained fn total_supply() -> pub u120 {
409357
storage.total_supply.read().value
410358
}
411359
// docs:end:total_supply
412360

413361
// docs:start:balance_of_private
414-
unconstrained fn balance_of_private(
415-
owner: AztecAddress,
416-
) -> u120 {
362+
unconstrained fn balance_of_private(owner: AztecAddress) -> pub u120 {
417363
storage.balances.at(owner).balance_of().value
418364
}
419365
// docs:end:balance_of_private
420366

421367
// docs:start:balance_of_public
422-
unconstrained fn balance_of_public(
423-
owner: AztecAddress,
424-
) -> u120 {
368+
unconstrained fn balance_of_public(owner: AztecAddress) -> pub u120 {
425369
storage.public_balances.at(owner.address).read().value
426370
}
427371
// docs:end:balance_of_public
@@ -433,7 +377,12 @@ contract Token {
433377
// Computes note hash and nullifier.
434378
// Note 1: Needs to be defined by every contract producing logs.
435379
// Note 2: Having it in all the contracts gives us the ability to compute the note hash and nullifier differently for different kind of notes.
436-
unconstrained fn compute_note_hash_and_nullifier(contract_address: Field, nonce: Field, storage_slot: Field, serialized_note: [Field; TOKEN_NOTE_LEN]) -> [Field; 4] {
380+
unconstrained fn compute_note_hash_and_nullifier(
381+
contract_address: Field,
382+
nonce: Field,
383+
storage_slot: Field,
384+
serialized_note: [Field; TOKEN_NOTE_LEN]
385+
) -> pub [Field; 4] {
437386
let note_header = NoteHeader::new(contract_address, nonce, storage_slot);
438387
if (storage_slot == 5) {
439388
note_utils::compute_note_hash_and_nullifier(TransparentNoteMethods, note_header, serialized_note)

noir/.dockerignore

+1-5
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ packages
77
**/node_modules
88
**/outputs
99

10-
# Source resolver
11-
compiler/source-resolver/lib
12-
compiler/source-resolver/lib-node
13-
1410
# Noir.js
1511
tooling/noir_js/lib
1612

@@ -19,4 +15,4 @@ compiler/wasm/nodejs
1915
compiler/wasm/web
2016
tooling/noirc_abi_wasm/nodejs
2117
tooling/noirc_abi_wasm/web
22-
tooling/noir_js/lib
18+
tooling/noir_js/lib

noir/.eslintrc.js

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
module.exports = {
2+
env: {
3+
browser: true,
4+
es6: true,
5+
node: true,
6+
},
27
root: true,
38
parser: '@typescript-eslint/parser',
49
plugins: ['@typescript-eslint', 'prettier'],

noir/.github/actions/setup/action.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ description: Installs the workspace's yarn dependencies and caches them
44
runs:
55
using: composite
66
steps:
7-
- name: Cache
8-
uses: actions/cache@v3
9-
id: cache
7+
- uses: actions/setup-node@v3
8+
id: node
109
with:
11-
path: "**/node_modules"
12-
key: yarn-v1-${{ hashFiles('**/yarn.lock') }}
10+
node-version: 18.17.1
11+
cache: 'yarn'
12+
cache-dependency-path: 'yarn.lock'
13+
1314
- name: Install
1415
run: yarn --immutable
1516
shell: bash
16-
if: steps.cache.outputs.cache-hit != 'true'

0 commit comments

Comments
 (0)