Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update to latest noir and update noir compiler #3696

Merged
merged 42 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
8791110
make `find_module` be an immutable reference
kevaundray Dec 10, 2023
24dfd77
add method in nargo that pre-populates the FileManager
kevaundray Dec 10, 2023
53bb4ab
change add_file to `name_to_id` -- we assume that the file manager ha…
kevaundray Dec 10, 2023
84133dc
cargo
kevaundray Dec 10, 2023
a64d6e9
Update tooling/nargo/src/lib.rs
kevaundray Dec 10, 2023
6aacb61
add a method in file manager that allows us to add a file with its so…
kevaundray Dec 10, 2023
2fe608f
add deprecation TODO to file_reader
kevaundray Dec 10, 2023
f2c5eeb
add stdlib file in noirc_driver that returns the stdlib paths alongsi…
kevaundray Dec 10, 2023
0e0f33d
add the contents of the stdlib whenever we call prepare_crate
kevaundray Dec 10, 2023
6562e68
cargo
kevaundray Dec 10, 2023
0d59846
cargo fmt
kevaundray Dec 10, 2023
10a0b0c
move tempfile to dev dependencies
kevaundray Dec 10, 2023
3953245
add files into file manager in test since find_module does not add fi…
kevaundray Dec 10, 2023
a626391
insert all files for this packages dependencies into the file manager…
kevaundray Dec 10, 2023
d718789
cargo fmt
kevaundray Dec 10, 2023
3050c49
remove un-needed fully qualified path
kevaundray Dec 10, 2023
c9b7701
Add note on stdlib
kevaundray Dec 10, 2023
342b093
cargo fmt
kevaundray Dec 10, 2023
65d2cf8
add comment to process_dep_graph and fix setup_test_context
kevaundray Dec 11, 2023
df9274c
replace expect with unwrap_or_else: expect doesn't allow you to add p…
kevaundray Dec 11, 2023
31fae7a
try: add a `PathToFileSourceMap` object
kevaundray Dec 11, 2023
275a634
remove extraneous forward slash
kevaundray Dec 11, 2023
6ab1514
add file_manager_with_source_map method so we ensure that FileManager…
kevaundray Dec 11, 2023
4b5e9a3
add expect
kevaundray Dec 11, 2023
580adc1
fix node tests
kevaundray Dec 11, 2023
b6a148b
fix browser tests and naming nit
kevaundray Dec 11, 2023
36cbc43
chore!: Remove `add_file` and `file_reader` from FileManager (#3762)
kevaundray Dec 11, 2023
ad62408
Update compiler/fm/src/lib.rs
kevaundray Dec 11, 2023
9a6c17c
file_reader is no longer being used
kevaundray Dec 11, 2023
251fffa
Removed source-resolver, provide virtual filesystem to noir_wasm
Thunkar Dec 14, 2023
41e4265
Removed inadverted edits
Thunkar Dec 14, 2023
0560a43
Reset settings.json
Thunkar Dec 14, 2023
bd1865f
Removed source-resolver package
Thunkar Dec 14, 2023
0ddfaeb
Removed sync methods from noir-compiler
Thunkar Dec 14, 2023
ce68861
yarn prepare
Thunkar Dec 14, 2023
35d2b89
Yarn formatting
Thunkar Dec 15, 2023
e5bf8df
Removed jest config from package.json in favor of standalone file
Thunkar Dec 15, 2023
3be3546
feat: Update noir subrepo and fix breaking changes (#3729)
sirasistant Dec 19, 2023
c0a5820
Merge branch 'master' into gj/noir-wasm-refactor
sirasistant Dec 19, 2023
6ffda68
chore: display any diff in gate count
sirasistant Dec 19, 2023
06d9e08
chore: extract nodejs file manager
sirasistant Dec 19, 2023
5140cd3
chore: remove extraneous package.json change
sirasistant Dec 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .github/workflows/mirror_noir_subrepo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Push to branch
run: |
SUBREPO_PATH=noir
BRANCH=aztec
BRANCH=aztec-packages
# identify ourselves, needed to commit
git config --global user.name AztecBot
git config --global user.email [email protected]
Expand All @@ -57,4 +57,4 @@ jobs:
pr_title: 'feat: aztec-packages'
pr_body: 'Development from Aztec.'
destination_branch: 'master'
source_branch: 'aztec'
source_branch: 'aztec-packages'
2 changes: 1 addition & 1 deletion .github/workflows/protocol-circuits-gate-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
uses: TomAFrench/noir-gates-diff@e7cf131b7e7f044c01615f93f0b855f65ddc02d4
with:
report: protocol_circuits_report.json
summaryQuantile: 1 # Display any diff in gate count
summaryQuantile: 0 # Display any diff in gate count

- name: Add gates diff to sticky comment
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
Expand Down
13 changes: 8 additions & 5 deletions boxes/blank/src/contracts/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@ contract Blank {
fn constructor() {}

#[aztec(private)]
fn getPublicKey(
address: Field,
) -> [Field; 2]{
fn getPublicKey(address: Field) -> [Field; 2] {
let pub_key = get_public_key(address);

[pub_key.x, pub_key.y]
}

// A function which needs to be implemented by every contract working with storage. Replace it's content with your
// own logic once you start working with private storage.
// TODO: Remove this placeholder once https://github.com/AztecProtocol/aztec-packages/issues/2918 is implemented.
unconstrained fn compute_note_hash_and_nullifier(contract_address: Field, nonce: Field, storage_slot: Field, serialized_note: [Field; 0]) -> [Field; 4] {
unconstrained fn compute_note_hash_and_nullifier(
contract_address: Field,
nonce: Field,
storage_slot: Field,
serialized_note: [Field; 0]
) -> pub [Field; 4] {
[0, 0, 0, 0]
}
}
101 changes: 25 additions & 76 deletions boxes/token/src/contracts/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@ contract Token {

// docs:start:set_admin
#[aztec(public)]
fn set_admin(
new_admin: AztecAddress,
) {
fn set_admin(new_admin: AztecAddress) {
assert(storage.admin.read().eq(AztecAddress::new(context.msg_sender())), "caller is not admin");
// docs:start:write_admin
storage.admin.write(new_admin);
Expand All @@ -140,10 +138,7 @@ contract Token {

// docs:start:set_minter
#[aztec(public)]
fn set_minter(
minter: AztecAddress,
approve: bool,
) {
fn set_minter(minter: AztecAddress, approve: bool) {
// docs:start:read_admin
assert(storage.admin.read().eq(AztecAddress::new(context.msg_sender())), "caller is not admin");
// docs:end:read_admin
Expand All @@ -155,10 +150,7 @@ contract Token {

// docs:start:mint_public
#[aztec(public)]
fn mint_public(
to: AztecAddress,
amount: Field,
) -> Field {
fn mint_public(to: AztecAddress, amount: Field) -> Field {
// docs:start:read_minter
assert(storage.minters.at(context.msg_sender()).read(), "caller is not minter");
// docs:end:read_minter
Expand All @@ -174,10 +166,7 @@ contract Token {

// docs:start:mint_private
#[aztec(public)]
fn mint_private(
amount: Field,
secret_hash: Field,
) -> Field {
fn mint_private(amount: Field, secret_hash: Field) -> Field {
assert(storage.minters.at(context.msg_sender()).read(), "caller is not minter");
let pending_shields = storage.pending_shields;
let mut note = TransparentNote::new(amount, secret_hash);
Expand All @@ -193,12 +182,7 @@ contract Token {

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

// docs:start:transfer_public
#[aztec(public)]
fn transfer_public(
from: AztecAddress,
to: AztecAddress,
amount: Field,
nonce: Field,
) -> Field {
fn transfer_public(from: AztecAddress, to: AztecAddress, amount: Field, nonce: Field) -> Field {
if (from.address != context.msg_sender()) {
assert_current_call_valid_authwit_public(&mut context, from);
} else {
Expand All @@ -245,11 +224,7 @@ contract Token {

// docs:start:burn_public
#[aztec(public)]
fn burn_public(
from: AztecAddress,
amount: Field,
nonce: Field,
) -> Field {
fn burn_public(from: AztecAddress, amount: Field, nonce: Field) -> Field {
if (from.address != context.msg_sender()) {
assert_current_call_valid_authwit_public(&mut context, from);
} else {
Expand All @@ -269,11 +244,7 @@ contract Token {

// docs:start:redeem_shield
#[aztec(private)]
fn redeem_shield(
to: AztecAddress,
amount: Field,
secret: Field,
) -> Field {
fn redeem_shield(to: AztecAddress, amount: Field, secret: Field) -> Field {
let pending_shields = storage.pending_shields;
let secret_hash = compute_secret_hash(secret);
let options = NoteGetterOptions::new().select(0, amount).select(1, secret_hash).set_limit(1);
Expand All @@ -289,12 +260,7 @@ contract Token {

// docs:start:unshield
#[aztec(private)]
fn unshield(
from: AztecAddress,
to: AztecAddress,
amount: Field,
nonce: Field,
) -> Field {
fn unshield(from: AztecAddress, to: AztecAddress, amount: Field, nonce: Field) -> Field {
if (from.address != context.msg_sender()) {
assert_current_call_valid_authwit(&mut context, from);
} else {
Expand All @@ -312,12 +278,7 @@ contract Token {

// docs:start:transfer
#[aztec(private)]
fn transfer(
from: AztecAddress,
to: AztecAddress,
amount: Field,
nonce: Field,
) -> Field {
fn transfer(from: AztecAddress, to: AztecAddress, amount: Field, nonce: Field) -> Field {
if (from.address != context.msg_sender()) {
assert_current_call_valid_authwit(&mut context, from);
} else {
Expand All @@ -334,11 +295,7 @@ contract Token {

// docs:start:burn
#[aztec(private)]
fn burn(
from: AztecAddress,
amount: Field,
nonce: Field,
) -> Field {
fn burn(from: AztecAddress, amount: Field, nonce: Field) -> Field {
if (from.address != context.msg_sender()) {
assert_current_call_valid_authwit(&mut context, from);
} else {
Expand All @@ -356,9 +313,7 @@ contract Token {

// docs:start:initialize
#[aztec(public)]
internal fn _initialize(
new_admin: AztecAddress,
) {
internal fn _initialize(new_admin: AztecAddress) {
storage.admin.write(new_admin);
storage.minters.at(new_admin.address).write(true);
}
Expand All @@ -368,20 +323,15 @@ contract Token {

// docs:start:increase_public_balance
#[aztec(public)]
internal fn _increase_public_balance(
to: AztecAddress,
amount: Field,
) {
internal fn _increase_public_balance(to: AztecAddress, amount: Field) {
let new_balance = storage.public_balances.at(to.address).read().add(SafeU120::new(amount));
storage.public_balances.at(to.address).write(new_balance);
}
// docs:end:increase_public_balance

// docs:start:reduce_total_supply
#[aztec(public)]
internal fn _reduce_total_supply(
amount: Field,
) {
internal fn _reduce_total_supply(amount: Field) {
// Only to be called from burn.
let new_supply = storage.total_supply.read().sub(SafeU120::new(amount));
storage.total_supply.write(new_supply);
Expand All @@ -391,37 +341,31 @@ contract Token {
/// Unconstrained ///

// docs:start:admin
unconstrained fn admin() -> Field {
unconstrained fn admin() -> pub Field {
storage.admin.read().address
}
// docs:end:admin

// docs:start:is_minter
unconstrained fn is_minter(
minter: AztecAddress,
) -> bool {
unconstrained fn is_minter(minter: AztecAddress) -> pub bool {
storage.minters.at(minter.address).read()
}
// docs:end:is_minter

// docs:start:total_supply
unconstrained fn total_supply() -> u120 {
unconstrained fn total_supply() -> pub u120 {
storage.total_supply.read().value
}
// docs:end:total_supply

// docs:start:balance_of_private
unconstrained fn balance_of_private(
owner: AztecAddress,
) -> u120 {
unconstrained fn balance_of_private(owner: AztecAddress) -> pub u120 {
storage.balances.at(owner).balance_of().value
}
// docs:end:balance_of_private

// docs:start:balance_of_public
unconstrained fn balance_of_public(
owner: AztecAddress,
) -> u120 {
unconstrained fn balance_of_public(owner: AztecAddress) -> pub u120 {
storage.public_balances.at(owner.address).read().value
}
// docs:end:balance_of_public
Expand All @@ -433,7 +377,12 @@ contract Token {
// Computes note hash and nullifier.
// Note 1: Needs to be defined by every contract producing logs.
// 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.
unconstrained fn compute_note_hash_and_nullifier(contract_address: Field, nonce: Field, storage_slot: Field, serialized_note: [Field; TOKEN_NOTE_LEN]) -> [Field; 4] {
unconstrained fn compute_note_hash_and_nullifier(
contract_address: Field,
nonce: Field,
storage_slot: Field,
serialized_note: [Field; TOKEN_NOTE_LEN]
) -> pub [Field; 4] {
let note_header = NoteHeader::new(contract_address, nonce, storage_slot);
if (storage_slot == 5) {
note_utils::compute_note_hash_and_nullifier(TransparentNoteMethods, note_header, serialized_note)
Expand Down
6 changes: 1 addition & 5 deletions noir/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ packages
**/node_modules
**/outputs

# Source resolver
compiler/source-resolver/lib
compiler/source-resolver/lib-node

# Noir.js
tooling/noir_js/lib

Expand All @@ -19,4 +15,4 @@ compiler/wasm/nodejs
compiler/wasm/web
tooling/noirc_abi_wasm/nodejs
tooling/noirc_abi_wasm/web
tooling/noir_js/lib
tooling/noir_js/lib
5 changes: 5 additions & 0 deletions noir/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
module.exports = {
env: {
browser: true,
es6: true,
node: true,
},
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'prettier'],
Expand Down
12 changes: 6 additions & 6 deletions noir/.github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ description: Installs the workspace's yarn dependencies and caches them
runs:
using: composite
steps:
- name: Cache
uses: actions/cache@v3
id: cache
- uses: actions/setup-node@v3
id: node
with:
path: "**/node_modules"
key: yarn-v1-${{ hashFiles('**/yarn.lock') }}
node-version: 18.17.1
cache: 'yarn'
cache-dependency-path: 'yarn.lock'

- name: Install
run: yarn --immutable
shell: bash
if: steps.cache.outputs.cache-hit != 'true'
Loading