diff --git a/docs/.gitignore b/docs/.gitignore index 2b2fad560102..67fcfa892b46 100644 --- a/docs/.gitignore +++ b/docs/.gitignore @@ -22,6 +22,6 @@ npm-debug.log* yarn-debug.log* yarn-error.log* -/docs/reference/developer_references/aztecjs -/docs/reference/developer_references/smart_contract_reference/aztec-nr +/docs/developers/reference/aztecjs +/docs/developers/reference/smart_contract_reference/aztec-nr test-results diff --git a/docs/.yarn/install-state.gz b/docs/.yarn/install-state.gz index f53abb6747ec..decac804d7de 100644 Binary files a/docs/.yarn/install-state.gz and b/docs/.yarn/install-state.gz differ diff --git a/docs/HOW_WE_WRITE_DOCS.md b/docs/HOW_WE_WRITE_DOCS.md index f585953aa10b..d81fe19a17a1 100644 --- a/docs/HOW_WE_WRITE_DOCS.md +++ b/docs/HOW_WE_WRITE_DOCS.md @@ -1,12 +1,12 @@ # How we write docs -This doc covers the structure and tone of Aztec developer documentation. For the contribution guidelines, go [here](./CONTRIBUTING.md). Please keep in mind that this is constantly changing. +This doc covers the structure and tone of Aztec developer documentation. For the contribution guidelines, go [here](./CONTRIBUTING.md). Please keep in mind that this is constantly changing. ## Structure ### High level -Aztec docs are divided into two main sections - `Learn` and `Build`. +Aztec docs are divided into two main sections - `Learn` and `Build`. Anyone technical can read the `Learn` section, whereas only developers who are actively building or starting to build on Aztec will read the `Build` section. @@ -16,7 +16,7 @@ The `Build` section contains information that only developers need to know - thi ### Types of pages -The Aztec docs roughly follow the [Diataxis](https://diataxis.fr/) framework. It is recommended to read this website before contributing to the docs. +The Aztec docs roughly follow the [Diataxis](https://diataxis.fr/) framework. It is recommended to read this website before contributing to the docs. Every page will fall into **one type of doc**. If your contribution covers multiple types, you will need to split it into multiple pages. @@ -39,8 +39,8 @@ These are docs that developers can consult to know exact and succinct informatio ## Tone * Concise and informative - for example, rather than repeating information, write "to learn more, read ..." -* Friendly and empathetic - for example, "you do not have to worry about this yet" -* Simple and jardon-avoidant when possible +* Friendly and empathetic - for example, "you do not have to worry about this yet" +* Simple and jardon-avoidant when possible * Short sentences * Unopinionated language - we know things are exciting sometimes, but try not to tell the developer what they should be excited about @@ -85,4 +85,4 @@ The Aztec docs use a sidebar - https://docusaurus.io/docs/sidebar/items ## Indexing and Search -Typesense docs search - https://typesense.org/ +Algolia docs search - https://docusaurus.io/docs/search#algolia-index-configuration diff --git a/docs/docs/reference/developer_references/common_errors/_category_.json b/docs/docs/aztec/concepts/accounts/_category_.json similarity index 51% rename from docs/docs/reference/developer_references/common_errors/_category_.json rename to docs/docs/aztec/concepts/accounts/_category_.json index d4521585c1ba..2aae1b60db18 100644 --- a/docs/docs/reference/developer_references/common_errors/_category_.json +++ b/docs/docs/aztec/concepts/accounts/_category_.json @@ -1,6 +1,6 @@ { - "label": "Common Errors", - "position": 5, + "label": "Accounts", + "position": 2, "collapsible": true, "collapsed": true } diff --git a/docs/docs/aztec/concepts/accounts/index.md b/docs/docs/aztec/concepts/accounts/index.md index 4f29f273ecb1..bfd8d6a2971f 100644 --- a/docs/docs/aztec/concepts/accounts/index.md +++ b/docs/docs/aztec/concepts/accounts/index.md @@ -72,7 +72,7 @@ def entryPoint(payload): enqueueCall(to, data, value, gasLimit); ``` -Read more about how to write an account contract [here](../../../tutorials/codealong/contract_tutorials/write_accounts_contract.md). +Read more about how to write an account contract [here](../../../developers/tutorials/codealong/contract_tutorials/write_accounts_contract.md). ### Account contracts and wallets @@ -135,7 +135,7 @@ However, during a public function execution, it is not possible to retrieve a va These two patterns combined allow an account contract to answer whether an action `is_valid_impl` for a given user both in private and public contexts. -You can read more about authorizing actions with authorization witnesses on [this page](./authwit.md). +You can read more about authorizing actions with authorization witnesses on [this page](../advanced/authwit.md). :::info @@ -147,7 +147,7 @@ Transaction simulations in the PXE are not currently simulated, this is future w Aztec requires users to define [encryption and nullifying keys](./keys.md) that are needed for receiving and spending private notes. Unlike transaction signing, encryption and nullifying is enshrined at the protocol. This means that there is a single scheme used for encryption and nullifying. These keys are derived from a master public key. This master public key, in turn, is used when deterministically deriving the account's address. -A side effect of committing to a master public key as part of the address is that _this key cannot be rotated_. While an account contract implementation could include methods for rotating the signing key, this is unfortunately not possible for encryption and nullifying keys (note that rotating nullifying keys also creates other challenges such as preventing double spends). We are exploring usage of [`SharedMutable`](../../../reference/developer_references/smart_contract_reference/storage/shared_state.md#sharedmutable) to enable rotating these keys. +A side effect of committing to a master public key as part of the address is that _this key cannot be rotated_. While an account contract implementation could include methods for rotating the signing key, this is unfortunately not possible for encryption and nullifying keys (note that rotating nullifying keys also creates other challenges such as preventing double spends). We are exploring usage of [`SharedMutable`](../../../developers/reference/smart_contract_reference/storage/shared_state.md) to enable rotating these keys. NOTE: While we entertained the idea of abstracting note encryption, where account contracts would define an `encrypt` method that would use a user-defined scheme, there are two main reasons we decided against this. First is that this entailed that, in order to receive funds, a user had to first deploy their account contract, which is a major UX issue. Second, users could define malicious `encrypt` methods that failed in certain circumstances, breaking application flows that required them to receive a private note. While this issue already exists in Ethereum when transferring ETH (see the [king of the hill](https://coinsbench.com/27-king-ethernaut-da5021cd4aa6)), its impact is made worse in Aztec since any execution failure in a private function makes the entire transaction unprovable (ie it is not possible to catch errors in calls to other private functions), and furthermore because encryption is required for any private state (not just for transferring ETH). Nevertheless, both of these problems are solvable. Initialization can be worked around by embedding a commitment to the bytecode in the address and removing the need for actually deploying contracts before interacting with them, and the king of the hill issue can be mitigated by introducing a full private VM that allows catching reverts. As such, we may be able to abstract encryption in the future as well. diff --git a/docs/docs/aztec/concepts/accounts/keys.md b/docs/docs/aztec/concepts/accounts/keys.md index f4ae669db301..89b1687ddce4 100644 --- a/docs/docs/aztec/concepts/accounts/keys.md +++ b/docs/docs/aztec/concepts/accounts/keys.md @@ -54,7 +54,7 @@ When it comes to notes encryption and decryption: ### Signing keys -Thanks to the native [account abstraction](../accounts#background/index.md), authorization logic can be implemented in an alternative way that is up to the developer (e.g. using Google authorization credentials, vanilla password logic or Face ID mechanism). In these cases, signing keys may not be relevant. +Thanks to the native [account abstraction](../accounts/index.md), authorization logic can be implemented in an alternative way that is up to the developer (e.g. using Google authorization credentials, vanilla password logic or Face ID mechanism). In these cases, signing keys may not be relevant. However if one wants to implement authorization logic containing signatures (e.g. ECDSA or Shnorr) they will need signing keys. Usually, an account contract will validate a signature of the incoming payload against a known signing public key. @@ -85,7 +85,7 @@ When it comes to storing the signing key in a private note, there are several de #### Using Shared Mutable state -By [Shared Mutable](../../../reference/developer_references/smart_contract_reference/storage/shared_state#sharedmutable) we mean privately readable publicly mutable state. +By [Shared Mutable](../../../developers/reference/smart_contract_reference/storage/shared_state.md#sharedmutable) we mean privately readable publicly mutable state. To make public state accessible privately, there is a delay window in public state updates. One needs this window to be able to generate proofs client-side. This approach would not generate additional nullifiers and commitments for each transaction while allowing the user to rotate their key. However, this causes every transaction to now have a time-to-live determined by the frequency of the mutable shared state, as well as imposing restrictions on how fast keys can be rotated due to minimum delays. @@ -123,7 +123,7 @@ App-siloed keys allow to minimize damage of potential key leaks as a leak of the App-siloed keys are derived from the corresponding master keys and the contract address. For example, for the app-siloed nullifier secret key: `nsk_app = hash(nsk_m, app_contract_address)`. -App-siloed keys [are derived](../storage/storage_slots#implementation/index.md) in PXE every time the user interacts with the application. +App-siloed keys [are derived](../advanced/storage/storage_slots.md#implementation) in PXE every time the user interacts with the application. App-siloed incoming viewing key also allows per-application auditability. A user may choose to disclose this key for a given application to an auditor or regulator (or for 3rd party interfaces, e.g. giving access to a block explorer to display my activity), as a means to reveal all their activity within that context, while retaining privacy across all other applications in the network. diff --git a/docs/docs/aztec/concepts/accounts/authwit.md b/docs/docs/aztec/concepts/advanced/authwit.md similarity index 95% rename from docs/docs/aztec/concepts/accounts/authwit.md rename to docs/docs/aztec/concepts/advanced/authwit.md index 307c07a0edba..fae1972c8ebc 100644 --- a/docs/docs/aztec/concepts/accounts/authwit.md +++ b/docs/docs/aztec/concepts/advanced/authwit.md @@ -1,7 +1,7 @@ --- title: Authentication Witness (Authwit) tags: [accounts, authwit] -importance: 1 +sidebar_position: 2 keywords: [authwit, authentication witness, accounts] --- @@ -42,9 +42,9 @@ All of these issues have been discussed in the community for a while, and there Adopting ERC20 for Aztec is not as simple as it might seem because of private state. -If you recall from the [Hybrid State model](../storage/state_model/index.md), private state is generally only known by its owner and those they have shared it with. Because it relies on secrets, private state might be "owned" by a contract, but it needs someone with knowledge of these secrets to actually spend it. You might see where this is going. +If you recall from the [Hybrid State model](../storage/state_model.md), private state is generally only known by its owner and those they have shared it with. Because it relies on secrets, private state might be "owned" by a contract, but it needs someone with knowledge of these secrets to actually spend it. You might see where this is going. -If we were to implement the `approve` with an allowance in private, you might know the allowance, but unless you also know about the individual notes that make up the user's balances, it would be of no use to you! It is private after all. To spend the user's funds you would need to know the decryption key, see [keys for more](./keys.md). +If we were to implement the `approve` with an allowance in private, you might know the allowance, but unless you also know about the individual notes that make up the user's balances, it would be of no use to you! It is private after all. To spend the user's funds you would need to know the decryption key, see [keys for more](../accounts/keys.md). While this might sound limiting in what we can actually do, the main use of approvals have been for simplifying contract interactions that the user is doing. In the case of private transactions, this is executed on the user device, so it is not a blocker that the user need to tell the executor a secret - the user is the executor! @@ -140,4 +140,4 @@ We don't need to limit ourselves to the `transfer` function, we can use the same ### Next Steps -Check out the [developer documentation](../../../guides/developer_guides/smart_contracts/writing_contracts/authwit.md) to see how to implement this in your own contracts. +Check out the [developer documentation](../../../developers/guides/smart_contracts/writing_contracts/authwit.md) to see how to implement this in your own contracts. diff --git a/docs/docs/aztec/concepts/advanced/circuits/_category_.json b/docs/docs/aztec/concepts/advanced/circuits/_category_.json new file mode 100644 index 000000000000..611f5ed6919f --- /dev/null +++ b/docs/docs/aztec/concepts/advanced/circuits/_category_.json @@ -0,0 +1,6 @@ +{ + "label": "Circuits", + "position": 3, + "collapsible": true, + "collapsed": true +} diff --git a/docs/docs/aztec/concepts/circuits/index.md b/docs/docs/aztec/concepts/advanced/circuits/index.md similarity index 97% rename from docs/docs/aztec/concepts/circuits/index.md rename to docs/docs/aztec/concepts/advanced/circuits/index.md index 69b2e70499c5..79f0a9aeaa18 100644 --- a/docs/docs/aztec/concepts/circuits/index.md +++ b/docs/docs/aztec/concepts/advanced/circuits/index.md @@ -1,6 +1,6 @@ --- title: Circuits -sidebar_position: 7 +sidebar_position: 2 tags: [protocol, circuits] --- @@ -53,7 +53,7 @@ In other words, since neither the EVM nor other rollups have rules for how to pr What kind of extra rules / checks does a rollup need, to enforce notions of private states and private functions? Stuff like: -- "Perform state reads and writes using new tree structures which prevent tx linkability" (see [trees](../storage/trees/index.md)). +- "Perform state reads and writes using new tree structures which prevent tx linkability" (see [indexed merkle tree](../storage/indexed_merkle_tree.mdx). - "Hide which function was just executed, by wrapping it in a zk-snark" - "Hide all functions which were executed as part of this tx's stack trace, by wrapping the whole tx in a zk-snark" diff --git a/docs/docs/tutorials/examples/_category_.json b/docs/docs/aztec/concepts/advanced/circuits/kernels/_category_.json similarity index 63% rename from docs/docs/tutorials/examples/_category_.json rename to docs/docs/aztec/concepts/advanced/circuits/kernels/_category_.json index 29f159518ad5..aa6ead3d71df 100644 --- a/docs/docs/tutorials/examples/_category_.json +++ b/docs/docs/aztec/concepts/advanced/circuits/kernels/_category_.json @@ -1,5 +1,5 @@ { - "label": "Smart Contract Examples", + "label": "Kernel Circuits", "position": 0, "collapsible": true, "collapsed": true diff --git a/docs/docs/aztec/concepts/circuits/kernels/private_kernel.md b/docs/docs/aztec/concepts/advanced/circuits/kernels/private_kernel.md similarity index 100% rename from docs/docs/aztec/concepts/circuits/kernels/private_kernel.md rename to docs/docs/aztec/concepts/advanced/circuits/kernels/private_kernel.md diff --git a/docs/docs/aztec/concepts/advanced/circuits/kernels/public_kernel.md b/docs/docs/aztec/concepts/advanced/circuits/kernels/public_kernel.md new file mode 100644 index 000000000000..a8b8945ffc0f --- /dev/null +++ b/docs/docs/aztec/concepts/advanced/circuits/kernels/public_kernel.md @@ -0,0 +1,6 @@ +--- +title: Public Kernel Circuit +tags: [protocol, circuits] +--- + +This circuit is executed by a Sequencer, since only a Sequencer knows the current state of the [public data tree](../../../storage/state_model.md#public-state) at any time. A Sequencer might choose to delegate proof generation to the Prover pool. diff --git a/docs/docs/aztec/concepts/circuits/rollup_circuits/index.md b/docs/docs/aztec/concepts/advanced/circuits/rollup_circuits/index.md similarity index 100% rename from docs/docs/aztec/concepts/circuits/rollup_circuits/index.md rename to docs/docs/aztec/concepts/advanced/circuits/rollup_circuits/index.md diff --git a/docs/docs/aztec/concepts/advanced/index.md b/docs/docs/aztec/concepts/advanced/index.md new file mode 100644 index 000000000000..c818c03e92ee --- /dev/null +++ b/docs/docs/aztec/concepts/advanced/index.md @@ -0,0 +1,12 @@ +--- +title: Advanced Concepts +sidebar_position: 7 +tags: [protocol] +--- + +In this section, you'll learn about the more advanced concepts of the Aztec Network. It is not required to understand these in order to start building on Aztec. + +import DocCardList from '@theme/DocCardList'; + + + diff --git a/docs/docs/aztec/_category_.json b/docs/docs/aztec/concepts/advanced/storage/_category_.json similarity index 62% rename from docs/docs/aztec/_category_.json rename to docs/docs/aztec/concepts/advanced/storage/_category_.json index 22b47d59039f..537ab73d1a05 100644 --- a/docs/docs/aztec/_category_.json +++ b/docs/docs/aztec/concepts/advanced/storage/_category_.json @@ -1,5 +1,5 @@ { - "label": "Aztec", + "label": "Advanced Storage Concepts", "position": 1, "collapsible": true, "collapsed": true diff --git a/docs/docs/aztec/concepts/storage/trees/indexed_merkle_tree.mdx b/docs/docs/aztec/concepts/advanced/storage/indexed_merkle_tree.mdx similarity index 99% rename from docs/docs/aztec/concepts/storage/trees/indexed_merkle_tree.mdx rename to docs/docs/aztec/concepts/advanced/storage/indexed_merkle_tree.mdx index 656b7bfd302a..22e7ea7603bd 100644 --- a/docs/docs/aztec/concepts/storage/trees/indexed_merkle_tree.mdx +++ b/docs/docs/aztec/concepts/advanced/storage/indexed_merkle_tree.mdx @@ -1,5 +1,7 @@ --- -title: Indexed Merkle Tree +title: Indexed Merkle Tree (Nullifier Tree) +tags: [storage, concepts, advanced] +sidebar_position: 2 --- import Image from "@theme/IdealImage"; @@ -48,7 +50,7 @@ Data is stored at the leaf index corresponding to its value. E.g. if I have a sp ## Problems introduced by using Sparse Merkle Trees for Nullifier Trees -While sparse Merkle Trees offer a simple and elegant solution, their implementation comes with some drawbacks. A sparse nullifier tree must have an index for $e \in \mathbb{F}_p$, which for the bn254 curve means that the sparse tree will need to have a depth of 254. +While sparse Merkle Trees offer a simple and elegant solution, their implementation comes with some drawbacks. A sparse nullifier tree must have an index for $e \in \mathbb{F}_p$, which for the bn254 curve means that the sparse tree will need to have a depth of 254. If you're familiar with hashing in circuits the alarm bells have probably started ringing. A tree of depth 254 means 254 hashes per membership proof. In routine nullifier insertions, a non membership check for a value is performed, then an insertion of said value. This amounts to two trips from leaf to root, hashing all the way up. This means that there are $254*2$ hashes per tree insertion. As the tree is sparse, insertions are random and must be performed in sequence. This means the number of hashes performed in the circuit scales linearly with the number of nullifiers being inserted. As a consequence number of constraints in a rollup circuit (where these checks are performed) will sky rocket, leading to long rollup proving times. diff --git a/docs/docs/aztec/concepts/storage/partial_notes.md b/docs/docs/aztec/concepts/advanced/storage/partial_notes.md similarity index 98% rename from docs/docs/aztec/concepts/storage/partial_notes.md rename to docs/docs/aztec/concepts/advanced/storage/partial_notes.md index ba5f7196f5fb..5d223862d935 100644 --- a/docs/docs/aztec/concepts/storage/partial_notes.md +++ b/docs/docs/aztec/concepts/advanced/storage/partial_notes.md @@ -2,6 +2,7 @@ title: Partial Notes description: Describes how partial notes are used in Aztec tags: [notes, storage] +sidebar_position: 3 --- Partial notes are a concept that allows users to commit to an encrypted value, and allows a counterparty to update that value without knowing the specific details of the encrypted value. @@ -138,7 +139,7 @@ This is implemented by applying the `partial_note` attribute: #include_code UintNote noir-projects/aztec-nr/uint-note/src/uint_note.nr rust -Those `G_x` are generators that generated [here](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/noir-projects/aztec-nr/aztec/src/generators.nr). Anyone can use them for separating different fields in a "partial note". +Those `G_x` are generators that generated [here](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/noir-projects/noir-projects/aztec-nr/aztec/src/generators.nr). Anyone can use them for separating different fields in a "partial note". We can see the complete implementation of creating and completing partial notes in an Aztec contract in the `setup_refund` and `complete_refund` functions. diff --git a/docs/docs/aztec/concepts/storage/storage_slots.md b/docs/docs/aztec/concepts/advanced/storage/storage_slots.md similarity index 73% rename from docs/docs/aztec/concepts/storage/storage_slots.md rename to docs/docs/aztec/concepts/advanced/storage/storage_slots.md index d3121c645d94..2bfc1ef43b03 100644 --- a/docs/docs/aztec/concepts/storage/storage_slots.md +++ b/docs/docs/aztec/concepts/advanced/storage/storage_slots.md @@ -1,9 +1,14 @@ +--- +title: Storage Slots +tags: [storage, concepts, advanced] +sidebar_position: 1 +--- # Storage Slots ## Public State Slots -As mentioned in [State Model](../storage/state_model/index.md), Aztec public state behaves similarly to public state on Ethereum from the point of view of the developer. Behind the scenes however, the storage is managed differently. As mentioned, public state has just one large sparse tree in Aztec - so we silo slots of public data by hashing it together with its contract address. +As mentioned in [State Model](../../storage/state_model.md), Aztec public state behaves similarly to public state on Ethereum from the point of view of the developer. Behind the scenes however, the storage is managed differently. As mentioned, public state has just one large sparse tree in Aztec - so we silo slots of public data by hashing it together with its contract address. The mental model is that we have a key-value store, where the siloed slot is the key, and the value is the data stored in that slot. You can think of the `real_storage_slot` identifying its position in the tree, and the `logical_storage_slot` identifying the position in the contract storage. @@ -11,13 +16,13 @@ The mental model is that we have a key-value store, where the siloed slot is the real_storage_slot = H(contract_address, logical_storage_slot) ``` -The siloing is performed by the [Kernel circuits](../circuits/index.md). +The siloing is performed by the [Kernel circuits](../circuits/kernels/private_kernel.md). For structs and arrays, we are logically using a similar storage slot computation to ethereum, e.g., as a struct with 3 fields would be stored in 3 consecutive slots. However, because the "actual" storage slot is computed as a hash of the contract address and the logical storage slot, the actual storage slot is not consecutive. ## Private State Slots -Private storage is a different beast. As you might remember from [Hybrid State Model](../storage/state_model/index.md), private state is stored in encrypted logs and the corresponding private state commitments in append-only tree, called the note hash tree where each leaf is a commitment. Append-only means that leaves are never updated or deleted; instead a nullifier is emitted to signify that some note is no longer valid. A major reason we used this tree, is that updates at a specific storage slot would leak information in the context of private state, even if the value is encrypted. That is not good privacy. +Private storage is a different beast. As you might remember from [Hybrid State Model](../../storage/state_model.md), private state is stored in encrypted logs and the corresponding private state commitments in append-only tree, called the note hash tree where each leaf is a commitment. Append-only means that leaves are never updated or deleted; instead a nullifier is emitted to signify that some note is no longer valid. A major reason we used this tree, is that updates at a specific storage slot would leak information in the context of private state, even if the value is encrypted. That is not good privacy. Following this, the storage slot as we know it doesn't really exist. The leaves of the note hashes tree are just commitments to content (think of it as a hash of its content). @@ -52,4 +57,4 @@ By doing this address-siloing at the kernel circuit we _force_ the inserted comm To ensure that nullifiers don't collide across contracts we also force this contract siloing at the kernel level. ::: -For an example of this see [developer documentation on storage](../../../reference/developer_references/smart_contract_reference/storage/index.md). +For an example of this see [developer documentation on storage](../../../../developers/reference/smart_contract_reference/storage/index.md). diff --git a/docs/docs/aztec/concepts/circuits/kernels/public_kernel.md b/docs/docs/aztec/concepts/circuits/kernels/public_kernel.md deleted file mode 100644 index c5466010908d..000000000000 --- a/docs/docs/aztec/concepts/circuits/kernels/public_kernel.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: Public Kernel Circuit -tags: [protocol, circuits] ---- - -This circuit is executed by a Sequencer, since only a Sequencer knows the current state of the [public data tree](../../storage/trees/index.md) at any time. A Sequencer might choose to delegate proof generation to the Prover pool. diff --git a/docs/docs/aztec/concepts/pxe/acir_simulator.md b/docs/docs/aztec/concepts/pxe/acir_simulator.md index 385e95c070bf..c6bb4ac8c8d7 100644 --- a/docs/docs/aztec/concepts/pxe/acir_simulator.md +++ b/docs/docs/aztec/concepts/pxe/acir_simulator.md @@ -20,7 +20,7 @@ Private functions can call other private functions and can request to call a pub ### Public Functions -Public functions are simulated and proved on the [sequencer](../../network/sequencer/index.md) side, and verified by the [public kernel circuit](../../concepts/circuits/kernels/public_kernel.md). +Public functions are simulated and proved on the sequencer side, and verified by the [public kernel circuit](../../concepts/advanced/circuits/kernels/public_kernel.md). They are run with the assistance of an oracle that provides any value read from the public state tree. diff --git a/docs/docs/aztec/concepts/pxe/index.md b/docs/docs/aztec/concepts/pxe/index.md index c5f5d0e5416e..c82f3bcc97f7 100644 --- a/docs/docs/aztec/concepts/pxe/index.md +++ b/docs/docs/aztec/concepts/pxe/index.md @@ -52,7 +52,7 @@ Until there are simulated simulations ([#9133](https://github.com/AztecProtocol/ ### Proof Generation -After simulation, the wallet calls `proveTx` on the PXE with all of the data generated during simulation and any [authentication witnesses](../accounts/authwit.md) (for allowing contracts to act on behalf of the users' account contract). +After simulation, the wallet calls `proveTx` on the PXE with all of the data generated during simulation and any [authentication witnesses](../advanced/authwit.md) (for allowing contracts to act on behalf of the users' account contract). Once proven, the wallet sends the transaction to the network and sends the transaction hash back to the application. @@ -108,5 +108,5 @@ Oracles are pieces of data that are injected into a smart contract function from To learn how to develop on top of the PXE, refer to these guides: -- [Run more than one PXE on your local machine](../../../guides/developer_guides/local_env/run_more_than_one_pxe_sandbox.md) -- [Use in-built oracles including oracles for arbitrary data](../../../guides/developer_guides/smart_contracts/writing_contracts/how_to_pop_capsules.md) +- [Run more than one PXE on your local machine](../../../developers/guides/local_env/run_more_than_one_pxe_sandbox.md) +- [Use in-built oracles including oracles for arbitrary data](../../../developers/guides/smart_contracts/writing_contracts/how_to_pop_capsules.md) diff --git a/docs/docs/aztec/concepts/storage/_category_.json b/docs/docs/aztec/concepts/storage/_category_.json new file mode 100644 index 000000000000..18fc6d50b8ce --- /dev/null +++ b/docs/docs/aztec/concepts/storage/_category_.json @@ -0,0 +1,6 @@ +{ + "label": "Storage", + "position": 0, + "collapsible": true, + "collapsed": true +} diff --git a/docs/docs/aztec/concepts/storage/index.md b/docs/docs/aztec/concepts/storage/index.md index 3e115ed8b44f..d440a19d8d41 100644 --- a/docs/docs/aztec/concepts/storage/index.md +++ b/docs/docs/aztec/concepts/storage/index.md @@ -1,7 +1,7 @@ --- title: Storage description: How are storage slots derived for public and private state -sidebar_position: 2 +sidebar_position: 0 tags: [protocol, storage] --- diff --git a/docs/docs/aztec/concepts/storage/state_model/index.md b/docs/docs/aztec/concepts/storage/state_model.md similarity index 96% rename from docs/docs/aztec/concepts/storage/state_model/index.md rename to docs/docs/aztec/concepts/storage/state_model.md index 9aa78d92d3f8..7fa650fc4987 100644 --- a/docs/docs/aztec/concepts/storage/state_model/index.md +++ b/docs/docs/aztec/concepts/storage/state_model.md @@ -35,4 +35,4 @@ This is achieved with two main features: ## Further reading -Read more about how to leverage the Aztec state model in Aztec contracts [here](../../storage/index.md). +Read more about how to leverage the Aztec state model in Aztec contracts [here](../../../developers/reference/smart_contract_reference/storage/index.md). diff --git a/docs/docs/aztec/concepts/storage/state_model/public_vm.md b/docs/docs/aztec/concepts/storage/state_model/public_vm.md deleted file mode 100644 index dd2f5b2d0b19..000000000000 --- a/docs/docs/aztec/concepts/storage/state_model/public_vm.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -title: Public VM ---- - -import Spec_Placeholder from '/components/snippet'; - - diff --git a/docs/docs/aztec/concepts/storage/trees/index.md b/docs/docs/aztec/concepts/storage/trees/index.md deleted file mode 100644 index 387a27dd87ec..000000000000 --- a/docs/docs/aztec/concepts/storage/trees/index.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -title: Trees ---- - -import Spec_Placeholder from '/components/snippet'; - - diff --git a/docs/docs/aztec/concepts/wallets/index.md b/docs/docs/aztec/concepts/wallets/index.md index 02b0f04fee9d..013336faa8b1 100644 --- a/docs/docs/aztec/concepts/wallets/index.md +++ b/docs/docs/aztec/concepts/wallets/index.md @@ -6,7 +6,7 @@ tags: [accounts] On this page we will cover the main responsibilities of a wallet in the Aztec network. -Refer to [writing an account contract](../../../tutorials/codealong/contract_tutorials/write_accounts_contract.md) for a tutorial on how to write a contract to back a user's account. +Refer to [writing an account contract](../../../developers/tutorials/codealong/contract_tutorials/write_accounts_contract.md) for a tutorial on how to write a contract to back a user's account. Go to [wallet architecture](./architecture.md) for an overview of its architecture and a reference on the interface a wallet must implement. @@ -22,7 +22,7 @@ The first step for any wallet is to let the user set up their [accounts](../acco A wallet must support at least one specific account contract implementation, which means being able to deploy such a contract, as well as interacting with it when sending transactions. Code-wise, this requires [implementing the `AccountContract` interface](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/aztec.js/src/account_contract/index.ts). -Note that users must be able to receive funds in Aztec before deploying their account. A wallet should let a user generate a [deterministic complete address](../accounts/keys.md#complete-address) without having to interact with the network, so they can share it with others to receive funds. This requires that the wallet pins a specific contract implementation, its initialization arguments, a deployment salt, and a privacy key. These values yield a deterministic address, so when the account contract is actually deployed, it is available at the precalculated address. Once the account contract is deployed, the user can start sending transactions using it as the transaction origin. +Note that users must be able to receive funds in Aztec before deploying their account. A wallet should let a user generate a [deterministic complete address](../accounts/keys.md#address-keys) without having to interact with the network, so they can share it with others to receive funds. This requires that the wallet pins a specific contract implementation, its initialization arguments, a deployment salt, and a privacy key. These values yield a deterministic address, so when the account contract is actually deployed, it is available at the precalculated address. Once the account contract is deployed, the user can start sending transactions using it as the transaction origin. ## Transaction lifecycle diff --git a/docs/docs/aztec/glossary/call_types.md b/docs/docs/aztec/glossary/call_types.md index 0bd73fcfd416..e956f4374cf7 100644 --- a/docs/docs/aztec/glossary/call_types.md +++ b/docs/docs/aztec/glossary/call_types.md @@ -144,7 +144,7 @@ aztec = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "#incl Even with the router contract achieving good privacy is hard. For example, if the value being checked against is unique and stored in the contract's public storage, it's then simple to find private transactions that are using that value in the enqueued public reads, and therefore link them to this contract. -For this reason it is encouraged to try to avoid public function calls and instead privately read [Shared State](../../reference/developer_references/smart_contract_reference/storage/shared_state.md) when possible. +For this reason it is encouraged to try to avoid public function calls and instead privately read [Shared State](../../developers/reference/smart_contract_reference/storage/shared_state.md) when possible. ### Public Execution diff --git a/docs/docs/aztec/concepts_overview.md b/docs/docs/aztec/index.md similarity index 92% rename from docs/docs/aztec/concepts_overview.md rename to docs/docs/aztec/index.md index 701e2e69b446..bb62dd08eec4 100644 --- a/docs/docs/aztec/concepts_overview.md +++ b/docs/docs/aztec/index.md @@ -1,5 +1,5 @@ --- -title: Concepts Overview +title: Aztec Overview sidebar_position: 0 tags: [protocol] --- @@ -42,9 +42,9 @@ The PXE is unaware of the Public VM. And the Public VM is unaware of the PXE. Th ## Private and public state -Private state works with UTXOs, which are chunks of data that we call notes. To keep things private, notes are stored in an [append-only UTXO tree](./concepts/storage/trees/index.md), and a nullifier is created when notes are invalidated (aka deleted). Nullifiers are stored in their own [nullifier tree](./concepts/storage/trees/index.md). +Private state works with UTXOs, which are chunks of data that we call notes. To keep things private, notes are stored in an [append-only UTXO tree](./concepts/advanced/storage/indexed_merkle_tree.mdx), and a nullifier is created when notes are invalidated (aka deleted). Nullifiers are stored in their own [nullifier tree](./concepts/advanced/storage/indexed_merkle_tree.mdx). -Public state works similarly to other chains like Ethereum, behaving like a public ledger. Public data is stored in a [public data tree](./concepts/storage/trees/index.md#public-state-tree). +Public state works similarly to other chains like Ethereum, behaving like a public ledger. Public data is stored in a public data tree. ![Public vs private state](../../static/img/public-and-private-state-diagram.png) @@ -79,7 +79,7 @@ Noir is a zero-knowledge domain specific language used for writing smart contrac ### Start coding
- +

Developer Getting Started Guide

@@ -104,15 +104,6 @@ Explore the Concepts for a deeper understanding into the components that make up
- - -

Protocol Circuits

-
- - Central to Aztec's operations are circuits in the core protocol and the developer-written Aztec.nr contracts - -
-

PXE (pronounced 'pixie')

@@ -149,4 +140,13 @@ Explore the Concepts for a deeper understanding into the components that make up
+ + +

Protocol Circuits

