Skip to content

Commit

Permalink
chore: update Noir version (#3082)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevaundray authored Oct 31, 2023
1 parent 09c3b75 commit 59eb6af
Show file tree
Hide file tree
Showing 53 changed files with 273 additions and 170 deletions.
4 changes: 2 additions & 2 deletions docs/docs/dev_docs/contracts/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ You need to setup the [Aztec sandbox](../getting_started/sandbox.md).

## Set up for aztec.nr contracts

1. Inside the yarn project you created from the [Sanbox page](../getting_started/sandbox.md), create a sub-folder where the contracts will reside.
1. Inside the yarn project you created from the [Sandbox page](../getting_started/sandbox.md), create a sub-folder where the contracts will reside.

```bash
mkdir contracts
Expand Down Expand Up @@ -71,7 +71,7 @@ Open Nargo.toml that is in the `contracts/example_contract` folder, and add the
[package]
name = "example_contract"
authors = [""]
compiler_version = "0.1"
compiler_version = ">=0.18.0"
type = "contract"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/dev_docs/contracts/syntax/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ For the PXE to successfully process the decrypted note we need to compute the no
Aztec.nr enables smart contract developers to design custom notes, meaning developers can also customize how a note's note hash and nullifier should be computed. Because of this customizability, and because there will be a potentially-unlimited number of smart contracts deployed to Aztec, an PXE needs to be 'taught' how to compute the custom note hashes and nullifiers for a particular contract. Therefore, developers will need to implement a `compute_note_hash_and_nullifier` function inside their contracts.

:::danger
If your function has private state variables, you **MUST** include a `compute_note_hash_and_nullifier` function to allow the RPC to process encrypted events.
If your contract works with storage (has Storage struct defined), you **MUST** include a `compute_note_hash_and_nullifier` function to allow PXE to process encrypted events.
:::

Every time a new note is successfully decrypted, the PXE will expect the existence of a `compute_note_hash_and_nullifier` function, which must teach it how to correctly process the new note.
Expand Down
8 changes: 6 additions & 2 deletions docs/docs/dev_docs/contracts/syntax/storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ struct Storage {
}
```

:::info
If your contract storage includes private state variables, it must include a `compute_note_hash_and_nullifier` function to allow the RPC to process encrypted events. See [encrypted events](./events.md#processing-encrypted-events) for more.
:::danger
If your contract works with storage (has Storage struct defined), you **MUST** include a `compute_note_hash_and_nullifier` function to allow PXE to process encrypted events. See [encrypted events](./events.md#processing-encrypted-events) for more.

If you don't yet have any private state variables defined put there a placeholder function:

#include_code compute_note_hash_and_nullifier_placeholder /yarn-project/noir-contracts/src/contracts/token_bridge_contract/src/main.nr rust
:::

Since Aztec.nr is written in Noir, which on its own is state-less, we need to specify how the storage struct should be initialized to read and write data correctly. This is done by specifying an `init` function that is run in functions that rely on reading or altering the state variables. This `init` function must declare the storage struct with an instantiation defining how variables are accessed and manipulated. The function MUST be called `init` for the Aztec.nr library to properly handle it (this will be relaxed in the future).
Expand Down
11 changes: 9 additions & 2 deletions docs/docs/dev_docs/tutorials/writing_token_contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Add the following dependencies to your Nargo.toml file, below the package inform
[package]
name = "token_contract"
authors = [""]
compiler_version = "0.1"
compiler_version = ">=0.18.0"
type = "contract"

[dependencies]
Expand Down Expand Up @@ -242,7 +242,7 @@ We are importing the Option type, items from the `value_note` library to help ma

[SafeU120](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/yarn-project/aztec-nr/safe-math/src/safe_u120.nr) is a library to do safe math operations on unsigned integers that protects against overflows and underflows.

For more detail on execution contexts, see [Contract Communitaction](../../concepts/foundation/communication/main).
For more detail on execution contexts, see [Contract Communication](../../concepts/foundation/communication/main).

We are also importing types from a `types.nr` file. The main thing to note from this types file is the `TransparentNote` definition. This defines how the contract moves value from the public domain into the private domain. It is similar to the `value_note` that we imported, but with some modifications namely, instead of a defined `owner`, it allows anyone that can produce the pre-image to the stored `secret_hash` to spend the note.

Expand Down Expand Up @@ -476,6 +476,13 @@ This must be included in every contract because it depends on the storage slots,

#include_code compute_note_hash_and_nullifier /yarn-project/noir-contracts/src/contracts/token_contract/src/main.nr rust

:::danger
If your contract works with storage (has Storage struct defined), you **MUST** include a `compute_note_hash_and_nullifier` function.
If you don't yet have any private state variables defined put there a placeholder function:

#include_code compute_note_hash_and_nullifier_placeholder /yarn-project/noir-contracts/src/contracts/token_bridge_contract/src/main.nr rust
:::

## Compiling

Now that the contract is complete, you should be able to compile it with the `aztec-cli`. See the [CLI page](../cli/main.md) for instructions on setting it up.
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec-nr/address-note/Nargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "address_note"
authors = ["aztec-labs"]
compiler_version = "0.7.1"
compiler_version = ">=0.18.0"
type = "lib"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec-nr/authwit/Nargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "auth_wit"
authors = ["aztec-labs"]
compiler_version = "0.1"
compiler_version = ">=0.18.0"
type = "lib"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec-nr/aztec/Nargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "noir_aztec"
authors = [""]
compiler_version = "0.1"
compiler_version = ">=0.18.0"
type = "lib"

[dependencies]
2 changes: 1 addition & 1 deletion yarn-project/aztec-nr/easy-private-state/Nargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "easy_private_state"
authors = ["aztec-labs"]
compiler_version = "0.7.1"
compiler_version = ">=0.18.0"
type = "lib"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec-nr/field-note/Nargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "field_note"
authors = ["aztec-labs"]
compiler_version = "0.7.1"
compiler_version = ">=0.18.0"
type = "lib"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec-nr/safe-math/Nargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "safe_math"
authors = [""]
compiler_version = "0.1"
compiler_version = ">=0.18.0"
type = "lib"

[dependencies]
2 changes: 1 addition & 1 deletion yarn-project/aztec-nr/value-note/Nargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "value_note"
authors = ["aztec-labs"]
compiler_version = "0.7.1"
compiler_version = ">=0.18.0"
type = "lib"

[dependencies]
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions yarn-project/boxes/blank-react/src/artifacts/Blank.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion yarn-project/boxes/blank-react/src/contracts/Nargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "blank"
authors = [""]
compiler_version = "0.1"
compiler_version = ">=0.18.0"
type = "contract"

[dependencies]
Expand Down
73 changes: 62 additions & 11 deletions yarn-project/boxes/blank/src/artifacts/Blank.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions yarn-project/boxes/blank/src/artifacts/Blank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ export class BlankContract extends ContractBase {
/** Type-safe wrappers for the public methods exposed by the contract. */
public methods!: {

/** compute_note_hash_and_nullifier(contract_address: field, nonce: field, storage_slot: field, preimage: array) */
compute_note_hash_and_nullifier: ((contract_address: FieldLike, nonce: FieldLike, storage_slot: FieldLike, preimage: FieldLike[]) => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;

/** getPublicKey(address: field) */
getPublicKey: ((address: FieldLike) => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;
};
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/boxes/blank/src/contracts/Nargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "blank"
authors = [""]
compiler_version = "0.1"
compiler_version = ">=0.18.0"
type = "contract"

[dependencies]
Expand Down
7 changes: 7 additions & 0 deletions yarn-project/boxes/blank/src/contracts/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,11 @@ contract Blank {

[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, preimage: [Field; 0]) -> [Field; 4] {
[0, 0, 0, 0]
}
}
206 changes: 103 additions & 103 deletions yarn-project/boxes/token/src/artifacts/Token.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion yarn-project/boxes/token/src/contracts/Nargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "token_contract"
authors = [""]
compiler_version = "0.1"
compiler_version = ">=0.18.0"
type = "contract"

[dependencies]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "test"
authors = [""]
compiler_version = "0.1"
compiler_version = ">=0.18.0"
type = "contract"

[dependencies]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "testlib"
authors = [""]
compiler_version = "0.1"
compiler_version = ">=0.18.0"
type = "lib"

[dependencies]
4 changes: 2 additions & 2 deletions yarn-project/noir-compiler/src/noir-version.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"tag": "v0.17.0-aztec.5",
"commit": "b6819f6261e63cea3e653a1b874727a2b5919f5e"
"tag": "v0.18.0-aztec.4",
"commit": "9d9ee7a09ab972180dcb8ad59cdf1d6dd17e5794"
}
2 changes: 1 addition & 1 deletion yarn-project/noir-contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ It has prebuilt binaries and is super easy to install using `noirup`
```
[package]
authors = [""]
compiler_version = "0.7.1"
compiler_version = "0>=.18.0"
[dependencies]
aztec = { path = "../../../../aztec-nr/aztec" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "benchmarking_contract"
authors = [""]
compiler_version = "0.1"
compiler_version = ">=0.18.0"
type = "contract"

[dependencies]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "card_game_contract"
authors = [""]
compiler_version = "0.1"
compiler_version = ">=0.18.0"
type = "contract"

[dependencies]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "child_contract"
authors = [""]
compiler_version = "0.1"
compiler_version = ">=0.18.0"
type = "contract"

[dependencies]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,9 @@ contract Child {
let pubSetValueSelector = compute_selector("pubSetValue(Field)");
let _ret = context.call_public_function(context.this_address(), pubSetValueSelector, [10]);
}

// 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, preimage: [Field; 0]) -> [Field; 4] {
[0, 0, 0, 0]
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "docs_example_contract"
authors = [""]
compiler_version = "0.1"
compiler_version = ">=0.18.0"
type = "contract"

[dependencies]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,4 +305,9 @@ contract DocsExample {

}
// docs:end:l1_to_l2_cross_chain_message

// 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, preimage: [Field; 0]) -> [Field; 4] {
[0, 0, 0, 0]
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "easy_private_token_contract"
authors = [""]
compiler_version = "0.1"
compiler_version = ">=0.18.0"
type = "contract"

[dependencies]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "ecdsa_account_contract"
authors = [""]
compiler_version = "0.1"
compiler_version = ">=0.18.0"
type = "contract"

[dependencies]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "escrow_contract"
authors = [""]
compiler_version = "0.1"
compiler_version = ">=0.18.0"
type = "contract"

[dependencies]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "import_test_contract"
authors = [""]
compiler_version = "0.1"
compiler_version = ">=0.18.0"
type = "contract"

[dependencies]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "lending_contract"
authors = [""]
compiler_version = "0.1"
compiler_version = ">=0.18.0"
type = "contract"

[dependencies]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,4 +381,9 @@ contract Lending {

[storage.collateral_asset.read(), storage.stable_coin.read()]
}

// 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, preimage: [Field; 0]) -> [Field; 4] {
[0, 0, 0, 0]
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "parent_contract"
authors = [""]
compiler_version = "0.1"
compiler_version = ">=0.18.0"
type = "contract"

[dependencies]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "pending_commitments_contract"
authors = [""]
compiler_version = "0.1"
compiler_version = ">=0.18.0"
type = "contract"

[dependencies]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "price_feed_contract"
authors = [""]
compiler_version = "0.1"
compiler_version = ">=0.18.0"
type = "contract"

[dependencies]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,9 @@ contract PriceFeed {

storage.assets.at(assetId).read()
}

// 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, preimage: [Field; 0]) -> [Field; 4] {
[0, 0, 0, 0]
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "schnorr_account_contract"
authors = [""]
compiler_version = "0.1"
compiler_version = ">=0.18.0"
type = "contract"

[dependencies]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "schnorr_hardcoded_account_contract"
authors = [""]
compiler_version = "0.1"
compiler_version = ">=0.18.0"
type = "contract"

[dependencies]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "schnorr_single_key_account_contract"
authors = [""]
compiler_version = "0.1"
compiler_version = ">=0.18.0"
type = "contract"

[dependencies]
Expand Down
Loading

0 comments on commit 59eb6af

Please sign in to comment.