From cadb3f3bb843a8bedbef783a9645b3a239a66806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro=20Sousa?= Date: Fri, 5 Jan 2024 15:03:34 +0000 Subject: [PATCH 1/5] chore(docs): starting a migration notes section --- docs/docs/misc/migration_notes.md | 41 +++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 docs/docs/misc/migration_notes.md diff --git a/docs/docs/misc/migration_notes.md b/docs/docs/misc/migration_notes.md new file mode 100644 index 000000000000..3534954bd475 --- /dev/null +++ b/docs/docs/misc/migration_notes.md @@ -0,0 +1,41 @@ +--- +title: Migration notes +description: Read about migration notes from previous versions, which could solve problems while updating +keywords: [sandbox, cli, aztec, notes, migration, updating, upgrading] +--- + +Aztec is in full-speed development. Literally every version breaks compatibility with the previous ones. This page attempts to target errors and difficulties you might encounter when upgrading, and how to resolve them. + +## ≥0.17 + +### Importing contracts in JS + +Contracts are now imported from a file with the type's name. + +For example: + +```js +import { TokenContract } from '@aztec/noir-contracts/Token' +``` + +instead of + +```js +import { TokenContract } from '@aztec/noir-contracts/types' +``` + +### Importing contracts in Nargo.toml + +Aztec contracts are now moved outside of the `src` folder, so you need to update your imports. + +For example, for `easy_private_token_contract`, you'd import them like this: + +```rust +easy_private_token_contract = {tag ="v0.1.0-alpha62", git = "", directory = "yarn-project/noir-contracts/src/contracts/easy_private_token_contract"} +``` + +Now, just remove the `src` folder, as such: + +```rust +easy_private_token_contract = {tag ="v0.1.0-alpha62", git = "", directory = "yarn-project/noir-contracts/src/contracts/easy_private_token_contract"} +``` From e905435b93c9f0ba1a2b8e569d8d3d9f4d863c94 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Fri, 5 Jan 2024 15:51:00 -0500 Subject: [PATCH 2/5] add migration notes --- docs/sidebars.js | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/docs/sidebars.js b/docs/sidebars.js index 4eb6dbdcac77..8d9748c6b545 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -81,9 +81,7 @@ const sidebars = { type: "doc", id: "concepts/foundation/state_model/main", }, - items: [ - "concepts/foundation/state_model/storage_slots" - ] + items: ["concepts/foundation/state_model/storage_slots"], }, { label: "Accounts", @@ -113,8 +111,8 @@ const sidebars = { id: "concepts/foundation/communication/public_private_calls/main", }, items: [ - "concepts/foundation/communication/public_private_calls/slow_updates_tree" - ] + "concepts/foundation/communication/public_private_calls/slow_updates_tree", + ], }, "concepts/foundation/communication/cross_chain_calls", ], @@ -324,9 +322,7 @@ const sidebars = { type: "doc", id: "dev_docs/contracts/syntax/storage/main", }, - items: [ - "dev_docs/contracts/syntax/storage/storage_slots", - ] + items: ["dev_docs/contracts/syntax/storage/storage_slots"], }, "dev_docs/contracts/syntax/events", "dev_docs/contracts/syntax/functions", @@ -361,10 +357,10 @@ const sidebars = { { label: "Common Patterns", type: "category", - link: { - type: "doc", - id: "dev_docs/contracts/resources/common_patterns/main", - }, + link: { + type: "doc", + id: "dev_docs/contracts/resources/common_patterns/main", + }, items: [ "dev_docs/contracts/resources/common_patterns/authwit", // "dev_docs/contracts/resources/common_patterns/sending_tokens_to_user", @@ -478,7 +474,7 @@ const sidebars = { value: "Miscellaneous", defaultStyle: true, }, - + "misc/migration_notes", "misc/glossary", { From f43b60f969ea7acdef7009395d4522fec782057e Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Fri, 5 Jan 2024 15:54:15 -0500 Subject: [PATCH 3/5] consistent formatting --- docs/docs/misc/migration_notes.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/docs/misc/migration_notes.md b/docs/docs/misc/migration_notes.md index 3534954bd475..402a31c0f851 100644 --- a/docs/docs/misc/migration_notes.md +++ b/docs/docs/misc/migration_notes.md @@ -15,13 +15,13 @@ Contracts are now imported from a file with the type's name. For example: ```js -import { TokenContract } from '@aztec/noir-contracts/Token' +import { TokenContract } from "@aztec/noir-contracts/Token"; ``` instead of ```js -import { TokenContract } from '@aztec/noir-contracts/types' +import { TokenContract } from "@aztec/noir-contracts/types"; ``` ### Importing contracts in Nargo.toml @@ -31,11 +31,11 @@ Aztec contracts are now moved outside of the `src` folder, so you need to update For example, for `easy_private_token_contract`, you'd import them like this: ```rust -easy_private_token_contract = {tag ="v0.1.0-alpha62", git = "", directory = "yarn-project/noir-contracts/src/contracts/easy_private_token_contract"} +easy_private_token_contract = {git = "https://github.com/AztecProtocol/aztec-packages/", tag ="v0.16.9", directory = "yarn-project/noir-contracts/src/contracts/easy_private_token_contract"} ``` Now, just remove the `src` folder, as such: ```rust -easy_private_token_contract = {tag ="v0.1.0-alpha62", git = "", directory = "yarn-project/noir-contracts/src/contracts/easy_private_token_contract"} +easy_private_token_contract = {git = "https://github.com/AztecProtocol/aztec-packages/", tag ="v0.17.0", directory = "yarn-project/noir-contracts/contracts/easy_private_token_contract"} ``` From f077b8921233ce75551a9c9d5087bfbccdf1b24b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro=20Sousa?= Date: Mon, 8 Jan 2024 10:19:43 +0000 Subject: [PATCH 4/5] chore(docs): adding another breaking change from #3844, thanks Palla --- docs/docs/misc/migration_notes.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/docs/misc/migration_notes.md b/docs/docs/misc/migration_notes.md index 402a31c0f851..b910598b525f 100644 --- a/docs/docs/misc/migration_notes.md +++ b/docs/docs/misc/migration_notes.md @@ -39,3 +39,17 @@ Now, just remove the `src` folder, as such: ```rust easy_private_token_contract = {git = "https://github.com/AztecProtocol/aztec-packages/", tag ="v0.17.0", directory = "yarn-project/noir-contracts/contracts/easy_private_token_contract"} ``` + +## New `@aztec/accounts` package + +When previously you would get the default accounts using the `getAccount` method from the `aztec.js` package: + +```js +import { getSchnorrAccount } from "@aztec/aztec.js" +``` + +You should now import them from the new package `@aztec/accounts` + +```js +import { getSchnorrAccount } from "@aztec/accounts" +``` From dd0162f952fa100d30924ab6cc0c9061555f3ed9 Mon Sep 17 00:00:00 2001 From: Rahul Kothari Date: Mon, 8 Jan 2024 15:30:52 +0000 Subject: [PATCH 5/5] add more migration notes --- docs/docs/dev_docs/updating.md | 1 + docs/docs/misc/migration_notes.md | 98 +++++++++++++++++++++++++------ 2 files changed, 80 insertions(+), 19 deletions(-) diff --git a/docs/docs/dev_docs/updating.md b/docs/docs/dev_docs/updating.md index 05c9b76de536..7d21478163c3 100644 --- a/docs/docs/dev_docs/updating.md +++ b/docs/docs/dev_docs/updating.md @@ -43,6 +43,7 @@ aztec-cli update . --contract src/contract1 --contract src/contract2 The sandbox must be running for the update command to work. +3. Refer [Migration Notes](../misc/migration_notes.md) on any breaking changes that might affect your dapp --- There are three components whose versions need to be kept compatible: diff --git a/docs/docs/misc/migration_notes.md b/docs/docs/misc/migration_notes.md index b910598b525f..6c20da38de8a 100644 --- a/docs/docs/misc/migration_notes.md +++ b/docs/docs/misc/migration_notes.md @@ -6,50 +6,110 @@ keywords: [sandbox, cli, aztec, notes, migration, updating, upgrading] Aztec is in full-speed development. Literally every version breaks compatibility with the previous ones. This page attempts to target errors and difficulties you might encounter when upgrading, and how to resolve them. -## ≥0.17 +## 0.17.0 -### Importing contracts in JS +### [js] New `@aztec/accounts` package -Contracts are now imported from a file with the type's name. +Before: -For example: +```js +import { getSchnorrAccount } from "@aztec/aztec.js" // previously you would get the default accounts from the `aztec.js` package: +``` + +Now, import them from the new package `@aztec/accounts` ```js -import { TokenContract } from "@aztec/noir-contracts/Token"; +import { getSchnorrAccount } from "@aztec/accounts" +``` + +### Typed Addresses +Address fields in Aztec.nr now is of type `AztecAddress` as opposed to `Field` + +Before: +```rust +unconstrained fn compute_note_hash_and_nullifier(contract_address: Field, nonce: Field, storage_slot: Field, serialized_note: [Field; VALUE_NOTE_LEN]) -> [Field; 4] { + let note_header = NoteHeader::new(_address, nonce, storage_slot); + ... +``` + +Now: +```rust +unconstrained fn compute_note_hash_and_nullifier( + contract_address: AztecAddress, + nonce: Field, + storage_slot: Field, + serialized_note: [Field; VALUE_NOTE_LEN] + ) -> pub [Field; 4] { + let note_header = NoteHeader::new(contract_address, nonce, storage_slot); ``` -instead of +Similarly, there are changes when using aztec.js to call functions. +To parse a `AztecAddress` to BigInt, use `.inner` +Before: ```js -import { TokenContract } from "@aztec/noir-contracts/types"; +const tokenBigInt = await bridge.methods.token().view() ``` -### Importing contracts in Nargo.toml +Now: +```js +const tokenBigInt = (await bridge.methods.token().view()).inner +``` -Aztec contracts are now moved outside of the `src` folder, so you need to update your imports. +### [Aztec.nr] Add `protocol_types` to Nargo.toml +```toml +aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/aztec" } +protocol_types = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/noir-protocol-circuits/src/crates/types"} +``` -For example, for `easy_private_token_contract`, you'd import them like this: +### [Aztec.nr] moving compute_address func to AztecAddress +Before: +```rust +let calculated_address = compute_address(pub_key_x, pub_key_y, partial_address); +``` +Now: ```rust -easy_private_token_contract = {git = "https://github.com/AztecProtocol/aztec-packages/", tag ="v0.16.9", directory = "yarn-project/noir-contracts/src/contracts/easy_private_token_contract"} +let calculated_address = AztecAddress::compute(pub_key_x, pub_key_y, partial_address); ``` -Now, just remove the `src` folder, as such: +### [Aztec.nr] moving `compute_selector` to FunctionSelector +Before: +```rust +let selector = compute_selector("_initialize((Field))"); +``` +Now: ```rust -easy_private_token_contract = {git = "https://github.com/AztecProtocol/aztec-packages/", tag ="v0.17.0", directory = "yarn-project/noir-contracts/contracts/easy_private_token_contract"} +let selector = FunctionSelector::from_signature("_initialize((Field))"); ``` -## New `@aztec/accounts` package +### [js] Importing contracts in JS + +Contracts are now imported from a file with the type's name. -When previously you would get the default accounts using the `getAccount` method from the `aztec.js` package: +Before: +```js +import { TokenContract } from "@aztec/noir-contracts/types"; +``` +Now: ```js -import { getSchnorrAccount } from "@aztec/aztec.js" +import { TokenContract } from "@aztec/noir-contracts/Token"; ``` -You should now import them from the new package `@aztec/accounts` +### [Aztec.nr] Aztec example contracts location change in Nargo.toml -```js -import { getSchnorrAccount } from "@aztec/accounts" +Aztec contracts are now moved outside of the `src` folder, so you need to update your imports. + +Before: +```rust +easy_private_token_contract = {git = "https://github.com/AztecProtocol/aztec-packages/", tag ="v0.16.9", directory = "yarn-project/noir-contracts/src/contracts/easy_private_token_contract"} +``` + +Now, just remove the `src` folder,: + +```rust +easy_private_token_contract = {git = "https://github.com/AztecProtocol/aztec-packages/", tag ="v0.17.0", directory = "yarn-project/noir-contracts/contracts/easy_private_token_contract"} ``` +