+
+ + Central to Aztec's operations are circuits in the core protocol and the developer-written Aztec.nr contracts + +
+
diff --git a/docs/docs/aztec/network/sequencer/index.md b/docs/docs/aztec/network/sequencer/index.md index 614f405daadb..e541d1fdd544 100644 --- a/docs/docs/aztec/network/sequencer/index.md +++ b/docs/docs/aztec/network/sequencer/index.md @@ -1,6 +1,7 @@ --- title: Sequencer -tags: [protocol] +tags: [protocol, sequencer] +draft: true --- The sequencer is a module responsible for creating and publishing new rollup blocks. This involves fetching txs from the P2P pool, ordering them, executing any public functions, running them through the rollup circuits, assembling the L2 block, and posting it to the L1 rollup contract along with any contract deployment public data. diff --git a/docs/docs/aztec/network/sequencer/sequencer_selection.md b/docs/docs/aztec/network/sequencer/sequencer_selection.md index 9feb7710294a..4fb9ad736644 100644 --- a/docs/docs/aztec/network/sequencer/sequencer_selection.md +++ b/docs/docs/aztec/network/sequencer/sequencer_selection.md @@ -1,6 +1,7 @@ --- title: Sequencer Selection -tags: [protocol] +tags: [protocol, sequencer] +draft: true --- ## Fernet diff --git a/docs/docs/aztec/roadmap/features_initial_ldt.md b/docs/docs/aztec/roadmap/features_initial_ldt.md index 9a43cb3dbd1c..2ccd80366216 100644 --- a/docs/docs/aztec/roadmap/features_initial_ldt.md +++ b/docs/docs/aztec/roadmap/features_initial_ldt.md @@ -6,7 +6,7 @@ tags: [sandbox] The Aztec Sandbox is intended to provide developers with a lightweight and fast local node, running alongside a PXE. -You can learn more about running the Sandbox [here](../../reference/developer_references/sandbox_reference/index.md). +You can learn more about running the Sandbox [here](../../developers/reference/environment_reference/sandbox-reference.md). Developers should be able to quickly spin up local, emulated instances of an Ethereum blockchain and an Aztec encrypted rollup, and start deploying private contracts and submitting private txs. diff --git a/docs/docs/aztec/smart_contracts/contract_creation.md b/docs/docs/aztec/smart_contracts/contract_creation.md index 6872b582fb81..7947c8cad92c 100644 --- a/docs/docs/aztec/smart_contracts/contract_creation.md +++ b/docs/docs/aztec/smart_contracts/contract_creation.md @@ -9,4 +9,4 @@ import Spec_Placeholder from '/components/snippet'; ## Further reading -To see how to deploy a contract in practice, check out the [dapp development tutorial](../../tutorials/codealong/js_tutorials/simple_dapp/index.md). +To see how to deploy a contract in practice, check out the [dapp development tutorial](../../developers/tutorials/codealong/js_tutorials/simple_dapp/index.md). diff --git a/docs/docs/aztec/smart_contracts/contract_structure.md b/docs/docs/aztec/smart_contracts/contract_structure.md index 79c7428faffb..2889475b0ddb 100644 --- a/docs/docs/aztec/smart_contracts/contract_structure.md +++ b/docs/docs/aztec/smart_contracts/contract_structure.md @@ -37,4 +37,4 @@ Here's a common layout for a basic Aztec.nr Contract project: ``` - See the vanilla Noir docs for [more info on packages](https://noir-lang.org/docs/noir/modules_packages_crates/crates_and_packages). -- You can review the structure of a complete contract in the NFT contract tutorial [here](../../tutorials/codealong/contract_tutorials/nft_contract.md). +- You can review the structure of a complete contract in the NFT contract tutorial [here](../../developers/tutorials/codealong/contract_tutorials/nft_contract.md). diff --git a/docs/docs/aztec/smart_contracts/functions/attributes.md b/docs/docs/aztec/smart_contracts/functions/attributes.md index 46ff05a666b1..1de3b944a4ea 100644 --- a/docs/docs/aztec/smart_contracts/functions/attributes.md +++ b/docs/docs/aztec/smart_contracts/functions/attributes.md @@ -6,13 +6,13 @@ tags: [functions] On this page you will learn about function attributes and macros. -If you are looking for a reference of function macros, go [here](../../../reference/developer_references/smart_contract_reference/macros.md). +If you are looking for a reference of function macros, go [here](../../../developers/reference/smart_contract_reference/macros.md). ## Private functions #[private] A private function operates on private information, and is executed by the user on their device. Annotate the function with the `#[private]` attribute to tell the compiler it's a private function. This will make the [private context](./context.md#the-private-context) available within the function's execution scope. The compiler will create a circuit to define this function. -`#[private]` is just syntactic sugar. At compile time, the Aztec.nr framework inserts code that allows the function to interact with the [kernel](../../../aztec/concepts/circuits/kernels/private_kernel.md). +`#[private]` is just syntactic sugar. At compile time, the Aztec.nr framework inserts code that allows the function to interact with the [kernel](../../../aztec/concepts/advanced/circuits/kernels/private_kernel.md). To help illustrate how this interacts with the internals of Aztec and its kernel circuits, we can take an example private function, and explore what it looks like after Aztec.nr's macro expansion. @@ -141,7 +141,7 @@ let storage = Storage::init(&mut context); ## Constrained `view` Functions #[view] -The `#[view]` attribute is used to define constrained view functions in Aztec contracts. These functions are similar to view functions in Solidity, in that they are read-only and do not modify the contract's state. They are similar to the [`unconstrained`](#unconstrained-functions-aztecunconstrained) keyword but are executed in a constrained environment. It is not possible to update state within an `#[view]` function. +The `#[view]` attribute is used to define constrained view functions in Aztec contracts. These functions are similar to view functions in Solidity, in that they are read-only and do not modify the contract's state. They are similar to the [`unconstrained`](#unconstrained-functions) keyword but are executed in a constrained environment. It is not possible to update state within an `#[view]` function. This means the results of these functions are verifiable and can be trusted, as they are part of the proof generation and verification process. This is unlike unconstrained functions, where results are provided by the PXE and are not verified. @@ -159,7 +159,7 @@ This is used to designate functions as initializers (or constructors) for an Azt Key things to keep in mind: - A contract can have multiple initializer functions defined, but only one initializer function should be called for the lifetime of a contract instance -- Other functions in the contract will have an initialization check inserted, ie they cannot be called until the contract is initialized, unless they are marked with [`#[noinitcheck]`](#aztecnoinitcheck) +- Other functions in the contract will have an initialization check inserted, ie they cannot be called until the contract is initialized, unless they are marked with [`#[noinitcheck]`](#noinitcheck) ## #[noinitcheck] @@ -167,7 +167,7 @@ In normal circumstances, all functions in an Aztec contract (except initializers When a function is annotated with `#[noinitcheck]`: -- The Aztec macro processor skips the [insertion of the initialization check](#initializer-functions-aztecinitializer) for this specific function +- The Aztec macro processor skips the [insertion of the initialization check](#initializer-functions-initializer) for this specific function - The function can be called at any time, even if the contract hasn't been initialized yet ## `Internal` functions #[internal] @@ -358,7 +358,7 @@ Key things to keep in mind: ## Further reading -- [Macros reference](../../../reference/developer_references/smart_contract_reference/macros.md) +- [Macros reference](../../../developers/reference/smart_contract_reference/macros.md) - [How do macros work](./attributes.md) diff --git a/docs/docs/aztec/smart_contracts/functions/context.md b/docs/docs/aztec/smart_contracts/functions/context.md index 346e822a25a6..fec4eca1aed5 100644 --- a/docs/docs/aztec/smart_contracts/functions/context.md +++ b/docs/docs/aztec/smart_contracts/functions/context.md @@ -6,7 +6,7 @@ tags: [functions, context] ## What is the context -The context is an object that is made available within every function in `Aztec.nr`. As mentioned in the [kernel circuit documentation](../../concepts/circuits/kernels/private_kernel.md). At the beginning of a function's execution, the context contains all of the kernel information that application needs to execute. During the lifecycle of a transaction, the function will update the context with each of its side effects (created notes, nullifiers etc.). At the end of a function's execution the mutated context is returned to the kernel to be checked for validity. +The context is an object that is made available within every function in `Aztec.nr`. As mentioned in the [kernel circuit documentation](../../concepts/advanced/circuits/kernels/private_kernel.md). At the beginning of a function's execution, the context contains all of the kernel information that application needs to execute. During the lifecycle of a transaction, the function will update the context with each of its side effects (created notes, nullifiers etc.). At the end of a function's execution the mutated context is returned to the kernel to be checked for validity. Behind the scenes, Aztec.nr will pass data the kernel needs to and from a circuit, this is abstracted away from the developer. In a developer's eyes; the context is a useful structure that allows access and mutate the state of the `Aztec` blockchain. diff --git a/docs/docs/aztec/smart_contracts/functions/function_transforms.md b/docs/docs/aztec/smart_contracts/functions/function_transforms.md index c87aeda95c14..67a22b36403b 100644 --- a/docs/docs/aztec/smart_contracts/functions/function_transforms.md +++ b/docs/docs/aztec/smart_contracts/functions/function_transforms.md @@ -12,7 +12,7 @@ Below, we go more into depth of what is happening under the hood when you create When you define a function in an Aztec contract, it undergoes several transformations when it is compiled. These transformations prepare the function for execution. These transformations include: - [Creating a context for the function](#context-creation) -- [Handling function inputs](#input-handling) +- [Handling function inputs](#private-and-public-input-injection) - [Processing return values](#return-value-handling) - [Computing note hashes and nullifiers](#computing-note-hash-and-nullifier) - [Generating function signatures](#function-signature-generation) @@ -192,7 +192,7 @@ fn compute_fn_signature_hash(fn_name: &str, parameters: &[Type]) -> u32 { - A string representation of the function is created, including the function name and parameter types - This signature string is then hashed using Keccak-256 -- The first 4 bytes of the resulting hash are converted to a u32 integer +- The first 4 bytes of the resulting hash are coverted to a u32 integer ### Integration into contract interface @@ -270,8 +270,8 @@ struct transfer_abi { Contract artifacts are important because: - They provide a machine-readable description of the contract -- They can be used to generate bindings for interacting with the contract (read [here](../../../guides/developer_guides/smart_contracts/how_to_compile_contract.md) to learn how to create TypeScript bindings) +- They can be used to generate bindings for interacting with the contract (read [here](../../../developers/guides/smart_contracts/how_to_compile_contract.md) to learn how to create TypeScript bindings) - They help decode function return values in the simulator ## Further reading -- [Function attributes and macros](./attributes.md) +- [Function attributes and macros](./attributes.md) \ No newline at end of file diff --git a/docs/docs/aztec/smart_contracts/functions/index.md b/docs/docs/aztec/smart_contracts/functions/index.md index 72a502f8050c..b0bffb318584 100644 --- a/docs/docs/aztec/smart_contracts/functions/index.md +++ b/docs/docs/aztec/smart_contracts/functions/index.md @@ -3,9 +3,9 @@ title: Defining Functions tags: [functions] --- -Functions serve as the building blocks of smart contracts. Functions can be either **public**, ie they are publicly available for anyone to see and can directly interact with public state, or **private**, meaning they are executed completely client-side in the [PXE](../../concepts/pxe/index.md). Read more about how private functions work [here](./attributes.md#private-functions). +Functions serve as the building blocks of smart contracts. Functions can be either **public**, ie they are publicly available for anyone to see and can directly interact with public state, or **private**, meaning they are executed completely client-side in the [PXE](../../concepts/pxe/index.md). Read more about how private functions work [here](./attributes.md#private-functions-private). -For a more practical guide of using multiple types of functions, follow the [NFT tutorial](../../../tutorials/codealong/contract_tutorials/nft_contract.md). +For a more practical guide of using multiple types of functions, follow the [NFT tutorial](../../../developers/tutorials/codealong/contract_tutorials/nft_contract.md). Currently, any function is "mutable" in the sense that it might alter state. However, we also support static calls, similarly to EVM. A static call is essentially a call that does not alter state (it keeps state static). @@ -22,8 +22,8 @@ There are also special oracle functions, which can get data from outside of the ## Learn more about functions - [How function visibility works in Aztec](./visibility.md) -- How to write an [initializer function](../../../guides/developer_guides/smart_contracts/writing_contracts/initializers.md) +- How to write an [initializer function](../../../developers/guides/smart_contracts/writing_contracts/initializers.md) - [Oracles](../oracles/index.md) and how Aztec smart contracts might use them - [How functions work under the hood](./attributes.md) -Find a function macros reference [here](../../../reference/developer_references/smart_contract_reference/macros.md) +Find a function macros reference [here](../../../developers/reference/smart_contract_reference/macros.md) diff --git a/docs/docs/aztec/smart_contracts/functions/visibility.md b/docs/docs/aztec/smart_contracts/functions/visibility.md index 599ce9818b06..006891f75c30 100644 --- a/docs/docs/aztec/smart_contracts/functions/visibility.md +++ b/docs/docs/aztec/smart_contracts/functions/visibility.md @@ -6,7 +6,7 @@ tags: [functions] In Aztec there are multiple different types of visibility that can be applied to functions. Namely we have `data visibility` and `function visibility`. This page explains these types of visibility. -For a practical guide of using multiple types of data and function visibility, follow the [NFT tutorial](../../../tutorials/codealong/contract_tutorials/nft_contract.md). +For a practical guide of using multiple types of data and function visibility, follow the [NFT tutorial](../../../developers/tutorials/codealong/contract_tutorials/nft_contract.md). ### Data Visibility diff --git a/docs/docs/aztec/smart_contracts/oracles/index.md b/docs/docs/aztec/smart_contracts/oracles/index.md index bd2f2ddc0a5c..c12afb6325c5 100644 --- a/docs/docs/aztec/smart_contracts/oracles/index.md +++ b/docs/docs/aztec/smart_contracts/oracles/index.md @@ -5,7 +5,7 @@ tags: [functions, oracles] This page goes over what oracles are in Aztec and how they work. -Looking for a hands-on guide? You can learn how to use oracles in a smart contract [here](../../../guides/developer_guides/smart_contracts/writing_contracts/how_to_pop_capsules.md). +Looking for a hands-on guide? You can learn how to use oracles in a smart contract [here](../../../developers/guides/smart_contracts/writing_contracts/how_to_pop_capsules.md). An oracle is something that allows us to get data from the outside world into our contracts. The most widely-known types of oracles in blockchain systems are probably Chainlink price feeds, which allow us to get the price of an asset in USD taking non-blockchain data into account. @@ -14,7 +14,7 @@ While this is one type of oracle, the more general oracle, allows us to get any **Why is this useful? Why don't just pass them as input parameters?** In the world of EVM, you would just read the values directly from storage and call it a day. However, when we are working with circuits for private execution, this becomes more tricky as you cannot just read the storage directly from your state tree, because there are only commitments (e.g. hashes) there. The pre-images (content) of your commitments need to be provided to the function to prove that you actually allowed to modify them. -If we fetch the notes using an oracle call, we can keep the function signature independent of the underlying data and make it easier to use. A similar idea, applied to the authentication mechanism is used for the Authentication Witnesses that allow us to have a single function signature for any wallet implementation, see [AuthWit](../../concepts/accounts/authwit.md) for more information on this. +If we fetch the notes using an oracle call, we can keep the function signature independent of the underlying data and make it easier to use. A similar idea, applied to the authentication mechanism is used for the Authentication Witnesses that allow us to have a single function signature for any wallet implementation, see [AuthWit](../../concepts/advanced/authwit.md) for more information on this. Oracles introduce **non-determinism** into a circuit, and thus are `unconstrained`. It is important that any information that is injected into a circuit through an oracle is later constrained for correctness. Otherwise, the circuit will be **under-constrained** and potentially insecure! @@ -23,7 +23,7 @@ Oracles introduce **non-determinism** into a circuit, and thus are `unconstraine ## Inbuilt oracles -- [`debug_log`](https://github.com/AztecProtocol/aztec-packages/blob/master/noir-projects/aztec-nr/aztec/src/oracle/debug_log.nr) - Provides a couple of debug functions that can be used to log information to the console. Read more about debugging [here](../../../reference/developer_references/debugging.md). +- [`debug_log`](https://github.com/AztecProtocol/aztec-packages/blob/master/noir-projects/aztec-nr/aztec/src/oracle/debug_log.nr) - Provides a couple of debug functions that can be used to log information to the console. Read more about debugging [here](../../../developers/reference/debugging/index.md). - [`auth_witness`](https://github.com/AztecProtocol/aztec-packages/blob/master/noir-projects/aztec-nr/authwit/src/auth_witness.nr) - Provides a way to fetch the authentication witness for a given address. This is useful when building account contracts to support approve-like functionality. - [`get_l1_to_l2_message`](https://github.com/AztecProtocol/aztec-packages/blob/master/noir-projects/aztec-nr/aztec/src/oracle/get_l1_to_l2_message.nr) - Useful for application that receive messages from L1 to be consumed on L2, such as token bridges or other cross-chain applications. - [`notes`](https://github.com/AztecProtocol/aztec-packages/blob/master/noir-projects/aztec-nr/aztec/src/oracle/notes.nr) - Provides a lot of functions related to notes, such as fetches notes from storage etc, used behind the scenes for value notes and other pre-build note implementations. @@ -31,4 +31,4 @@ Oracles introduce **non-determinism** into a circuit, and thus are `unconstraine Find a full list [on GitHub](https://github.com/AztecProtocol/aztec-packages/tree/master/noir-projects/aztec-nr/aztec/src/oracle). -Please note that it is **not** possible to write a custom oracle for your dapp. Oracles are implemented in the PXE, so all users of your dapp would have to use a PXE service with your custom oracle included. If you want to inject some arbitrary data that does not have a dedicated oracle, you can use [popCapsule](../../../guides/developer_guides/smart_contracts/writing_contracts/how_to_pop_capsules.md). +Please note that it is **not** possible to write a custom oracle for your dapp. Oracles are implemented in the PXE, so all users of your dapp would have to use a PXE service with your custom oracle included. If you want to inject some arbitrary data that does not have a dedicated oracle, you can use [popCapsule](../../../developers/guides/smart_contracts/writing_contracts/how_to_pop_capsules.md). diff --git a/docs/docs/aztec/smart_contracts_overview.md b/docs/docs/aztec/smart_contracts_overview.md index 234467d06e77..cd6ac1e5c391 100644 --- a/docs/docs/aztec/smart_contracts_overview.md +++ b/docs/docs/aztec/smart_contracts_overview.md @@ -25,4 +25,4 @@ There are no plans for EVM compatibility or to support Solidity in Aztec. The pr ## Further reading -Jump in and write your first smart contract [here](../tutorials/codealong/contract_tutorials/counter_contract.md) +Jump in and write your first smart contract [here](../developers/tutorials/codealong/contract_tutorials/counter_contract.md) diff --git a/docs/docs/aztec.md b/docs/docs/building_in_public.md similarity index 98% rename from docs/docs/aztec.md rename to docs/docs/building_in_public.md index 1f53886812d4..627e9d2b65ef 100644 --- a/docs/docs/aztec.md +++ b/docs/docs/building_in_public.md @@ -1,6 +1,7 @@ --- title: Building in Public sidebar_position: 0 +id: building_in_public --- import Disclaimer from "@site/src/components/Disclaimers/\_wip_disclaimer.mdx"; diff --git a/docs/docs/guides/getting_started.md b/docs/docs/developers/getting_started.md similarity index 99% rename from docs/docs/guides/getting_started.md rename to docs/docs/developers/getting_started.md index 1e1eafa8750f..9f552ce4e65b 100644 --- a/docs/docs/guides/getting_started.md +++ b/docs/docs/developers/getting_started.md @@ -226,7 +226,7 @@ Simulation result: 25n Now you have a development network running, so you're ready to start coding your first app with Aztec.nr and Aztec.js!
- +

Write your first contract

