Skip to content

Commit

Permalink
improved docs
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Feb 27, 2024
1 parent c69d59b commit 024ff1f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Interestingly, if a developer requires a private state to be modifiable by users

## `PrivateMutable<NoteType>`

PrivateMutable is a private state variable that is unique in a way. When a PrivateMutable is initialized, a note is created to represent its value. And the way to update the value is to destroy the current note, and create a new one with the updated value.
PrivateMutable (formerly known as `Singleton`) is a private state variable that is unique in a way. When a PrivateMutable is initialized, a note is created to represent its value. And the way to update the value is to destroy the current note, and create a new one with the updated value.

Like for public state, we define the struct to have context and a storage slot. You can view the implementation [here](https://github.com/AztecProtocol/aztec-packages/blob/master/noir-projects/aztec-nr/aztec/src/state_vars/private_mutable.nr).

Expand Down Expand Up @@ -134,7 +134,7 @@ Functionally similar to [`get_note`](#get_note), but executed in unconstrained f

## `PrivateImmutable<NoteType>`

`PrivateImmutable` represents a unique private state variable that, as the name suggests, is immutable. Once initialized, its value cannot be altered. You can view the implementation [here](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/noir-projects/aztec-nr/aztec/src/state_vars/private_immutable.nr).
`PrivateImmutable` (formerly known as `ImmutableSingleton`) represents a unique private state variable that, as the name suggests, is immutable. Once initialized, its value cannot be altered. You can view the implementation [here](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/noir-projects/aztec-nr/aztec/src/state_vars/private_immutable.nr).

### `new`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ For a higher level overview of the state model in Aztec, see the [state model](.

## Overview

The `PublicMutable` struct is generic over the variable type `T`. The type _must_ implement Serialize and Deserialize traits, as specified here:
The `PublicMutable` (formerly known as `PublicState`) struct is generic over the variable type `T`. The type _must_ implement Serialize and Deserialize traits, as specified here:

#include_code serialize /noir-projects/noir-protocol-circuits/src/crates/types/src/traits.nr rust
#include_code deserialize /noir-projects/noir-protocol-circuits/src/crates/types/src/traits.nr rust
Expand Down Expand Up @@ -91,7 +91,7 @@ We have a `write` method on the `PublicMutable` struct that takes the value to w

## Shared Immutable

`SharedImmutable` is a special type that can be read from both public and private!
`SharedImmutable` (formerly known as `StablePublicState`) is a special type 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.

Expand All @@ -101,6 +101,10 @@ Just like the `PublicMutable` it is generic over the variable type `T`. The type

You can find the details of `SharedImmutable` in the implementation [here](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/noir-projects/aztec-nr/aztec/src/state_vars/shared_immutable.nr).

:::info
The word `Shared` in Aztec protocol means read/write from public, read only from private.
:::

### `new`

Is done exactly like the `PublicMutable` struct, but with the `SharedImmutable` struct.
Expand Down

0 comments on commit 024ff1f

Please sign in to comment.