Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ impl PrivateContext {
/// network as a whole. For example, if a contract interaction sets include-by to some publicly-known value (e.g.
/// the time when a contract upgrades), then the wallet might wish to set an even lower one to avoid revealing that
/// this tx is interacting with said contract. Ideally, all wallets should standardize on an approach in order to
/// provide users with a large anonymity set -- although the exact approach
/// provide users with a large privacy set -- although the exact approach
/// will need to be discussed. Wallets that deviate from a standard might accidentally reveal which wallet each
/// transaction originates from.
///
Expand Down
4 changes: 2 additions & 2 deletions noir-projects/aztec-nr/aztec/src/history/nullifier.nr
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ mod test;
///
/// ## Cost
///
/// This function performs a full merkle tree inclusion proof, which is in the order of 4k gates.
/// This function performs a single merkle tree inclusion proof, which is in the order of 4k gates.
///
/// If you don't need to assert existence at a _specific_ past block, consider using
/// [`PrivateContext::assert_nullifier_exists`](crate::context::PrivateContext::assert_nullifier_exists) instead, which
Expand Down Expand Up @@ -82,7 +82,7 @@ pub fn assert_nullifier_existed_by(block_header: BlockHeader, siloed_nullifier:
///
/// ## Cost
///
/// This function performs a full merkle tree inclusion proof, which is in the order of 4k gates.
/// This function performs a single merkle tree inclusion proof, which is in the order of 4k gates.
pub fn assert_nullifier_did_not_exist_by(block_header: BlockHeader, siloed_nullifier: Field) {
// 1) Get the membership witness of a low nullifier of the nullifier.
// Safety: The witness is only used as a "magical value" that makes the proof below pass. Hence it's safe.
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/aztec/src/macros/notes.nr
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ pub comptime fn custom_note(s: TypeDefinition) -> Quoted {
}
}

/// Asserts that the given note implements the `Packable` trait.
/// Asserts that the given note implements the [`Packable`](crate::protocol::traits::Packable) trait.
///
/// We require that notes have the `Packable` trait implemented because it is used when emitting a note in a log or as
/// an offchain message.
Expand Down
341 changes: 323 additions & 18 deletions noir-projects/aztec-nr/aztec/src/state_vars/delayed_public_mutable.nr

Large diffs are not rendered by default.

29 changes: 14 additions & 15 deletions noir-projects/aztec-nr/aztec/src/state_vars/public_immutable.nr
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ mod test;
/// A value stored in a `PublicImmutable` can be read and initialized from public contract functions.
///
/// Unlike [`PublicMutable`](crate::state_vars::PublicMutable) it is **also** possible to read a `PublicImmutable` from
/// a
/// private contract function, though it is not possible to initialize one. A common pattern is to have these functions
/// [enqueue a public self calls](crate::contract_self::ContractSelf::enqueue_self) in which the initialization
/// operation is performed.
/// a private contract function, though it is not possible to initialize one. A common pattern is to have these
/// functions [enqueue a public self calls](crate::contract_self::ContractSelf::enqueue_self) in which the
/// initialization operation is performed.
///
/// For a mutable (with restrictions) variant which also can be read from private functions see
/// [`DelayedPublicMutable`](crate::state_vars::DelayedPublicMutable).
Expand All @@ -54,26 +53,26 @@ mod test;
///
/// `PublicImmutable`'s main limitation is the immutability, which in many cases leads to
/// [`DelayedPublicMutable`](crate::state_vars::DelayedPublicMutable) being used instead. But in those cases where
/// fixed
/// values are not a problem, this is a fine choice for storage.
/// fixed values are not a problem, this is a fine choice for storage.
///
/// ## Examples
///
/// Declaring a `PublicImmutable` in the the contract's [`storage`](crate::macros::storage::storage) struct requires
/// Declaring a `PublicImmutable` in the contract's [`storage`](crate::macros::storage::storage) struct requires
/// specifying the type `T` that is stored in the variable:
///
/// ```noir
/// #[storage]
/// struct Storage<Context> {
/// decimals: PublicImmutable<u8, Context>,
/// struct Storage<C> {
/// decimals: PublicImmutable<u8, C>,
///
/// account_types: Map<AztecAddress, PublicImmutable<AccountType, Context>, Context>,
/// account_types: Map<AztecAddress, PublicImmutable<AccountType, C>, C>,
/// }
/// ```
///
/// ## Requirements
///
/// The type `T` stored in the `PublicImmutable` must implement the `Packable` trait.
/// The type `T` stored in the `PublicImmutable` must implement the `Eq` and
/// [`Packable`](crate::protocol::traits::Packable) traits.
///
/// ## Implementation Details
///
Expand Down Expand Up @@ -130,7 +129,7 @@ impl<T> PublicImmutable<T, PublicContext> {
/// #[external("public")]
/// #[initializer]
/// fn initialize(decimals: u8) {
/// self.storage.decimals.iniitalize(decimals);
/// self.storage.decimals.initialize(decimals);
/// }
/// ```
///
Expand All @@ -139,7 +138,7 @@ impl<T> PublicImmutable<T, PublicContext> {
/// // Can only be called once per account
/// #[external("public")]
/// fn set_account_type(account_type: AccountType) {
/// self.storage.account_types.at(self.msg_sender()).iniitalize(account_type);
/// self.storage.account_types.at(self.msg_sender()).initialize(account_type);
/// }
/// ```
///
Expand Down Expand Up @@ -223,7 +222,7 @@ impl<T> PublicImmutable<T, PublicContext> {
/// #[external("public")]
/// fn set_account_type_if_not_set(account_type: AccountType) {
/// if !self.storage.account_types.at(self.msg_sender()).is_initialized() {
/// self.storage.account_types.at(self.msg_sender()).iniitalize(account_type);
/// self.storage.account_types.at(self.msg_sender()).initialize(account_type);
/// }
/// }
/// ```
Expand Down Expand Up @@ -301,7 +300,7 @@ impl<T> PublicImmutable<T, &mut PrivateContext> {
/// #[storage]
/// struct Storage<Context> {
/// decimals: PublicImmutable<u8, Context>,
/// symbol: PubicImmutable<FieldCompressedString, Context>,
/// symbol: PublicImmutable<FieldCompressedString, Context>,
/// }
///
/// // Good: both `decimals` and `symbol` are retrieved in a single historical public storage read
Expand Down
21 changes: 11 additions & 10 deletions noir-projects/aztec-nr/aztec/src/state_vars/public_mutable.nr
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use crate::state_vars::StateVariable;
/// This is suitable for any kind of global state that needs to be accessible by everyone. For example, a token may
/// have a public total supply, or a voting contract may have public vote tallies.
///
/// Note that contracts having public values does not necessarily mean the the actions that update these values must
/// Note that contracts having public values does not necessarily mean the actions that update these values must
/// themselves be wholly public. For example, the token could allow for private minting and burning, and casting a vote
/// could be kept private: these private functions would enqueue a public function that writes to the `PublicMutable`.
///
Expand All @@ -49,22 +49,23 @@ use crate::state_vars::StateVariable;
///
/// ## Examples
///
/// Declaring a `PublicMutable` in the the contract's [`storage`](crate::macros::storage::storage) struct requires
/// Declaring a `PublicMutable` in the contract's [`storage`](crate::macros::storage::storage) struct requires
/// specifying the type `T` that is stored in the variable:
///
/// ```noir
/// #[storage]
/// struct Storage<Context> {
/// total_supply: PublicMutable<u128, Context>,
/// public_balances: Map<AztecAddress, PublicMutable<u128, Context>, Context>,
/// struct Storage<C> {
/// total_supply: PublicMutable<u128, C>,
/// public_balances: Map<AztecAddress, PublicMutable<u128, C>, C>,
///
/// vote_tallies: Map<ElectionId, PublicMutable<u128, Context>, Context>,
/// vote_tallies: Map<ElectionId, PublicMutable<u128, C>, C>,
/// }
/// ```
///
/// ## Requirements
///
/// The type `T` stored in the `PublicMutable` must implement the `Packable` trait.
/// The type `T` stored in the `PublicMutable` must implement the [`Packable`](crate::protocol::traits::Packable)
/// trait.
///
/// ## Implementation Details
///
Expand Down Expand Up @@ -161,7 +162,7 @@ impl<T> PublicMutable<T, PublicContext> {
/// }
/// ```
///
/// An [`only_self`](crate::macros::functions::only_self) helper that updates public state trigered by a private
/// An [`only_self`](crate::macros::functions::only_self) helper that updates public state triggered by a private
/// function:
/// ```noir
/// #[external("private")]
Expand All @@ -174,8 +175,8 @@ impl<T> PublicMutable<T, PublicContext> {
/// #[external("public")]
/// #[only_self]
/// fn _tally_vote(election_id: ElectionId, votes: u128) {
/// let current = self.storage.vote_tallies.read();
/// self.storage.vote_tallies.write(current + votes);
/// let current = self.storage.vote_tallies.at(election_id).read();
/// self.storage.vote_tallies.at(election_id).write(current + votes);
/// }
/// ```
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub contract Auth {
};

// docs:start:delayed_public_mutable_storage
// Authorizing a new address has a certain delay before it goes into effect. Set to 180 seconds which is 5 slots.
// Authorizing a new address has a certain delay before it goes into effect. Set to 180 seconds.
pub(crate) global CHANGE_AUTHORIZED_DELAY: u64 = 180;

#[storage]
Expand Down
Loading
Loading