diff --git a/docs/docs/guides/_category_.json b/docs/docs/developers/guides/_category_.json similarity index 100% rename from docs/docs/guides/_category_.json rename to docs/docs/developers/guides/_category_.json diff --git a/docs/docs/guides/developer_guides/getting_started/_category_.json b/docs/docs/developers/guides/getting_started/_category_.json similarity index 100% rename from docs/docs/guides/developer_guides/getting_started/_category_.json rename to docs/docs/developers/guides/getting_started/_category_.json diff --git a/docs/docs/guides/developer_guides/getting_started/codespaces.md b/docs/docs/developers/guides/getting_started/codespaces.md similarity index 100% rename from docs/docs/guides/developer_guides/getting_started/codespaces.md rename to docs/docs/developers/guides/getting_started/codespaces.md diff --git a/docs/docs/guides/developer_guides/js_apps/_category_.json b/docs/docs/developers/guides/js_apps/_category_.json similarity index 100% rename from docs/docs/guides/developer_guides/js_apps/_category_.json rename to docs/docs/developers/guides/js_apps/_category_.json diff --git a/docs/docs/guides/developer_guides/js_apps/authwit.md b/docs/docs/developers/guides/js_apps/authwit.md similarity index 98% rename from docs/docs/guides/developer_guides/js_apps/authwit.md rename to docs/docs/developers/guides/js_apps/authwit.md index 92dd49dc6775..4392befc9770 100644 --- a/docs/docs/guides/developer_guides/js_apps/authwit.md +++ b/docs/docs/developers/guides/js_apps/authwit.md @@ -5,7 +5,7 @@ tags: [accounts, authwit] This page assumes you have authwit set up correctly in your contract. To learn how to do that, [go here](../smart_contracts/writing_contracts/authwit.md). -For an introduction to authentication witnesses on Aztec, [read this explainer](../../../aztec/concepts/accounts/authwit.md). +For an introduction to authentication witnesses on Aztec, [read this explainer](../../../aztec/concepts/advanced/authwit.md). ## Import libraries @@ -117,5 +117,5 @@ If you created an arbitrary message, you would replace the first param struct wi ## Further reading -- [An explainer of authentication witnesses](../../../aztec/concepts/accounts/authwit.md) +- [An explainer of authentication witnesses](../../../aztec/concepts/advanced/authwit.md) - [Authwits in Aztec.nr](../smart_contracts/writing_contracts/authwit.md) diff --git a/docs/docs/guides/developer_guides/js_apps/call_view_function.md b/docs/docs/developers/guides/js_apps/call_view_function.md similarity index 100% rename from docs/docs/guides/developer_guides/js_apps/call_view_function.md rename to docs/docs/developers/guides/js_apps/call_view_function.md diff --git a/docs/docs/guides/developer_guides/js_apps/create_account.md b/docs/docs/developers/guides/js_apps/create_account.md similarity index 100% rename from docs/docs/guides/developer_guides/js_apps/create_account.md rename to docs/docs/developers/guides/js_apps/create_account.md diff --git a/docs/docs/guides/developer_guides/js_apps/deploy_contract.md b/docs/docs/developers/guides/js_apps/deploy_contract.md similarity index 100% rename from docs/docs/guides/developer_guides/js_apps/deploy_contract.md rename to docs/docs/developers/guides/js_apps/deploy_contract.md diff --git a/docs/docs/guides/developer_guides/js_apps/send_transaction.md b/docs/docs/developers/guides/js_apps/send_transaction.md similarity index 100% rename from docs/docs/guides/developer_guides/js_apps/send_transaction.md rename to docs/docs/developers/guides/js_apps/send_transaction.md diff --git a/docs/docs/guides/developer_guides/js_apps/test.md b/docs/docs/developers/guides/js_apps/test.md similarity index 84% rename from docs/docs/guides/developer_guides/js_apps/test.md rename to docs/docs/developers/guides/js_apps/test.md index d2f90b396686..8c3f0d1a9c01 100644 --- a/docs/docs/guides/developer_guides/js_apps/test.md +++ b/docs/docs/developers/guides/js_apps/test.md @@ -61,7 +61,7 @@ This debug information will be populated in the transaction receipt. You can log #include_code debug /yarn-project/end-to-end/src/e2e_token_contract/private_transfer_recursion.test.ts typescript -You can also log directly from Aztec contracts. Read [this guide](../../../reference/developer_references/debugging.md#logging-in-aztecnr) for some more information. +You can also log directly from Aztec contracts. Read [this guide](../../reference/debugging/index.md#logging-in-aztecnr) for some more information. ### Examples @@ -101,13 +101,13 @@ WARN Error processing tx 06dc87c4d64462916ea58426ffcfaf20017880b353c9ec3e0f0ee5f We can check private or public state directly rather than going through view-only methods, as we did in the initial example by calling `token.methods.balance().simulate()`. -To query storage directly, you'll need to know the slot you want to access. This can be checked in the [contract's `Storage` definition](../../../reference/developer_references/smart_contract_reference/storage/index.md) directly for most data types. However, when it comes to mapping types, as in most EVM languages, we'll need to calculate the slot for a given key. To do this, we'll use the [`CheatCodes`](../../../reference/developer_references/sandbox_reference/cheat_codes.md) utility class: +To query storage directly, you'll need to know the slot you want to access. This can be checked in the [contract's `Storage` definition](../../reference/smart_contract_reference/storage/index.md) directly for most data types. However, when it comes to mapping types, as in most EVM languages, we'll need to calculate the slot for a given key. To do this, we'll use the [`CheatCodes`](../../reference/environment_reference/cheat_codes.md) utility class: #include_code calc-slot /yarn-project/end-to-end/src/guides/dapp_testing.test.ts typescript #### Querying private state -Private state in the Aztec is represented via sets of [private notes](../../../aztec/concepts/storage/state_model/index.md#private-state). We can query the Private Execution Environment (PXE) for all notes encrypted for a given user in a contract slot. For example, this gets all notes encrypted for the `owner` user that are stored on the token contract address and on the slot that was calculated earlier. To calculate the actual balance, it extracts the `value` of each note, which is the first element, and sums them up. +Private state in the Aztec is represented via sets of [private notes](../../../aztec/concepts/storage/state_model.md#private-state). We can query the Private Execution Environment (PXE) for all notes encrypted for a given user in a contract slot. For example, this gets all notes encrypted for the `owner` user that are stored on the token contract address and on the slot that was calculated earlier. To calculate the actual balance, it extracts the `value` of each note, which is the first element, and sums them up. #include_code private-storage /yarn-project/end-to-end/src/guides/dapp_testing.test.ts typescript @@ -129,7 +129,7 @@ We can query the PXE for the public logs emitted in the block where our transact ## Cheats -The [`CheatCodes`](../../../reference/developer_references/sandbox_reference/cheat_codes.md) class, which we used for [calculating the storage slot above](#querying-state), also includes a set of cheat methods for modifying the chain state that can be handy for testing. +The [`CheatCodes`](../../reference/environment_reference/cheat_codes.md) class, which we used for [calculating the storage slot above](#querying-state), also includes a set of cheat methods for modifying the chain state that can be handy for testing. ### Set next block timestamp @@ -146,5 +146,5 @@ You can then use the `warp` function on the EthCheatCodes to progress the underl - [How to send a transactions in Aztec.js](./send_transaction.md) - [How to deploy a contract in Aztec.js](./deploy_contract.md) - [How to create an account in Aztec.js](./create_account.md) -- [Cheat codes](../../../reference/developer_references/sandbox_reference/cheat_codes.md) +- [Cheat codes](../../reference/environment_reference/cheat_codes.md) - [How to compile a contract](../smart_contracts/how_to_compile_contract.md). diff --git a/docs/docs/guides/developer_guides/local_env/_category_.json b/docs/docs/developers/guides/local_env/_category_.json similarity index 100% rename from docs/docs/guides/developer_guides/local_env/_category_.json rename to docs/docs/developers/guides/local_env/_category_.json diff --git a/docs/docs/guides/developer_guides/local_env/cloning_a_box.md b/docs/docs/developers/guides/local_env/cloning_a_box.md similarity index 100% rename from docs/docs/guides/developer_guides/local_env/cloning_a_box.md rename to docs/docs/developers/guides/local_env/cloning_a_box.md diff --git a/docs/docs/guides/developer_guides/local_env/creating_schnorr_accounts.md b/docs/docs/developers/guides/local_env/creating_schnorr_accounts.md similarity index 96% rename from docs/docs/guides/developer_guides/local_env/creating_schnorr_accounts.md rename to docs/docs/developers/guides/local_env/creating_schnorr_accounts.md index b45b653b7f9b..6e88e456a22e 100644 --- a/docs/docs/guides/developer_guides/local_env/creating_schnorr_accounts.md +++ b/docs/docs/developers/guides/local_env/creating_schnorr_accounts.md @@ -65,4 +65,4 @@ Once this has completed, the L2 block is retrieved and pulled down to the PXE so ## Next Steps -Check out our section on [Writing your own Account Contract](../../../tutorials/codealong/contract_tutorials/write_accounts_contract.md) leveraging our account abstraction. +Check out our section on [Writing your own Account Contract](../../tutorials/codealong/contract_tutorials/write_accounts_contract.md) leveraging our account abstraction. diff --git a/docs/docs/guides/developer_guides/local_env/installing_noir_lsp.md b/docs/docs/developers/guides/local_env/installing_noir_lsp.md similarity index 100% rename from docs/docs/guides/developer_guides/local_env/installing_noir_lsp.md rename to docs/docs/developers/guides/local_env/installing_noir_lsp.md diff --git a/docs/docs/guides/developer_guides/local_env/run_more_than_one_pxe_sandbox.md b/docs/docs/developers/guides/local_env/run_more_than_one_pxe_sandbox.md similarity index 95% rename from docs/docs/guides/developer_guides/local_env/run_more_than_one_pxe_sandbox.md rename to docs/docs/developers/guides/local_env/run_more_than_one_pxe_sandbox.md index d937f6f5f139..574fbd492d27 100644 --- a/docs/docs/guides/developer_guides/local_env/run_more_than_one_pxe_sandbox.md +++ b/docs/docs/developers/guides/local_env/run_more_than_one_pxe_sandbox.md @@ -42,4 +42,4 @@ You should see something like this: Aztec Server listening on port 8080 ``` -You can learn more about custom commands in the [sandbox reference](../../../reference/developer_references/sandbox_reference/sandbox-reference.md). +You can learn more about custom commands in the [sandbox reference](../../reference/environment_reference/sandbox-reference.md). diff --git a/docs/docs/guides/developer_guides/local_env/sandbox_proving.md b/docs/docs/developers/guides/local_env/sandbox_proving.md similarity index 94% rename from docs/docs/guides/developer_guides/local_env/sandbox_proving.md rename to docs/docs/developers/guides/local_env/sandbox_proving.md index c6fd869a971c..e84a1bd914e9 100644 --- a/docs/docs/guides/developer_guides/local_env/sandbox_proving.md +++ b/docs/docs/developers/guides/local_env/sandbox_proving.md @@ -46,12 +46,12 @@ You can enable proving on a per-transaction basis using the `aztec-wallet` CLI b PXE_PROVER_ENABLED=1 aztec-wallet create-account -a test ``` -Check the [Quickstart](../../getting_started.md) for a refresher on how to send transactions using `aztec-wallet` or check the [reference here](../../../reference/developer_references/cli_wallet_reference.md) +Check the [Quickstart](../../getting_started.md) for a refresher on how to send transactions using `aztec-wallet` or check the [reference here](../../reference/environment_reference/cli_wallet_reference.md) Note that you do not need to restart the sandbox in order to start sending proven transactions. You can optionally set this for one-off transactions. If this is the first time you are sending transactions with proving enabled, it will take a while to download a CRS file (which is several MBs) that is required for proving. :::note -You can also profile your transactions to get gate count, if you don't want to prove your transactions but check how many constraints it is. Follow the [guide here](../../developer_guides/smart_contracts/profiling_transactions.md) +You can also profile your transactions to get gate count, if you don't want to prove your transactions but check how many constraints it is. Follow the [guide here](../../guides/smart_contracts/profiling_transactions.md) ::: diff --git a/docs/docs/guides/developer_guides/local_env/versions-updating.md b/docs/docs/developers/guides/local_env/versions-updating.md similarity index 98% rename from docs/docs/guides/developer_guides/local_env/versions-updating.md rename to docs/docs/developers/guides/local_env/versions-updating.md index 9e90f47102c9..f3a77b0abc2f 100644 --- a/docs/docs/guides/developer_guides/local_env/versions-updating.md +++ b/docs/docs/developers/guides/local_env/versions-updating.md @@ -94,7 +94,7 @@ cd your/aztec/project aztec update . --contract src/contract1 --contract src/contract2 ``` -The sandbox must be running for the update command to work. Make sure it is [installed and running](../../../reference/developer_references/sandbox_reference/sandbox-reference.md). +The sandbox must be running for the update command to work. Make sure it is [installed and running](../../reference/environment_reference/sandbox-reference.md). Follow [updating Aztec.nr packages](#updating-aztecnr-packages) and [updating JavaScript packages](#updating-aztecjs-packages) guides. diff --git a/docs/docs/guides/developer_guides/smart_contracts/_category_.json b/docs/docs/developers/guides/smart_contracts/_category_.json similarity index 100% rename from docs/docs/guides/developer_guides/smart_contracts/_category_.json rename to docs/docs/developers/guides/smart_contracts/_category_.json diff --git a/docs/docs/guides/developer_guides/smart_contracts/how_to_compile_contract.md b/docs/docs/developers/guides/smart_contracts/how_to_compile_contract.md similarity index 98% rename from docs/docs/guides/developer_guides/smart_contracts/how_to_compile_contract.md rename to docs/docs/developers/guides/smart_contracts/how_to_compile_contract.md index df41a986f684..ceec6fcbd5a2 100644 --- a/docs/docs/guides/developer_guides/smart_contracts/how_to_compile_contract.md +++ b/docs/docs/developers/guides/smart_contracts/how_to_compile_contract.md @@ -8,7 +8,7 @@ Once you have written a contract in Aztec.nr, you will need to compile it into a In this guide we will cover how to do so, both using the `aztec-nargo` command and programmatically. -We'll also cover how to generate a helper [TypeScript interface](#typescript-interfaces) and an [Aztec.nr interface](#noir-interfaces) for easily interacting with your contract from your typescript app and from other Aztec.nr contracts, respectively. +We'll also cover how to generate a helper [TypeScript interface](#typescript-interfaces) and an [Aztec.nr interface](#aztecnr-interfaces) for easily interacting with your contract from your typescript app and from other Aztec.nr contracts, respectively. ## Compile using aztec-nargo @@ -444,7 +444,7 @@ export class TokenContract extends ContractBase { } ``` -Read more about interacting with contracts using `aztec.js` [by following this tutorial](../../../tutorials/codealong/js_tutorials/aztecjs-getting-started.md). +Read more about interacting with contracts using `aztec.js` [by following this tutorial](../../tutorials/codealong/js_tutorials/aztecjs-getting-started.md). ### Aztec.nr interfaces diff --git a/docs/docs/guides/developer_guides/smart_contracts/how_to_deploy_contract.md b/docs/docs/developers/guides/smart_contracts/how_to_deploy_contract.md similarity index 93% rename from docs/docs/guides/developer_guides/smart_contracts/how_to_deploy_contract.md rename to docs/docs/developers/guides/smart_contracts/how_to_deploy_contract.md index c6f7e9e57b48..8ff26d815823 100644 --- a/docs/docs/guides/developer_guides/smart_contracts/how_to_deploy_contract.md +++ b/docs/docs/developers/guides/smart_contracts/how_to_deploy_contract.md @@ -10,7 +10,7 @@ You can use this method to deploy your contracts to the sandbox or to a remote n ## Prerequisites -- `aztec-nargo` installed (go to [Sandbox section](../../../reference/developer_references/sandbox_reference/sandbox-reference.md) for installation instructions) +- `aztec-nargo` installed (go to [Sandbox section](../../reference/environment_reference/sandbox-reference.md) for installation instructions) - contract artifacts ready (go to [How to Compile Contract](./how_to_compile_contract.md) for instructions on how to compile contracts) - Aztec Sandbox running (go to [Getting Started](../../getting_started.md) for instructions on how to install and run the sandbox) diff --git a/docs/docs/guides/developer_guides/smart_contracts/index.mdx b/docs/docs/developers/guides/smart_contracts/index.mdx similarity index 100% rename from docs/docs/guides/developer_guides/smart_contracts/index.mdx rename to docs/docs/developers/guides/smart_contracts/index.mdx diff --git a/docs/docs/guides/developer_guides/smart_contracts/profiling_transactions.md b/docs/docs/developers/guides/smart_contracts/profiling_transactions.md similarity index 96% rename from docs/docs/guides/developer_guides/smart_contracts/profiling_transactions.md rename to docs/docs/developers/guides/smart_contracts/profiling_transactions.md index 66715f452e1e..0cd790bd211e 100644 --- a/docs/docs/guides/developer_guides/smart_contracts/profiling_transactions.md +++ b/docs/docs/developers/guides/smart_contracts/profiling_transactions.md @@ -14,7 +14,7 @@ In this guide, we will look at how to profile the private execution of a transac ## Prerequisites -- `aztec-nargo` installed (go to [Sandbox section](../../../reference/developer_references/sandbox_reference/sandbox-reference.md) for installation instructions) +- `aztec-nargo` installed (go to [Sandbox section](../../reference/environment_reference/sandbox-reference.md) for installation instructions) - `aztec-wallet` installed (installed as part of the Sandbox) ## Profiling using aztec-wallet diff --git a/docs/docs/guides/developer_guides/smart_contracts/testing.md b/docs/docs/developers/guides/smart_contracts/testing.md similarity index 99% rename from docs/docs/guides/developer_guides/smart_contracts/testing.md rename to docs/docs/developers/guides/smart_contracts/testing.md index 0a5c256c3c86..59b5e4e9cfe8 100644 --- a/docs/docs/guides/developer_guides/smart_contracts/testing.md +++ b/docs/docs/developers/guides/smart_contracts/testing.md @@ -215,7 +215,8 @@ You can also use the `assert_public_call_fails` or `assert_private_call_fails` m ### Logging -You can use `aztec.nr`'s oracles as usual for debug logging, as explained [here](../../../reference/developer_references/debugging.md) +You can use `aztec.nr`'s oracles as usual for debug logging, as explained [here](../../reference/debugging/index.md) + :::warning Remember to set the following environment variables to activate debug logging: diff --git a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/_category_.json b/docs/docs/developers/guides/smart_contracts/writing_contracts/_category_.json similarity index 100% rename from docs/docs/guides/developer_guides/smart_contracts/writing_contracts/_category_.json rename to docs/docs/developers/guides/smart_contracts/writing_contracts/_category_.json diff --git a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/authwit.md b/docs/docs/developers/guides/smart_contracts/writing_contracts/authwit.md similarity index 97% rename from docs/docs/guides/developer_guides/smart_contracts/writing_contracts/authwit.md rename to docs/docs/developers/guides/smart_contracts/writing_contracts/authwit.md index dc4af796cfa2..cf56fa598766 100644 --- a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/authwit.md +++ b/docs/docs/developers/guides/smart_contracts/writing_contracts/authwit.md @@ -10,13 +10,13 @@ For a guide on using authwit in Aztec.js, [read this](../../js_apps/authwit.md). ## Prerequisite reading -- [Authwit](../../../../aztec/concepts/accounts/authwit.md) +- [Authwit](../../../../aztec/concepts/advanced/authwit.md) ## Introduction Authentication Witness (authwit) is a scheme for authentication actions on Aztec, so users can allow third-parties (eg other contracts) to execute an action on their behalf. Authwits can only authorize actions for contracts that your account is calling, they cannot be used to permit other users to take actions on your behalf. -How it works logically is explained in the [concepts](../../../../aztec/concepts/accounts/authwit.md) but we will do a short recap here. +How it works logically is explained in the [concepts](../../../../aztec/concepts/advanced/authwit.md) but we will do a short recap here. An authentication witness is defined for a specific action, such as allowing a Defi protocol to transfer funds on behalf of the user. An action is here something that could be explained as `A is allowed to perform X operation on behalf of B` and we define it as a hash computed as such: @@ -40,10 +40,7 @@ authentication_witness_action = H( Given the action, the developer can ask the `on_behalf_of` account contract if the action is authenticated or not. -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid sequenceDiagram actor Alice participant AC as Alice Account @@ -68,7 +65,6 @@ sequenceDiagram Defi->>Defi: deposit(Token, 1000); deactivate Defi deactivate AC - ``` :::info @@ -171,7 +167,7 @@ With private functions covered, how can we use this in a public function? Well, Authenticating an action in the public domain is slightly different from the private domain, since we are executing a function on the auth registry contract to add the witness flag. As you might recall, this was to ensure that we don't need to call into the account contract from public, which is a potential DOS vector. -In the snippet below, this is done as a separate contract call, but can also be done as part of a batch as mentioned in the [Accounts concepts](../../../../aztec/concepts/accounts/authwit.md#what-about-public). +In the snippet below, this is done as a separate contract call, but can also be done as part of a batch as mentioned in the [Accounts concepts](../../../../aztec/concepts/advanced/authwit.md#what-about-public). #include_code authwit_public_transfer_example /yarn-project/end-to-end/src/e2e_token_contract/transfer_in_public.test.ts typescript @@ -189,10 +185,7 @@ An example of this would be our Uniswap example which performs a cross chain swa Outlining more of the `swap` flow: this simplified diagram shows how it will look for contracts that are not wallets but also need to support authentication witnesses. -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid sequenceDiagram actor A as Alice participant AC as Alice Account @@ -227,7 +220,6 @@ sequenceDiagram CC-->>CC: Emit L2->L1 message deactivate CC; deactivate AC; - ``` :::info **TODO** diff --git a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/call_contracts.md b/docs/docs/developers/guides/smart_contracts/writing_contracts/call_contracts.md similarity index 96% rename from docs/docs/guides/developer_guides/smart_contracts/writing_contracts/call_contracts.md rename to docs/docs/developers/guides/smart_contracts/writing_contracts/call_contracts.md index 6a47645f5c0b..c1573a9abd98 100644 --- a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/call_contracts.md +++ b/docs/docs/developers/guides/smart_contracts/writing_contracts/call_contracts.md @@ -53,7 +53,7 @@ To call a public function from private, you will need to enqueue it like this: #include_code enqueue_public /noir-projects/noir-contracts/contracts/lending_contract/src/main.nr rust -Public functions are always executed after private execution. To learn why, read the [concepts overview](../../../../aztec/concepts_overview.md). +Public functions are always executed after private execution. To learn why, read the [concepts overview](../../../../aztec/index.md). #### Other call types diff --git a/docs/docs/developers/guides/smart_contracts/writing_contracts/call_functions.md b/docs/docs/developers/guides/smart_contracts/writing_contracts/call_functions.md new file mode 100644 index 000000000000..c1573a9abd98 --- /dev/null +++ b/docs/docs/developers/guides/smart_contracts/writing_contracts/call_functions.md @@ -0,0 +1,60 @@ +--- +title: Calling Other Contracts +sidebar_position: 4 +tags: [functions, contracts] +--- + +A contract is a collection of persistent state variables and functions which may manipulate these variables. + +Functions and state variables within a contract's scope are said to belong to that contract. A contract can only access and modify its own state. + +If a contract wishes to access or modify another contract's state, it must make a call to an external function of the other contract. For anything to happen on the Aztec network, an external function of a contract needs to be called. + +### Add Contract as a Dependency + +Import the contract that you want to call into your `Nargo.toml` under `dependencies` like this: + +```toml +token = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="noir-projects/noir-contracts/contracts/token_contract" } +``` + +### Import into your contract + +At the top of your contract, import the contract you want to call like this: + +```rust +use token::Token; +``` + +### Call the function + +To call the function, you need to + +- Specify the address of the contract with `Contract::at(contract_address)` +- Call the function name with `.function_name()` +- Pass the parameters into the function call, like `.function_name(param1,param2)` +- Specify the type of call you want to make and pass a mut reference to the context, like `.call(&mut context)` + +#### Private calls + +To call a private function, you can just use `call()` like this: + +#include_code call_function noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr rust + +#### Public -> Public calls + +To call a public function from a public function, it is the same as above. You can just use `call()` like this: + +#include_code public_to_public_call noir-projects/noir-contracts/contracts/lending_contract/src/main.nr rust + +#### Private -> Public calls + +To call a public function from private, you will need to enqueue it like this: + +#include_code enqueue_public /noir-projects/noir-contracts/contracts/lending_contract/src/main.nr rust + +Public functions are always executed after private execution. To learn why, read the [concepts overview](../../../../aztec/index.md). + +#### Other call types + +There are other call types, for example to ensure no state changes are made. You can learn more about them in the [call types glossary](../../../../aztec/glossary/call_types.md). diff --git a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/common_patterns/index.md b/docs/docs/developers/guides/smart_contracts/writing_contracts/common_patterns/index.md similarity index 91% rename from docs/docs/guides/developer_guides/smart_contracts/writing_contracts/common_patterns/index.md rename to docs/docs/developers/guides/smart_contracts/writing_contracts/common_patterns/index.md index 6ee1b680d162..27519369e91e 100644 --- a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/common_patterns/index.md +++ b/docs/docs/developers/guides/smart_contracts/writing_contracts/common_patterns/index.md @@ -41,7 +41,7 @@ Note - you could also create a note and send it to the user. The problem is ther You can't read public storage in private domain. But nevertheless reading public storage is desirable. There are two ways to achieve the desired effect: -1. For public values that change infrequently, you can use [shared state](../../../../../reference/developer_references/smart_contract_reference/storage/shared_state.md). +1. For public values that change infrequently, you can use [shared state](../../../../reference/smart_contract_reference/storage/shared_state.md). 1. You pass the data as a parameter to your private method and later assert in public that the data is correct. E.g.: @@ -77,7 +77,7 @@ In this situation, try to mark the public function as `internal`. This ensures y ### Moving public data into the private domain -See [partial notes](../../../../../aztec/concepts/storage/partial_notes.md). Partial notes are how public balances are transferred to private [in the NFT contract](../../../../../tutorials/codealong/contract_tutorials/nft_contract.md). +See [partial notes](../../../../../aztec/concepts/advanced/storage/partial_notes.md). Partial notes are how public balances are transferred to private [in the NFT contract](../../../../tutorials/codealong/contract_tutorials/nft_contract.md). ### Discovering my notes @@ -108,7 +108,7 @@ Hence, it's necessary to add a "randomness" field to your note to prevent such a ### L1 -- L2 interactions -Refer to [Token Portal codealong tutorial on bridging tokens between L1 and L2](../../../../../tutorials/codealong/contract_tutorials/token_bridge/index.md) and/or [Uniswap smart contract example that shows how to swap on L1 using funds on L2](../../../../../tutorials/examples/uniswap/index.md). Both examples show how to: +Refer to [Token Portal codealong tutorial on bridging tokens between L1 and L2](../../../../tutorials/codealong/contract_tutorials/token_bridge/0_setup.md) and/or [Uniswap smart contract example that shows how to swap on L1 using funds on L2](../../../../tutorials/codealong/contract_tutorials/uniswap/index.md). Both examples show how to: 1. L1 -> L2 message flow 2. L2 -> L1 message flow @@ -122,7 +122,7 @@ To send a note to someone, they need to have a key which we can encrypt the note There are several patterns here: 1. Give the contract a key and share it amongst all participants. This leaks privacy, as anyone can see all the notes in the contract. -2. `transfer_to_public` funds into the contract - this is used in the [Uniswap smart contract example where a user sends private funds into a Uniswap Portal contract which eventually withdraws to L1 to swap on L1 Uniswap](../../../../../tutorials/examples/uniswap/index.md). This works like Ethereum - to achieve contract composability, you move funds into the public domain. This way the contract doesn't even need keys. +2. `transfer_to_public` funds into the contract - this is used in the [Uniswap smart contract example where a user sends private funds into a Uniswap Portal contract which eventually withdraws to L1 to swap on L1 Uniswap](../../../../tutorials/codealong/contract_tutorials/uniswap/index.md). This works like Ethereum - to achieve contract composability, you move funds into the public domain. This way the contract doesn't even need keys. There are several other designs we are discussing through [in this discourse post](https://discourse.aztec.network/t/how-to-handle-private-escrows-between-two-parties/2440) but they need some changes in the protocol or in our demo contract. If you are interested in this discussion, please participate in the discourse post! diff --git a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/how_to_emit_event.md b/docs/docs/developers/guides/smart_contracts/writing_contracts/how_to_emit_event.md similarity index 100% rename from docs/docs/guides/developer_guides/smart_contracts/writing_contracts/how_to_emit_event.md rename to docs/docs/developers/guides/smart_contracts/writing_contracts/how_to_emit_event.md diff --git a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/how_to_pop_capsules.md b/docs/docs/developers/guides/smart_contracts/writing_contracts/how_to_pop_capsules.md similarity index 100% rename from docs/docs/guides/developer_guides/smart_contracts/writing_contracts/how_to_pop_capsules.md rename to docs/docs/developers/guides/smart_contracts/writing_contracts/how_to_pop_capsules.md diff --git a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/how_to_prove_history.md b/docs/docs/developers/guides/smart_contracts/writing_contracts/how_to_prove_history.md similarity index 90% rename from docs/docs/guides/developer_guides/smart_contracts/writing_contracts/how_to_prove_history.md rename to docs/docs/developers/guides/smart_contracts/writing_contracts/how_to_prove_history.md index 45d862b7a398..a0e69834bd46 100644 --- a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/how_to_prove_history.md +++ b/docs/docs/developers/guides/smart_contracts/writing_contracts/how_to_prove_history.md @@ -4,11 +4,11 @@ sidebar_position: 4 tags: [contracts] --- -The Aztec Protocol uses an append-only Merkle tree to store hashes of the headers of all previous blocks in the chain as its leaves. This is known as the Archive tree. You can learn more about how it works in the [concepts section](../../../../aztec/concepts/storage/trees/index.md). +The Aztec Protocol uses an append-only Merkle tree to store hashes of the headers of all previous blocks in the chain as its leaves. This is known as the Archive tree. This page is a quick introductory guide to creating historical proofs proofs from the archive tree. -For a reference, go [here](../../../../reference/developer_references/smart_contract_reference/aztec-nr/aztec/history/contract_inclusion.md). +For a reference, go [here](../../../reference/smart_contract_reference/aztec-nr/aztec/history/contract_inclusion.md). ## Inclusion and non-inclusion proofs @@ -81,4 +81,4 @@ You can also prove that a note was not nullified in a specified block by using ` ## Prove contract inclusion, public value inclusion, and use current state in lookups -To see what else you can do with historical proofs, check out the [reference](../../../../reference/developer_references/smart_contract_reference/aztec-nr/aztec/history/contract_inclusion.md) +To see what else you can do with historical proofs, check out the [reference](../../../reference/smart_contract_reference/aztec-nr/aztec/history/contract_inclusion.md) diff --git a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/index.mdx b/docs/docs/developers/guides/smart_contracts/writing_contracts/index.mdx similarity index 100% rename from docs/docs/guides/developer_guides/smart_contracts/writing_contracts/index.mdx rename to docs/docs/developers/guides/smart_contracts/writing_contracts/index.mdx diff --git a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/initializers.md b/docs/docs/developers/guides/smart_contracts/writing_contracts/initializers.md similarity index 95% rename from docs/docs/guides/developer_guides/smart_contracts/writing_contracts/initializers.md rename to docs/docs/developers/guides/smart_contracts/writing_contracts/initializers.md index 25e1a312a43c..cf5ae43d2099 100644 --- a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/initializers.md +++ b/docs/docs/developers/guides/smart_contracts/writing_contracts/initializers.md @@ -45,4 +45,4 @@ You can set multiple functions as an initializer function simply by annotating e Calling any one of the functions annotated with `#[initializer]` will mark the contract as initialized. -To see an initializer in action, follow the [Counter codealong tutorial](../../../../tutorials/codealong/contract_tutorials/counter_contract.md). +To see an initializer in action, follow the [Counter codealong tutorial](../../../tutorials/codealong/contract_tutorials/counter_contract.md). diff --git a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/notes/address_note.md b/docs/docs/developers/guides/smart_contracts/writing_contracts/notes/address_note.md similarity index 90% rename from docs/docs/guides/developer_guides/smart_contracts/writing_contracts/notes/address_note.md rename to docs/docs/developers/guides/smart_contracts/writing_contracts/notes/address_note.md index 3c831979e224..956ac9195af9 100644 --- a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/notes/address_note.md +++ b/docs/docs/developers/guides/smart_contracts/writing_contracts/notes/address_note.md @@ -40,4 +40,4 @@ In this example, `owner` is the `address` and the `npk_m_hash` of the donor was - [Keys, including nullifier keys and outgoing viewer](../../../../../aztec/concepts/accounts/keys.md) - [How to write a custom note](./custom_note.md) -- [AddressNote reference](../../../../../reference/developer_references/smart_contract_reference/aztec-nr/address-note/address_note.md) +- [AddressNote reference](../../../../reference/smart_contract_reference/aztec-nr/address-note/address_note.md) diff --git a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/notes/custom_note.md b/docs/docs/developers/guides/smart_contracts/writing_contracts/notes/custom_note.md similarity index 97% rename from docs/docs/guides/developer_guides/smart_contracts/writing_contracts/notes/custom_note.md rename to docs/docs/developers/guides/smart_contracts/writing_contracts/notes/custom_note.md index 733e1edf7fa3..a3cfa178abff 100644 --- a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/notes/custom_note.md +++ b/docs/docs/developers/guides/smart_contracts/writing_contracts/notes/custom_note.md @@ -49,5 +49,5 @@ If you are also planning to be able to access the data with a note in public sta ## Further reading - [What is `#[note]` actually doing? + functions such as serialize() and deserialize()](../../../../../aztec/smart_contracts/functions//attributes.md#custom-notes-note) -- [Macros reference](../../../../../reference/developer_references/smart_contract_reference/macros.md) +- [Macros reference](../../../../reference/smart_contract_reference/macros.md) - [Keys, including npk_m_hash (nullifier public key master)](../../../../../aztec/concepts/accounts/keys.md) diff --git a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/notes/index.md b/docs/docs/developers/guides/smart_contracts/writing_contracts/notes/index.md similarity index 81% rename from docs/docs/guides/developer_guides/smart_contracts/writing_contracts/notes/index.md rename to docs/docs/developers/guides/smart_contracts/writing_contracts/notes/index.md index b92782a21a29..9a35317828d4 100644 --- a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/notes/index.md +++ b/docs/docs/developers/guides/smart_contracts/writing_contracts/notes/index.md @@ -4,4 +4,4 @@ sidebar_position: 3 tags: [contracts, notes] --- -Notes are the fundamental data structure in Aztec when working with private state. In this section there are guides about how to work with `AddressNote`, `ValueNote`, and custom notes in Aztec.nr. You can learn more about notes in the [concepts section](../../../../../aztec/concepts/storage/state_model/index.md#private-state). +Notes are the fundamental data structure in Aztec when working with private state. In this section there are guides about how to work with `AddressNote`, `ValueNote`, and custom notes in Aztec.nr. You can learn more about notes in the [concepts section](../../../../../aztec/concepts/storage/state_model.md). diff --git a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/notes/value_note.md b/docs/docs/developers/guides/smart_contracts/writing_contracts/notes/value_note.md similarity index 94% rename from docs/docs/guides/developer_guides/smart_contracts/writing_contracts/notes/value_note.md rename to docs/docs/developers/guides/smart_contracts/writing_contracts/notes/value_note.md index c0511785dba2..0a639f59574c 100644 --- a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/notes/value_note.md +++ b/docs/docs/developers/guides/smart_contracts/writing_contracts/notes/value_note.md @@ -60,4 +60,4 @@ The `decrement` function works similarly except the `amount` is the number that - [Keys, including nullifier keys and outgoing viewer](../../../../../aztec/concepts/accounts/keys.md) - [How to write a custom note](./custom_note.md) -- [ValueNote reference](../../../../../reference/developer_references/smart_contract_reference/aztec-nr/value-note/value_note.md) +- [ValueNote reference](../../../../reference/smart_contract_reference/aztec-nr/value-note/value_note.md) diff --git a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/portals/communicate_with_portal.md b/docs/docs/developers/guides/smart_contracts/writing_contracts/portals/communicate_with_portal.md similarity index 98% rename from docs/docs/guides/developer_guides/smart_contracts/writing_contracts/portals/communicate_with_portal.md rename to docs/docs/developers/guides/smart_contracts/writing_contracts/portals/communicate_with_portal.md index 93e000319137..7ea4d5fb30d4 100644 --- a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/portals/communicate_with_portal.md +++ b/docs/docs/developers/guides/smart_contracts/writing_contracts/portals/communicate_with_portal.md @@ -3,7 +3,7 @@ title: Communicating with L1 tags: [contracts, portals] --- -Follow the [token bridge tutorial](../../../../../tutorials/codealong/contract_tutorials/token_bridge/index.md) for hands-on experience writing and deploying a Portal contract. +Follow the [token bridge tutorial](../../../../tutorials/codealong/contract_tutorials/token_bridge/index.md) for hands-on experience writing and deploying a Portal contract. ## Passing data to the rollup @@ -41,7 +41,7 @@ Note that while the `secret` and the `content` are both hashed, they are actuall ### Token bridge example -Computing the `content` must currently be done manually, as we are still adding a number of bytes utilities. A good example exists within the [Token bridge example (codealong tutorial)](../../../../../tutorials/codealong/contract_tutorials/token_bridge/index.md). +Computing the `content` must currently be done manually, as we are still adding a number of bytes utilities. A good example exists within the [Token bridge example (codealong tutorial)](../../../../tutorials/codealong/contract_tutorials/token_bridge/index.md). #include_code claim_public /noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr rust diff --git a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/portals/index.md b/docs/docs/developers/guides/smart_contracts/writing_contracts/portals/index.md similarity index 100% rename from docs/docs/guides/developer_guides/smart_contracts/writing_contracts/portals/index.md rename to docs/docs/developers/guides/smart_contracts/writing_contracts/portals/index.md diff --git a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/storage/index.md b/docs/docs/developers/guides/smart_contracts/writing_contracts/storage/index.md similarity index 81% rename from docs/docs/guides/developer_guides/smart_contracts/writing_contracts/storage/index.md rename to docs/docs/developers/guides/smart_contracts/writing_contracts/storage/index.md index f895fd3e10f0..622df9645037 100644 --- a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/storage/index.md +++ b/docs/docs/developers/guides/smart_contracts/writing_contracts/storage/index.md @@ -8,7 +8,7 @@ On this page, you will learn how to define storage in your smart contract. To learn more about how storage works in Aztec, read [the concepts](./storage_slots.md). -[See the storage reference](../../../../../reference/developer_references/smart_contract_reference/storage/index.md). +[See the storage reference](../../../../reference/smart_contract_reference/storage/index.md). ```rust #[storage] diff --git a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/storage/notes.md b/docs/docs/developers/guides/smart_contracts/writing_contracts/storage/notes.md similarity index 95% rename from docs/docs/guides/developer_guides/smart_contracts/writing_contracts/storage/notes.md rename to docs/docs/developers/guides/smart_contracts/writing_contracts/storage/notes.md index 2e8100bb9f8d..2093a74e0ce0 100644 --- a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/storage/notes.md +++ b/docs/docs/developers/guides/smart_contracts/writing_contracts/storage/notes.md @@ -34,7 +34,7 @@ A couple of things to unpack here: #### Storage "slot" -Storage slots are more literal for public storage, a place where a value is stored. For private storage, a storage slot is logical (more [here](../../../../../aztec/concepts/storage/index.md#private-state-slots---slots-arent-real)). +Storage slots are more literal for public storage, a place where a value is stored. For private storage, a storage slot is logical (more [here](../../../../../aztec/concepts/advanced/storage/storage_slots.md)). #### Silos @@ -83,9 +83,9 @@ To update a value, its previous note hash(es) are nullified. The new note value Some optional background resources on notes can be found here: -- [High level network architecture](../../../../../aztec/concepts_overview.md), specifically the Private Execution Environment +- [High level network architecture](../../../../../aztec/index.md), specifically the Private Execution Environment - [Transaction lifecycle (simple diagram)](../../../../../aztec/concepts/transactions.md#simple-example-of-the-private-transaction-lifecycle) -- [Public and Private state](../../../../../aztec/concepts/storage/state_model/index.md) +- [Public and Private state](../../../../../aztec/concepts/storage/state_model.md) Notes touch several core components of the protocol, but we will focus on a the essentials first. @@ -150,11 +150,10 @@ Notice how the `add` function shows the simplicity of appending a new note to al ### Apply -Try the [NFT tutorial](../../../../../tutorials/codealong/contract_tutorials/nft_contract.md) to see what notes can achieve. In this section you will also find other tutorials using notes in different ways. +Try the [NFT tutorial](../../../../tutorials/codealong/contract_tutorials/nft_contract.md) to see what notes can achieve. In this section you will also find other tutorials using notes in different ways. ### Further reading -- [Storage Trees](../../../../../aztec/concepts/storage/trees/index.md) - [Proof of prior notes](../how_to_prove_history.md) - public/private reading of public/private proof of state (public or private) If you're curious about any of the following related topics, search the documentation for... diff --git a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/storage/storage_slots.md b/docs/docs/developers/guides/smart_contracts/writing_contracts/storage/storage_slots.md similarity index 87% rename from docs/docs/guides/developer_guides/smart_contracts/writing_contracts/storage/storage_slots.md rename to docs/docs/developers/guides/smart_contracts/writing_contracts/storage/storage_slots.md index a4ad001b7017..b406a866338f 100644 --- a/docs/docs/guides/developer_guides/smart_contracts/writing_contracts/storage/storage_slots.md +++ b/docs/docs/developers/guides/smart_contracts/writing_contracts/storage/storage_slots.md @@ -3,7 +3,7 @@ title: Storage slots tags: [contracts, storage] --- -From the description of storage slots [in the Concepts](../../../../../aztec/concepts/storage/index.md#private-state-slots---slots-arent-real) you will get an idea around the logic of storage slots. In this section we will go into more detail and walk through an entire example of how storage slots are computed for private state to improve our storage slot intuition. Recall, that storage slots in the private domain is just a logical construct, and are not "actually" used for lookups, but rather just as a value to constrain against. +From the description of storage slots [in the Concepts](../../../../../aztec/concepts/advanced/storage/storage_slots.md) you will get an idea around the logic of storage slots. In this section we will go into more detail and walk through an entire example of how storage slots are computed for private state to improve our storage slot intuition. Recall, that storage slots in the private domain is just a logical construct, and are not "actually" used for lookups, but rather just as a value to constrain against. For the case of the example, we will look at what is inserted into the note hashes tree when adding a note in the Token contract. Specifically, we are looking at the last part of the `transfer` function: @@ -18,10 +18,7 @@ In the end a siloed note hash is computed in the kernel. Some of the syntax below is a little butchered to make it easier to follow variables without the full code. ::: -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid sequenceDiagram alt Call Token->>BalanceMap: Map::new(map_slot); @@ -40,7 +37,6 @@ sequenceDiagram end Context->>Kernel: unique_note_hash = H(nonce, note_hash) Context->>Kernel: siloed_note_hash = H(contract_address, unique_note_hash) - ``` Notice the `siloed_note_hash` at the very end. It's a hash that will be inserted into the note hashes tree. To clarify what this really is, we "unroll" the values to their simplest components. This gives us a better idea around what is actually inserted into the tree. diff --git a/docs/docs/developers/index.md b/docs/docs/developers/index.md new file mode 100644 index 000000000000..8acdf5530b9b --- /dev/null +++ b/docs/docs/developers/index.md @@ -0,0 +1,67 @@ +--- +id: index +sidebar_position: 0 +title: Build +--- + +# Build + +## Get Started + +
+ + +

Getting Started

+
+ + Get started on Aztec by installing the sandbox and playing with it + +
+
+ +## Build applications + +
+ + +

Contract Tutorials

+
+ + Go from zero to hero by following these tutorials in order, starting with a counter contract + +
+ + + +

Full stack app on Aztec

+
+ + Learn how everything works together by building an app in JavaScript that connects to a contract + +
+
+ +## Clone a repo + + + + GitHub Icon + + +

Full stack app on Aztec

