From e67d94b9c335b94b2ca01ebb71f2da54747b9ee1 Mon Sep 17 00:00:00 2001 From: josh crites Date: Tue, 6 Feb 2024 14:36:28 -0500 Subject: [PATCH] fix(docs): Update mdx files to md (#4459) renames mdx files to md in the docs --- .../contracts/syntax/{context.mdx => context.md} | 8 ++++---- .../contracts/syntax/functions/inner_workings.md | 8 ++------ .../syntax/functions/public_private_unconstrained.md | 6 +++--- docs/docs/developers/contracts/syntax/storage/main.md | 8 ++++---- .../contracts/syntax/storage/public_state.md | 11 ++++++----- docs/docs/developers/limitations/main.md | 2 +- 6 files changed, 20 insertions(+), 23 deletions(-) rename docs/docs/developers/contracts/syntax/{context.mdx => context.md} (98%) diff --git a/docs/docs/developers/contracts/syntax/context.mdx b/docs/docs/developers/contracts/syntax/context.md similarity index 98% rename from docs/docs/developers/contracts/syntax/context.mdx rename to docs/docs/developers/contracts/syntax/context.md index 47e3c586ebf..29194058641 100644 --- a/docs/docs/developers/contracts/syntax/context.mdx +++ b/docs/docs/developers/contracts/syntax/context.md @@ -4,8 +4,6 @@ description: Documentation of Aztec's Private and Public execution contexts hide_table_of_contents: false --- -import Image from "@theme/IdealImage"; - # The Function Context ## What is the context @@ -23,7 +21,9 @@ On this page, you'll learn - Differences between the private and public contexts, especially the unique features and variables in the public context ## Two context's one API -The `Aztec` blockchain contains two environments [public and private](../../../learn/concepts/hybrid_state/main.md). + +The `Aztec` blockchain contains two environments [public and private](../../../learn/concepts/hybrid_state/main.md). + - Private, for private transactions taking place on user's devices. - Public, for public transactions taking place on the network's sequencers. @@ -57,7 +57,7 @@ The call context contains information about the current call being made: > The graphic below illustrates how the message sender changes throughout the kernel circuit iterations. - + 2. Storage contract address diff --git a/docs/docs/developers/contracts/syntax/functions/inner_workings.md b/docs/docs/developers/contracts/syntax/functions/inner_workings.md index 3a6174d920c..a1d6ce4fdd6 100644 --- a/docs/docs/developers/contracts/syntax/functions/inner_workings.md +++ b/docs/docs/developers/contracts/syntax/functions/inner_workings.md @@ -54,7 +54,7 @@ Inside the kernel circuits, the inputs to functions are reduced to a single valu **Creating the function's context.** #include_code context-example-context /yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr rust -Each Aztec function has access to a [context](../context.mdx) object. This object, although labelled a global variable, is created locally on a users' device. It is initialized from the inputs provided by the kernel, and a hash of the function's inputs. +Each Aztec function has access to a [context](../context.md) object. This object, although labelled a global variable, is created locally on a users' device. It is initialized from the inputs provided by the kernel, and a hash of the function's inputs. #include_code context-example-context-return /yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr rust @@ -77,7 +77,7 @@ This function takes the application context, and converts it into the `PrivateCi Defining a function as `unconstrained` tells Aztec to simulate it completely client-side in the [ACIR simulator](../../../../learn/concepts/pxe/acir_simulator.md) without generating proofs. They are useful for extracting information from a user through an [oracle](./oracles.md). -When an unconstrained function is called, it prompts the ACIR simulator to +When an unconstrained function is called, it prompts the ACIR simulator to 1. generate the execution environment 2. execute the function within this environment @@ -94,7 +94,3 @@ This: 2. Converts `args` into a format suitable for the ACVM (Abstract Circuit Virtual Machine), creating an initial witness (witness = set of inputs required to compute the function). `args` might be an oracle to request a user's balance 3. Executes the function in the ACVM, which involves running the ACIR with the initial witness and the context. If requesting a user's balance, this would query the balance from the PXE database 4. Extracts the return values from the `partialWitness` and decodes them based on the artifact to get the final function output. The [artifact](../../artifacts.md) is the compiled output of the contract, and has information like the function signature, parameter types, and return types - - - - diff --git a/docs/docs/developers/contracts/syntax/functions/public_private_unconstrained.md b/docs/docs/developers/contracts/syntax/functions/public_private_unconstrained.md index 678fc7ad9d3..be2c97c27b3 100644 --- a/docs/docs/developers/contracts/syntax/functions/public_private_unconstrained.md +++ b/docs/docs/developers/contracts/syntax/functions/public_private_unconstrained.md @@ -12,13 +12,13 @@ A public function is executed by the sequencer and has access to a state model t All data inserted into private storage from a public function will be publicly viewable (not private). ::: -To create a public function you can annotate it with the `#[aztec(public)]` attribute. This will make the [public context](../context.mdx) available within the function's execution scope. +To create a public function you can annotate it with the `#[aztec(public)]` attribute. This will make the [public context](../context.md) available within the function's execution scope. #include_code set_minter /yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust ## `Private` Functions -A private function operates on private information, and is executed by the user. Annotate the function with the `#[aztec(private)]` attribute to tell the compiler it's a private function. This will make the [private context](../context.mdx#private-context-broken-down) available within the function's execution scope. +A private function operates on private information, and is executed by the user. Annotate the function with the `#[aztec(private)]` attribute to tell the compiler it's a private function. This will make the [private context](../context.md#private-context-broken-down) available within the function's execution scope. #include_code redeem_shield /yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust @@ -32,4 +32,4 @@ Beyond using them inside your other functions, they are convenient for providing :::info Note, that unconstrained functions can have access to both public and private data when executed on the user's device. This is possible since it is not actually part of the circuits that are executed in contract execution. -::: \ No newline at end of file +::: diff --git a/docs/docs/developers/contracts/syntax/storage/main.md b/docs/docs/developers/contracts/syntax/storage/main.md index 1d233536235..d28110bdb87 100644 --- a/docs/docs/developers/contracts/syntax/storage/main.md +++ b/docs/docs/developers/contracts/syntax/storage/main.md @@ -49,7 +49,7 @@ If you don't yet have any private state variables defined you can use this place Since Aztec.nr is written in Noir, which is state-less, we need to specify how the storage struct should be initialized to read and write data correctly. In most cases, the initialization of the storage is handled by the Aztec.nr library, which creates a default implementation based on the provided `Storage` struct. :::danger -The automatic initialization has some limitations. Using any combination of the provided storage primitives (`PublicState`, `Singleton`, `ImmutableSingleton`, `Set`, `Map`, including nested ones) will ensure that the library will be able to handle it on its own. +The automatic initialization has some limitations. Using any combination of the provided storage primitives (`PublicState`, `Singleton`, `ImmutableSingleton`, `Set`, `Map`, including nested ones) will ensure that the library will be able to handle it on its own. Custom structures are also supported as long as they are generic over `T`, where `T` implements `Serialize` and `Deserialize` in the case it represents public state and additionally `NoteInterface` for private state. ::: @@ -81,13 +81,13 @@ A `map` is a state variable that "maps" a key to a value. It can be used with pr In Aztec.nr, keys are always `Field`s, or types that can be serialized as Fields, and values can be any type - even other maps. `Field`s are finite field elements, but you can think of them as integers. ::: -It includes a [`Context`](../context.mdx) to specify the private or public domain, a `storage_slot` to specify where in storage the map is stored, and a `start_var_constructor` which tells the map how it should operate on the underlying type. This includes how to serialize and deserialize the type, as well as how commitments and nullifiers are computed for the type if it's private. +It includes a [`Context`](../context.md) to specify the private or public domain, a `storage_slot` to specify where in storage the map is stored, and a `start_var_constructor` which tells the map how it should operate on the underlying type. This includes how to serialize and deserialize the type, as well as how commitments and nullifiers are computed for the type if it's private. You can view the implementation in the Aztec.nr library [here](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/aztec-nr/aztec/src/state_vars/map.nr). ### `new` -When declaring the storage for a map, we use the `Map::new()` constructor. This takes the `storage_slot` and the `start_var_constructor` along with the [`Context`](../context.mdx). +When declaring the storage for a map, we use the `Map::new()` constructor. This takes the `storage_slot` and the `start_var_constructor` along with the [`Context`](../context.md). We will see examples of map constructors for public and private variables in later sections. @@ -130,4 +130,4 @@ require(minters[msg.sender], "caller is not minter"); - [Hybrid State Model](../../../../learn/concepts/hybrid_state/main.md) - [Public-private execution](../../../../learn/concepts/communication/public_private_calls/main.md) -- [Function Contexts](../context.mdx) +- [Function Contexts](../context.md) diff --git a/docs/docs/developers/contracts/syntax/storage/public_state.md b/docs/docs/developers/contracts/syntax/storage/public_state.md index 8c2a16bfe41..87853bf379f 100644 --- a/docs/docs/developers/contracts/syntax/storage/public_state.md +++ b/docs/docs/developers/contracts/syntax/storage/public_state.md @@ -8,7 +8,7 @@ For a higher level overview of the state model in Aztec, see the [state model](. ## Overview -The `PublicState` struct is generic over the variable type `T`. The type *must* implement Serialize and Deserialize traits, as specified here: +The `PublicState` struct is generic over the variable type `T`. The type _must_ implement Serialize and Deserialize traits, as specified here: #include_code serialize /yarn-project/noir-protocol-circuits/src/crates/types/src/traits.nr rust #include_code deserialize /yarn-project/noir-protocol-circuits/src/crates/types/src/traits.nr rust @@ -23,7 +23,7 @@ An example using a larger struct can be found in the [lending example](https://g ### `new` -When declaring the storage for `T` as a persistent public storage variable, we use the `PublicState::new()` constructor. As seen below, this takes the `storage_slot` and the [`Context`](../context.mdx), which in this case is used to share interface with other structures. You can view the implementation [here](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/yarn-project/aztec-nr/aztec/src/state_vars/public_state.nr). +When declaring the storage for `T` as a persistent public storage variable, we use the `PublicState::new()` constructor. As seen below, this takes the `storage_slot` and the [`Context`](../context.md), which in this case is used to share interface with other structures. You can view the implementation [here](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/yarn-project/aztec-nr/aztec/src/state_vars/public_state.nr). #### Single value example @@ -91,9 +91,9 @@ We have a `write` method on the `PublicState` struct that takes the value to wri ## Stable Public State -`StablePublicState` is a special type of `PublicState` that can be read from both public and private! +`StablePublicState` is a special type of `PublicState` that can be read from both public and private! -Since private execution is based on historical data, the user can pick ANY of its prior values to read from. This is why it `MUST` not be updated after the contract is deployed. The variable should be initialized at the constructor and then never changed. +Since private execution is based on historical data, the user can pick ANY of its prior values to read from. This is why it `MUST` not be updated after the contract is deployed. The variable should be initialized at the constructor and then never changed. This makes the stable public variables useful for stuff that you would usually have in `immutable` values in solidity. For example this can be the name of a token or its number of decimals. @@ -102,6 +102,7 @@ Just like the `PublicState` it is generic over the variable type `T`. The type ` You can find the details of `StablePublicState` in the implementation [here](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/yarn-project/aztec-nr/aztec/src/state_vars/stable_public_state.nr). ### `new` + Is done exactly like the `PublicState` struct, but with the `StablePublicState` struct. #include_code storage-stable-declaration /yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr rust @@ -123,8 +124,8 @@ Currently this is not constrained as we are in the middle of changing deployment Reading the value is like `PublicState`, simply with `read_public` instead of `read`. #include_code read_decimals_public /yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust - ### `read_private` + Reading the value is like `PublicState`, simply with `read_private` instead of `read`. This part can only be executed in private. #include_code read_decimals_private /yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust diff --git a/docs/docs/developers/limitations/main.md b/docs/docs/developers/limitations/main.md index 4101aeeb6d9..a2db0df2acf 100644 --- a/docs/docs/developers/limitations/main.md +++ b/docs/docs/developers/limitations/main.md @@ -34,7 +34,7 @@ Help shape and define: - These values are unused in the call-context. - Beware that what you think of as a `view` could alter state ATM! Notably the account could alter state or re-enter whenever the account contract's `is_valid` function is called. - `msg_sender` is currently leaking when doing private -> public calls - - The `msg_sender` will always be set, if you call a public function from the private world, the `msg_sender` will be set to the private caller's address. See [function context](../contracts/syntax/context.mdx). + - The `msg_sender` will always be set, if you call a public function from the private world, the `msg_sender` will be set to the private caller's address. See [function context](../contracts/syntax/context.md). - The initial `msg_sender` is 0, which can be problematic for some contracts, see [function visibility](../contracts/syntax/functions/visibility.md). - Unencrypted logs don't link to the contract that emitted it, so essentially just a `debug_log`` that you can match values against. - A note that is created and nullified in the same transaction will still emit an encrypted log.