+
+ + Learn how everything works together by building an app in JavaScript that connects to a contract + +
+ diff --git a/docs/docs/reference/_category_.json b/docs/docs/developers/reference/considerations/_category_.json similarity index 59% rename from docs/docs/reference/_category_.json rename to docs/docs/developers/reference/considerations/_category_.json index 31e9f9521da8..3d16e4d09376 100644 --- a/docs/docs/reference/_category_.json +++ b/docs/docs/developers/reference/considerations/_category_.json @@ -1,5 +1,5 @@ { - "label": "Reference", + "label": "Considerations and Limitations", "position": 4, "collapsible": true, "collapsed": true diff --git a/docs/docs/reference/developer_references/limitations.md b/docs/docs/developers/reference/considerations/limitations.md similarity index 97% rename from docs/docs/reference/developer_references/limitations.md rename to docs/docs/developers/reference/considerations/limitations.md index 60c659119c2a..c5c57b7d84d9 100644 --- a/docs/docs/reference/developer_references/limitations.md +++ b/docs/docs/developers/reference/considerations/limitations.md @@ -173,11 +173,11 @@ This will be patched in the near future, but unfortunately, app developers might ### New Privacy Standards are required -There are many [patterns](../../guides/privacy_considerations.md) which can leak privacy, even on Aztec. Standards haven't been developed yet, to encourage best practices when designing private smart contracts. +There are many [patterns](../../reference/considerations/privacy_considerations.md) which can leak privacy, even on Aztec. Standards haven't been developed yet, to encourage best practices when designing private smart contracts. #### What are the consequences? -For example, until community standards are developed to reduce the uniqueness of ['Tx Fingerprints'](../../guides/privacy_considerations.md#function-fingerprints-and-tx-fingerprints) app developers might accidentally forfeit some function privacy. +For example, until community standards are developed to reduce the uniqueness of ['Tx Fingerprints'](../../reference/considerations/privacy_considerations.md#function-fingerprints-and-tx-fingerprints) app developers might accidentally forfeit some function privacy. ## Circuit limitations diff --git a/docs/docs/guides/privacy_considerations.md b/docs/docs/developers/reference/considerations/privacy_considerations.md similarity index 100% rename from docs/docs/guides/privacy_considerations.md rename to docs/docs/developers/reference/considerations/privacy_considerations.md diff --git a/docs/docs/developers/reference/debugging/_category_.json b/docs/docs/developers/reference/debugging/_category_.json new file mode 100644 index 000000000000..99db708f09cb --- /dev/null +++ b/docs/docs/developers/reference/debugging/_category_.json @@ -0,0 +1,6 @@ +{ + "label": "Debugging", + "position": 3, + "collapsible": true, + "collapsed": true +} diff --git a/docs/docs/reference/developer_references/common_errors/aztecnr-errors.md b/docs/docs/developers/reference/debugging/aztecnr-errors.md similarity index 94% rename from docs/docs/reference/developer_references/common_errors/aztecnr-errors.md rename to docs/docs/developers/reference/debugging/aztecnr-errors.md index 2a2b3f3d3819..63554f154e58 100644 --- a/docs/docs/reference/developer_references/common_errors/aztecnr-errors.md +++ b/docs/docs/developers/reference/debugging/aztecnr-errors.md @@ -17,7 +17,7 @@ You can learn more about dependencies and their paths [here](../smart_contract_r #### `backend has encountered an error` -This is likely due to a version mismatch or bad install of barretenberg. Try [reinstalling nargo](../../../guides/developer_guides/local_env/versions-updating.md#updating-aztec-nargo) or uninstalling barretenberg: +This is likely due to a version mismatch or bad install of barretenberg. Try [reinstalling nargo](../../guides/local_env/versions-updating.md) or uninstalling barretenberg: ```bash nargo backend uninstall acvm-backend-barretenberg @@ -27,7 +27,7 @@ It will then reinstall when you compile. #### `Oracle callback {} not found` & `Oracle callback pedersenHash not found` -This can occasionally happen when there are breaking releases. Make sure that your dependencies in `Nargo.toml` are [updated to the latest release](../../../guides/developer_guides/local_env/versions-updating.md#dependency-versions). +This can occasionally happen when there are breaking releases. Make sure that your dependencies in `Nargo.toml` are [updated to the latest release](../../guides/local_env/versions-updating.md#dependency-versions). #### `error: Failed constraint: 'Public state writes only supported in public functions` diff --git a/docs/docs/reference/developer_references/debugging.md b/docs/docs/developers/reference/debugging/index.md similarity index 98% rename from docs/docs/reference/developer_references/debugging.md rename to docs/docs/developers/reference/debugging/index.md index 1befeeac72b5..548a35af9a06 100644 --- a/docs/docs/reference/developer_references/debugging.md +++ b/docs/docs/developers/reference/debugging/index.md @@ -1,6 +1,6 @@ --- title: Debugging -sidebar_position: 4 +sidebar_position: 1 --- ## Logging in Aztec.nr diff --git a/docs/docs/reference/developer_references/common_errors/sandbox-errors.md b/docs/docs/developers/reference/debugging/sandbox-errors.md similarity index 90% rename from docs/docs/reference/developer_references/common_errors/sandbox-errors.md rename to docs/docs/developers/reference/debugging/sandbox-errors.md index 41414eda80d2..2dbf490cdca7 100644 --- a/docs/docs/reference/developer_references/common_errors/sandbox-errors.md +++ b/docs/docs/developers/reference/debugging/sandbox-errors.md @@ -15,7 +15,7 @@ This section contains a list of errors you may encounter when using Aztec Sandbo ### Kernel Circuits -We have several versions of public and private kernels as explained in [the circuits section in the concepts](../../../aztec/concepts/circuits/index.md). Certain things are only possible in certain versions of the circuits. So always ensure that the right version is being used for proof generation. For example, there is a specific version of the public kernel that only works if the previous kernel iteration was a private kernel. Similarly there is one that only works if the previous kernel was public. +We have several versions of public and private kernels as explained in [the circuits section in the concepts](../../../aztec/concepts/advanced/circuits/index.md). Certain things are only possible in certain versions of the circuits. So always ensure that the right version is being used for proof generation. For example, there is a specific version of the public kernel that only works if the previous kernel iteration was a private kernel. Similarly there is one that only works if the previous kernel was public. Remember that for each function call (i.e. each item in the call stack), there is a new kernel iteration that gets run. @@ -132,17 +132,17 @@ For static calls, no new note hashes or nullifiers can be added to the state. ### Rollup circuit errors -These are errors that occur when kernel proofs (transaction proofs) are sent to the rollup circuits to create an L2 block. See [rollup circuits](../../../aztec/concepts/circuits/rollup_circuits/index.md) for more information. +These are errors that occur when kernel proofs (transaction proofs) are sent to the rollup circuits to create an L2 block. See [rollup circuits](../../../aztec/concepts/advanced/circuits/rollup_circuits/index.md) for more information. #### 4007 - BASE\_\_INVALID_CHAIN_ID -The L1 chain ID you used in your proof generation (for your private transaction) is different to what the rollup circuits expected. Double check against the global variables passed to noir and the config set in [Aztec's rollup contract (GitHub link)](https://github.com/AztecProtocol/aztec-packages/blob/master/l1-contracts/src/core/Rollup.sol) which are [read in by sequencer GitHub link](https://github.com/AztecProtocol/aztec3-packages/blob/master/yarn-project/sequencer-client/src/global_variable_builder/global_builder.ts#L32) and subsequently passed in as inputs to the base rollup. When the sequencer submits the block to the rollup contracts, this is again sanity checked so ensure this is the same everywhere. +The L1 chain ID you used in your proof generation (for your private transaction) is different to what the rollup circuits expected. Double check against the global variables passed to noir and the config set in [Aztec's rollup contract (GitHub link)](https://github.com/AztecProtocol/aztec-packages/blob/master/l1-contracts/src/core/Rollup.sol) which are [read in by sequencer GitHub link](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/sequencer-client/src/global_variable_builder/global_builder.ts#L32) and subsequently passed in as inputs to the base rollup. When the sequencer submits the block to the rollup contracts, this is again sanity checked so ensure this is the same everywhere. #### 4008 - BASE\_\_INVALID_VERSION Same as [section 4007](#4007---base__invalid_chain_id) except the `version` refers to the version of the Aztec L2 instance. -Some scary bugs like `4003 - BASE__INVALID_NULLIFIER_SUBTREE` and `4004 - BASE__INVALID_NULLIFIER_RANGE` which are to do malformed nullifier trees (see [Indexed Merkle Trees](../../../aztec/concepts/storage/trees/indexed_merkle_tree.mdx)) etc may seem unrelated at a glance, but at a closer look may be because of some bug in an application's Aztec.nr code. Same is true for certain instances of `7008 - MEMBERSHIP_CHECK_FAILED`. +Some scary bugs like `4003 - BASE__INVALID_NULLIFIER_SUBTREE` and `4004 - BASE__INVALID_NULLIFIER_RANGE` which are to do malformed nullifier trees (see [Indexed Merkle Trees](../../../aztec/concepts/advanced/storage/indexed_merkle_tree.mdx)) etc may seem unrelated at a glance, but at a closer look may be because of some bug in an application's Aztec.nr code. Same is true for certain instances of `7008 - MEMBERSHIP_CHECK_FAILED`. ### Generic circuit errors @@ -173,7 +173,7 @@ Users may create a proof against a historical state in Aztec. The rollup circuit - using invalid historical L1 to L2 message data tree state - inserting a subtree into the greater tree - we make a smaller merkle tree of all the new note hashes/nullifiers etc that were created in a transaction or in a rollup and add it to the bigger state tree. Before inserting, we do a merkle membership check to ensure that the index to insert at is indeed an empty subtree (otherwise we would be overwriting state). This can happen when `next_available_leaf_index` in the state tree's snapshot is wrong (it is fetched by the sequencer from the archiver). The error message should reveal which tree is causing this issue - - nullifier tree related errors - The nullifier tree uses an [Indexed Merkle Tree](../../../aztec/concepts/storage/trees/indexed_merkle_tree.mdx). It requires additional data from the archiver to know which is the nullifier in the tree that is just below the current nullifier before it can perform batch insertion. If the low nullifier is wrong, or the nullifier is in incorrect range, you may receive this error. + - nullifier tree related errors - The nullifier tree uses an [Indexed Merkle Tree](../../../aztec/concepts/advanced/storage/indexed_merkle_tree.mdx). It requires additional data from the archiver to know which is the nullifier in the tree that is just below the current nullifier before it can perform batch insertion. If the low nullifier is wrong, or the nullifier is in incorrect range, you may receive this error. --- diff --git a/docs/docs/developers/reference/environment_reference/_category_.json b/docs/docs/developers/reference/environment_reference/_category_.json new file mode 100644 index 000000000000..e51f342c74a7 --- /dev/null +++ b/docs/docs/developers/reference/environment_reference/_category_.json @@ -0,0 +1,6 @@ +{ + "label": "Developer Environment", + "position": 0, + "collapsible": true, + "collapsed": true +} diff --git a/docs/docs/reference/developer_references/sandbox_reference/cheat_codes.md b/docs/docs/developers/reference/environment_reference/cheat_codes.md similarity index 99% rename from docs/docs/reference/developer_references/sandbox_reference/cheat_codes.md rename to docs/docs/developers/reference/environment_reference/cheat_codes.md index 2f96ebf6165a..633c386e77b7 100644 --- a/docs/docs/reference/developer_references/sandbox_reference/cheat_codes.md +++ b/docs/docs/developers/reference/environment_reference/cheat_codes.md @@ -1,7 +1,7 @@ --- title: Cheat Codes tags: [sandbox] -sidebar_position: 1 +sidebar_position: 4 --- import Disclaimer from "@site/src/components/Disclaimers/\_wip_disclaimer.mdx"; diff --git a/docs/docs/reference/developer_references/cli_reference.md b/docs/docs/developers/reference/environment_reference/cli_reference.md similarity index 99% rename from docs/docs/reference/developer_references/cli_reference.md rename to docs/docs/developers/reference/environment_reference/cli_reference.md index 85d7dae21697..7e922854dc14 100644 --- a/docs/docs/reference/developer_references/cli_reference.md +++ b/docs/docs/developers/reference/environment_reference/cli_reference.md @@ -1,7 +1,7 @@ --- title: CLI Reference tags: [sandbox] -sidebar_position: 1 +sidebar_position: 2 --- :::warning diff --git a/docs/docs/reference/developer_references/cli_wallet_reference.md b/docs/docs/developers/reference/environment_reference/cli_wallet_reference.md similarity index 84% rename from docs/docs/reference/developer_references/cli_wallet_reference.md rename to docs/docs/developers/reference/environment_reference/cli_wallet_reference.md index 2d8fc65a8e61..cc6a0c9658b1 100644 --- a/docs/docs/reference/developer_references/cli_wallet_reference.md +++ b/docs/docs/developers/reference/environment_reference/cli_wallet_reference.md @@ -2,7 +2,7 @@ title: CLI Wallet tags: [sandbox, wallet, cli] keywords: [wallet, cli wallet] -sidebar_position: 2 +sidebar_position: 3 --- For development, it may be useful to deploy, transact, or create notes in a non-programmatic way. You can use Aztec's CLI Wallet for thing such as: @@ -10,8 +10,8 @@ For development, it may be useful to deploy, transact, or create notes in a non- - Deploying contracts - Sending transactions - Bridging L1 "Fee Juice" into Aztec -- Pushing arbitrary [notes](../../guides/developer_guides/smart_contracts/writing_contracts/notes/index.md) to your PXE -- Creating [authwits](../../guides/developer_guides/smart_contracts/writing_contracts/authwit.md) +- Pushing arbitrary [notes](../../guides/smart_contracts/writing_contracts/notes/index.md) to your PXE +- Creating [authwits](../../guides/smart_contracts/writing_contracts/authwit.md) - Aliasing info and secrets for further usage - Proving your transactions and profile gate counts @@ -69,9 +69,9 @@ $ aztec-wallet deploy-account -f master_yoda ### Deploy -You can deploy a [compiled contract](../../guides/developer_guides/smart_contracts/how_to_compile_contract.md) to the network. +You can deploy a [compiled contract](../../guides/smart_contracts/how_to_compile_contract.md) to the network. -You probably want to look at flags such as `--init` which allows you to specify the [initializer function](../../guides/developer_guides/smart_contracts/writing_contracts/initializers.md) to call, or `-k` for the [encryption public key](../../aztec/concepts/accounts/keys.md#incoming-viewing-keys) if the contract is expected to have notes being encrypted to it. +You probably want to look at flags such as `--init` which allows you to specify the [initializer function](../../guides/smart_contracts/writing_contracts/initializers.md) to call, or `-k` for the [encryption public key](../../../aztec/concepts/accounts/keys.md#incoming-viewing-keys) if the contract is expected to have notes being encrypted to it. You can pass arguments with the `--arg` flag. @@ -98,7 +98,7 @@ Again, notice how it's not necessary to pass `contracts:jedi_order` as the walle ### Manage authwits -You can use the CLI wallet to quickly generate [Authentication Witnesses](../../guides/developer_guides/smart_contracts/writing_contracts/authwit.md). These allow you to authorize the caller to execute an action on behalf of an account. They get aliased into the `authwits` type. +You can use the CLI wallet to quickly generate [Authentication Witnesses](../../guides/smart_contracts/writing_contracts/authwit.md). These allow you to authorize the caller to execute an action on behalf of an account. They get aliased into the `authwits` type. ### In private @@ -134,7 +134,7 @@ aztec-wallet simulate --from master_yoda --contract-address jedi_order --args "l ### Profile -Simulates a transaction with profiling enabled. This allows you to get the gate count of each private function in the transaction. Read more about profiling [here](../../guides/developer_guides/smart_contracts/profiling_transactions.md). +Simulates a transaction with profiling enabled. This allows you to get the gate count of each private function in the transaction. Read more about profiling [here](../../guides/smart_contracts/profiling_transactions.md). #### Example @@ -167,4 +167,4 @@ aztec-wallet add-note JediMember available_members -a master_yoda -ca jedi_order ``` ## Proving -You can prove a transaction using the aztec-wallet with a running sandbox. Follow the guide [here](../../guides/developer_guides/local_env/sandbox_proving.md#proving-with-aztec-wallet) +You can prove a transaction using the aztec-wallet with a running sandbox. Follow the guide [here](../../guides/local_env/sandbox_proving.md#proving-with-aztec-wallet) diff --git a/docs/docs/reference/developer_references/sandbox_reference/index.md b/docs/docs/developers/reference/environment_reference/index.md similarity index 89% rename from docs/docs/reference/developer_references/sandbox_reference/index.md rename to docs/docs/developers/reference/environment_reference/index.md index b67c867d7b59..669c0329faf6 100644 --- a/docs/docs/reference/developer_references/sandbox_reference/index.md +++ b/docs/docs/developers/reference/environment_reference/index.md @@ -1,5 +1,5 @@ --- -title: Sandbox Reference +title: Developer Environment tags: [sandbox] sidebar_position: 0 --- @@ -16,4 +16,4 @@ The current sandbox does not generate or verify proofs, but provides a working e ## Command line tools -Aztec-nargo and aztec CLI are command-line tool allowing you to compile smart contracts. See the [compiling contracts guide](../../../guides/developer_guides/smart_contracts/how_to_compile_contract.md) for more information. +Aztec-nargo and aztec CLI are command-line tool allowing you to compile smart contracts. See the [compiling contracts guide](../../guides/local_env/run_more_than_one_pxe_sandbox.md) for more information. diff --git a/docs/docs/reference/developer_references/sandbox_reference/sandbox-reference.md b/docs/docs/developers/reference/environment_reference/sandbox-reference.md similarity index 97% rename from docs/docs/reference/developer_references/sandbox_reference/sandbox-reference.md rename to docs/docs/developers/reference/environment_reference/sandbox-reference.md index d00ef025751b..798d3d52e5e1 100644 --- a/docs/docs/reference/developer_references/sandbox_reference/sandbox-reference.md +++ b/docs/docs/developers/reference/environment_reference/sandbox-reference.md @@ -1,12 +1,12 @@ --- title: Sandbox Reference tags: [sandbox] -sidebar_position: 0 +sidebar_position: 1 --- :::tip -For a quick start, follow the [guide](../../../guides/getting_started) to install the sandbox. +For a quick start, follow the [guide](../../getting_started.md) to install the sandbox. ::: @@ -165,7 +165,7 @@ If you wish to run components of the Aztec network stack separately, you can use aztec start --node [nodeOptions] --pxe [pxeOptions] --archiver [archiverOptions] --sequencer [sequencerOptions] --prover [proverOptions] --p2p-bootstrap [p2pOptions] ``` -Starting the aztec node alongside a PXE, sequencer or archiver, will attach the components to the node. Eg if you want to run a PXE separately to a node, you can [read this guide](../../../guides/developer_guides/local_env/run_more_than_one_pxe_sandbox.md). +Starting the aztec node alongside a PXE, sequencer or archiver, will attach the components to the node. Eg if you want to run a PXE separately to a node, you can [read this guide](../../guides/local_env/run_more_than_one_pxe_sandbox.md). ## Update the sandbox diff --git a/docs/docs/reference/developer_references/smart_contract_reference/_category_.json b/docs/docs/developers/reference/smart_contract_reference/_category_.json similarity index 82% rename from docs/docs/reference/developer_references/smart_contract_reference/_category_.json rename to docs/docs/developers/reference/smart_contract_reference/_category_.json index 13f5f1ecc0ad..968f9bcf0a6b 100644 --- a/docs/docs/reference/developer_references/smart_contract_reference/_category_.json +++ b/docs/docs/developers/reference/smart_contract_reference/_category_.json @@ -1,6 +1,6 @@ { "label": "Smart Contract Reference", - "position": 3, + "position": 1, "collapsible": true, "collapsed": true } diff --git a/docs/docs/reference/developer_references/smart_contract_reference/contract_artifact.md b/docs/docs/developers/reference/smart_contract_reference/contract_artifact.md similarity index 100% rename from docs/docs/reference/developer_references/smart_contract_reference/contract_artifact.md rename to docs/docs/developers/reference/smart_contract_reference/contract_artifact.md diff --git a/docs/docs/reference/developer_references/smart_contract_reference/dependencies.md b/docs/docs/developers/reference/smart_contract_reference/dependencies.md similarity index 90% rename from docs/docs/reference/developer_references/smart_contract_reference/dependencies.md rename to docs/docs/developers/reference/smart_contract_reference/dependencies.md index 1a2bf74b08c1..e54f10f4991c 100644 --- a/docs/docs/reference/developer_references/smart_contract_reference/dependencies.md +++ b/docs/docs/developers/reference/smart_contract_reference/dependencies.md @@ -20,7 +20,7 @@ This is the core Aztec library that is required for every Aztec.nr smart contrac authwit = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="noir-projects/aztec-nr/authwit"} ``` -This allows you to use authentication witnesses in your contract. Read a guide of how to use it [here](../../../guides/developer_guides/smart_contracts/writing_contracts/authwit.md). +This allows you to use authentication witnesses in your contract. Read a guide of how to use it [here](../../guides/smart_contracts/writing_contracts/authwit.md). ## Address note @@ -52,4 +52,4 @@ This library contains types that are used in the Aztec protocol. Find it on [Git value_note = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="noir-projects/aztec-nr/value-note" } ``` -This is a library for a note that stores one arbitrary value. You can see an example of how it might be used in the [crowdfunding contract codealong tutorial](../../../tutorials/codealong/contract_tutorials/crowdfunding_contract.md). +This is a library for a note that stores one arbitrary value. You can see an example of how it might be used in the [crowdfunding contract codealong tutorial](../../tutorials/codealong/contract_tutorials/crowdfunding_contract.md). diff --git a/docs/docs/reference/developer_references/smart_contract_reference/globals.md b/docs/docs/developers/reference/smart_contract_reference/globals.md similarity index 100% rename from docs/docs/reference/developer_references/smart_contract_reference/globals.md rename to docs/docs/developers/reference/smart_contract_reference/globals.md diff --git a/docs/docs/reference/developer_references/smart_contract_reference/macros.md b/docs/docs/developers/reference/smart_contract_reference/macros.md similarity index 100% rename from docs/docs/reference/developer_references/smart_contract_reference/macros.md rename to docs/docs/developers/reference/smart_contract_reference/macros.md diff --git a/docs/docs/reference/developer_references/smart_contract_reference/portals/_category_.json b/docs/docs/developers/reference/smart_contract_reference/portals/_category_.json similarity index 100% rename from docs/docs/reference/developer_references/smart_contract_reference/portals/_category_.json rename to docs/docs/developers/reference/smart_contract_reference/portals/_category_.json diff --git a/docs/docs/reference/developer_references/smart_contract_reference/portals/data_structures.md b/docs/docs/developers/reference/smart_contract_reference/portals/data_structures.md similarity index 100% rename from docs/docs/reference/developer_references/smart_contract_reference/portals/data_structures.md rename to docs/docs/developers/reference/smart_contract_reference/portals/data_structures.md diff --git a/docs/docs/reference/developer_references/smart_contract_reference/portals/inbox.md b/docs/docs/developers/reference/smart_contract_reference/portals/inbox.md similarity index 100% rename from docs/docs/reference/developer_references/smart_contract_reference/portals/inbox.md rename to docs/docs/developers/reference/smart_contract_reference/portals/inbox.md diff --git a/docs/docs/reference/developer_references/smart_contract_reference/portals/outbox.md b/docs/docs/developers/reference/smart_contract_reference/portals/outbox.md similarity index 100% rename from docs/docs/reference/developer_references/smart_contract_reference/portals/outbox.md rename to docs/docs/developers/reference/smart_contract_reference/portals/outbox.md diff --git a/docs/docs/reference/developer_references/smart_contract_reference/portals/registry.md b/docs/docs/developers/reference/smart_contract_reference/portals/registry.md similarity index 100% rename from docs/docs/reference/developer_references/smart_contract_reference/portals/registry.md rename to docs/docs/developers/reference/smart_contract_reference/portals/registry.md diff --git a/docs/docs/reference/developer_references/smart_contract_reference/storage/_category_.json b/docs/docs/developers/reference/smart_contract_reference/storage/_category_.json similarity index 100% rename from docs/docs/reference/developer_references/smart_contract_reference/storage/_category_.json rename to docs/docs/developers/reference/smart_contract_reference/storage/_category_.json diff --git a/docs/docs/reference/developer_references/smart_contract_reference/storage/index.md b/docs/docs/developers/reference/smart_contract_reference/storage/index.md similarity index 97% rename from docs/docs/reference/developer_references/smart_contract_reference/storage/index.md rename to docs/docs/developers/reference/smart_contract_reference/storage/index.md index d5c3bccd90ea..ba028b0930a0 100644 --- a/docs/docs/reference/developer_references/smart_contract_reference/storage/index.md +++ b/docs/docs/developers/reference/smart_contract_reference/storage/index.md @@ -4,7 +4,7 @@ title: Storage Smart contracts rely on storage, acting as the persistent memory on the blockchain. In Aztec, because of its hybrid, privacy-first architecture, the management of this storage is more complex than other blockchains like Ethereum. -To learn how to define a storage struct, read [this guide](../../../../guides/developer_guides/smart_contracts/writing_contracts/storage/index.md). +To learn how to define a storage struct, read [this guide](../../../guides/smart_contracts/writing_contracts/storage/index.md). To learn more about storage slots, read [this explainer in the Concepts section](../../../../aztec/concepts/storage/index.md). You control this storage in Aztec using a struct annotated with `#[storage]`. This struct serves as the housing unit for all your smart contract's state variables - the data it needs to keep track of and maintain. @@ -101,6 +101,6 @@ require(minters[msg.sender], "caller is not minter"); ## Concepts mentioned -- [State Model](../../../../aztec/concepts/storage/state_model/index.md) +- [State Model](../../../../aztec/concepts/storage/state_model.md) - [Public-private execution](../../../../aztec/smart_contracts/functions/public_private_calls.md) - [Function Contexts](../../../../aztec/smart_contracts/functions/context.md) diff --git a/docs/docs/reference/developer_references/smart_contract_reference/storage/private_state.md b/docs/docs/developers/reference/smart_contract_reference/storage/private_state.md similarity index 99% rename from docs/docs/reference/developer_references/smart_contract_reference/storage/private_state.md rename to docs/docs/developers/reference/smart_contract_reference/storage/private_state.md index ec24ad687b81..62bfa64e7931 100644 --- a/docs/docs/reference/developer_references/smart_contract_reference/storage/private_state.md +++ b/docs/docs/developers/reference/smart_contract_reference/storage/private_state.md @@ -4,7 +4,7 @@ title: Private State On this page we will look at how to manage private state in Aztec contracts. We will look at how to declare private state, how to read and write to it, and how to use it in your contracts. -For a higher level overview of the state model in Aztec, see the [hybrid state model](../../../../aztec/concepts/storage/state_model/index.md) page. +For a higher level overview of the state model in Aztec, see the [hybrid state model](../../../../aztec/concepts/storage/state_model.md) page. ## Overview diff --git a/docs/docs/reference/developer_references/smart_contract_reference/storage/public_state.md b/docs/docs/developers/reference/smart_contract_reference/storage/public_state.md similarity index 98% rename from docs/docs/reference/developer_references/smart_contract_reference/storage/public_state.md rename to docs/docs/developers/reference/smart_contract_reference/storage/public_state.md index d49aebd81e22..11848a79f77d 100644 --- a/docs/docs/reference/developer_references/smart_contract_reference/storage/public_state.md +++ b/docs/docs/developers/reference/smart_contract_reference/storage/public_state.md @@ -4,7 +4,7 @@ title: Public State On this page we will look at how to manage public state in Aztec contracts. We will look at how to declare public state, how to read and write to it, and how to use it in your contracts. -For a higher level overview of the state model in Aztec, see the [state model](../../../../aztec/concepts/storage/state_model/index.md) concepts page. +For a higher level overview of the state model in Aztec, see the [state model](../../../../aztec/concepts/storage/state_model.md) concepts page. ## `PublicMutable` diff --git a/docs/docs/reference/developer_references/smart_contract_reference/storage/shared_state.md b/docs/docs/developers/reference/smart_contract_reference/storage/shared_state.md similarity index 100% rename from docs/docs/reference/developer_references/smart_contract_reference/storage/shared_state.md rename to docs/docs/developers/reference/smart_contract_reference/storage/shared_state.md diff --git a/docs/docs/tutorials/_category_.json b/docs/docs/developers/tutorials/_category_.json similarity index 100% rename from docs/docs/tutorials/_category_.json rename to docs/docs/developers/tutorials/_category_.json diff --git a/docs/docs/tutorials/codealong/cli_wallet/_category_.json b/docs/docs/developers/tutorials/codealong/cli_wallet/_category_.json similarity index 100% rename from docs/docs/tutorials/codealong/cli_wallet/_category_.json rename to docs/docs/developers/tutorials/codealong/cli_wallet/_category_.json diff --git a/docs/docs/tutorials/codealong/cli_wallet/faceid_wallet.md b/docs/docs/developers/tutorials/codealong/cli_wallet/faceid_wallet.md similarity index 87% rename from docs/docs/tutorials/codealong/cli_wallet/faceid_wallet.md rename to docs/docs/developers/tutorials/codealong/cli_wallet/faceid_wallet.md index cf2cd0bcde09..d43de43197a5 100644 --- a/docs/docs/tutorials/codealong/cli_wallet/faceid_wallet.md +++ b/docs/docs/developers/tutorials/codealong/cli_wallet/faceid_wallet.md @@ -5,7 +5,7 @@ keywords: [wallet, cli wallet, faceid] importance: 3 --- -In this tutorial, we will use Apple Mac's Secure Enclave to store the private key, and use it in Aztec's [CLI Wallet](../../../reference/developer_references/cli_wallet_reference.md). This enables fully private, native, and seedless account abstraction! +In this tutorial, we will use Apple Mac's Secure Enclave to store the private key, and use it in Aztec's [CLI Wallet](../../../reference/environment_reference/cli_wallet_reference.md). This enables fully private, native, and seedless account abstraction! :::warning @@ -15,7 +15,7 @@ Aztec is in active development and this has only been tested on MacOS. Please re ## Prerequisites -For this tutorial, we will need to have the [Sandbox](../../../reference/developer_references/sandbox_reference/index.md) installed. +For this tutorial, we will need to have the [Sandbox](../../../reference/environment_reference/sandbox-reference.md) installed. We also need to install Secretive, a nice open-source package that allows us to store keys on the Secure Enclave. You can head to the [secretive releases page](https://github.com/maxgoedjen/secretive/releases) and get the last release's `zip`, unzip and move to Applications, or use [Homebrew](https://brew.sh/): @@ -45,7 +45,7 @@ Make sure Secretive's "Secret Agent" is running. The Secure Enclave is a protected chip on most recent iPhones and Macs and it's meant to be airgapped. It is not safe to use in production. -Fortunately, Aztec implements [Account Abstraction](../../../aztec/concepts/accounts#what-is-account-abstraction) at the protocol level. You could write logic to allow someone else to recover your account, or use a different key or keys for recovery. +Fortunately, Aztec implements [Account Abstraction](../../../../aztec/concepts/accounts/index.md#what-is-account-abstraction) at the protocol level. You could write logic to allow someone else to recover your account, or use a different key or keys for recovery. ::: @@ -92,7 +92,7 @@ aztec-wallet deploy --from accounts:my-wallet token_contract@Token --args accoun You should get prompted to sign with TouchID or password. Once authorized, you should see `Contract stored in database with aliases last & devtoken` ``` -Check [the reference](../../../reference/developer_references/cli_wallet_reference.md) for the whole set of commands, but these mean: +Check [the reference](../../../reference/environment_reference/cli_wallet_reference.md) for the whole set of commands, but these mean: - --from is the sender: our account `my-wallet`. We use the alias because it's easier than writing the key stored in our Secure Enclave. The wallet resolves the alias and knows where to grab it. - token_contract@Token is a shorthand to look in the `target` folder for our contract `token_contract-Token` @@ -111,7 +111,7 @@ aztec-wallet simulate balance_of_public -ca contracts:devtoken --args accounts:n ### What next -In this tutorial, we created an account with the Aztec's [CLI Wallet](../../../reference/developer_references/cli_wallet_reference.md), using the Apple Mac's Secure Enclave to store the private key. +In this tutorial, we created an account with the Aztec's [CLI Wallet](../../../reference/environment_reference/cli_wallet_reference.md), using the Apple Mac's Secure Enclave to store the private key. You can use a multitude of authentication methods, for example with RSA you could use a passport as a recovery, or even as a signer in a multisig. All of this is based on the account contract. diff --git a/docs/docs/tutorials/codealong/contract_tutorials/_category_.json b/docs/docs/developers/tutorials/codealong/contract_tutorials/_category_.json similarity index 100% rename from docs/docs/tutorials/codealong/contract_tutorials/_category_.json rename to docs/docs/developers/tutorials/codealong/contract_tutorials/_category_.json diff --git a/docs/docs/tutorials/codealong/contract_tutorials/counter_contract.md b/docs/docs/developers/tutorials/codealong/contract_tutorials/counter_contract.md similarity index 95% rename from docs/docs/tutorials/codealong/contract_tutorials/counter_contract.md rename to docs/docs/developers/tutorials/codealong/contract_tutorials/counter_contract.md index 0ab8bc479b55..ad07e67aca27 100644 --- a/docs/docs/tutorials/codealong/contract_tutorials/counter_contract.md +++ b/docs/docs/developers/tutorials/codealong/contract_tutorials/counter_contract.md @@ -7,9 +7,9 @@ In this guide, we will create our first Aztec.nr smart contract. We will build a ## Prerequisites -- You have followed the [quickstart](../../../guides/getting_started.md) +- You have followed the [quickstart](../../../getting_started.md) - Running Aztec Sandbox -- Installed [Noir LSP](../../../guides/developer_guides/local_env/installing_noir_lsp.md) (optional) +- Installed [Noir LSP](../../../guides/local_env/installing_noir_lsp.md) (optional) ## Set up a project @@ -159,4 +159,4 @@ Follow the private voting contract tutorial on the [next page](./private_voting_ ### Optional: Learn more about concepts mentioned here - - [Functions and annotations like `#[private]`](../../../aztec/smart_contracts/functions/function_transforms.md#private-functions) + - [Functions and annotations like `#[private]`](../../../../aztec/smart_contracts/functions/function_transforms.md#private-functions) diff --git a/docs/docs/tutorials/codealong/contract_tutorials/crowdfunding_contract.md b/docs/docs/developers/tutorials/codealong/contract_tutorials/crowdfunding_contract.md similarity index 95% rename from docs/docs/tutorials/codealong/contract_tutorials/crowdfunding_contract.md rename to docs/docs/developers/tutorials/codealong/contract_tutorials/crowdfunding_contract.md index 637572c8493e..6ebc0ec01212 100644 --- a/docs/docs/tutorials/codealong/contract_tutorials/crowdfunding_contract.md +++ b/docs/docs/developers/tutorials/codealong/contract_tutorials/crowdfunding_contract.md @@ -26,7 +26,7 @@ Along the way you will: ### Install tools -Please ensure that you already have [Installed the Sandbox](../../../guides/getting_started) +Please ensure that you already have [Installed the Sandbox](../../../getting_started) ### Create an Aztec project @@ -196,7 +196,7 @@ Follow the account contract tutorial on the [next page](./write_accounts_contrac ### Optional: Learn more about concepts mentioned here - - [Initializer functions](../../../guides/developer_guides/smart_contracts/writing_contracts/initializers.md) - - [Versions](../../../guides/developer_guides/local_env/versions-updating.md). - - [Authorizing actions](../../../aztec/concepts/accounts/index.md#authorizing-actions) - - [Public logs](../../../guides/developer_guides/smart_contracts/writing_contracts/how_to_emit_event.md#call-emit_public_log) + - [Initializer functions](../../../guides/smart_contracts/writing_contracts/initializers.md) + - [Versions](../../../guides/local_env/versions-updating.md). + - [Authorizing actions](../../../../aztec/concepts/advanced/authwit.md) + - [Public logs](../../../guides/smart_contracts/writing_contracts/how_to_emit_event.md) diff --git a/docs/docs/tutorials/codealong/contract_tutorials/nft_contract.md b/docs/docs/developers/tutorials/codealong/contract_tutorials/nft_contract.md similarity index 91% rename from docs/docs/tutorials/codealong/contract_tutorials/nft_contract.md rename to docs/docs/developers/tutorials/codealong/contract_tutorials/nft_contract.md index cdd551fa0c17..fefa4bf7ed45 100644 --- a/docs/docs/tutorials/codealong/contract_tutorials/nft_contract.md +++ b/docs/docs/developers/tutorials/codealong/contract_tutorials/nft_contract.md @@ -87,7 +87,7 @@ These are functions that have transparent logic, will execute in a publicly veri - [`set_minter`](#set_minter) - adds a minter to the `minters` mapping - [`mint`](#mint) - mints an NFT with a specified `token_id` to the recipient - [`transfer_in_public`](#transfer_in_public) - publicly transfer the specified token -- [`finalize_transfer_to_private`](#finalize_transfer_to_private) - finalize the transfer of the NFT from public to private context by completing the [partial note](../../../aztec/concepts/storage/partial_notes.md)(more on this below) +- [`finalize_transfer_to_private`](#finalize_transfer_to_private) - finalize the transfer of the NFT from public to private context by completing the [partial note](../../../../aztec/concepts/advanced/storage/partial_notes.md)(more on this below) #### Public `view` functions @@ -103,8 +103,8 @@ These functions are useful for getting contract information for use in other con These are functions that have private logic and will be executed on user devices to maintain privacy. The only data that is submitted to the network is a proof of correct execution, new data commitments and nullifiers, so users will not reveal which contract they are interacting with or which function they are executing. The only information that will be revealed publicly is that someone executed a private transaction on Aztec. -- [`transfer_to_private`](#transfer_to_private) - privately initiates the transfer of an NFT from the public context to the private context by creating a [partial note](../../../aztec/concepts/storage/partial_notes.md) -- [`prepare_private_balance_increase`](#prepare_private_balance_increase) - creates a [partial note](../../../aztec/concepts/storage/partial_notes.md) to transfer an NFT from the public context to the private context. +- [`transfer_to_private`](#transfer_to_private) - privately initiates the transfer of an NFT from the public context to the private context by creating a [partial note](../../../../aztec/concepts/advanced/storage/partial_notes.md) +- [`prepare_private_balance_increase`](#prepare_private_balance_increase) - creates a [partial note](../../../../aztec/concepts/advanced/storage/partial_notes.md) to transfer an NFT from the public context to the private context. - [`cancel_authwit`](#cancel_authwit) - emits a nullifier to cancel a private authwit - [`transfer_in_private`](#transfer_in_private) - transfers an NFT to another account, privately - [`transfer_to_public`](#transfer_to_public) - transfers a NFT from private to public context @@ -158,7 +158,7 @@ We are also importing types from a `types.nr` file, which imports types from the :::note -Private state in Aztec is all [UTXOs](../../../aztec/concepts/storage/index.md). +Private state in Aztec is all [UTXOs](../../../../aztec/concepts/storage/state_model.md). ::: @@ -172,7 +172,7 @@ Below the dependencies, paste the following Storage struct: ## Custom Notes -The contract storage uses a [custom note](../../../guides/developer_guides/smart_contracts/writing_contracts/notes/custom_note.md) implementation. Custom notes are useful for defining your own data types. You can think of a custom note as a "chunk" of private data, the entire thing is added, updated or nullified (deleted) together. This NFT note is very simple and stores only the owner and the `token_id` and uses `randomness` to hide its contents. +The contract storage uses a [custom note](../../../guides/smart_contracts/writing_contracts/notes/custom_note.md) implementation. Custom notes are useful for defining your own data types. You can think of a custom note as a "chunk" of private data, the entire thing is added, updated or nullified (deleted) together. This NFT note is very simple and stores only the owner and the `token_id` and uses `randomness` to hide its contents. Randomness is required because notes are stored as commitments (hashes) in the note hash tree. Without randomness, the contents of a note may be derived through brute force (e.g. without randomness, if you know my Aztec address, you may be able to figure out which note hash in the tree is mine by hashing my address with many potential `token_id`s). @@ -196,7 +196,7 @@ This function sets the admin and makes them a minter, and sets the name and symb Public functions are declared with the `#[public]` macro above the function name. -As described in the [execution contexts section above](#execution-contexts), public function logic and transaction information is transparent to the world. Public functions update public state, but can be used to finalize notes prepared in a private context ([partial notes flow](../../../aztec/concepts/storage/partial_notes.md)). +As described in the [execution contexts section above](#execution-contexts), public function logic and transaction information is transparent to the world. Public functions update public state, but can be used to finalize notes prepared in a private context ([partial notes flow](../../../../aztec/concepts/advanced/storage/partial_notes.md)). Storage is referenced as `storage.variable`. @@ -255,7 +255,7 @@ Transfers token with `token_id` from public balance of the sender to a private b #### `prepare_private_balance_increase` -This function prepares a [partial note](../../../aztec/concepts/storage/partial_notes.md) to transfer an NFT from the public context to the private context. The caller specifies an `AztecAddress` that will receive the NFT in private storage. +This function prepares a [partial note](../../../../aztec/concepts/advanced/storage/partial_notes.md) to transfer an NFT from the public context to the private context. The caller specifies an `AztecAddress` that will receive the NFT in private storage. :::note @@ -275,7 +275,7 @@ Cancels a private authwit by emitting the corresponding nullifier. #### `transfer_in_private` -Transfers an NFT between two addresses in the private context. Uses [authwits](../../../aztec/concepts/accounts/authwit.md) to allow contracts to transfer NFTs on behalf of other accounts. +Transfers an NFT between two addresses in the private context. Uses [authwits](../../../../aztec/concepts/advanced/authwit.md) to allow contracts to transfer NFTs on behalf of other accounts. #include_code transfer_in_private /noir-projects/noir-contracts/contracts/nft_contract/src/main.nr rust @@ -359,7 +359,7 @@ A getter function for checking the private balance of the provided Aztec account ## Compiling -Now that the contract is complete, you can compile it with `aztec-nargo`. See the [Sandbox reference page](../../../reference/developer_references/sandbox_reference/index.md) for instructions on setting it up. +Now that the contract is complete, you can compile it with `aztec-nargo`. See the [Sandbox reference page](../../../reference/environment_reference/index.md) for instructions on setting it up. Run the following command in the directory where your `Nargo.toml` file is located: @@ -376,7 +376,7 @@ aztec codegen target -o src/artifacts ### Optional: Dive deeper into this contract and concepts mentioned here - Review [the end to end tests (Github link)](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/yarn-project/end-to-end/src/e2e_nft.test.ts) for reference. -- [Nullifiers](../../../aztec/concepts/storage/trees/index.md#nullifier-tree) -- [Public / Private function calls](../../../aztec/smart_contracts/functions/public_private_calls.md). -- [Contract Storage](../../../aztec/concepts/storage/index.md) -- [Authwit](../../../aztec/concepts/accounts/authwit.md) +- [Nullifier tree](../../../../aztec/concepts/advanced/storage/indexed_merkle_tree.mdx) +- [Public / Private function calls](../../../../aztec/smart_contracts/functions/public_private_calls.md). +- [Contract Storage](../../../../aztec/concepts/storage/index.md) +- [Authwit](../../../../aztec/concepts/advanced/authwit.md) diff --git a/docs/docs/tutorials/codealong/contract_tutorials/private_voting_contract.md b/docs/docs/developers/tutorials/codealong/contract_tutorials/private_voting_contract.md similarity index 93% rename from docs/docs/tutorials/codealong/contract_tutorials/private_voting_contract.md rename to docs/docs/developers/tutorials/codealong/contract_tutorials/private_voting_contract.md index 2c7f0d81f86f..499150b03ff4 100644 --- a/docs/docs/tutorials/codealong/contract_tutorials/private_voting_contract.md +++ b/docs/docs/developers/tutorials/codealong/contract_tutorials/private_voting_contract.md @@ -21,7 +21,7 @@ To keep things simple, we won't create ballots or allow for delegate voting. ## Prerequisites -- You have followed the [quickstart](../../../guides/getting_started) to install `aztec-nargo` and `aztec`. +- You have followed the [quickstart](../../../getting_started.md) to install `aztec-nargo` and `aztec`. - Running Aztec Sandbox ## Set up a project @@ -172,7 +172,7 @@ Follow the crowdfunding contracts tutorial on the [next page](./crowdfunding_con ### Optional: Learn more about concepts mentioned here -- [Unconstrained functions](../../../aztec/smart_contracts/functions/index.md). -- [Oracles](../../../aztec/smart_contracts/oracles/index.md) -- [Nullifier secrets](../../../aztec/concepts/accounts/keys.md#nullifier-secrets). -- [How to deploy a contract to the sandbox](../../../guides/developer_guides/smart_contracts/how_to_deploy_contract.md) +- [Unconstrained functions](../../../../aztec/smart_contracts/functions/attributes.md#unconstrained-functions). +- [Oracles](../../../../aztec/smart_contracts/oracles/index.md) +- [Nullifier secrets](../../../../aztec/concepts/accounts/keys.md#nullifier-keys). +- [How to deploy a contract to the sandbox](../../../guides/smart_contracts/how_to_deploy_contract.md) diff --git a/docs/docs/tutorials/codealong/contract_tutorials/token_bridge/0_setup.md b/docs/docs/developers/tutorials/codealong/contract_tutorials/token_bridge/0_setup.md similarity index 98% rename from docs/docs/tutorials/codealong/contract_tutorials/token_bridge/0_setup.md rename to docs/docs/developers/tutorials/codealong/contract_tutorials/token_bridge/0_setup.md index 4ec44d065e70..0a4d73b13e02 100644 --- a/docs/docs/tutorials/codealong/contract_tutorials/token_bridge/0_setup.md +++ b/docs/docs/developers/tutorials/codealong/contract_tutorials/token_bridge/0_setup.md @@ -17,7 +17,7 @@ We recommend going through this setup to fully understand where things live. - [node v18+ (GitHub link)](https://github.com/tj/n) - [docker](https://docs.docker.com/) -- [Aztec sandbox](../../../../../guides/getting_started) - you should have this running before starting the tutorial +- [Aztec sandbox](../../../../../developers/getting_started) - you should have this running before starting the tutorial Start the sandbox diff --git a/docs/docs/tutorials/codealong/contract_tutorials/token_bridge/1_depositing_to_aztec.md b/docs/docs/developers/tutorials/codealong/contract_tutorials/token_bridge/1_depositing_to_aztec.md similarity index 100% rename from docs/docs/tutorials/codealong/contract_tutorials/token_bridge/1_depositing_to_aztec.md rename to docs/docs/developers/tutorials/codealong/contract_tutorials/token_bridge/1_depositing_to_aztec.md diff --git a/docs/docs/tutorials/codealong/contract_tutorials/token_bridge/2_minting_on_aztec.md b/docs/docs/developers/tutorials/codealong/contract_tutorials/token_bridge/2_minting_on_aztec.md similarity index 100% rename from docs/docs/tutorials/codealong/contract_tutorials/token_bridge/2_minting_on_aztec.md rename to docs/docs/developers/tutorials/codealong/contract_tutorials/token_bridge/2_minting_on_aztec.md diff --git a/docs/docs/tutorials/codealong/contract_tutorials/token_bridge/3_withdrawing_to_l1.md b/docs/docs/developers/tutorials/codealong/contract_tutorials/token_bridge/3_withdrawing_to_l1.md similarity index 100% rename from docs/docs/tutorials/codealong/contract_tutorials/token_bridge/3_withdrawing_to_l1.md rename to docs/docs/developers/tutorials/codealong/contract_tutorials/token_bridge/3_withdrawing_to_l1.md diff --git a/docs/docs/tutorials/codealong/contract_tutorials/token_bridge/4_typescript_glue_code.md b/docs/docs/developers/tutorials/codealong/contract_tutorials/token_bridge/4_typescript_glue_code.md similarity index 98% rename from docs/docs/tutorials/codealong/contract_tutorials/token_bridge/4_typescript_glue_code.md rename to docs/docs/developers/tutorials/codealong/contract_tutorials/token_bridge/4_typescript_glue_code.md index 4020d5f6df86..7af4ab182d64 100644 --- a/docs/docs/tutorials/codealong/contract_tutorials/token_bridge/4_typescript_glue_code.md +++ b/docs/docs/developers/tutorials/codealong/contract_tutorials/token_bridge/4_typescript_glue_code.md @@ -171,4 +171,4 @@ Follow the tutorial [here](../../js_tutorials/aztecjs-getting-started.md). ### Optional: Learn more about concepts mentioned here -- [Functions under the hood (concepts)](../../../../aztec/smart_contracts/functions/function_transforms.md) +- [Functions under the hood (concepts)](../../../../../aztec/smart_contracts/functions/function_transforms.md) diff --git a/docs/docs/tutorials/codealong/contract_tutorials/token_bridge/index.md b/docs/docs/developers/tutorials/codealong/contract_tutorials/token_bridge/index.md similarity index 100% rename from docs/docs/tutorials/codealong/contract_tutorials/token_bridge/index.md rename to docs/docs/developers/tutorials/codealong/contract_tutorials/token_bridge/index.md diff --git a/docs/docs/tutorials/codealong/contract_tutorials/token_contract.md b/docs/docs/developers/tutorials/codealong/contract_tutorials/token_contract.md similarity index 95% rename from docs/docs/tutorials/codealong/contract_tutorials/token_contract.md rename to docs/docs/developers/tutorials/codealong/contract_tutorials/token_contract.md index 9c58a4bb1602..b3308fa477c7 100644 --- a/docs/docs/tutorials/codealong/contract_tutorials/token_contract.md +++ b/docs/docs/developers/tutorials/codealong/contract_tutorials/token_contract.md @@ -85,7 +85,7 @@ These are functions that have private logic and will be executed on user devices - [`cancel_authwit`](#cancel_authwit) enables an account to cancel an authorization to spend tokens - [`burn_private`](#burn_private) enables tokens to be burned privately - [`setup_refund`](#setup_refund) allows users using a fee paying contract to receive unspent transaction fees -- [`prepare_private_balance_increase`](#prepare_private_balance_increase) is used to set up a [partial note](../../../aztec/concepts/storage/partial_notes.md) to be completed in public +- [`prepare_private_balance_increase`](#prepare_private_balance_increase) is used to set up a [partial note](../../../../aztec/concepts/advanced/storage/partial_notes.md) to be completed in public #### Private `view` functions @@ -101,7 +101,7 @@ Internal functions are functions that can only be called by the contract itself. - [`_increase_public_balance`](#_increase_public_balance) increases the public balance of an account when `transfer_to_public` is called - [`_reduce_total_supply`](#_reduce_total_supply) reduces the total supply of tokens when a token is privately burned -- [`complete_refund`](#complete_refund) used in the fee payment flow. There is more detail on the [partial note](../../../aztec/concepts/storage/partial_notes.md#private-fee-payment-implementation) page. +- [`complete_refund`](#complete_refund) used in the fee payment flow. There is more detail on the [partial note](../../../../aztec/concepts/advanced/storage/partial_notes.md#complete_refund) page. - [`_finalize_transfer_to_private_unsafe`](#_finalize_transfer_to_private_unsafe) is the public component for finalizing a transfer from a public balance to private balance. It is considered `unsafe` because `from` is not enforced in this function, but it is in enforced the private function that calls this one (so it's safe). - [`_finalize_mint_to_private_unsafe`](#_finalize_mint_to_private_unsafe) finalizes a private mint. Like the function above, it is considered `unsafe` because `from` is not enforced in this function, but it is in enforced the private function that calls this one (so it's safe). @@ -156,7 +156,7 @@ We are also importing types from a `types.nr` file, which imports types from the :::note -Private state in Aztec is all [UTXOs](../../../aztec/concepts/storage/index.md). +Private state in Aztec is all [UTXOs](../../../../aztec/concepts/storage/index.md). ::: @@ -191,7 +191,7 @@ This function sets the creator of the contract (passed as `msg_sender` from the Public functions are declared with the `#[public]` macro above the function name. -As described in the [execution contexts section above](#execution-contexts), public function logic and transaction information is transparent to the world. Public functions update public state, but can be used to finalize notes prepared in a private context ([partial notes flow](../../../aztec/concepts/storage/partial_notes.md)). +As described in the [execution contexts section above](#execution-contexts), public function logic and transaction information is transparent to the world. Public functions update public state, but can be used to finalize notes prepared in a private context ([partial notes flow](../../../../aztec/concepts/advanced/storage/partial_notes.md)). Storage is referenced as `storage.variable`. @@ -386,13 +386,13 @@ Unconstrained functions are similar to `view` functions in Solidity in that they #### `balance_of_private` -A getter function for checking the private balance of the provided Aztec account. Note that the [Private Execution Environment (PXE) (GitHub link)](https://github.com/AztecProtocol/aztec-packages/tree/#include_aztec_version/yarn-project/pxe) must have `ivsk` ([incoming viewing secret key](../../../aztec/concepts/accounts/keys.md#incoming-viewing-keys)) in order to decrypt the notes. +A getter function for checking the private balance of the provided Aztec account. Note that the [Private Execution Environment (PXE) (GitHub link)](https://github.com/AztecProtocol/aztec-packages/tree/#include_aztec_version/yarn-project/pxe) must have `ivsk` ([incoming viewing secret key](../../../../aztec/concepts/accounts/keys.md#incoming-viewing-keys)) in order to decrypt the notes. #include_code balance_of_private /noir-projects/noir-contracts/contracts/token_contract/src/main.nr rust ## Compiling -Now that the contract is complete, you can compile it with `aztec-nargo`. See the [Sandbox reference page](../../../reference/developer_references/sandbox_reference/index.md) for instructions on setting it up. +Now that the contract is complete, you can compile it with `aztec-nargo`. See the [Sandbox reference page](../../../reference/environment_reference/index.md) for instructions on setting it up. Run the following command in the directory where your `Nargo.toml` file is located: @@ -410,7 +410,7 @@ aztec codegen target -o src/artifacts ### Token Bridge Contract -The [token bridge tutorial](.//token_bridge/index.md) is a great follow up to this one. +The [token bridge tutorial](./token_bridge/index.md) is a great follow up to this one. It builds on the Token contract described here and goes into more detail about Aztec contract composability and Ethereum (L1) and Aztec (L2) cross-chain messaging. @@ -418,7 +418,7 @@ It builds on the Token contract described here and goes into more detail about A - Review [the end to end tests (Github link)](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/yarn-project/end-to-end/src/e2e_token_contract/) for reference. - [Commitments (Wikipedia link)](https://en.wikipedia.org/wiki/Commitment_scheme) -- [Nullifiers](../../../aztec/concepts/storage/trees/index.md#nullifier-tree) -- [Public / Private function calls](../../../aztec/smart_contracts/functions/public_private_calls.md). -- [Contract Storage](../../../aztec/concepts/storage/index.md) -- [Authwit](../../../aztec/concepts/accounts/authwit.md) +- [Nullifier tree](../../../../aztec/concepts/advanced/storage/indexed_merkle_tree.mdx) +- [Public / Private function calls](../../../../aztec/smart_contracts/functions/public_private_calls.md). +- [Contract Storage](../../../../aztec/concepts/storage/index.md) +- [Authwit](../../../../aztec/concepts/advanced/authwit.md) diff --git a/docs/docs/tutorials/examples/uniswap/_category_.json b/docs/docs/developers/tutorials/codealong/contract_tutorials/uniswap/_category_.json similarity index 100% rename from docs/docs/tutorials/examples/uniswap/_category_.json rename to docs/docs/developers/tutorials/codealong/contract_tutorials/uniswap/_category_.json diff --git a/docs/docs/tutorials/examples/uniswap/e2e_tests.md b/docs/docs/developers/tutorials/codealong/contract_tutorials/uniswap/e2e_tests.md similarity index 100% rename from docs/docs/tutorials/examples/uniswap/e2e_tests.md rename to docs/docs/developers/tutorials/codealong/contract_tutorials/uniswap/e2e_tests.md diff --git a/docs/docs/tutorials/examples/uniswap/index.md b/docs/docs/developers/tutorials/codealong/contract_tutorials/uniswap/index.md similarity index 87% rename from docs/docs/tutorials/examples/uniswap/index.md rename to docs/docs/developers/tutorials/codealong/contract_tutorials/uniswap/index.md index d31c03b0418e..1e3e804f06c1 100644 --- a/docs/docs/tutorials/examples/uniswap/index.md +++ b/docs/docs/developers/tutorials/codealong/contract_tutorials/uniswap/index.md @@ -1,6 +1,6 @@ --- -title: Overview -sidebar_position: 0 +title: Swap on L1 from L2s +sidebar_position: 7 --- import Image from "@theme/IdealImage"; @@ -15,7 +15,7 @@ The flow will be: 2. We create an L2 → L1 message to swap on L1 3. On L1, the user gets their input tokens, consumes the swap message, and executes the swap 4. The user deposits the “output” tokens to the output token portal so it can be deposited into L2 -5. We will assume that token portals and token bridges for the input and output tokens must exist. These are what we built in the [token bridge tutorial](../../codealong/contract_tutorials/token_bridge/index.md). +5. We will assume that token portals and token bridges for the input and output tokens must exist. These are what we built in the [token bridge tutorial](../token_bridge/index.md). The execution of swap on L1 should be designed such that any 3rd party can execute the swap on behalf of the user. This helps maintain user privacy by not requiring links between L1 and L2 activity. @@ -27,5 +27,5 @@ This reference will cover: This diagram describes the private flow. -This code works alongside a token portal that you can learn to build [in this codealong tutorial](../../codealong/contract_tutorials/token_bridge/index.md). +This code works alongside a token portal that you can learn to build [in this codealong tutorial](../token_bridge/index.md). diff --git a/docs/docs/tutorials/examples/uniswap/l1_contract.md b/docs/docs/developers/tutorials/codealong/contract_tutorials/uniswap/l1_contract.md similarity index 94% rename from docs/docs/tutorials/examples/uniswap/l1_contract.md rename to docs/docs/developers/tutorials/codealong/contract_tutorials/uniswap/l1_contract.md index c9b16928ed14..eec465e9a202 100644 --- a/docs/docs/tutorials/examples/uniswap/l1_contract.md +++ b/docs/docs/developers/tutorials/codealong/contract_tutorials/uniswap/l1_contract.md @@ -3,7 +3,7 @@ title: L1 contracts (EVM) sidebar_position: 2 --- -This page goes over the code in the L1 contract for Uniswap, which works alongside a [token portal (codealong tutorial)](../../codealong/contract_tutorials/token_bridge/index.md). +This page goes over the code in the L1 contract for Uniswap, which works alongside a [token portal (codealong tutorial)](../token_bridge/index.md). ## Setup diff --git a/docs/docs/tutorials/examples/uniswap/l2_contract.md b/docs/docs/developers/tutorials/codealong/contract_tutorials/uniswap/l2_contract.md similarity index 95% rename from docs/docs/tutorials/examples/uniswap/l2_contract.md rename to docs/docs/developers/tutorials/codealong/contract_tutorials/uniswap/l2_contract.md index a3ce0e6de53e..597755f9a5e1 100644 --- a/docs/docs/tutorials/examples/uniswap/l2_contract.md +++ b/docs/docs/developers/tutorials/codealong/contract_tutorials/uniswap/l2_contract.md @@ -3,7 +3,7 @@ title: L2 Contracts (Aztec) sidebar_position: 1 --- -This page goes over the code in the L2 contract for Uniswap, which works alongside a [token bridge (codealong tutorial)](../../codealong/contract_tutorials/token_bridge/index.md). +This page goes over the code in the L2 contract for Uniswap, which works alongside a [token bridge (codealong tutorial)](../token_bridge/index.md). ## Main.nr @@ -16,11 +16,11 @@ We just need to store the portal address for the token that we want to swap. #include_code swap_public noir-projects/noir-contracts/contracts/uniswap_contract/src/main.nr rust -1. We check that `msg.sender()` has appropriate approval to call this on behalf of the sender by constructing an authwit message and checking if `from` has given the approval (read more about authwit [here](../../../aztec/concepts/accounts/authwit.md)). +1. We check that `msg.sender()` has appropriate approval to call this on behalf of the sender by constructing an authwit message and checking if `from` has given the approval (read more about authwit [here](../../../../../aztec/concepts/advanced/authwit.md)). 2. We fetch the underlying aztec token that needs to be swapped. 3. We transfer the user’s funds to the Uniswap contract. Like with Ethereum, the user must have provided approval to the Uniswap contract to do so. The user must provide the nonce they used in the approval for transfer, so that Uniswap can send it to the token contract, to prove it has appropriate approval. 4. Funds are added to the Uniswap contract. -5. Uniswap must exit the input tokens to L1. For this it has to approve the bridge to burn its tokens on its behalf and then actually exit the funds. We call the [`exit_to_l1_public()` method on the token bridge](../../codealong/contract_tutorials/token_bridge/index.md). We use the public flow for exiting since we are operating on public state. +5. Uniswap must exit the input tokens to L1. For this it has to approve the bridge to burn its tokens on its behalf and then actually exit the funds. We call the [`exit_to_l1_public()` method on the token bridge](../token_bridge/3_withdrawing_to_l1.md). We use the public flow for exiting since we are operating on public state. 6. It is not enough for us to simply emit a message to withdraw the funds. We also need to emit a message to display our swap intention. If we do not do this, there is nothing stopping a third party from calling the Uniswap portal with their own parameters and consuming our message. So the Uniswap portal (on L1) needs to know: diff --git a/docs/docs/tutorials/codealong/contract_tutorials/write_accounts_contract.md b/docs/docs/developers/tutorials/codealong/contract_tutorials/write_accounts_contract.md similarity index 90% rename from docs/docs/tutorials/codealong/contract_tutorials/write_accounts_contract.md rename to docs/docs/developers/tutorials/codealong/contract_tutorials/write_accounts_contract.md index 43cd5b5902f6..1dcc03e75bf5 100644 --- a/docs/docs/tutorials/codealong/contract_tutorials/write_accounts_contract.md +++ b/docs/docs/developers/tutorials/codealong/contract_tutorials/write_accounts_contract.md @@ -17,13 +17,13 @@ You will learn: Writing your own account contract allows you to define the rules by which user transactions are authorized and paid for, as well as how user keys are managed (including key rotation and recovery). In other words, writing an account contract lets you make the most out of account abstraction in the Aztec network. -It is highly recommended that you understand how an [account](../../../aztec/concepts/accounts/index.md) is defined in Aztec, as well as the differences between privacy and authentication [keys](../../../aztec/concepts/accounts/keys.md). You will also need to know how to write a contract in Noir, as well as some basic [Typescript](https://www.typescriptlang.org/). +It is highly recommended that you understand how an [account](../../../../aztec/concepts/accounts/index.md) is defined in Aztec, as well as the differences between privacy and authentication [keys](../../../../aztec/concepts/accounts/keys.md). You will also need to know how to write a contract in Noir, as well as some basic [Typescript](https://www.typescriptlang.org/). For this tutorial, we will write an account contract that uses Schnorr signatures for authenticating transaction requests. Every time a transaction payload is passed to this account contract's `entrypoint` function, the account contract requires a valid Schnorr signature, whose signed message matches the transaction payload, and whose signer matches the account contract owner's public key. If the signature fails, the transaction will fail. -For the sake of simplicity, we will hardcode the signing public key into the contract, but you could store it [in a private note](../../../aztec/concepts/accounts/keys.md#using-a-private-note), [in an immutable note](../../../aztec/concepts/accounts/keys.md#using-an-immutable-private-note), or [on a separate keystore](../../../aztec/concepts/accounts/keys.md#using-a-separate-keystore), to mention a few examples. +For the sake of simplicity, we will hardcode the signing public key into the contract, but you could store it [in a private note](../../../../aztec/concepts/accounts/keys.md#using-a-private-note), [in an immutable note](../../../../aztec/concepts/accounts/keys.md#using-an-immutable-private-note), or [on a separate keystore](../../../../aztec/concepts/accounts/keys.md#using-a-separate-keystore), to mention a few examples. ## Contract @@ -91,7 +91,7 @@ More signing schemes are available in case you want to experiment with other typ Let's try creating a new account backed by our account contract, and interact with a simple token contract to test it works. -To create and deploy the account, we will use the `AccountManager` class, which takes an instance of an Private Execution Environment (PXE), a [privacy private key](../../../aztec/concepts/accounts/keys.md#incoming-viewing-keys), and an instance of our `AccountContract` class: +To create and deploy the account, we will use the `AccountManager` class, which takes an instance of an Private Execution Environment (PXE), a [privacy private key](../../../../aztec/concepts/accounts/keys.md#incoming-viewing-keys), and an instance of our `AccountContract` class: #include_code account-contract-deploy yarn-project/end-to-end/src/guides/writing_an_account_contract.test.ts typescript @@ -113,5 +113,5 @@ Lo and behold, we get `Error: Assertion failed: 'verification == true'` when run - [ECDSA signer account contract (GitHub link)](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/noir-projects/noir-contracts/contracts/ecdsa_account_contract/src/main.nr) - [Schnorr signer account contract (GitHub link)](https://github.com/AztecProtocol/aztec-packages/tree/#include_aztec_version/noir-projects/noir-contracts/contracts/schnorr_account_contract) -- [Account abstraction](../../../aztec/concepts/accounts/index.md#what-is-account-abstraction) -- [Authentication witness](../../../aztec/concepts/accounts/authwit.md) +- [Account abstraction](../../../../aztec/concepts/accounts/index.md#what-is-account-abstraction) +- [Authentication witness](../../../../aztec/concepts/advanced/authwit.md) diff --git a/docs/docs/tutorials/codealong/js_tutorials/_category_.json b/docs/docs/developers/tutorials/codealong/js_tutorials/_category_.json similarity index 100% rename from docs/docs/tutorials/codealong/js_tutorials/_category_.json rename to docs/docs/developers/tutorials/codealong/js_tutorials/_category_.json diff --git a/docs/docs/tutorials/codealong/js_tutorials/aztecjs-getting-started.md b/docs/docs/developers/tutorials/codealong/js_tutorials/aztecjs-getting-started.md similarity index 94% rename from docs/docs/tutorials/codealong/js_tutorials/aztecjs-getting-started.md rename to docs/docs/developers/tutorials/codealong/js_tutorials/aztecjs-getting-started.md index 6dd6b117e5c0..2fb60c63e3d1 100644 --- a/docs/docs/tutorials/codealong/js_tutorials/aztecjs-getting-started.md +++ b/docs/docs/developers/tutorials/codealong/js_tutorials/aztecjs-getting-started.md @@ -7,7 +7,7 @@ import Image from "@theme/IdealImage"; In this guide, we will retrieving the Sandbox and deploy a pre-written contract to it using Aztec.js. -This guide assumes you have followed the [quickstart](../../../guides/getting_started.md). +This guide assumes you have followed the [quickstart](../../../../developers/getting_started.md). ## Prerequisites @@ -134,7 +134,7 @@ The sandbox is preloaded with multiple accounts so you don't have to sit and cre #include_code load_accounts /yarn-project/end-to-end/src/composed/e2e_sandbox_example.test.ts typescript -An explanation on accounts on Aztec can be found [here](../../../aztec/concepts/accounts/index.md). +An explanation on accounts on Aztec can be found [here](../../../../aztec/concepts/accounts/index.md). ## Deploy a contract @@ -295,7 +295,7 @@ This function takes: 2. A recipient 3. An amount of tokens to mint -This function starts as private to set up the creation of a [partial note](../../../aztec/concepts/storage/partial_notes.md). The private function calls a public function that checks that the minter is authorized to mint new tokens an increments the public total supply. The recipient of the tokens remains private, but the minter and the amount of tokens minted are public. +This function starts as private to set up the creation of a [partial note](../../../../aztec/concepts/advanced/storage/partial_notes.md). The private function calls a public function that checks that the minter is authorized to mint new tokens an increments the public total supply. The recipient of the tokens remains private, but the minter and the amount of tokens minted are public. Let's now use these functions to mint some tokens to Bob's account using Typescript, add this to `index.ts`: @@ -339,7 +339,7 @@ Our complete output should now be something like: token Bob's balance 10543 +43ms ``` -That's it! We have successfully deployed a token contract to an instance of the Aztec network and mined private state-transitioning transactions. We have also queried the resulting state all via the interfaces provided by the contract. To see exactly what has happened here, you can learn about the transaction flow [on the Concepts page here](../../../aztec/concepts/transactions.md). +That's it! We have successfully deployed a token contract to an instance of the Aztec network and mined private state-transitioning transactions. We have also queried the resulting state all via the interfaces provided by the contract. To see exactly what has happened here, you can learn about the transaction flow [on the Concepts page here](../../../../aztec/concepts/transactions.md). ## Next Steps @@ -349,5 +349,5 @@ Follow the [dapp tutorial](./simple_dapp/index.md). ### Optional: Learn more about concepts mentioned here -- [Authentication witness](../../../aztec/concepts/accounts/authwit.md) -- [Functions under the hood](../../../aztec/smart_contracts/functions/function_transforms.md) +- [Authentication witness](../../../../aztec/concepts/advanced/authwit.md) +- [Functions under the hood](../../../../aztec/smart_contracts/functions/function_transforms.md) diff --git a/docs/docs/tutorials/codealong/js_tutorials/simple_dapp/0_project_setup.md b/docs/docs/developers/tutorials/codealong/js_tutorials/simple_dapp/0_project_setup.md similarity index 100% rename from docs/docs/tutorials/codealong/js_tutorials/simple_dapp/0_project_setup.md rename to docs/docs/developers/tutorials/codealong/js_tutorials/simple_dapp/0_project_setup.md diff --git a/docs/docs/tutorials/codealong/js_tutorials/simple_dapp/1_pxe_service.md b/docs/docs/developers/tutorials/codealong/js_tutorials/simple_dapp/1_pxe_service.md similarity index 86% rename from docs/docs/tutorials/codealong/js_tutorials/simple_dapp/1_pxe_service.md rename to docs/docs/developers/tutorials/codealong/js_tutorials/simple_dapp/1_pxe_service.md index 727b94d079b6..fbb5e1bb09d8 100644 --- a/docs/docs/tutorials/codealong/js_tutorials/simple_dapp/1_pxe_service.md +++ b/docs/docs/developers/tutorials/codealong/js_tutorials/simple_dapp/1_pxe_service.md @@ -4,7 +4,7 @@ PXE is a component of the Aztec Protocol that provides a private execution envir As an app developer, the PXE interface provides you with access to the user's accounts and their private state, as well as a connection to the network for accessing public global state. -The [Aztec Sandbox](.././../../../reference/developer_references/sandbox_reference/sandbox-reference.md) runs a local PXE and an Aztec Node, both connected to a local Ethereum development node like Anvil. +The Aztec Sandbox (reference [here](../../../../reference/environment_reference/sandbox-reference.md)) runs a local PXE and an Aztec Node, both connected to a local Ethereum development node like Anvil. The Sandbox also includes a set of pre-initialized accounts that you can use from your app. @@ -21,7 +21,7 @@ Let's create our first file `src/index.mjs` with the following contents: #include_code all yarn-project/end-to-end/src/sample-dapp/connect.mjs javascript -Make sure the [Sandbox is running](../../../../guides/getting_started.md) and run the example +Make sure the [Sandbox is running](../../../../getting_started.md) and run the example ```bash node src/index.mjs diff --git a/docs/docs/tutorials/codealong/js_tutorials/simple_dapp/2_contract_deployment.md b/docs/docs/developers/tutorials/codealong/js_tutorials/simple_dapp/2_contract_deployment.md similarity index 93% rename from docs/docs/tutorials/codealong/js_tutorials/simple_dapp/2_contract_deployment.md rename to docs/docs/developers/tutorials/codealong/js_tutorials/simple_dapp/2_contract_deployment.md index 324e3d59d0cf..ab5374d707d3 100644 --- a/docs/docs/tutorials/codealong/js_tutorials/simple_dapp/2_contract_deployment.md +++ b/docs/docs/developers/tutorials/codealong/js_tutorials/simple_dapp/2_contract_deployment.md @@ -3,7 +3,7 @@ To add contracts to your application, we'll start by creating a new `aztec-nargo` project. We'll then compile the contracts, and write a simple script to deploy them to our Sandbox. :::info -Follow the instructions [here](../../../../guides/getting_started.md) to install `aztec-nargo` if you haven't done so already. +Follow the instructions [here](../../../../getting_started.md) to install `aztec-nargo` if you haven't done so already. ::: ## Initialize Aztec project @@ -73,7 +73,7 @@ Here, we are using the `Contract` class with the compiled artifact to send a new Note that the token's `constructor()` method expects an `owner` address to set as the contract `admin`. We are using the first account from the Sandbox for this. :::info -If you are using the generated typescript classes, you can drop the generic `ContractDeployer` in favor of using the `deploy` method of the generated class, which will automatically load the artifact for you and type-check the constructor arguments. See the [How to deploy a contract](../../../../guides/developer_guides/smart_contracts/how_to_deploy_contract.md) page for more info. +If you are using the generated typescript classes, you can drop the generic `ContractDeployer` in favor of using the `deploy` method of the generated class, which will automatically load the artifact for you and type-check the constructor arguments. See the [How to deploy a contract](../../../../guides/smart_contracts/how_to_deploy_contract.md) page for more info. ::: Run the snippet above as `node src/deploy.mjs`, and you should see the following output, along with a new `addresses.json` file in your project root: diff --git a/docs/docs/tutorials/codealong/js_tutorials/simple_dapp/3_contract_interaction.md b/docs/docs/developers/tutorials/codealong/js_tutorials/simple_dapp/3_contract_interaction.md similarity index 92% rename from docs/docs/tutorials/codealong/js_tutorials/simple_dapp/3_contract_interaction.md rename to docs/docs/developers/tutorials/codealong/js_tutorials/simple_dapp/3_contract_interaction.md index 72583b361af3..7b28795ecacb 100644 --- a/docs/docs/tutorials/codealong/js_tutorials/simple_dapp/3_contract_interaction.md +++ b/docs/docs/developers/tutorials/codealong/js_tutorials/simple_dapp/3_contract_interaction.md @@ -11,7 +11,7 @@ Let's start by showing our user's private balance for the token across their acc #include_code balance_of_private noir-projects/noir-contracts/contracts/token_contract/src/main.nr rust :::info -Note that this function will only return a valid response for accounts registered in the Private eXecution Environment (PXE), since it requires access to the [user's private state](../../../../aztec/concepts/wallets/index.md#private-state). In other words, you cannot query the private balance of another user for the token contract. +Note that this function will only return a valid response for accounts registered in the Private eXecution Environment (PXE), since it requires access to the [user's private state](../../../../../aztec/concepts/wallets/index.md#private-state). In other words, you cannot query the private balance of another user for the token contract. ::: To do this, let's first initialize a new `Contract` instance using `aztec.js` that represents our deployed token contracts. Create a new `src/contracts.mjs` file with the imports for our artifacts and other dependencies: @@ -99,12 +99,12 @@ At the time of this writing, there are no events emitted when new private notes ## Working with public state -While [private and public state](../../../../aztec/concepts/storage/state_model/index.md) are fundamentally different, the API for working with private and public functions and state from `aztec.js` is equivalent. To query the balance in public tokens for our user accounts, we can just call the `balance_of_public` view function in the contract: +While [private and public state](../../../../../aztec/concepts/storage/index.md) are fundamentally different, the API for working with private and public functions and state from `aztec.js` is equivalent. To query the balance in public tokens for our user accounts, we can just call the `balance_of_public` view function in the contract: #include_code showPublicBalances yarn-project/end-to-end/src/sample-dapp/index.mjs javascript :::info -Since this we are working with public balances, we can now query the balance for any address, not just those registered in our local PXE. We can also send funds to addresses for which we don't know their [public encryption key](../../../../aztec/concepts/accounts/keys.md#encryption-keys). +Since this we are working with public balances, we can now query the balance for any address, not just those registered in our local PXE. We can also send funds to addresses for which we don't know their [public encryption key](../../../../../aztec/concepts/accounts/keys.md#keys-generation). ::: Here, since the token contract does not mint any initial funds upon deployment, the balances for all of our user's accounts will be zero. diff --git a/docs/docs/tutorials/codealong/js_tutorials/simple_dapp/4_testing.md b/docs/docs/developers/tutorials/codealong/js_tutorials/simple_dapp/4_testing.md similarity index 94% rename from docs/docs/tutorials/codealong/js_tutorials/simple_dapp/4_testing.md rename to docs/docs/developers/tutorials/codealong/js_tutorials/simple_dapp/4_testing.md index d162345d4486..1c0b037fd9de 100644 --- a/docs/docs/tutorials/codealong/js_tutorials/simple_dapp/4_testing.md +++ b/docs/docs/developers/tutorials/codealong/js_tutorials/simple_dapp/4_testing.md @@ -14,7 +14,7 @@ Start by installing our test runner, in this case jest: yarn add -D jest ``` -We'll need to [install and run the Sandbox](../../../../guides/getting_started.md). +We'll need to [install and run the Sandbox](../../../../getting_started.md). ## Test setup @@ -71,4 +71,4 @@ yarn node --experimental-vm-modules $(yarn bin jest) --testRegex '.*\.test\.mjs$ Have you written a contract from scratch? If not, follow a tutorial for [writing contracts with Noir](../../contract_tutorials/counter_contract.md) -Or read about the [fundamental concepts behind Aztec Network](../../../../aztec/concepts_overview.md) and dive deeper into how things work. +Or read about the [fundamental concepts behind Aztec Network](../../../../../aztec) and dive deeper into how things work. diff --git a/docs/docs/tutorials/codealong/js_tutorials/simple_dapp/index.md b/docs/docs/developers/tutorials/codealong/js_tutorials/simple_dapp/index.md similarity index 92% rename from docs/docs/tutorials/codealong/js_tutorials/simple_dapp/index.md rename to docs/docs/developers/tutorials/codealong/js_tutorials/simple_dapp/index.md index 5457d22e4c5f..8e8d532689dd 100644 --- a/docs/docs/tutorials/codealong/js_tutorials/simple_dapp/index.md +++ b/docs/docs/developers/tutorials/codealong/js_tutorials/simple_dapp/index.md @@ -4,7 +4,7 @@ title: Node.js app that interacts with contracts In this tutorial we'll go through the steps for building a simple application that interacts with the Aztec Sandbox. We'll be building a console application using Javascript and NodeJS, but you may reuse the same concepts here for a web-based app. All Aztec libraries are written in Typescript and fully typed, so you can use Typescript instead of Javascript to make the most out of its type checker. -This tutorial will focus on environment setup, including creating accounts and deployments, as well as interacting with your contracts. It will not cover [how to write contracts in Noir](../../../../aztec/smart_contracts_overview.md). +This tutorial will focus on environment setup, including creating accounts and deployments, as well as interacting with your contracts. It will not cover [how to write contracts in Noir](../../../../../aztec/smart_contracts_overview.md). The full code for this tutorial is [available on the `aztec-packages` repository](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/end-to-end/src/sample-dapp). @@ -12,7 +12,7 @@ The full code for this tutorial is [available on the `aztec-packages` repository - Linux or OSX environment - [NodeJS](https://nodejs.org/) 18 or higher -- [Aztec Sandbox](../../../guides/getting_started) +- [Aztec Sandbox](../../../../getting_started.md) ## Prerequisites diff --git a/docs/docs/guides/developer_guides/running_nodes/running_provers.md b/docs/docs/guides/developer_guides/running_nodes/running_provers.md deleted file mode 100644 index 65c662794863..000000000000 --- a/docs/docs/guides/developer_guides/running_nodes/running_provers.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -draft: true ---- - -# Running Prover Nodes - -TODO(https://github.com/AztecProtocol/aztec-packages/issues/9190) -_Details about how to configure a prover node and hardware requirements are to be determined. This guide will be updated once the information becomes available._ - -For the current state of design please see the RFC at https://forum.aztec.network/t/request-for-comments-aztecs-block-production-system/6155. - -## Overview of Prover Nodes - -Prover nodes play a critical role in the Aztec network by generating zero-knowledge proofs (ZKPs) that finalize blocks on the Proven Chain. - -### Role of Prover Nodes - -- **Proof Generation**: Provers generate zero-knowledge proofs for entire epochs, ensuring the validity of transactions and state transitions. These are verified by the solidity rollup smart contract on Ethereum. -- **Finalizing Blocks**: Proofs are submitted to the rollup contract on Layer 1 (L1) to finalize blocks on the Proven Chain. - -### Prover Bond - -- **Bond Requirement**: Provers must post a bond denominated in TST tokens (bond details subject to change). -- **Commitment**: The bond serves as a commitment to produce valid proofs within a specified time frame. -- **Slashing**: Failure to deliver proofs results in bond slashing, incentivizing timely and accurate proof generation. - -### Consensus Participation - -- **Collaboration with Validators**: Provers work alongside validators to secure the network and advance the Proven Chain. -- **Proof Submission**: Provers submit proofs to the rollup contract, which are then verified and used to finalize blocks. -- **Incentives**: Provers are rewarded for timely and accurate proof generation, promoting network health. diff --git a/docs/docs/guides/developer_guides/running_nodes/running_validators.md b/docs/docs/guides/developer_guides/running_nodes/running_validators.md deleted file mode 100644 index 455880453417..000000000000 --- a/docs/docs/guides/developer_guides/running_nodes/running_validators.md +++ /dev/null @@ -1,309 +0,0 @@ ---- -draft: true ---- - -# Aztec Validator Node Guide - -## Introduction - -This guide provides step-by-step instructions on how to set up an Aztec Layer 2 validator node. Running a node allows you to participate in the Aztec network as a validator (also known as a sequencer or proposer), contributing to the network's security and decentralization. - -The use of Docker means that the environment is set up in a way that works in a variety of environments. For complex deployments with load balancing (for validator redundancy to maximize liveness) there are helm charts available for use with kubernetes (with the same images). - -## Table of Contents - -1. [Prerequisites](#prerequisites) -2. [Port Forwarding](#port-forwarding) -3. [Setting Up on Ubuntu 24](#setting-up-on-ubuntu-24) -4. [Setting Up on Other Operating Systems](#setting-up-on-other-operating-systems) -5. [Configuring Deployment](#configuring-deployment) -6. [Troubleshooting](#troubleshooting) -7. [Background Knowledge](#background-knowledge) - ---- - -## Prerequisites - -- **Operating System**: One of the following - - Ubuntu 24.04 LTS - - macOS - - Windows -- **Knowledge**: Basic familiarity with running commands on a command-line interface. -- **Hardware Requirements**: - -``` - 🖥️ Minimum Recommended -|---------|---------------|----------------| -| CPU | 16 cores | 32 cores | -| Network | 32 mb/s | 128 mb/s | -| Storage | 3 TB | 5 TB | -| RAM | 32 GB | 64 GB | -``` - -## Port Forwarding - -### Understanding Port Forwarding - -Port forwarding allows external devices to access services on a private network by mapping an external port to an internal IP address and port. It's crucial for your Aztec node to communicate with other nodes in the network and form a decentralized peer network. You will need one open UDP port per validator instance you wish to run (even if they are on the same computer). - -- **Reference Guide**: [How to Set Up Port Forwarding on a Router](https://www.noip.com/support/knowledgebase/general-port-forwarding-guide/) -- If using a cloud provider, use security groups (for AWS) or a similar capability to configure open UDP ports on your server. - -### When Port Forwarding Is Not Possible - -Port forwarding may not be possible under certain conditions: - -- **ISP Restrictions**: Some Internet Service Providers (ISPs) block port forwarding. -- **Network Limitations**: If you're on a public or corporate network without router access. - -#### Workarounds - -For example, a restrictive setup like hotel Wi-Fi would require the use of a VPN, using `socat` into a port-forwarded computer, or just using a cloud instance directly with instructions above. Note: It may be possible to use a P2P relay service that works with the DiscV5 protocol, but it is currently untested. - -## Setting Up on Ubuntu 24 - -**Note**: The scripts mentioned here do not currently work on ARM architectures. Support for ARM will be added in the future. - -### Updating the System - -Open your terminal and update your package list: - -```bash -sudo apt update -``` - -### Installing Docker - -Install Docker to manage containerized applications: - -```bash -sudo apt install docker.io -``` - -### Starting Docker Service - -Start and enable the Docker service: - -```bash -sudo systemctl start docker -sudo systemctl enable docker -``` - -### Setting Up Docker User Group - -Add your user to the Docker group to run Docker commands without `sudo`: - -```bash -sudo groupadd docker -sudo usermod -aG docker $USER -newgrp docker -``` - -### Cloning the Aztec Packages Repository - -Clone the Aztec Protocol packages from GitHub: - -```bash -git clone https://github.com/AztecProtocol/aztec-packages -``` - -### Copying the Deploy Script - -Navigate to the directory where you cloned the repository, and copy the deploy script to your home directory: - -```bash -cd aztec-packages -cp spartan/oitavos/deploy-oitavos-team.sh ~/deploy.sh -``` - -**Note**: The script `deploy-oitavos-team.sh` is a temporary name and will be updated in future releases. This script deploys a validator node. - -### Exporting Environment Variables - -Export the following environment variables that will remain constant for your deployment: - -```bash -export AZTEC_IMAGE=your_aztec_image -export ETHEREUM_HOST=your_ethereum_host -export BOOT_NODE_URL=your_boot_node_url -export PUBLIC_IP=your_public_ip -``` - -- **AZTEC_IMAGE**: The Docker image for the Aztec node. -- **ETHEREUM_HOST**: The Ethereum host node your validator will connect to. -- **BOOT_NODE_URL**: The URL of the boot node for peer discovery. -- **PUBLIC_IP**: The public IP address of your machine. - -Replace the placeholders with your actual values. - -### Deploying the Validator Node - -Whenever you want to launch a validator instance, you need to run a container with unique ports. Since the deploy script reads and writes from the current working directory, create a separate directory for each validator. - -For example, to launch the first validator: - -```bash -mkdir val1 -cd val1 -VALIDATOR_PRIVATE_KEY=your_validator_private_key \ -VALIDATOR_ADDRESS=your_validator_address \ -NODE_PORT=8080 \ -P2P_TCP_PORT=40400 \ -P2P_UDP_PORT=40500 \ -~/deploy.sh -``` - -- **VALIDATOR_PRIVATE_KEY**: Your validator's private key. -- **VALIDATOR_ADDRESS**: Your validator's Ethereum address. -- **NODE_PORT**: The HTTP port for your node (use a unique port for each validator). -- **P2P_TCP_PORT** and **P2P_UDP_PORT**: Must be port-forward as detailed above! The TCP and UDP ports for peer-to-peer communication (use unique ports). - -Replace the placeholders with your actual values. - -To deploy additional validators, use different directories and ports: - -```bash -# Ensure the same environment variables exported earlier are set -mkdir val2 -cd val2 -VALIDATOR_PRIVATE_KEY=another_validator_private_key \ -VALIDATOR_ADDRESS=another_validator_address \ -NODE_PORT=8081 \ -P2P_TCP_PORT=40401 \ -P2P_UDP_PORT=40501 \ -~/deploy.sh -``` - -Ensure that each validator instance uses unique ports to avoid conflicts. - -## Setting Up on Other Operating Systems - -### macOS - -**Installing Docker Desktop**: - -- Download and install [Docker Desktop for Mac](https://www.docker.com/products/docker-desktop). - -**Installing Homebrew** (if not already installed): - -```bash -/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" -``` - -** (Optional) Installing Kind and Helm**: - -```bash -brew install kind -brew install helm -``` - -** (Optional) Setting Up Kubernetes**: - -- Docker Desktop includes Kubernetes; enable it in the Docker settings. - -### Windows - -**Installing Docker Desktop**: - -- Download and install [Docker Desktop for Windows](https://www.docker.com/products/docker-desktop). - -**Enabling WSL 2 Backend**: - -- Follow the instructions to enable the Windows Subsystem for Linux (WSL 2). - -**Installing Chocolatey** (Windows Package Manager): - -- Run the following in PowerShell as Administrator: - - ```powershell - Set-ExecutionPolicy Bypass -Scope Process -Force; ` - [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; ` - iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) - ``` - -** (Optional) Installing Kind and Helm**: - -```powershell -choco install kind -choco install kubernetes-helm -``` - -## Configuring Deployment - -Before deploying your validator node, ensure you have a funded Ethereum address on the network you are joining. For test networks, you may need to use a faucet or contact network maintainers for test ETH. - -### Preparing Your Validator Credentials - -- **Validator Private Key**: The private key corresponding to your validator's Ethereum address. -- **Validator Address**: Your validator's Ethereum address. - -### Setting Up Environment Variables - -Export the necessary environment variables: - -```bash -export AZTEC_IMAGE=your_aztec_image -export ETHEREUM_HOST=your_ethereum_host -export BOOT_NODE_URL=your_boot_node_url -export PUBLIC_IP=your_public_ip -``` - -Ensure these variables are set in your shell session before deploying the validator. - -### Deploying the Validator Node - -Follow the steps outlined in the [Deploying the Validator Node](#deploying-the-validator-node) section under **Setting Up on Ubuntu 24** to launch your validator instance. - -For multiple validators, ensure that each instance uses unique ports and directories. - -### Deploying the Cluster (Advanced) - -If you are deploying a cluster of validator nodes using Kubernetes, you can use the provided deployment script: - -```bash -./deploy-oitavos-spartan.sh aztecprotocol/aztec:your_stable_image -``` - -This script will add external load balancing services to the `oitavos` namespace. - -After running the script: - -1. Update the values in `oitavos-spartan.yaml` with the new service addresses. -2. Cancel the deployment and rerun it to apply the updated values. -3. In the `oitavos` namespace, restart the prover node pod to apply the new configuration. - -**Note**: In future releases, the pods may be able to dynamically grab the addresses without manual intervention. -**Note**: Name subject to change. - -## Troubleshooting - -- Check logs for error messages. -- Verify network connectivity, e.g., running isolated commands to ensure that your UDP ports are open. -- Open issues on [GitHub](https://github.com/AztecProtocol/aztec-packages/issues) for suspected bugs or gaps in documentation. - -## Background Knowledge - -This is a brief summary to understand what the validator is doing at a high level. For the current state of design, please see the [RFC](https://forum.aztec.network/t/request-for-comments-aztecs-block-production-system/6155). - -Validators are selected through a committee selection process: - -- **Epoch Initialization**: - - - At the start of each epoch, the rollup contract computes a random seed using `block.prevrandao`. - - The seed is used to select a committee of validators using the Swap-or-Not algorithm. - - The committee size is fixed for the duration of the epoch. - -- **Proposer Selection**: - - - Each validator in the committee is assigned proposer duties for specific slots within the epoch. - - Proposers know in advance when they will be required to propose a block. - -- **Validator Registration**: - - - The rollup contract maintains the active set of validators. - - Updates to the validator set occur at the beginning of new epochs. - - Registration includes staking a minimum threshold of collateral (amount to be determined). - -- **Interaction with the Contract**: - - Validators interact with the rollup contract to fulfill their duties. - - Proposers submit block proposals and proofs to the contract. diff --git a/docs/docs/guides/index.md b/docs/docs/guides/index.md deleted file mode 100644 index 05eb85fea9ba..000000000000 --- a/docs/docs/guides/index.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -id: index -sidebar_position: 0 -title: Guides and Tutorials ---- - -# Guides and Tutorials - -In this section you will find: - -- A list of tutorials in order of increasing complexity, allowing you to write contracts and build applications on Aztec -- How-to guides for accomplishing quick, specific goals - -## Getting Started - -
- - -

Getting Started

-
- - Get started on Aztec by installing the sandbox and playing with it - -
-
- -## Building applications - -
- - -

Contract Tutorials

-
- - Go from zero to hero by following these tutorials in order, starting with a counter contract - -
- - - -

Full stack app on Aztec

-
- - Learn how everything works together by building an app in JavaScript that connects to a contract - -
-
diff --git a/docs/docs/index.mdx b/docs/docs/index.mdx index c4a07c696521..79431c7fa54f 100644 --- a/docs/docs/index.mdx +++ b/docs/docs/index.mdx @@ -22,12 +22,12 @@ On Ethereum today, everything is publicly visible, by everyone. In the real worl To make this possible, Aztec is *not EVM compatible* and is extending the Ethereum ecosystem by creating a new alt-VM! -To learn more about how Aztec achieves these things, check out the [Aztec concepts overview](/aztec/concepts_overview). +To learn more about how Aztec achieves these things, check out the [Aztec concepts overview](/aztec). ## Start coding
- +

Developer Getting Started Guide

@@ -40,7 +40,7 @@ To learn more about how Aztec achieves these things, check out the [Aztec concep ## Learn how Aztec works
- +

Aztec Overview

diff --git a/docs/docs/protocol-specs/calls/public-private-messaging.md b/docs/docs/protocol-specs/calls/public-private-messaging.md index a1121fbad46e..3dc4ab83e5ea 100644 --- a/docs/docs/protocol-specs/calls/public-private-messaging.md +++ b/docs/docs/protocol-specs/calls/public-private-messaging.md @@ -19,10 +19,7 @@ Since private functions execute first, they cannot 'wait' on the results of thei By way of example, suppose a function makes a call to a public function, and then to a private function. The public function will not be executed immediately, but will instead be enqueued for the sequencer to execute later. -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid graph LR A[Private Function 1] --> |1st call| B(Public Function 1) A --> |2nd call| C[Private Function 2] @@ -30,15 +27,11 @@ graph LR A --> |3rd call| D(Public Function 2) A --> |4th call| E[Private Function 3] E --> |return values| A - ``` The order of execution will actually be: -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid graph LR A[Private Function 1] --> C[Private Function 2] C --> |return values| A @@ -46,18 +39,13 @@ graph LR E --> |return values| A A -----> |Enqueued| B(Public Function 1) A -----> |Enqueued| D(Public Function 2) - ``` And the order of proving will actually be: -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid flowchart LR A[Private Function 1] --> C[Private Function 2] --> E[Private Function 3] ----> B(Public Function 1) --> D(Public Function 2) - ``` ## Private to Public Messaging diff --git a/docs/docs/protocol-specs/circuits/high-level-topology.md b/docs/docs/protocol-specs/circuits/high-level-topology.md index caca2bee49b9..43f00cb05ea1 100644 --- a/docs/docs/protocol-specs/circuits/high-level-topology.md +++ b/docs/docs/protocol-specs/circuits/high-level-topology.md @@ -15,10 +15,7 @@ A note for Aztec protocol developers: In this protocol spec, the order in which -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid flowchart LR f0([f0]) --> f1([f1]) f0 --> f2([f2]) @@ -30,15 +27,11 @@ flowchart LR f3 --> f4([f4]) f3 -.-> F4 f3 --> f5([f5]) - ``` This transaction contains 6 private functions (f0 to f5) and 5 public functions (F0 to F4), with `f0` being the entrypoint. The entire transaction is processed as follows: -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid flowchart TB subgraph Transaction A subgraph Private Functions @@ -133,7 +126,6 @@ flowchart TB MR1 --> MR2 MR2 --> ROOT MR3 --> ROOT - ``` A few things to note: diff --git a/docs/docs/protocol-specs/circuits/private-kernel-initial.mdx b/docs/docs/protocol-specs/circuits/private-kernel-initial.mdx index 2258bd682515..4d414ea9909e 100644 --- a/docs/docs/protocol-specs/circuits/private-kernel-initial.mdx +++ b/docs/docs/protocol-specs/circuits/private-kernel-initial.mdx @@ -296,10 +296,7 @@ Key:
-```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid classDiagram direction LR class ParentClass { @@ -323,7 +320,6 @@ class D { ParentClass *-- ChildClass: Composition. A .. B: Perform a consistency check on values in these classes. C ..> D: Copy the data from the inputs A to the outputs B\n(possibly with some modification along the way). - ```
@@ -339,10 +335,7 @@ The diagram:
-```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid classDiagram direction TB @@ -701,7 +694,7 @@ class PublicInputs { } ConstantData --* PublicInputs : constant_data TransientAccumulatedData --* PublicInputs: transient_accumulated_data - + ```
diff --git a/docs/docs/protocol-specs/circuits/private-kernel-inner.mdx b/docs/docs/protocol-specs/circuits/private-kernel-inner.mdx index 10546522b34b..78d97022a67e 100644 --- a/docs/docs/protocol-specs/circuits/private-kernel-inner.mdx +++ b/docs/docs/protocol-specs/circuits/private-kernel-inner.mdx @@ -130,10 +130,7 @@ NOTE TO ANYONE EDITING THIS DIAGRAM: To save repeating yourself, you only need to edit the END of this diagram (demarcated clearly, further down the page - you'll see it). COPY-PASTE the beginning of this diagram (up to the demarcation) from ../private-kernel-initial. --> -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid classDiagram direction TB @@ -552,6 +549,7 @@ PrivateKernelPublicInputs ..> KERNEL_PROOF_VERIFICATION KernelVerificationKey ..> KERNEL_VK_EXISTENCE_CHECK KernelVKMembershipWitness ..> KERNEL_VK_EXISTENCE_CHECK + ```
diff --git a/docs/docs/protocol-specs/cryptography/hashing/hashing.md b/docs/docs/protocol-specs/cryptography/hashing/hashing.md index 6f83f0b8f98e..bb093888eb67 100644 --- a/docs/docs/protocol-specs/cryptography/hashing/hashing.md +++ b/docs/docs/protocol-specs/cryptography/hashing/hashing.md @@ -14,7 +14,7 @@ To minimize the potential for collisions between distinct hashing contexts, all In the case of using Poseidon2 for hashing (which is the case for most hashing in the Aztec protocol), the string is converted from a big-endian byte representation into a `Field` element, and passed as a first argument into the hash. In the case of using non-algebraic hash functions (such as sha256), the string is converted from a big-endian byte representation into bits, and passed as the first bits into the hash. These details are conveyed more clearly as pseudocode in the relevant sections of the spec. -For some hashes there is further domain-separation. For example, [Merkle tree hashing](../../../aztec/concepts/storage/trees/index.md#layers) of the tree. +For some hashes there is further domain-separation. For example, [Merkle tree hashing](../merkle-trees.md#hashing) of the tree. ### Pseudo-randomness diff --git a/docs/docs/protocol-specs/decentralization/block-production.md b/docs/docs/protocol-specs/decentralization/block-production.md index 0306f1fd119d..a344e68efff9 100644 --- a/docs/docs/protocol-specs/decentralization/block-production.md +++ b/docs/docs/protocol-specs/decentralization/block-production.md @@ -1,4 +1,8 @@ -# Aztec Block Production +--- +title: Block Production +draft: true +--- + :::info This document aims to be the latest source of truth for the Fernet sequencer selection protocol, and reflect the decision to implement the [Sidecar](https://forum.aztec.network/t/proposal-prover-coordination-sidecar/2428) proving coordination protocol. Notably, this is written within the context of the first instance or deployment of Aztec. The definitions and protocol may evolve over time with each version. @@ -88,12 +92,7 @@ What is Aztec's economic security needs? Please clarify. Currently, Provers don't need to register but must commit a bond during the `prover commitment phase` articulated below. This ensures economic guarantees for timely proof generation, and therefore short-term liveness. If the prover is unable or unwilling to produce a proof for which they committed to in the allotted time their bond will be slashed. -Future updates may introduce a registration process for Provers, possibly leading to a smaller, more consistent group, but this is currently not suggested to be required. - -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid sequenceDiagram participant Anyone @@ -101,9 +100,8 @@ participant Contract as Aztec L1 Contract participant Network as Aztec Network Anyone ->> Contract: register as a sequencer -Anyone --> Anyone: Wait 7 days +Anyone --> Anyone: Wait epoch Anyone ->> Network: eligible as a sequencer - ``` ## Block production @@ -130,10 +128,7 @@ Every staked sequencers participate in the following phases, comprising an Aztec - For data layers that is not on the host, the host must have learned of the publication from the **Reveal** before the **Finalization** can begin. 6. **Backup:** Should no prover commitment be put down, or should the block not get finalized, then an additional phase is opened where anyone can submit a block with its proof, in a based-rollup mode. In the backup phase, the first rollup verified will become canonical. -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid sequenceDiagram participant Contract as Aztec L1 Contract @@ -156,7 +151,6 @@ loop Happy Path Block Production Contract --> Contract: validates proofs and state transition Note right of Contract: "block confirmed!" end - ``` ### Constraining Randao @@ -185,10 +179,7 @@ When a sequencer move to `exiting`, they might have to await for an additional d **Lasse Comment**: I'm unsure what you mean by "active" here. Is active that you are able to produce blocks? Is so, active seems fine. Also, not clear to me if `exiting` means that they be unable to propose blocks? If they are voting in them, sure put a delay in there, but otherwise I don't see why they should be unable to leave (when we don't have consensus for block production). ::: -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid sequenceDiagram participant Anyone as Sequencer @@ -199,8 +190,6 @@ Anyone ->> Contract: exit() from being a sequencer Note left of Contract: Sequencer no longer eligible for Fernet elections Anyone --> Anyone: Wait 7-21 days Anyone ->> Network: exit successful, stake unlocked - - ``` ## Confirmation rules @@ -220,10 +209,7 @@ Below, we outline the stages of confirmation. 6. In a proven block that has been verified / validated by the L1 rollup contracts 7. In a proven block that has been finalized on the L1 -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid sequenceDiagram participant Anyone as User @@ -243,15 +229,11 @@ Contract --> Contract: waits N more blocks Contract --> Contract: finalizes block Network --> Contract: updates state to reflect finality Anyone ->> Network: confirms on their own node or block explorer - ``` -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid journey title Wallet use case, basic transfer (tx confirmation happy path) section User Device @@ -264,7 +246,6 @@ journey section L1 Tx in block verified on L1: 6: Sequencer Tx in block finalized on L1: 7: Sequencer - ``` ## Economics @@ -306,10 +287,7 @@ Initially it's expected that the negotiations and commitment could be facilitate I'm not fully understanding the different groups, is the aztec network just the node software or 👀? Maybe coloring is nice to mark what is contracts and entities or groups of entities. Otherwise seems quite nice. ::: -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid sequenceDiagram participant Anyone @@ -319,7 +297,7 @@ participant Sequencers participant Provers Anyone ->> Contract: register() -Anyone --> Anyone: Wait 7 days +Anyone --> Anyone: Wait epoch Anyone ->> Network: eligible as a sequencer loop Happy Path Block Production Sequencers --> Sequencers: Generate random hashes and rank them @@ -337,18 +315,14 @@ loop Happy Path Block Production Note right of Contract: "block confirmed!" end Sequencers ->> Contract: exit() -Sequencers --> Sequencers: wait 7 days - +Sequencers --> Sequencers: wait epoch ``` ### Voting on upgrades In the initial implementation of Aztec, sequencers may vote on upgrades alongside block proposals. If they wish to vote alongside an upgrade, they signal by updating their client software or an environment configuration variable. If they wish to vote no or abstain, they do nothing. Because the "election" is randomized, the voting acts as a random sampling throughout the current sequencer set. This implies that the specific duration of the vote must be sufficiently long and RANDAO sufficiently randomized to ensure that the sampling is reasonably distributed. -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid sequenceDiagram participant Contract as Aztec L1 Contract @@ -371,17 +345,13 @@ loop Happy Path Block Production Contract --> Contract: validates proofs and state transition Note right of Contract: "block confirmed! votes counted for upgrade!" end - ``` ### Backup mode In the event that no one submits a valid block proposal, we introduce a "backup" mode which enables a first come first serve race to submit the first proof to the L1 smart contracts. -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid sequenceDiagram participant Anyone @@ -398,7 +368,6 @@ loop Happy Path Block Production Contract --> Contract: validates proofs and state transition Note right of Contract: "block confirmed!" end - ``` :::danger @@ -407,10 +376,7 @@ There is an outstanding concern that this may result in L1 censorship. L1 builde We also introduce a similar backup mode in the event that there is a valid proposal, but no valid prover commitment (deposit) by the end of the prover commitment phase. -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid sequenceDiagram participant Anyone @@ -431,7 +397,6 @@ loop Happy Path Block Production Contract --> Contract: validates proofs and state transition Note right of Contract: "block confirmed!" end - ``` ## Glossary diff --git a/docs/docs/protocol-specs/decentralization/governance.md b/docs/docs/protocol-specs/decentralization/governance.md index c4484f26e814..ee7208b76f93 100644 --- a/docs/docs/protocol-specs/decentralization/governance.md +++ b/docs/docs/protocol-specs/decentralization/governance.md @@ -128,10 +128,7 @@ Importantly we differentiate between `Aztec Governance`, and the governance of a ### Happy path -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid sequenceDiagram participant Current Canonical Rollup as Current Rollup @@ -155,17 +152,13 @@ Version Registry ->> Version Registry: markPendingCanonical(nextRollup) Note right of Version Registry: Wait at least 30 days! Next Rollup ->> Version Registry: markCanonical(nextRollup) Sequencers ->> Next Rollup: Proposing new blocks here! - ``` ### "Bricked" rollup proposals In this diagram, we articulate the scenario in which the current canonical rollup contains bugs that result in it being unable to produce not only a block, but a vote of any kind. In this scenario, someone or a group (Lasse refers to as the "unbrick DAO") may lock 1% (specific # TBD) of total supply in order to propose a new canonical rollup. It is expected that this scenario is very unlikely, however, we believe it to be a nice set of checks and balances between the token holders and the decisions of the current rollup implementation. -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid sequenceDiagram participant Current Canonical Rollup as Current Rollup @@ -185,7 +178,6 @@ Note right of Version Registry: Wait at least 30 days! Note left of Sequencers: Upgrade to new client Next Rollup ->> Version Registry: markCanonical(nextRollup) Sequencers ->> Next Rollup: Proposing new blocks here! - ``` ### Vote Delegation @@ -198,10 +190,7 @@ Any token holder can delegate their token's voting weight to another address, in The diagram below articulates calling delegateTo(address) on both the governance contract and specifying a particular address. Additionally calling delegateTo() on the current canonical rollup if you wish to align with whatever voting mechanism that system currently as in place. -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid sequenceDiagram participant Current Canonical Rollup as Current Rollup @@ -229,7 +218,6 @@ Version Registry ->> Version Registry: markPendingCanonical(nextRollup) Note right of Version Registry: Wait at least 30 days! Next Rollup ->> Version Registry: markCanonical(nextRollup) Sequencers ->> Next Rollup: Proposing new blocks here! - ``` ## Emergency mode diff --git a/docs/docs/protocol-specs/gas-and-fees/kernel-tracking.md b/docs/docs/protocol-specs/gas-and-fees/kernel-tracking.md index 47ad4edb8f9c..738c4ba5ffe8 100644 --- a/docs/docs/protocol-specs/gas-and-fees/kernel-tracking.md +++ b/docs/docs/protocol-specs/gas-and-fees/kernel-tracking.md @@ -16,10 +16,7 @@ On the private side, the ordering of the circuits is: The structs are (irrelevant fields omitted): -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid classDiagram class PrivateContextInputs { @@ -147,7 +144,7 @@ class PrivateKernelTailToPublicCircuitPrivateInputs { +PrivateKernelData previous_kernel } PrivateKernelTailToPublicCircuitPrivateInputs --> PrivateKernelData - + ``` ## Private Context Initialization @@ -275,10 +272,7 @@ On the public side, the order of the circuits is: The structs are (irrelevant fields omitted): -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid classDiagram class Gas { @@ -411,7 +405,7 @@ class GasFees { +Fr fee_per_da_gas +Fr fee_per_l2_gas } - + ``` ## Public Context Initialization diff --git a/docs/docs/protocol-specs/gas-and-fees/specifying-gas-fee-info.md b/docs/docs/protocol-specs/gas-and-fees/specifying-gas-fee-info.md index cede01d0c097..274afac824fd 100644 --- a/docs/docs/protocol-specs/gas-and-fees/specifying-gas-fee-info.md +++ b/docs/docs/protocol-specs/gas-and-fees/specifying-gas-fee-info.md @@ -8,10 +8,7 @@ When users submit a `TxExecutionRequest` on the Aztec Network, they provide a `T An abridged version of the class diagram is shown below: -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid classDiagram class TxExecutionRequest { +TxContext txContext @@ -41,7 +38,6 @@ class GasFees { TxContext --> GasSettings GasSettings --> Gas GasSettings --> GasFees - ``` :::note @@ -77,10 +73,7 @@ Separately, the **protocol** specifies the current `feePerGas` for each dimensio These are held in the L2 blocks `Header` -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid classDiagram class Header { +GlobalVariables globalVariables @@ -100,7 +93,6 @@ class GasFees { Header --> GlobalVariables GlobalVariables --> GasFees - ``` A transaction cannot be executed if the `maxFeesPerGas` is less than the `feePerGas` for any dimension. diff --git a/docs/docs/protocol-specs/intro.md b/docs/docs/protocol-specs/intro.md index f9842bd3ead5..58966b25c73b 100644 --- a/docs/docs/protocol-specs/intro.md +++ b/docs/docs/protocol-specs/intro.md @@ -26,10 +26,7 @@ To increase the probability of diagrams being up-to-date we encourage you to wri You simply create a codeblock specifying the language as `mermaid` and write your diagram in the codeblock. For example: ````txt -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid graph LR A --> B B --> C @@ -37,10 +34,7 @@ graph LR ``` ```` -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid graph LR A --> B B --> C @@ -52,10 +46,7 @@ Mermaid supports multiple types of diagrams, so finding one that suits your need When writing class diagrams, we recommend using the `classDiagram` type and composition arrows `*--` to represent extensions. Also for the sake of readability, add all the components in the class itself, including composite types. For example: ````txt -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid classDiagram class A{ foo: Bar @@ -74,10 +65,7 @@ classDiagram ``` ```` -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid classDiagram class A{ foo: Bar diff --git a/docs/docs/protocol-specs/l1-smart-contracts/index.md b/docs/docs/protocol-specs/l1-smart-contracts/index.md index db1326fede21..845c77e36aaa 100644 --- a/docs/docs/protocol-specs/l1-smart-contracts/index.md +++ b/docs/docs/protocol-specs/l1-smart-contracts/index.md @@ -63,10 +63,7 @@ For more information around the requirements we have for the availability, see [ Using the data structures defined throughout the [rollup circuits](./../rollup-circuits/index.md) section, we can outline the validating light node structure as follows: -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid classDiagram class Inbox { @@ -88,7 +85,6 @@ class StateTransitioner { StateTransitioner --> Inbox: consume() StateTransitioner --> Outbox: insert() StateTransitioner --> Verifier: verify() - ``` ### State transitioner @@ -481,10 +477,7 @@ Below, we will outline the **LOGICAL** execution of a L2 block and how the contr We will be executing cross-chain communication before and after the block itself. Note that the L2 inbox only exists conceptually and its functionality is handled by the kernel and the rollup circuits. -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid sequenceDiagram autonumber title Logical Interactions of Crosschain Messages @@ -547,7 +540,6 @@ sequenceDiagram P->>O: Consume a msg O->>O: Validate msg O->>O: Update state (nullify) - ``` We will walk briefly through the steps of the diagram above. diff --git a/docs/docs/protocol-specs/rollup-circuits/base-rollup.md b/docs/docs/protocol-specs/rollup-circuits/base-rollup.md index 32df2e70bf42..a4859a4b4f46 100644 --- a/docs/docs/protocol-specs/rollup-circuits/base-rollup.md +++ b/docs/docs/protocol-specs/rollup-circuits/base-rollup.md @@ -6,23 +6,16 @@ The base rollup circuit is the most complex of the rollup circuits, as it has to Take `BaseRollupInputs` as an input value, and transform it to `BaseOrMergeRollupPublicInputs` as an output value while making sure that the validity conditions are met. -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid graph LR A[BaseRollupInputs] --> C[BaseRollupCircuit] --> B[BaseOrMergeRollupPublicInputs] - ``` ## Overview Below is a subset of the figure from [earlier](./index.md) (granted, not much is removed). The figure shows the data structures related to the Base Rollup circuit. -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid classDiagram direction TB @@ -233,7 +226,6 @@ class BaseOrMergeRollupPublicInputs { BaseOrMergeRollupPublicInputs *-- ConstantRollupData : constants BaseOrMergeRollupPublicInputs *-- PartialStateReference : start BaseOrMergeRollupPublicInputs *-- PartialStateReference : end - ``` :::warning TODO diff --git a/docs/docs/protocol-specs/rollup-circuits/index.md b/docs/docs/protocol-specs/rollup-circuits/index.md index 1c7ca403926a..d85df805dd27 100644 --- a/docs/docs/protocol-specs/rollup-circuits/index.md +++ b/docs/docs/protocol-specs/rollup-circuits/index.md @@ -33,10 +33,7 @@ And for the message parity we have: In the diagram the size of the tree is limited for demonstration purposes, but a larger tree would have more layers of merge rollups proofs. Exactly how many layers and what combination of `base` and/or `merge` circuits are consumed is based on filling a [wonky tree](../state/tree-implementations.md#wonky-merkle-trees) with N transactions. Circles mark the different types of proofs, while squares mark the different circuit types. -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid graph BT R_p((Root)) R_c[Root] @@ -139,7 +136,6 @@ graph BT style I1 fill:#1976D2; style I2 fill:#1976D2; style I3 fill:#1976D2; - ``` To understand what the circuits are doing and what checks they need to apply it is useful to understand what data is going into the circuits and what data is coming out. @@ -153,10 +149,7 @@ Note that the diagram does not include much of the operations for kernels, but m -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid classDiagram direction TB @@ -433,10 +426,7 @@ If this is not the case, the kernel proof might be valid, but the state changes It is therefore of the highest importance that the circuits ensure that the state is progressed correctly across circuit types and proofs. Logically, taking a few of the kernels from the above should be executed/proven as shown below, $k_n$ applied on top of the state that applied $k_{n-1}$ -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid graph LR SM[State Machine] S0((State n-1)) @@ -478,10 +468,7 @@ We can do so by building merkle trees of partial "commitments", whose roots are Below, we outline the `TxsHash` merkle tree that is based on the `TxEffect`s and a `OutHash` which is based on the `l2_to_l1_msgs` (cross-chain messages) for each transaction, with four transactions in this rollup. While the `TxsHash` implicitly includes the `OutHash` we need it separately such that it can be passed to the `Outbox` for consumption by the portals with minimal work. -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid graph BT R[TxsHash] M0[Hash 0-1] @@ -515,10 +502,7 @@ graph BT K7 --> B3 ``` -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid graph BT R[OutHash] M0[Hash 0-1] @@ -568,10 +552,7 @@ graph BT K15 --> K7 ``` -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid graph BT R[InHash] M0[Hash 0-1] diff --git a/docs/docs/protocol-specs/rollup-circuits/merge-rollup.md b/docs/docs/protocol-specs/rollup-circuits/merge-rollup.md index b63ac550b3da..5d8ce56943f7 100644 --- a/docs/docs/protocol-specs/rollup-circuits/merge-rollup.md +++ b/docs/docs/protocol-specs/rollup-circuits/merge-rollup.md @@ -4,23 +4,16 @@ title: Merge Rollup The Merge rollup circuit is our in-between circuit, it doesn't need to perform any state updates, but mainly check the consistency of its inputs. -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid graph LR A[MergeRollupInputs] --> C[MergeRollupCircuit] --> B[BaseOrMergeRollupPublicInputs] - ``` ## Overview Below is a subset of the data structures figure from earlier for easy reference. -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid classDiagram direction TB @@ -75,7 +68,6 @@ class MergeRollupInputs { } MergeRollupInputs *-- ChildRollupData: left MergeRollupInputs *-- ChildRollupData: right - ``` ### Validity Conditions diff --git a/docs/docs/protocol-specs/rollup-circuits/root-rollup.md b/docs/docs/protocol-specs/rollup-circuits/root-rollup.md index f4185de2b892..0e09c4663ff9 100644 --- a/docs/docs/protocol-specs/rollup-circuits/root-rollup.md +++ b/docs/docs/protocol-specs/rollup-circuits/root-rollup.md @@ -4,13 +4,9 @@ title: Root Rollup The root rollup circuit is our top circuit, it applies the state changes passed through its children and the cross-chain messages. Essentially, it is the last step that allows us to prove that the state transition function $\mathcal{T}(S, B) \mapsto S'$ was applied correctly for a state $S$ and a block $B$. Note, that the root rollup circuit's public inputs do not comprise the block entirely as it would be too costly to verify. Given a `ProvenBlock` and proof a node can derive the public inputs and validate the correctness of the state progression. -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid graph LR A[RootRollupInputs] --> C[RootRollupCircuit] --> B[RootRollupPublicInputs] --> D[ProvenBlock] --> E[Node] - ``` For rollup purposes, the node we want to convince of the correctness is the [validating light node](../l1-smart-contracts/index.md) that we put on L1. We will cover it in more detail in the [cross-chain communication](../l1-smart-contracts/index.md) section. @@ -21,10 +17,7 @@ This might practically happen through a series of "squisher" circuits that will ## Overview -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid classDiagram direction TB @@ -170,7 +163,6 @@ class RootRollupPublicInputs { header: Header } RootRollupPublicInputs *--Header : header - ``` ### Validity Conditions diff --git a/docs/docs/protocol-specs/rollup-circuits/tree-parity.md b/docs/docs/protocol-specs/rollup-circuits/tree-parity.md index 6760e9877576..77ec759a851f 100644 --- a/docs/docs/protocol-specs/rollup-circuits/tree-parity.md +++ b/docs/docs/protocol-specs/rollup-circuits/tree-parity.md @@ -14,10 +14,7 @@ As earlier we are using a tree-like structure. Instead of having a `base`, `merge` and `root` circuits, we will have only `base` and `root` parity circuits. We only need these two, since what would have been the `merge` is doing the same as the `root` for this case. -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid graph BT R((RootParity)) @@ -64,7 +61,6 @@ style I0 fill:#1976D2; style I1 fill:#1976D2; style I2 fill:#1976D2; style I3 fill:#1976D2; - ``` The output of the "combined" circuit will be the `converted_root` which is the root of the snark-friendly message tree. @@ -72,10 +68,7 @@ And the `sha_root` which must match the root of the sha256 message tree from the The circuit computes the two trees using the same inputs, and then we ensure that the elements of the trees match the inbox later in the [state transitioner](./../l1-smart-contracts/index.md#overview). It proves parity of the leaves in the two trees. -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid classDiagram direction LR @@ -100,7 +93,6 @@ RootParityInput *-- ParityPublicInputs: public_inputs class BaseParityInputs { msgs: List~Fr[2]~ } - ``` The logic of the circuits is quite simple - build both a SHA256 and a snark-friendly tree from the same inputs. diff --git a/docs/docs/protocol-specs/state/archive.md b/docs/docs/protocol-specs/state/archive.md index fd58b8206705..459cea3b924e 100644 --- a/docs/docs/protocol-specs/state/archive.md +++ b/docs/docs/protocol-specs/state/archive.md @@ -43,10 +43,7 @@ Therefore, we can probably remove the `contract_tree` and `ContractData` referen -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid classDiagram direction TB @@ -125,5 +122,4 @@ class ArchiveTree { leaves: List~Header~ } ArchiveTree *.. "m" Header : leaves - ``` diff --git a/docs/docs/protocol-specs/state/index.md b/docs/docs/protocol-specs/state/index.md index ac11c1fd9980..4dd342cfb806 100644 --- a/docs/docs/protocol-specs/state/index.md +++ b/docs/docs/protocol-specs/state/index.md @@ -83,10 +83,7 @@ To recall, the global state in Aztec is represented by a set of Merkle trees: th -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid classDiagram direction TB @@ -211,7 +208,6 @@ State *-- ArchiveTree : archive_tree State *-- NoteHashTree : note_hash_tree State *-- NullifierTree : nullifier_tree State *-- PublicDataTree : public_data_tree - ``` import DocCardList from '@theme/DocCardList'; diff --git a/docs/docs/protocol-specs/state/tree-implementations.md b/docs/docs/protocol-specs/state/tree-implementations.md index b40a5557d65a..dfeded6c8242 100644 --- a/docs/docs/protocol-specs/state/tree-implementations.md +++ b/docs/docs/protocol-specs/state/tree-implementations.md @@ -20,7 +20,7 @@ Indexed Merkle trees, introduced [here](https://eprint.iacr.org/2021/1263.pdf), With an Indexed Merkle tree, proving non-membership of a value `x` then requires a membership proof of the node with value lower than `x` and a next-highest value greater than `x`. The cost of this proof is proportional to the height of the tree, which can be set according to the expected number of elements to be stored in the tree. For comparison, a non-membership proof in a sparse tree requires a tree with height proportional to the size of the elements, so when working with 256-bit elements, 256 hashes are required for a proof. -Refer to [this page](../../aztec/concepts/storage/trees/indexed_merkle_tree.mdx) for more details on how insertions, updates, and membership proofs are executed on an Indexed Merkle tree. +Refer to [this page](../state/tree-implementations.md#indexed-merkle-trees) for more details on how insertions, updates, and membership proofs are executed on an Indexed Merkle tree. diff --git a/docs/docs/protocol-specs/state/wonky-tree.md b/docs/docs/protocol-specs/state/wonky-tree.md index fb7953f470d8..093e7334e5ee 100644 --- a/docs/docs/protocol-specs/state/wonky-tree.md +++ b/docs/docs/protocol-specs/state/wonky-tree.md @@ -4,10 +4,7 @@ A 'wonky' tree is an append-only unbalanced merkle tree, filled from left to rig For example, using a balanced merkle tree to rollup 5 transactions requires padding of 3 empty transactions: -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid graph BT R_c[Root] @@ -62,10 +59,7 @@ Where each node marked with `*` indicates a circuit proving entirely empty infor Our wonky tree implementation instead gives the below structure for 5 transactions: -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid graph BT R_c[Root] @@ -106,10 +100,7 @@ graph BT Here, each circuit is proving useful transaction information with no wasted compute. We can construct a tree like this one for any number of transactions by greedy filling from left to right. Given the required 5 base circuits: -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid graph B0_c[Base 0] B1_c[Base 1] @@ -120,10 +111,7 @@ graph ...we theh pair these base circuits up to form merges: -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid graph BT M0_c[Merge 0] M1_c[Merge 1] @@ -142,10 +130,7 @@ graph BT Since we have an odd number of transactions, we cannot pair up the final base. Instead, we continue to pair the next layers until we reach a layer with an odd number of members. In this example, that's when we reach merge 2: -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid graph BT M0_c[Merge 0] M1_c[Merge 1] @@ -168,10 +153,7 @@ graph BT Once paired, the base layer has length 4, the next merge layer has 2, and the final merge layer has 1. After reaching a layer with odd length, the orchestrator can now pair base 4: -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid graph BT R_c[Root] @@ -230,10 +212,7 @@ Subtrees: [16, 8, 4, 2, 1] -> An unrolled recursive algorithm is not the easiest thing to read. This diagram represents the 31 transactions rolled up in our wonky structure, where each `Merge ` is a 'subroot' above: -```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - +```mermaid graph BT M2_c[Merge 2] M3_c[Merge D @@ -327,10 +306,7 @@ Here is a step-by-step example to construct the _`block_logs_data`_: 1. A rollup, _R01_, merges two transactions: _tx0_ containing _tx_logs_data_0_, and _tx1_ containing _tx_logs_data_1_: - ```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - + ```mermaid flowchart BT tx0((tx0)) tx1((tx1)) @@ -345,10 +321,7 @@ import { Mermaid } from '@docusaurus/theme-mermaid'; 2. Another rollup, _R23_, merges two transactions: _tx3_ containing _tx_logs_data_3_, and _tx2_ without any logs: - ```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - + ```mermaid flowchart BT tx2((tx2)) tx3((tx3)) @@ -363,10 +336,7 @@ import { Mermaid } from '@docusaurus/theme-mermaid'; 3. A rollup, _RA_, merges the two rollups _R01_ and _R23_: - ```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - + ```mermaid flowchart BT tx0((tx0)) tx1((tx1)) @@ -389,10 +359,7 @@ import { Mermaid } from '@docusaurus/theme-mermaid'; 4. A rollup, _RB_, merges the above rollup _RA_ and another rollup _R45_: - ```mdx -import { Mermaid } from '@docusaurus/theme-mermaid'; - - + ```mermaid flowchart BT tx0((tx0)) tx1((tx1)) diff --git a/docs/docs/reference/index.md b/docs/docs/reference/index.md deleted file mode 100644 index 2b725e63ad98..000000000000 --- a/docs/docs/reference/index.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -title: References -sidebar_position: 0 ---- - -# References - -Welcome to the References section! In this section you will find reference material for developing on Aztec Protocol. - -This page lists popular references. Please see the sidebar for them all. - - -## Popular - -### Smart contracts - -
- - - -

Storage

-
- - A detailed reference for storage types - -
- - - -

Portals

-
- - A detailed reference for working with portals and L1/L2 communication - -
- -
- -### Others - -
- - - -

Common Sandbox Errors

-
- - Help debug your sandbox environment - -
- - - -

CLI reference

-
- - A full list of commands for working with the Aztec CLI - -
-
- - diff --git a/docs/docs/run_node/concepts/_category_.json b/docs/docs/run_node/concepts/_category_.json new file mode 100644 index 000000000000..19d79cf9e982 --- /dev/null +++ b/docs/docs/run_node/concepts/_category_.json @@ -0,0 +1,6 @@ +{ + "position": 1, + "collapsible": true, + "collapsed": true, + "label": "Decentralization Concepts" +} diff --git a/docs/docs/guides/developer_guides/running_nodes/_category_.json b/docs/docs/run_node/concepts/deployments/_category_.json similarity index 51% rename from docs/docs/guides/developer_guides/running_nodes/_category_.json rename to docs/docs/run_node/concepts/deployments/_category_.json index 88c8b42bc8f4..03142f5a9e87 100644 --- a/docs/docs/guides/developer_guides/running_nodes/_category_.json +++ b/docs/docs/run_node/concepts/deployments/_category_.json @@ -1,6 +1,6 @@ { - "position": 5, + "position": 2, "collapsible": true, "collapsed": true, - "label": "Aztec Protocol" + "label": "Deployments" } diff --git a/docs/docs/run_node/concepts/deployments/what_is_deployment.md b/docs/docs/run_node/concepts/deployments/what_is_deployment.md new file mode 100644 index 000000000000..cd691a0036a4 --- /dev/null +++ b/docs/docs/run_node/concepts/deployments/what_is_deployment.md @@ -0,0 +1,244 @@ +--- +sidebar_position: 0 +title: What is a Deployment? +--- + +An Aztec deployment is a set of the following contracts: + +| Smart Contract | Immutability | +|--------------------------------|--------------| +| Hypothetical Asset | Immutable | +| Issuer Contract | Immutable | +| Registry Contract | Immutable | +| Reward Distribution Contract | Mutable | +| Proposals Contract | Mutable | +| Governance Contract | Immutable | +| Rollup Contract | Immutable | + +## Hypothetical Asset Contract + +Hypothetical Asset would live on Ethereum L1. It may have a minter which would be the only actor capable of calling the `mint` function on the Hypothetical Asset contract. + +This is brought up to the community for discussion purposes only to illustrate how proposed governance mechanisms could work with a Hypothetical Asset. + +- **Validators** must stake the Hypothetical Asset within the instance's contract to join that instance's validator set. +- **Holders** must lock Hypothetical Asset with the Governance contract to be able to vote on proposals. +- **Provers** must deposit Hypothetical Asset in the escrow contract in order to bid for the right to create a proof for an epoch. + +## Issuer Contract + +This contract will be the sole minter of Hypothetical Asset. It will itself have an owner, which is the only actor capable of calling the `mint` function on the Hypothetical Asset ERC20 contract. + +The `mint` function will limit the amount of Hypothetical Assets that could be minted in a given time period. The reasoning behind this limit is that it makes supply expansions more predictable since "infinite mints" cannot be made. + +```mermaid +flowchart LR + Issuer -->|Calls mint| HypotheticalAsset +``` + +```solidity +contract Issuer is Ownable { + ERC20 immutable public ASSET; // Hypothetical Asset + uint256 immutable public RATE; + uint256 public timeOfLastMint; + + constructor(ERC20 _asset, uint256 _rate, address _owner) Ownable(_owner) { + ASSET = _asset; + RATE = _rate; + timeOfLastMint = block.timestamp; + } + + function mint(address _to, uint256 _amount) external onlyOwner { + uint256 maxMint = RATE * (block.timestamp - timeOfLastMint); + require(_amount <= maxMint, 'Insufficient mint available'); + + timeOfLastMint = block.timestamp; + ASSET.mint(_to, _amount); + } +} +``` + +## Registry Contract + +The governance of Aztec will be community driven - the Aztec community will be able to decide whether to upgrade or migrate to a new rollup instance. Portals / apps donʼt need to follow along with the Aztec governance and can specify the specific instance (i.e. “versionˮ) of the rollup that they view as canonical. + +Therefore it will be necessary to keep track onchain of what versions of the rollup have existed as well as what version the Aztec governance views as the current canonical rollup. Only the current canonical rollup from the perspective of Aztec governance will be eligible to claim any further Hypothetical Asset rewards. + +```mermaid +flowchart LR + Registry --> RollupContract0["Rollup Contract
Instance 0"] + Registry --> RollupContract1["Rollup Contract
Instance 1"] + Registry --> |Returns latest instance|RollupContractN["Rollup Contract
Instance n"] +``` +In practice, the Registry is an array of rollup instances that can only be inserted into by the Registryʼs owner - the Governance contract. + +```solidity +contract Registry is IRegistry, Ownable { + struct Instance { + address rollup; + uint96 blockNumber; + } + + Instance[] public instances; + + constructor(address _gov) Ownable(_gov) { + instances.push( + Instance({address: address(0), blockNumber: block.number}) + ); + } + + function addInstance(address _rollup) external onlyOwner { + instances.push( + Instance({address: _rollup, blockNumber: block.number}) + ); + } + + function getRollup() external view returns (address) { + return instances[instances.length - 1].rollup; + } + + function getInstancesLength() external view returns (uint256) { + return instances.length; + } +} +``` + +## Reward Distribution Contract + +This contract distributes ERC20 rewards only to the instance the Registry contract says is canonical. This is separated from the Registry and the Issuer so that the distribution logic can be changed without replacing the Registry. + +In practice, the flow is expected to be such that infrequently, the Aztec Governance votes that the Issuer smart contract mints a quantity of Hypothetical Asset and sends them to the Distribution contract. The rollup contract will call the `claim(_to)` on the Distribution contract which checks that the calling Rollup is the current canonical Rollup before releasing a Hypothetical Asset to the rollup. + +The Rollup smart contract implements custom logic for how to split `BLOCK_REWARDS` amongst the proposers/committee/provers who provide real work in the form of electricity and hardware intensive computational resources to the Rollup smart contract. + +```mermaid +flowchart TD + Issuer -->|1. Calls mint| HypotheticalAsset + Issuer -->|2. Transfer Hypothetical Asset| RewardDistribution + RollupContract -->|3. Calls claim| RewardDistribution +``` + +```solidity +contract RewardDistribution is Ownable { + uint256 public constant BLOCK_REWARD = xxx; + + IERC20 public immutable ASSET; + IRegistry public registry; + + // constructor etc + + function claim(address _to) external returns (uint256) { + address canonical = registry.getRollup(); + require(msg.sender == canonical); + ASSET.safeTransfer(_to, BLOCK_REWARD); + return BLOCK_REWARD; + } + + function updateRegistry(IRegistry _registry) external onlyOwner { + // ... + } +} +``` + +Rollup contacts implementations should not revert if the `claim()` call reverts because the rollup is no longer canonical. Otherwise, no one could sequence the rollup anymore. + +The separation of Distribution and Issuer is primarily for code hygiene purposes. + +The protocol inflation rate is defined in the Issuer smart contract as the constant `RATE`. It is not possible to change this inflation rate once the Issuer smart contract has been deployed. Aztec Governance can vote on a proposal to deploy a new Issuer smart contract that contains a new `RATE` + +The Aztec Governance will choose how often to call `mint()` on the Issuer smart contract which will send any Hypothetical Assets to the Distribution smart contract. The Distribution smart contract defines a `BLOCK_REWARD` constant value (again cannot be changed). Every epoch, the Rollup contract can call the Distribution smart contract to claim `BLOCK_REWARD` of Hypothetical Assets from the Distribution contract. + +Both `RATE` and `BLOCK_REWARD` will be set upon deployment of the Aztec Rollup by the Aztec Governance. Both values are immutable and cannot be changed without re-deploying a new smart contract and a successful vote by Aztec Governance to switch to the new smart contracts. + +## Proposals contract + +This is the only smart contract that is able to submit proposals to the Governance contract. + +The Proposals Contract will accept proposals only from sequencers of the current canonical instance, as indicated by the Registry. + +```solidity +contract Proposals is IProposals { + + // ... imports + + IGovernance public immutable GOVERNANCE; + IRegistry public immutable REGISTRY; + uint256 public immutable N; + uint256 public immutable M; + + constructor(IGovernance _governane, IRegistry _registry, uint256 _n, uint256 _m) { + // ... + + require(N > M / 2); + require(N <= M); + } + + function vote(address _proposal) external override(IProposals) returns (bool) { + require(_proposal.code.length > 0); + // ... + + Rollup instance = Rollup(REGISTRY.getRollup()); + address proposer = instance.getCurrentProposer(); + require(msg.sender == proposer); + } + // ... +} +``` +To vote to table a proposal, the current sequencer of the canonical rollup must deploy the contracts being proposed to upgrade / migrate to, to the L1. Then the current sequencer deploys the upgrade logic i.e. `_proposal`, then call `Proposals.vote(_proposal)`. + +The Proposals contract will then count votes specifying that same `_proposal`. For a proposal to be nominated for voting, it must garner at least N votes in a single round, where a round is defined as a M consecutive L2 slots. Round 1 is L2 slots 0 - M - 1, while Round 2 is L2 slots M - 2M - 1 and so on. + +Note that a sequencer’s ability to vote is not affected by the rollupʼs availability since voting happens on the L1. + +```mermaid +flowchart TD + Issuer[Issuer] -->|1. Calls mint| HypotheticalAsset[Hypothetical Asset] + Issuer -->|2. Transfer Hypothetical Asset| RewardDistribution[Reward Distribution] + RewardDistribution -->|3. Calls claim| RollupContract[RollupContract] +``` + +If the quorum has been reahed, anyone can call `pushProposal(uint256 _roundNumber)` on the Proposals contract to send the proposal to the Governance contract for voting. As a result, only one proposal can be nominated for voting at any given round. + +## Governance contract + +This contract is the “assembly of Aztec citizensˮ that is the final arbiter of whether to enact the proposals from the Proposals Contract or not. + +This contract decides what is the canonical instance which gets block rewards. + +The Proposals contract tables proposals for voting, Holders who lock their Hypothetical Assets with the Governance contract may vote once for each Hypothetical Asset locked. They can vote either Yea or Nea. + +Once a proposal garners the minimum number of votes, and the Yay votes exceed Nay by at least the `quorum%` , the proposal can be executed by the Governance contract. + +```solidity +contract Governance is IGovernance { // ... imports + IERC20 public immutable ASSET; address public proposalsContract; // ... + constructor(IERC20 _asset, address _proposalsContract, ui nt256 _votingDelay, uint256 _votingDuration, uint256 _gracePeriod, uint256 _quorum, uin t256 _voteDifferential, uint256 _minimumVotes) { // ... + configuration = DataStructures.Configuration({ votingDelay: Timestamp.wrap(_votingDelay), // Min time between proposal creation and when voting starts votingDuration: Timestamp.wrap(_votingDuration), // Max duration of voting period + executionDelay: Timestamp.wrap(_executionDelay), // Min time between voting passing and proposal execution gracePeriod: Timestamp.wrap(_gracePeriod), // max time between proposal creation and proposal execution. + quorum: _quorum, // % of deposited ASSET that mus t participate in a vote (could be Yes or No) voteDifferential: _voteDifferential, // Yea must outweight Nea by this % to pass vote minimumVotes: _minimumVotes, // users with this much cummulative deposited ASSET must participate in the vote }) + } +// ... +function deposit(address _onBehalfOf, uint256 _amount) external override(IGovernance) { + // deposits are allowed on behalf of other addresses + users[_onBehalfOf].add(_amount); + // ... +} + +function initiateWithdraw(address _to, uint256 _amount) external override(IGovernance) returns (uint256) { + // ... + // No one can withdraw on behalf of someone else + users[msg.sender].sub(_amount); + // ... +} + +function propose(address _payload) external override(IGovernance) returns (bool) { + require(msg.sender == proposalsContract); + // ... +} + +function vote(uint256 _proposalId, uint256 _amount, bool _support) external override(IGovernance) returns (bool) {} + +function execute(uint256 _proposalId) external override(IGovernance) returns (bool) { + // execute proposal via `call()` +} +``` diff --git a/docs/docs/run_node/concepts/governance/_category_.json b/docs/docs/run_node/concepts/governance/_category_.json new file mode 100644 index 000000000000..69efe5a14964 --- /dev/null +++ b/docs/docs/run_node/concepts/governance/_category_.json @@ -0,0 +1,6 @@ +{ + "position": 1, + "collapsible": true, + "collapsed": true, + "label": "Governance" +} diff --git a/docs/docs/run_node/concepts/governance/governance.md b/docs/docs/run_node/concepts/governance/governance.md new file mode 100644 index 000000000000..7669574ddd49 --- /dev/null +++ b/docs/docs/run_node/concepts/governance/governance.md @@ -0,0 +1,17 @@ +--- +id: governance +sidebar_position: 3 +title: Governance Overview +--- + +import Image from "@theme/IdealImage"; + +This diagram outlines how governance works on Aztec: + + + +Sequencers put forward, or “nominate”, proposals for voting by the Aztec citizens. To do this, sequencers interact with the Governance Proposer smart contract. Nominations are “signals” by sequencers that they wish to put up for vote the execution of certain code by the Governance smart contract. + +If the Governance Proposer smart contract records a certain number of nominations/signals from sequencers, then the Governance Proposer smart contract initiates a voting process where any holders of any Hypothetical Assets (as defined below) can participate. Holders of such Hypothetical Assets are called Aztec citizens. + +All voting and signalling happen on the L1. diff --git a/docs/docs/run_node/concepts/governance/putting_forward_proposals.md b/docs/docs/run_node/concepts/governance/putting_forward_proposals.md new file mode 100644 index 000000000000..b110899e4538 --- /dev/null +++ b/docs/docs/run_node/concepts/governance/putting_forward_proposals.md @@ -0,0 +1,17 @@ +--- +sidebar_position: 0 +title: Putting forward Proposals +--- + +Sequencers of the *current* canonical rollup (as indicated by the Registry) can propose changes to the Aztec community for voting. In order for a proposal to be voted on through the governance process, *N* sequencers must nominate the proposal in any given round. A round is defined as a sequence of contiguous M L2 blocks. Both *N* and *M* are governance defined parameters. + +Sequencers can only nominate a proposal during an L1 slot for which they’ve been assigned proposer duties. This minimizes timing games and provides a lower bound on the time required to successfully bring about a vote by governance. + +A mechanism is also proposed whereby any digital asset (“Hypothetical Assetˮ) holder (“Holderˮ) can burn a large quantity of Hypothetical Asset to trigger a vote on a proposal, without having the sequencers nominating the proposal. Note that Hypothetical Asset holders would still need to vote to approve any proposals nominated via this mechanism. + +To nominate a proposal, a validator of the current canonical rollup would deploy two sets of contracts: +1. The upgraded contracts they wish to upgrade to +2. `code` which can be executed by governance to upgrade into these contracts + +Then when it is their turn as the proposer, they call `vote(address _proposal)` on the `Proposals` contract, where `_proposal ` is the address of the `code` payload. + diff --git a/docs/docs/run_node/concepts/governance/upgrades.md b/docs/docs/run_node/concepts/governance/upgrades.md new file mode 100644 index 000000000000..08bd1910cec6 --- /dev/null +++ b/docs/docs/run_node/concepts/governance/upgrades.md @@ -0,0 +1,38 @@ +--- +sidebar_position: 4 +title: Upgrades +--- + +Upgrades involve transitioning the network to a new instance of the Rollup contract. They might fix vulnerabilities, introduce new features, or enhance performance. + +## AZIP + +It is expected that the community will coordinate upgrade proposals via an AZIP process, which is a design document outlining the upgrade rationale and one that allows for collecting technical input from and by the community. + +Once developers of client software agree to support the upgrade, sequencers can begin signaling to table this proposal from a certain block height. + +## Initial Contract Deployment + +The initial deployment creates a set of contracts, as described in the [Deployment section](../deployments/what_is_deployment.md). + +## Upgrading the Rollup Contract + +1. **Proposal Creation:** + - A new Rollup contract is deployed to the network + - Proposal code to execute the upgrade is deployed separately + +2. **Governance Approval:** + - Governance contract holders vote to approve or reject the proposal. Votes are proportional to the amount of Hypothetical Asset locked in the Governance contract. + +3. **Sequencer Participation:** + - Sequencers must signal their readiness by voting through the Proposals contract. + - This vote occurs during their assigned L2 slot, as dictated by the L1 Rollup smart contract. + +## Proposal Execution + +After governance approval and a delay period, the proposal becomes executable: + +- Any Ethereum account can call `execute(_proposalId)` on the Governance contract. +- The `execute` function calls the proposal code, transitioning the network to the new Rollup instance. + +For a more hands-on guide to reacting to upgrades as a sequencer/validators, read [this](../../guides/reacting_to_upgrades.md). \ No newline at end of file diff --git a/docs/docs/run_node/concepts/governance/voting.md b/docs/docs/run_node/concepts/governance/voting.md new file mode 100644 index 000000000000..911e88269457 --- /dev/null +++ b/docs/docs/run_node/concepts/governance/voting.md @@ -0,0 +1,10 @@ +--- +sidebar_position: 1 +title: Voting on Proposals +--- + +Holders have the ability to vote on proposals as long as they lock any Hypothetical Assets within the Governance contract. The act of locking the funds can be thought of as “activatingˮ the voting power of Hypothetical Asset. Locked Hypothetical Assets used to vote on a proposal must wait a delay before being withdrawn to prevent malicious governance attacks. + +Hypothetical Assets locked in the Governance contract are simply locked and not “at stakeˮ i.e. there are no slashing conditions. + +Since sequencers may be able to stake Hypothetical Assets with the rollup instances in order to join the validator set, the rollup instance could in turn lock those Hypothetical Assets in the Governance contract and vote on behalf of the sequencers. This is expected behavior. diff --git a/docs/docs/run_node/concepts/proof_of_stake/_category_.json b/docs/docs/run_node/concepts/proof_of_stake/_category_.json new file mode 100644 index 000000000000..b4fac2f6e6ab --- /dev/null +++ b/docs/docs/run_node/concepts/proof_of_stake/_category_.json @@ -0,0 +1,6 @@ +{ + "position": 3, + "collapsible": true, + "collapsed": true, + "label": "Proof of Stake" +} diff --git a/docs/docs/run_node/concepts/proof_of_stake/index.md b/docs/docs/run_node/concepts/proof_of_stake/index.md new file mode 100644 index 000000000000..1d5498bc3b6d --- /dev/null +++ b/docs/docs/run_node/concepts/proof_of_stake/index.md @@ -0,0 +1,7 @@ +--- +sidebar_position: 1 +title: Proof of Stake system +draft: true +--- + +This doc will be updated soon. \ No newline at end of file diff --git a/docs/docs/run_node/concepts/proof_of_stake/slashing.md b/docs/docs/run_node/concepts/proof_of_stake/slashing.md new file mode 100644 index 000000000000..f54eaf05aaba --- /dev/null +++ b/docs/docs/run_node/concepts/proof_of_stake/slashing.md @@ -0,0 +1,52 @@ +--- +sidebar_position: 2 +title: Slashing +draft: true +--- + +We need to make sure that the chain is always (eventually) finalizing new blocks. +These conditions are required for the chain to finalize new blocks: + +1. More than 2/3 of the committee is making attestations +2. Provers are producing proofs. + +## Avoiding network halt + +There are some actions that impact the chainʼs ability to finalize new blocks: + +### Insufficient quorum + +In the event that a significant portion of the validator set goes offline (i.e. geopolitical emergency) and proposers are unable to get enough attestations on block proposals, the Aztec Rollup will be unable to finalize new blocks. This will require the community to engage to fix the issue and make sure new blocks are being finalized. + +In the event of a prolonged period where the Aztec Rollup is not finalizing new blocks, it may enter Based Fallback mode. The conditions that lead to [Based Fallback (forum link)](https://forum.aztec.network/t/request-for-comments-aztecs-block-production-system/6155) mode are expected to be well defined by the community of sequencers, provers, client teams and all other Aztec Rollup stakeholders and participants. + +During Based Fallback mode, anyone can propose blocks if they supply proofs for these blocks alongside them. This is in contrast to the usual condition that only the sequencer assigned to a particular slot can propose blocks during that slot. This means that the inactive validator set is bypassed and anyone can advance the chain in the event of an inactive / non-participating validator set. + +But terminally inactive validators must be removed from the validator set or otherwise we end up in Based Fallback too often. Slashing is a method whereby the validator set votes to “slash” the stake of inactive validators down to a point where they are kicked off the validator set. For example, if we set `MINIMUM_STAKING_BALANCE=50%` then as soon as 50% or more of a validator’s balance is slashed, they will be kicked out of the set. + +### Committee withholding data from the provers + +Provers need the transaction data (i.e. `TxObjects`) plus the client-side generated proofs to produce the final rollup proof, none of which are posted onchain. Client side proofs + transaction data are gossiped on the p2p instead so that committee members can re-execute block proposals and verify that the proposed state root is correct. + +Recall from the [RFC (forum link)](https://forum.aztec.network/t/request-for-comments-aztecs-block-production-system/6155) on block production that the committee is a subset of validators, randomly sampled from the entire validator set. Block proposers are sampled from this committee. ⅔ + 1 of this committee must attest to L2 block proposals before they are posted to the L1 by the block proposer. + +A malicious committee may not gossip the transaction data or proofs to the rest of the validator set, nor to the provers. As a result, no prover can produce the proof and the epoch in question will reorg by design.Recall from the RFC on block production that if no proof for epoch N is submitted to L1 by the end of epoch N+1, then epoch N + any blocks built in epoch N+1 are reorged. + +### Committee proposing an invalid state root + +Committee members who receive a block proposal from a proposer, must execute the block’s transaction to compare the resulting state root with that contained in the proposal. In theory, a committee member should only attest to a block proposal’s validity after checking for the correctness of the state root. + +A committee member could skip re-executing block proposals, for a number of reasons including saving compute, faulty client software or maliciousness. This opens up the possibility of a malicious proposer posting an invalid state transition to L1. Or a malicious entity that bribes ⅔ + 1 of the committee can obtain the required signatures to post an invalid state transition. +The epoch will not be proven and will be re-orged. + +### L1 congestion has made it impossible for provers to land proofs on time + +An honest prover who has funds at stake (i.e. posted a bond to produce the epoch proof), could be unable to post the proof on L1 due to congestion, an L1 reorg or just an inactivity of the L1 proposers (i.e. inactivity leak). + +## Slashing mechanism + +In all the previous cases, it is very hard to verify and automatically slash for these events onchain. This is mainly due to the fact that neither TxObjects nor client side proofs are posted onchain. Committee members also gossip attestations on the p2p and do not post them directly on chain. + +Therefore a slashing mechanism is required as a deterrence against the malicious behaviour by validators and to make sure that the Aztec Rollup retains liveness. The validator set votes to slash dishonest validators based on evidence that is collected onchain + offchain, and discussed and analyzed offchain (i.e. on a forum). + +A validator must aggregate BLS signatures on slashing proposals and post them to the L1 for slash execution. diff --git a/docs/docs/run_node/concepts/provers-and-sequencers/_category_.json b/docs/docs/run_node/concepts/provers-and-sequencers/_category_.json new file mode 100644 index 000000000000..24bb8c8ac104 --- /dev/null +++ b/docs/docs/run_node/concepts/provers-and-sequencers/_category_.json @@ -0,0 +1,7 @@ +{ + "position": 4, + "collapsible": true, + "collapsed": true, + "label": "Provers and Sequencers" +} + diff --git a/docs/docs/run_node/concepts/provers-and-sequencers/index.md b/docs/docs/run_node/concepts/provers-and-sequencers/index.md new file mode 100644 index 000000000000..262874206b5f --- /dev/null +++ b/docs/docs/run_node/concepts/provers-and-sequencers/index.md @@ -0,0 +1,14 @@ +--- +sidebar_position: 0 +title: Provers and Sequencers +--- + +## Block Production Overview + +Both sequencing and proving in the Aztec Network are intended to be fully decentralized. + +Sequencers will be chosen via a random election, while provers will be selected by sequencers via an out-of-protocol coordination mechanism. + +The proposers in the first `C=13` slots in epoch `N+1` will accept quotes to prove epoch N from provers. The winning prover will have until the end of epoch `N+1` to produce and submit the proof to L1. + +If are you interested in running a validator node (also known as a sequencer node) or a prover node, you can refer to [the guides section](./../../guides/run_nodes/index.md). diff --git a/docs/docs/run_node/concepts/provers-and-sequencers/proving_coordination_workflow.md b/docs/docs/run_node/concepts/provers-and-sequencers/proving_coordination_workflow.md new file mode 100644 index 000000000000..2b7f6ddebc6a --- /dev/null +++ b/docs/docs/run_node/concepts/provers-and-sequencers/proving_coordination_workflow.md @@ -0,0 +1,108 @@ +--- +sidebar_position: 1 +title: Proving Coordination Workflow +draft: true +--- + +Proposers run RFQs to obtain quotes from provers. Quotes are binding promises from provers to prove an entire epoch. The exact channel over which provers send quotes to proposers is **NOT** enshrined by the protocol. + +However, Aztec Nodes will support two optional mechanisms that provers can use to submit quotes to proposers: + +- Gossip quotes via the P2P +- Send a quote directly via HTTP (i.e. http://aztec-node:8000) + +To send a quote via the P2P, do not set the environment variable `PROVER_COORDINATION_NODE_URL` and make sure that `P2P_ENABLED` is set to `true`. + +:::note +For S&P Testnet, please make sure that you are gossiping quotes via the P2P. Set `P2P_ENABLED` to `true` and do not use `PROVER_COORDINATION_NODE_URL`. +::: + + +```rust +struct EpochProofQuote { + Signature signature; + address prover; + uint256 epochNumber; + uint256 epochInitBlock; + uint256 epochFinalBlock; + uint256 totalFees; + address rollupAddress; + uint32 basisPointFee; + uint256 bondAmount; +} +``` + +To accomplish this coordination through the Aztec node software, we extend both the `P2PClient` and `ProverNode`. + +## P2P client + +The `P2PClient` will be extended by: + +```typescript +class P2PClient { + //... + + async addEpochProofQuote(quote: EpochProofQuote): Promise { + // Add quote to quote memory pool + this.epochProofQuotePool.addQuote(quote); + + // Propagate quote via P2P + this.broadcastEpochProofQuote(quote); + } +} +``` + +This is called by the Prover Node inside `ProverNode.sendEpochProofQuote()` after it detects an epoch has ended. + +## Prover Node + +As for the Prover Node, we add `QuoteProvider` and `BondManager` interfaces. Also an `EpochMonitor` which sits on the main start loop of the Prover Node. It fetches the most recent completed epochs and checks whether the proposer accepted an `EpochProofQuote`. + +If no quote has been accepted yet, the `EpochMonitor` will call on `BondManager` and `QuoteProvider` to provide a valid quote. If the claim detected belongs to the prover, the monitor will kick off a `handleCall()` to create proving jobs. + +```typescript +interface BondManager { + ensureBond(amount: number): Promise; +} +interface QuoteProvider { + getQuote(epoch: number): Promise; +} +``` + +When the prover node first starts up, it will call `BondManager.ensureBond` to ensure it has the minimum deposit amount `PROVER_MINIMUM_ESCROW_AMOUNT` deposited in the escrow contract. If it does not, it will top up to the target deposit amount `PROVER_TARGET_ESCROW_AMOUNT`. + +Both `PROVER_MINIMUM_ESCROW_AMOUNT` and `PROVER_TARGET_ESCROW_AMOUNT` are customizable environment variables. + +The `EpochMonitor` will then get the last completed, unproven epoch and will call the `QuoteProvider` to generate a quote if the epoch has not been claimed by any provers yet. The `QuoteProvider` will be provided with all the blocks in the unproven epoch so it could perform any custom logic to determine the quote parameters, i.e., `bondAmount`, `basisPointFee`, etc. + +Alternatively, the quote provider can issue an HTTP POST to a configurable `QUOTE_PROVIDER_URL` to get the quote. The request body is JSON-encoded and contains the following fields: + +- `epochNumber`: The epoch number to prove +- `fromBlock`: The first block number of the epoch to prove +- `endBlock`: The last block number (inclusive) of the epoch to prove +- `txCount`: The total number of txs in the epoch +- `totalFees`: The accumulated total fees across all txs in the epoch + +The response is also expected in JSON and to contain `basisPointFee` and `bondAmount` fields. Optionally, the request can include a `validUntilSlot` parameter, which specifies for how many slots the quote remains valid. For example, an `EpochProofQuote` with parameters `epochProofQuote#80` and `validUntilSlot#5` means that any of the first 5 proposers in epoch 101 can “claim” this quote. + +If no `QUOTE_PROVIDER_URL` is passed along to the Prover Node, then a `SimpleQuoteProvider` is used, which always returns the same `basisPointFee` and `bondAmount` as set in the `QUOTE_PROVIDER_BASIS_POINT_FEE` and `QUOTE_PROVIDER_BOND_AMOUNT` environment variables. + +:::warning +If the `QuoteProvider` does not return a `bondAmount` or a `basisPointFee`, the Prover Node will not generate nor submit a quote to the proposer. +::: + +Separately, the Prover Node needs a watcher on L1 to detect if its quote has been selected. + +To this end, the `L1Publisher` will be extended with a new method to retrieve proof claims. + +```typescript +interface L1Publisher { + getProofClaim(): Promise; +} +``` + +The Prover Node will call this method at least once per L2 slot to check for unclaimed accepted quotes if its quotes have been accepted. You can update the polling interval using the environment variable `PROVER_NODE_POLLING_INTERVAL_MS`. + +## Run a prover + +Go to the [Prover Guide](../../guides/run_nodes/how_to_run_prover.md) to run a prover. \ No newline at end of file diff --git a/docs/docs/run_node/guides/_category_.json b/docs/docs/run_node/guides/_category_.json new file mode 100644 index 000000000000..5dc689496822 --- /dev/null +++ b/docs/docs/run_node/guides/_category_.json @@ -0,0 +1,6 @@ +{ + "position": 2, + "collapsible": true, + "collapsed": true, + "label": "Guides" +} diff --git a/docs/docs/run_node/guides/connecting_to_node.md b/docs/docs/run_node/guides/connecting_to_node.md new file mode 100644 index 000000000000..32ccbcb2bfe4 --- /dev/null +++ b/docs/docs/run_node/guides/connecting_to_node.md @@ -0,0 +1,5 @@ +--- +sidebar_position: 0 +title: Connecting to a node +draft: true +--- \ No newline at end of file diff --git a/docs/docs/run_node/guides/node_reference.md b/docs/docs/run_node/guides/node_reference.md new file mode 100644 index 000000000000..4b45fbd9e474 --- /dev/null +++ b/docs/docs/run_node/guides/node_reference.md @@ -0,0 +1,5 @@ +--- +sidebar_position: 5 +title: Node reference +draft: true +--- \ No newline at end of file diff --git a/docs/docs/run_node/guides/reacting_to_upgrades.md b/docs/docs/run_node/guides/reacting_to_upgrades.md new file mode 100644 index 000000000000..293922e4c0b3 --- /dev/null +++ b/docs/docs/run_node/guides/reacting_to_upgrades.md @@ -0,0 +1,36 @@ +--- +sidebar_position: 4 +title: Reacting to upgrades +--- + +This is a guide for sequencer nodes to understand how to react to protocol upgrades. To learn about how upgrades work, read the [concept section](../concepts/governance/upgrades.md). + +## Deploying the initial contracts + +Assume that there is an initial deployment, which is a set of contracts as described in the [Deployment section](../concepts/deployments/what_is_deployment.md). + +Once an AZIP garners enough buy-in from the community, sequencers can begin adopting the upgrade. + +## New Rollup contract is deployed to L1 and a proposal is initiated + +To upgrade to a new Rollup instance is to: + +1. Convince the Governance contract to call `Registry.upgrade(_addressOfNewRollup)` + +2. Sequencers move stake to the new Rollup contract to be eligible for any Hypothetical Asset rewards. + +To achieve 1, a new Rollup contract is deployed at an address, and the code for calling `Registry.upgrade(_addressOfNewRollup)` is deployed at a separate address. + +Sequencers of the current canonical rollup, that is the current rollup as pointed to by the Registry, must then call `vote(proposal)` on the Proposals contract. Sequencers can only vote during L2 slots for which they’ve been assigned as the block proposer by the L1 Rollup smart contract. For any given L2 slot, there is only one such sequencer. + +Sequencers vote by updating an environment variable `PROPOSAL_PAYLOAD` in their client software. If enough votes are received by the Proposals contract, any Ethereum account can call `pushProposal(_roundNumber)` where `_roundNumber` can be read from the L1. + +## Voting starts and proposal executed after delay + +Holders who locked their Hypothetical Assets in the Governance contract can vote on proposals. Each vote specifies whether it is in support of the upgrade or not, and the amount of locked Hypothetical Assets the holder wishes to vote. + +If the vote passes, a proposal is moved to an Executable state after some delay. + +## Proposal executed + +Anyone can call `execute(_proposalId)` on the Governance contract which in turn will call the proposal code that was deployed. diff --git a/docs/docs/run_node/guides/run_nodes/_category_.json b/docs/docs/run_node/guides/run_nodes/_category_.json new file mode 100644 index 000000000000..bab7be349b11 --- /dev/null +++ b/docs/docs/run_node/guides/run_nodes/_category_.json @@ -0,0 +1,6 @@ +{ + "position": 2, + "collapsible": true, + "collapsed": true, + "label": "Running nodes" +} diff --git a/docs/docs/run_node/guides/run_nodes/how_to_run_prover.md b/docs/docs/run_node/guides/run_nodes/how_to_run_prover.md new file mode 100644 index 000000000000..27e44517a3c2 --- /dev/null +++ b/docs/docs/run_node/guides/run_nodes/how_to_run_prover.md @@ -0,0 +1,8 @@ +--- +sidebar_position: 2 +title: How to Run a Prover Node +--- + +It is recommended to read the concepts before running a node, specifically the [provers and sequencers](../../concepts/provers-and-sequencers/index.md) section. + +As we are in active development, this guide is actively changing. Please refer to [this HackMD page](https://hackmd.io/@aztec-network/epoch-proving-integration-guide#Running-a-Prover-Node) for the latest information. \ No newline at end of file diff --git a/docs/docs/run_node/guides/run_nodes/how_to_run_prover_draft.md b/docs/docs/run_node/guides/run_nodes/how_to_run_prover_draft.md new file mode 100644 index 000000000000..8c1ea44feac5 --- /dev/null +++ b/docs/docs/run_node/guides/run_nodes/how_to_run_prover_draft.md @@ -0,0 +1,96 @@ +--- +sidebar_position: 2 +title: How to run a prover node (draft) +draft: true +--- + +!! We will update and publish this when ready !! + +It is recommended to read the concepts before running a node, specifically the [provers and sequencers](../../concepts/provers-and-sequencers/index.md) section. + +The Aztec client can be run as a Prover Node. In this mode, the client will automatically monitor L1 for unclaimed epochs and propose bids (i.e. EpochProofQuote) for proving them. The prover node watches the L1 to see when a bid they submitted has been accepted by a sequencer, the prover node will then kick off an epoch proving job which performs the following tasks: + +- Downloads the transaction hashes in the epoch and all L1 to L2 messages from L1. +- Downloads the transaction objects with their ClientIVC proofs from a remote node (to be replaced by loading them from the P2P pool). +- Executes transactions in the epoch in order, generating proving jobs for each of them. +- Generates the inputs for each circuit and kicks off individual proving jobs to prover agents, recursively proving until it gets to the root rollup proof. +- Submits the root rollup proof to L1 to advance the proven chain. + +```mermaid +flowchart TD + style prover-node stroke:#333,stroke-width:4px + + prover-node[Prover Node] + proving-job[Proving Job] + tx-provider[Tx Provider] + l1-publisher[L1 Publisher] + l2-block-source[L2 Block Source] + world-state[World State DB] + tx-processor[Tx Processor] + prover-client[Proving Orchestrator] + proving-queue[Proof Broker] + prover-agent[Prover Agent] + bb[Barretenberg] + + prover-node --trigger--> proving-job + proving-job --"process-tx"--> tx-processor --"add-tx"--> prover-client + proving-job --start-batch--> prover-client + proving-job --get-tx-hashes--> l2-block-source + proving-job --"advance-to"--> world-state + proving-job --"get-txs"--> tx-provider + tx-processor --rw--> world-state + world-state --"get-blocks"--> l2-block-source + prover-client --"rw"--> world-state + proving-job --publish-proof--> l1-publisher + prover-client --"push-job"--> proving-queue + %%prover-agent --"pull-job"--> proving-queue + proving-queue <--"pull-jobs"--o prover-agent + subgraph "Prover Agent" + prover-agent --"prove"--> bb + end + + %% p2p-client --> tx-pool --"save-tx"--> tx-db + %% p2p-client --get-blocks--> l2-block-source +``` + +The Aztec client needed to run a prover node is shipped as a [docker image](https://hub.docker.com/r/aztecprotocol/aztec) The image exposes the Aztec CLI as its `ENTRYPOINT`, which includes a `start` command for starting different components. You can download it directly or use the sandbox scripts which will automatically pull the image and add the aztec shell script to your path. + +Once the `aztec` command is available, you can run a prover node via: + +```bash +aztec start --prover-node --archiver +``` + +To run a prover agent, either run `aztec start --prover`, or add the `--prover` flag to the command above to start an in-process prover. + +## Configuration + +The Aztec client is configured via environment variables, the following ones being relevant for the prover node: + +- **ETHEREUM_HOST**: URL to an Ethereum node. +- **L1_CHAIN_ID**: Chain ID for the L1 Ethereum chain. +- **DATA_DIRECTORY**: Local folder where archive and world state data is stored. +- **AZTEC_PORT**: Port where the JSON-RPC APIs will be served. +- **PROVER_PUBLISHER_PRIVATE_KEY**: Private key used for publishing proofs to L1. Ensure it corresponds to an address with ETH to pay for gas. +- **PROVER_AGENT_ENABLED**: Whether to run a prover agent process on the same host running the Prover Node. We recommend setting to `false` and running prover agents on separate hosts. +- **P2P_ENABLED**: Set to `true` so that your node can discover peers, receive tx data and gossip quotes to sequencers. +- **PROVER_COORDINATION_NODE_URL**: Send quotes via http. Only used if `P2P_ENABLED` is `false`. +- **BOOT_NODE_URL**: The URL of the boot node for peer discovery. +- **AZTEC_NODE_URL**: Used by the Prover Node to fetch the L1 contract addresses if they were not manually set via environment variables. + +:::note +For S&P Testnet, we will be providing an Ethereum host, a Boot Node URL and a specific Aztec Image. +::: + +The prover agent, on the other hand, relies on the following environment variables: + +- **PROVER_BROKER_HOST**: URL to the Prover Node that acts as a proving job source. +- **PROVER_AGENT_CONCURRENCY**: Maximum concurrency for this given prover agent. Defaults to `1`. + +Both the prover node and agent also rely on the following: + +- **PROVER_REAL_PROOFS**: Whether to generate actual proofs, as opposed to only simulating the circuit and outputting fake proofs. **Set to `true` for the scope of the S&P Testnet.** +- **LOG_LEVEL**: One of `debug`, `verbose`, `info`, `warn`, or `error`. +- **LOG_JSON**: Set to `true` to output logs in JSON format (unreleased). +- **OTEL_EXPORTER_OTLP_METRICS_ENDPOINT**: Optional URL for pushing telemetry data to a remote OpenTelemetry data collector. + diff --git a/docs/docs/run_node/guides/run_nodes/how_to_run_sequencer_draft.md b/docs/docs/run_node/guides/run_nodes/how_to_run_sequencer_draft.md new file mode 100644 index 000000000000..ff82314a085b --- /dev/null +++ b/docs/docs/run_node/guides/run_nodes/how_to_run_sequencer_draft.md @@ -0,0 +1,159 @@ +--- +sidebar_position: 1 +title: How to run a Validator/Sequencer Node (draft) +draft: true +--- + +# Running a Sequencer using Aztec Spartan + +This tool helps to boot an Aztec Sequencer and Prover (S&P) Testnet. + +This script does the following: + +- Checks for the presence of Docker in your machine +- Prompts you for some environment variables +- Outputs a templated docker-compose file with your variables +- Runs the docker compose file + +It should work in most UNIX-based machines. + +## Installation + +To configure a new node, create a new directory and run the install script: + +```bash +mkdir val1 && cd val1 +curl -L sp-testnet.aztec.network | bash +``` + +This will install `aztec-spartan.sh` in the current directory. You can now run it: + +```bash +./aztec-spartan.sh config +``` + +If you don't have Docker installed, the script will do it for you. It will then prompt for any required environment variables and output both a `docker-compose.yml` and an `.env` file. You will also be prompted to choose whether to use a [named volume](https://docs.docker.com/engine/storage/volumes/) (default) or if you want to use a local directory to store the node's data. + +Run `./aztec-spartan.sh` without any command to see all available options, and pass them as flags, i.e. `npx aztec-spartan config -p 8080 -p2p 40400`. If you want to use a different key for p2p peer id, pass it with `-pk `. + +For more options, see the [Node Configuration](#node-configuration) section. + +:::tip +Ensure that each validator instance uses unique ports to avoid conflicts. +::: + +## Running + +You can use `npx aztec-spartan [start/stop/logs/update]` to start, stop, output logs or pull the latest docker images. + +:::note +The above deploy script will connect your node to the p2p network where it will register peers and start receiving messages from other nodes on the network. You will not be in the validator set just yet. + +Once you connect and begin to see gossiped messages such as attestations, proposals etc notify notify a team member and they will add you to the validator set. +::: + +## Node Configuration + +The `aztec-spartan.sh` script will set the following required variables on your behalf. You can ofcourse override the variables set by the script by simply changing the `.env` file directly and re-running `./aztec-spartan.sh` + +| Variable | Description | +| ----- | ----- | +| ETHEREUM_HOST | URL to the Ethereum node your validator will connect to. For as long as we're on private networks, please use the value in `aztec-spartan.sh`| +| BOOTNODE_URL | URL to a bootnode that supplies L1 contract addresses and the ENR of the bootstrap nodes. | +| IMAGE | The docker image to run | + +In addition, the user is prompted to enter 1) an IP Address and a P2P port to be used for the TCP and UDP addresses (defaults to 40400) 2) A port for your node (8080) 3) an Ethereum private key 4) `COINBASE` which is the Ethereum address associated with the private key and 5) a path to a local directory to store node data if you don't opt for a named volume. + +On a first run, the script will generate a p2p private key and store it in `$DATA_DIR/var/lib/aztec/p2p-private-key`. If you wish to change your p2p private key, you can pass it on as a CLI arg using the flag `-pk` or update the `PEER_ID_PRIVATE_KEY` in the env file. + +### Publisher and Archiver + +The Publisher is the main node component that interacts with the Ethereum L1, for read and write operations. It is mainly responsible for block publishing, proof submission and tx management. + +The Archiver's primary functions are data storage and retrieval (i.e. L1->L2 messages), state synchronization and re-org handling. + +|Variable| Description| +|----|-----| +|ETHEREUM_HOST| This is the URL to the L1 node your validator will connect to. For as long as we're on private networks, please use the value in `aztec-spartan.sh`| +|L1_CHAIN_ID | Chain ID of the L1 | +| DATA_DIRECTORY | Optional dir to store archiver and world state data. If omitted will store in memory | +| ARCHIVER_POLLING_INTERVAL_MS | The polling interval in ms for retrieving new L2 blocks and encrypted logs +| SEQ_PUBLISHER_PRIVATE_KEY | This should be the same as your validator private key | +|SEQ_PUBLISH_RETRY_INTERVAL_MS | The interval to wait between publish retries| +| SEQ_VIEM_POLLING_INTERVAL_TIME | The polling interval viem uses in ms | + +### Sequencer Config + +The Sequencer Client is a criticial component that coordinates tx validation, L2 block creation, collecting attestations and block submission (through the Publisher). + +|Variable| Description| +|----|-----| +| VALIDATOR_DISABLED | If this is True, the client won't perform any validator duties. | +|VALIDATOR_ATTESTATIONS_WAIT_TIMEOUT_MS | Wait for attestations timeout. After this, client throws an error and does not propose a block for that slot. | +| VALIDATOR_ATTESTATIONS_POLLING_INTERVAL_MS | If not enough attestations, sleep for this long and check again | +|GOVERNANCE_PROPOSER_PAYLOAD_ADDRESS | To nominate proposals for voting, you must set this variable to the Ethereum address of the `proposal` payload. You must edit this to vote on a governance upgrade.| +| SEQ_ENFORCE_TIME_TABLE | Whether to enforce strict timeliness requirement when building blocks. Refer [here](#sequencer-timeliness-requirements) for more on the timetable | +| SEQ_MAX_TX_PER_BLOCK | Increase this to make larger blocks | +| SEQ_MIN_TX_PER_BLOCK | Increase this to require making larger blocks | +| SEQ_MIN_SECONDS_BETWEEN_BLOCKS | If greater than zero, the sequencer will not propose a block until this much time has passed since the last L2 block was published to L1 | +| SEQ_MAX_SECONDS_BETWEEN_BLOCKS | Sequencer will ignore the minTxPerBlock if this many seconds have passed since the last L2 block.| +| COINBASE | This is the Ethereum address that will receive the validator's share of block rewards. It defaults to your validator address. | +| FEE_RECIPIENT | This is the Aztec address that will receive the validator's share of transaction fees. Also defaults to your validator's address (but on Aztec L2). | + +#### Sequencer Timeliness Requirements + +During testing, it was helpful to constrain some actions of the sequencer based on the time passed into the slot. The time-aware sequencer can be told to do action A only if there's a certain amount of time left in the slot. + +For example, at the beginning of a slot, the sequencer will first sync state, then request txs from peers then attempt to build a block, then collect attestations then publish to L1. You can create constraints of the form "Only attempt to build a block if under 5 seconds have passed in the slot". + +If this is helpful in your testing as well, you can turn it on using the environment variable `SEQ_ENFORCE_TIME_TABLE`. + +Currently the default timetable values are hardcoded in [sequencer.ts](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/sequencer-client/src/sequencer/sequencer.ts#L72). Time checks are enforced in `this.setState()`. + +### P2P Config + +The P2P client coordinates peer-to-peer communication between Nodes. + +| Variable | Description | +| ---- | ------| +| BOOTSTRAP_NODES | A list of bootstrap peer ENRs to connect to. Separated by commas. | +| P2P_TCP_ANNOUNCE_ADDR | Format: `:`| +|P2P_UDP_ANNOUNCE_ADDR |Format: `:`| +| P2P_TCP_LISTEN_ADDR | Format: `:` or can use `0.0.0.0:` to listen on all interfaces| +| P2P_UDP_LISTEN_ADDR |Format: `:` or can use `0.0.0.0:` to listen on all interfaces | +| P2P_QUERY_FOR_IP | Useful in dynamic environments where your IP is not known in advance. Set this to True, and only supply `:TCP_PORT` and `:UDP_PORT` for the `ANNOUNCE_ADDR` variables. If you know your public IP address in advance, set this to False or just provide the full announce addresses. +| P2P_ENABLED | Whether to run the P2P module. Defaults to False, so make sure to set to True | +| P2P_MIN_PEERS | The min number of peers to connect to. | +| P2P_MAX_PEERS | The max number of peers to connect to. | +| P2P_BLOCK_CHECK_INTERVAL_MS | How milliseconds to wait between each check for new L2 blocks. | + +### Prover Config + +Please refer to the [Prover Guide](./how_to_run_prover.md) for info on how to setup your prover node. + +## Governance Upgrades + +During a governance upgrade, we'll announce details on the discord. At some point we'll also write AZIPs (Aztec Improvement Proposals) and post them to either the github or forum to collect feedback. + +We'll deploy the payload to the L1 and share the address of the payload with the sequencers on discord. + +To participate in the governance vote, sequencers must change the variable `GOVERNANCE_PROPOSER_PAYLOAD_ADDRESS` in the Sequencer Client to vote during the L2 slot they've been assigned sequencer duties. + +## Troubleshooting + +:::tip +Please make sure you are in the Discord server and that you have been assigned the role `S&P Participant`. Say gm in the `sequencer-and-prover` channel and turn on notifications for the announcements channel. +::: + +If you encounter any errors or bugs, please try basic troubleshooting steps like restarting your node, checking ports and configs. + +If issue persists, please share on the sequencer-and-prover channel and tag [Amin](discordapp.com/users/65773032211231539). + +Some issues are fairly light, the group and ourselves can help you within 60 minutes. If the issue isn't resolved, please send more information: + +**Error Logs**: Attach any relevant error logs. If possible, note the timestamp when the issue began. +**Error Description**: Briefly describe the issue. Include details like what you were doing when it started, and any unusual behaviors observed. +**Steps to Reproduce (if known)**: If there’s a clear way to reproduce the error, please describe it. +**System Information**: Share details like your system’s operating system, hardware specs, and any other relevant environment information. + +That way we can dedicate more time to troubleshoot and open Github issues if no known fix. \ No newline at end of file diff --git a/docs/docs/run_node/guides/run_nodes/how_to_run_validator_sequencer.md b/docs/docs/run_node/guides/run_nodes/how_to_run_validator_sequencer.md new file mode 100644 index 000000000000..d87d530f9c1c --- /dev/null +++ b/docs/docs/run_node/guides/run_nodes/how_to_run_validator_sequencer.md @@ -0,0 +1,10 @@ +--- +sidebar_position: 1 +title: How to run a Validator/Sequencer Node +--- + +It is recommended to read the concepts before running a node, specifically the [provers and sequencers](../../concepts/provers-and-sequencers/index.md) section. + +As we are in active development, this guide is actively changing. Please refer to [this README](https://github.com/AztecProtocol/aztec-packages/blob/master/spartan/releases/README.md) for the latest information. + + diff --git a/docs/docs/run_node/guides/run_nodes/index.md b/docs/docs/run_node/guides/run_nodes/index.md new file mode 100644 index 000000000000..9d4630ebc616 --- /dev/null +++ b/docs/docs/run_node/guides/run_nodes/index.md @@ -0,0 +1,26 @@ +--- +id: index +sidebar_position: 0 +title: Run a Node, Sequencer, or Prover +--- + +## Running Aztec Nodes + +
+ + +

Run Aztec Validator Nodes

+
+ + Participate in the Aztec protocol as a validator (also called a sequencer) that helps form consensus on what goes into a block. Runs on consumer hardware. + +
+ + +

Run Aztec Prover Nodes

+
+ + Participate in the Aztec protocol as a prover node, proving the rollup integrity that is pivotal to the protocol. Runs on hardware fit for data centers. + +
+
\ No newline at end of file diff --git a/docs/docs/run_node/index.md b/docs/docs/run_node/index.md new file mode 100644 index 000000000000..29fdc991272d --- /dev/null +++ b/docs/docs/run_node/index.md @@ -0,0 +1,51 @@ +--- +id: index +sidebar_position: 0 +title: Run a node +--- + +In this section, you can explore how governance works on Aztec, the types of nodes that can be run, and how to contribute to decentralization on the Aztec Testnet. + +## Learn about governance on Aztec + +
+ + +

Governance

+
+ + An introduction to Aztec's governance model + +
+
+ +## Decentralization Components + +
+ + +

Sequencers

+
+ + How sequencers propose and produce blocks + +
+
+ +## Run a node + +
+ + +

Run a validator node (sequencer)

+
+ +
+ + + +

Run a prover node

+
+ +
+
diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js index 20918552819f..7399dda10064 100644 --- a/docs/docusaurus.config.js +++ b/docs/docusaurus.config.js @@ -134,7 +134,7 @@ const config = { entryPoints: ["../yarn-project/circuit-types/src/interfaces/pxe.ts"], tsconfig: "../yarn-project/circuit-types/tsconfig.json", entryPointStrategy: "expand", - out: "reference/developer_references/aztecjs/pxe", + out: "developers/reference/aztecjs/pxe", readme: "none", sidebar: { categoryLabel: "Private Execution Environment (PXE)", @@ -152,7 +152,7 @@ const config = { ], tsconfig: "../yarn-project/aztec.js/tsconfig.json", entryPointStrategy: "resolve", - out: "reference/developer_references/aztecjs/aztec-js", + out: "developers/reference/aztecjs/aztec-js", readme: "none", sidebar: { categoryLabel: "Aztec.js", @@ -173,7 +173,7 @@ const config = { ], tsconfig: "../yarn-project/accounts/tsconfig.json", entryPointStrategy: "resolve", - out: "reference/developer_references/aztecjs/accounts", + out: "developers/reference/aztecjs/accounts", readme: "none", sidebar: { categoryLabel: "Accounts", @@ -208,19 +208,12 @@ const config = { ], apiKey: "gpH8o2YnqsOEj2jgtIMTULbtHi1kZ2X3", // public search-only api key, safe to commit }, - contextualSearch: true, }, colorMode: { defaultMode: "light", disableSwitch: false, respectPrefersColorScheme: false, }, - // docs: { - // sidebar: { - // hideable: true, - // autoCollapseCategories: false, - // }, - // }, navbar: { logo: { alt: "Aztec Logo", @@ -231,26 +224,32 @@ const config = { items: [ { type: "doc", - docId: "index", + docId: "aztec/index", position: "left", label: "Learn", }, + { type: "docSidebar", - sidebarId: "guidesSidebar", + sidebarId: "buildSidebar", position: "left", - label: "Guides", + label: "Build", }, { type: "docSidebar", - sidebarId: "referenceSidebar", + sidebarId: "nodesSidebar", position: "left", - label: "Reference", + label: "Run a node", + }, + { + to: "/developers/getting_started", + label: "Install Sandbox", + position: "right", }, { type: "dropdown", label: "Resources", - position: "left", + position: "right", items: [ { type: "html", @@ -353,7 +352,7 @@ const config = { }, { label: "Developer Getting Started Guide", - to: "/guides/getting_started", + to: "/developers/getting_started", }, { label: "Aztec.nr", diff --git a/docs/internal_notes/dev_docs/sandbox/components.md b/docs/internal_notes/dev_docs/sandbox/components.md index fb8e6bfa1162..f9d407faf88d 100644 --- a/docs/internal_notes/dev_docs/sandbox/components.md +++ b/docs/internal_notes/dev_docs/sandbox/components.md @@ -137,7 +137,6 @@ Implementation notes for this milestone: - Can be used as both the spending and decryption key for early development. ### Private Execution Environment (PXE) - ![](https://hackmd.io/_uploads/ryS0sOLyh.png) Implements: diff --git a/docs/netlify.toml b/docs/netlify.toml index 3a0097de71b6..5dba9ffe4bba 100644 --- a/docs/netlify.toml +++ b/docs/netlify.toml @@ -1,22 +1,26 @@ [[redirects]] from = "/guides/smart_contracts/writing_contracts/initializers" - to = "/guides/developer_guides/smart_contracts/writing_contracts/initializers" + to = "/developers/guides/smart_contracts/writing_contracts/initializers" [[redirects]] from = "/reference/aztecjs/accounts" - to = "/reference/developer_references/aztecjs/accounts" + to = "/developers/reference/aztecjs/accounts" [[redirects]] from = "/getting_started" - to = "/guides/getting_started" + to = "/developers/getting_started" [[redirects]] - from = "/tutorials/simple_dapp/*" - to = "/tutorials/codealong/simple_dapp" + from = "/developers/getting_started/main" + to = "/developers/getting_started" + +[[redirects]] + from = "guides/getting_started" + to = "/developers/getting_started" [[redirects]] - from = "/tutorials/simple_dapp" - to = "/tutorials/codealong/simple_dapp" + from = "/tutorials/simple_dapp/*" + to = "developers/tutorials/codealong/js_tutorials/simple_dapp" [[redirects]] from = "/tutorials/contract_tutorials//token_bridge/typescript_glue_code" @@ -64,7 +68,7 @@ [[redirects]] from = "/developers/sandbox/*" - to = "/guides/getting_started" + to = "/developers/getting_started" [[redirects]] from = "/developers/contracts/*" @@ -72,7 +76,7 @@ [[redirects]] from = "/dev_docs/*" - to = "/guides/getting_started" + to = "/developers/getting_started" [[redirects]] from = "/aztec/cryptography/cryptography-roadmap" @@ -136,16 +140,60 @@ [[redirects]] from = "/reference/sandbox_reference/sandbox-reference" - to = "/guides/getting_started" + to = "/developers/getting_started" [[redirects]] from = "/reference/sandbox_reference" - to = "/guides/getting_started" + to = "/developers/getting_started" + +[[redirects]] + from = "/guides/getting_started/*" + to = "/developers/getting_started/*" + +[[redirects]] + from = "/guides/developer_guides/getting_started/quickstart" + to = "/developers/getting_started" + +[[redirects]] + from = "/aztec/concepts_overview" + to = "/aztec" + +[[redirects]] + from = "/aztec/concepts/accounts/authwit" + to = "/aztec/concepts/advanced/authwit" + +[[redirects]] + from = "/aztec/concepts/storage/storage_slots" + to = "/aztec/concepts/advanced/storage/storage_slots" + +[[redirects]] + from = "/aztec/concepts/storage/trees/*" + to = "/aztec/concepts/advanced/storage/indexed_merkle_tree" + +[[redirects]] + from = "/aztec/concepts/storage/partial_notes" + to = "/aztec/concepts/advanced/storage/partial_notes" + +[[redirects]] + from = "/aztec/concepts/circuits/*" + to = "/aztec/concepts/advanced/circuits" + +[[redirects]] + from = "/tutorials/*" + to = "/developers/tutorials/*" + +[[redirects]] + from = "/guides/*" + to = "/developers/guides/*" + +[[redirects]] + from = "/reference/*" + to = "/developers/reference/*" [[redirects]] - from = "/guides/getting_started/quickstart" - to = "/guides/getting_started" + from = "/guides/privacy_considerations" + to = "/developers/reference/considerations/privacy_considerations" [[redirects]] -from = "/guides/developer_guides/getting_started/quickstart" -to = "/guides/developer_guides/getting_started" \ No newline at end of file + from = "/reference/developer_references/limitations" + to = "/developers/reference/considerations/limitations" \ No newline at end of file diff --git a/docs/package.json b/docs/package.json index 0e9563dbfcec..98bd39e0a2fa 100644 --- a/docs/package.json +++ b/docs/package.json @@ -73,4 +73,4 @@ ] }, "packageManager": "yarn@4.5.2" -} +} \ No newline at end of file diff --git a/docs/scripts/clean.sh b/docs/scripts/clean.sh index 8d27b2091b40..ce1fe639f84d 100755 --- a/docs/scripts/clean.sh +++ b/docs/scripts/clean.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash rm -rf 'processed-docs' 'processed-docs-cache' -rm -rf 'docs/reference/developer_references/aztecjs' 'docs/reference/developer_references/smart_contract_reference/aztec-nr' +rm -rf 'docs/developers/reference/aztecjs' 'docs/developers/reference/smart_contract_reference/aztec-nr' docusaurus clear diff --git a/docs/scripts/move_processed.sh b/docs/scripts/move_processed.sh index b841f2e5eb16..23d40065bedb 100755 --- a/docs/scripts/move_processed.sh +++ b/docs/scripts/move_processed.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash -echo "label: \"AztecJS\"" > ./docs/reference/developer_references/aztecjs/_category_.yml -mv ./docs/reference/developer_references/aztecjs ./processed-docs/reference/developer_references/aztecjs -mv ./docs/reference/developer_references/smart_contract_reference/aztec-nr ./processed-docs/reference/developer_references/smart_contract_reference/aztec-nr +echo "label: \"AztecJS\"" > ./docs/developers/reference/aztecjs/_category_.yml +mv ./docs/developers/reference/aztecjs ./processed-docs/developers/reference/aztecjs +mv ./docs/developers/reference/smart_contract_reference/aztec-nr ./processed-docs/developers/reference/smart_contract_reference/aztec-nr diff --git a/docs/sidebars.js b/docs/sidebars.js index ae40d1e6a513..7079d2566654 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -6,36 +6,16 @@ const path = require("path"); /** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */ export default { sidebar: [ - { - type: "html", - value: 'Concepts', - className: "sidebar-title", - }, { type: "doc", - id: "aztec/concepts_overview", - label: "Concepts Overview", + id: "aztec/index", + label: "Aztec Overview", }, { type: "category", label: "Concepts", items: [{ type: "autogenerated", dirName: "aztec/concepts" }], }, - { - type: "html", - value: 'Network', - className: "sidebar-title", - }, - { - type: "doc", - id: "aztec/network_overview", - label: "Network Overview", - }, - { - type: "category", - label: "Network Infrastructure", - items: [{ type: "autogenerated", dirName: "aztec/network" }], - }, { type: "html", value: 'Smart Contracts', @@ -62,15 +42,19 @@ export default { { type: "doc", label: "Building in Public", - id: "aztec", + id: "building_in_public", + }, + { + type: "doc", + id: "aztec_connect_sunset", }, ], - guidesSidebar: [ + buildSidebar: [ { type: "doc", - id: "guides/index", - label: "Guides and Tutorials", + id: "developers/index", + label: "Build", }, { type: "html", @@ -80,7 +64,12 @@ export default { { type: "doc", label: "Quickstart", - id: "guides/getting_started" + id: "developers/getting_started" + }, + { + type: "link", + label: "Aztec Starter GitHub repo", + href: "https://github.com/AztecProtocol/aztec-starter", }, { type: "html", @@ -93,16 +82,20 @@ export default { }, { type: "autogenerated", - dirName: "tutorials/codealong", + dirName: "developers/tutorials/codealong", + }, + { + type: "html", + value: '', }, { type: "html", - value: 'Advanced Examples', + value: 'How-to Guides', className: "sidebar-title", }, { type: "autogenerated", - dirName: "tutorials/examples", + dirName: "developers/guides" }, { type: "html", @@ -110,65 +103,59 @@ export default { }, { type: "html", - value: 'How-to Guides', + value: 'References', className: "sidebar-title", }, { type: "autogenerated", - dirName: "guides/developer_guides" + dirName: "developers/reference", }, { type: "html", value: '', }, - ], - - referenceSidebar: [ { type: "doc", - label: "References", - id: "reference/index", + id: "migration_notes", }, + ], + + roadmapSidebar: [ { - type: "html", - value: 'Developer References', - className: "sidebar-title", + type: "autogenerated", + dirName: "aztec/roadmap", }, + ], + + nodesSidebar: [ + { - type: "autogenerated", - dirName: "reference/developer_references", + type: "doc", + id: "run_node/index", }, { type: "html", - value: 'Considerations', + value: 'Concepts', className: "sidebar-title", }, { - type: "doc", - id: "migration_notes", - }, - { - type: "doc", - label: "Privacy Considerations", - id: "guides/privacy_considerations" + type: "autogenerated", + dirName: "run_node/concepts", }, { type: "html", value: '', }, { - type: "doc", - id: "aztec_connect_sunset", + type: "html", + value: 'Guides', + className: "sidebar-title", }, - ], - - roadmapSidebar: [ { type: "autogenerated", - dirName: "aztec/roadmap", + dirName: "run_node/guides", }, ], - ...(process.env.SHOW_PROTOCOL_SPECS ? { protocolSpecSidebar: [ "protocol-specs/intro", diff --git a/docs/src/components/Disclaimers/_wip_disclaimer.mdx b/docs/src/components/Disclaimers/_wip_disclaimer.mdx index 61f31593ea50..131eec88d592 100644 --- a/docs/src/components/Disclaimers/_wip_disclaimer.mdx +++ b/docs/src/components/Disclaimers/_wip_disclaimer.mdx @@ -5,7 +5,7 @@ :::caution Disclaimer We are building Aztec as transparently as we can. The documents published here are living documents. The protocol, sandbox, language, and tools are all subject to change over time. -Please see [here](/reference/developer_references/limitations) for details of known Aztec protocol and Aztec Sandbox limitations. +Please see [here](/developers/reference/considerations/limitations) for details of known Aztec protocol and Aztec Sandbox limitations. If you would like to help us build Aztec: diff --git a/docs/src/preprocess/generate_aztecnr_reference.js b/docs/src/preprocess/generate_aztecnr_reference.js index 7d0a3396a42a..3512ec15c366 100644 --- a/docs/src/preprocess/generate_aztecnr_reference.js +++ b/docs/src/preprocess/generate_aztecnr_reference.js @@ -323,7 +323,7 @@ function processFiles(baseDir, outputBaseDir) { let baseDir = path.resolve(__dirname, "../../../noir-projects/aztec-nr"); let outputBaseDir = path.resolve( __dirname, - "../../docs/reference/developer_references/smart_contract_reference/aztec-nr" + "../../docs/developers/reference/smart_contract_reference/aztec-nr" ); console.log(outputBaseDir); processFiles(baseDir, outputBaseDir); diff --git a/docs/static/img/governance.png b/docs/static/img/governance.png new file mode 100644 index 000000000000..991dee3115c4 Binary files /dev/null and b/docs/static/img/governance.png differ diff --git a/docs/typesense.config.json b/docs/typesense.config.json index f20205e727c0..7dccc1f3dc63 100644 --- a/docs/typesense.config.json +++ b/docs/typesense.config.json @@ -1,47 +1,47 @@ { - "index_name": "aztec-docs", - "start_urls": [ - "https://docs.aztec.network/" - ], - "sitemap_urls": [ - "https://docs.aztec.network/sitemap.xml" - ], - "sitemap_alternate_links": true, - "selectors": { - "lvl0": { - "selector": "(//ul[contains(@class,'menu__list')]//a[contains(@class, 'menu__link menu__link--sublist menu__link--active')]/text() | //nav[contains(@class, 'navbar')]//a[contains(@class, 'navbar__link--active')]/text())[last()]", - "type": "xpath", - "global": true, - "default_value": "Documentation" - }, - "lvl1": "header h1", - "lvl2": "header h2", - "lvl3": "header h3", - "lvl4": "header h4", - "lvl5": "header h5", - "lvl6": "header h6", - "text": "article p, article li, article td:last-child" - }, - "strip_chars": " .,;:#", - "custom_settings": { - "separatorsToIndex": "_", - "attributesForFaceting": [ - "language", - "version", - "type", - "docusaurus_tag" - ], - "attributesToRetrieve": [ - "hierarchy", - "content", - "anchor", - "url", - "url_without_anchor", - "type" - ] + "index_name": "aztec-docs", + "start_urls": [ + "https://docs.aztec.network/" + ], + "sitemap_urls": [ + "https://docs.aztec.network/sitemap.xml" + ], + "sitemap_alternate_links": true, + "selectors": { + "lvl0": { + "selector": "(//ul[contains(@class,'menu__list')]//a[contains(@class, 'menu__link menu__link--sublist menu__link--active')]/text() | //nav[contains(@class, 'navbar')]//a[contains(@class, 'navbar__link--active')]/text())[last()]", + "type": "xpath", + "global": true, + "default_value": "Documentation" }, - "conversation_id": [ - "833762294" + "lvl1": "header h1", + "lvl2": "header h2", + "lvl3": "header h3", + "lvl4": "header h4", + "lvl5": "header h5", + "lvl6": "header h6", + "text": "article p, article li, article td:last-child" + }, + "strip_chars": " .,;:#", + "custom_settings": { + "separatorsToIndex": "_", + "attributesForFaceting": [ + "language", + "version", + "type", + "docusaurus_tag" ], - "nb_hits": 46250 - } \ No newline at end of file + "attributesToRetrieve": [ + "hierarchy", + "content", + "anchor", + "url", + "url_without_anchor", + "type" + ] + }, + "conversation_id": [ + "833762294" + ], + "nb_hits": 46250 +} \ No newline at end of file diff --git a/yarn-project/accounts/src/defaults/index.ts b/yarn-project/accounts/src/defaults/index.ts index d5b399a1dd26..237e118c3ff5 100644 --- a/yarn-project/accounts/src/defaults/index.ts +++ b/yarn-project/accounts/src/defaults/index.ts @@ -1,7 +1,7 @@ /** * The `@aztec/accounts/defaults` export provides the base class {@link DefaultAccountContract} for implementing account contracts that use the default entrypoint payload module. * - * Read more in {@link https://docs.aztec.network/developers/wallets/writing_an_account_contract | Writing an account contract}. + * Read more in {@link https://docs.aztec.network/developers/tutorials/codealong/contract_tutorials/write_accounts_contract | Writing an account contract}. * * @packageDocumentation */ diff --git a/yarn-project/aztec.js/README.md b/yarn-project/aztec.js/README.md index 8fdc97fa5219..ff0540e71d83 100644 --- a/yarn-project/aztec.js/README.md +++ b/yarn-project/aztec.js/README.md @@ -1,6 +1,6 @@ # Aztec.js -Aztec.js is a library that provides APIs for managing accounts and interacting with contracts on the Aztec network. It communicates with the [Private eXecution Environment (PXE)](https://docs.aztec.network/reference/aztecjs/pxe) through a `PXE` implementation, allowing developers to easily register new accounts, deploy contracts, view functions, and send transactions. +Aztec.js is a library that provides APIs for managing accounts and interacting with contracts on the Aztec network. It communicates with the [Private eXecution Environment (PXE)](https://docs.aztec.network/developers/reference/aztecjs/pxe) through a `PXE` implementation, allowing developers to easily register new accounts, deploy contracts, view functions, and send transactions. ## Installing diff --git a/yarn-project/aztec.js/src/contract/index.ts b/yarn-project/aztec.js/src/contract/index.ts index b69395de86e2..265886aea9cc 100644 --- a/yarn-project/aztec.js/src/contract/index.ts +++ b/yarn-project/aztec.js/src/contract/index.ts @@ -1,7 +1,7 @@ /** * The `contract` module provides utilities for deploying and interacting with contracts, based on a * `Wallet` instance and a compiled artifact. Refer to the {@link account} module for how to obtain a valid - * `Wallet` instance, and to the {@link https://docs.aztec.network/developers/contracts/compiling | Compiling contracts} + * `Wallet` instance, and to the {@link https://docs.aztec.network/developers/guides/smart_contracts/how_to_compile_contract | Compiling contracts} * section of the documentation for how to generate an artifact out of your Noir source code. * * The {@link Contract} class is the main class in this module, and provides static methods for deploying @@ -30,7 +30,7 @@ * has synchronized its changes. * * @remarks If you are using typescript, consider using the - * {@link https://docs.aztec.network/developers/contracts/compiling#typescript-interfaces | autogenerated type-safe interfaces} + * {@link https://docs.aztec.network/developers/guides/smart_contracts/how_to_compile_contract#typescript-interfaces | autogenerated type-safe interfaces} * for interacting with your contracts. * * @packageDocumentation diff --git a/yarn-project/cli/src/cmds/misc/update.ts b/yarn-project/cli/src/cmds/misc/update.ts index fa8265e425cd..34c3d3eed50a 100644 --- a/yarn-project/cli/src/cmds/misc/update.ts +++ b/yarn-project/cli/src/cmds/misc/update.ts @@ -10,7 +10,7 @@ import { updateAztecNr } from './update/noir.js'; import { getNewestVersion, updateAztecDeps, updateLockfile } from './update/npm.js'; const AZTECJS_PACKAGE = '@aztec/aztec.js'; -const UPDATE_DOCS_URL = 'https://docs.aztec.network/developers/updating'; +const UPDATE_DOCS_URL = 'https://docs.aztec.network/developers/guides/local_env/versions-updating'; export async function updateProject( projectPath: string, diff --git a/yarn-project/entrypoints/src/index.ts b/yarn-project/entrypoints/src/index.ts index 75ba38e75d6f..fb1c0fedaba8 100644 --- a/yarn-project/entrypoints/src/index.ts +++ b/yarn-project/entrypoints/src/index.ts @@ -1,7 +1,7 @@ /** * The `@aztec/accounts/defaults` export provides the base class {@link DefaultAccountContract} for implementing account contracts that use the default entrypoint payload module. * - * Read more in {@link https://docs.aztec.network/tutorials/write_accounts_contract | Writing an account contract}. + * Read more in {@link https://docs.aztec.network/developers/tutorials/codealong/contract_tutorials/write_accounts_contract | Writing an account contract}. * * @packageDocumentation */ diff --git a/yarn-project/pxe/src/pxe_service/pxe_service.ts b/yarn-project/pxe/src/pxe_service/pxe_service.ts index 3094bb24242a..43942bf99fb8 100644 --- a/yarn-project/pxe/src/pxe_service/pxe_service.ts +++ b/yarn-project/pxe/src/pxe_service/pxe_service.ts @@ -657,7 +657,7 @@ export class PXEService implements PXE { const contract = await this.db.getContract(to); if (!contract) { throw new Error( - `Unknown contract ${to}: add it to PXE Service by calling server.addContracts(...).\nSee docs for context: https://docs.aztec.network/reference/common_errors/aztecnr-errors#unknown-contract-0x0-add-it-to-pxe-by-calling-serveraddcontracts`, + `Unknown contract ${to}: add it to PXE Service by calling server.addContracts(...).\nSee docs for context: https://docs.aztec.network/developers/reference/debugging/aztecnr-errors#unknown-contract-0x0-add-it-to-pxe-by-calling-serveraddcontracts`, ); }