Aztec 백서

Aztec

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 70쪽

have been renamed from "base fee" to "min fee" to better reflect their purpose. **Renamed functions:** * `getManaBaseFeeAt` → `getManaMinFeeAt` * `getManaBaseFeeComponentsAt` → `getManaMinFeeComponentsAt` **Renamed types:** * `ManaBaseFeeComponents` → `ManaMinFeeComponents` **Renamed errors:** * `Rollup__InvalidManaBaseFee` → `Rollup__InvalidManaMinFee` **Migration:** ``` - uint256 fee = rollup.getManaBaseFeeAt(timestamp, true); + uint256 fee = rollup.getManaMinFeeAt(timestamp, true); - ManaBaseFeeComponents memory components = rollup.getManaBaseFeeComponentsAt(timestamp, true); + ManaMinFeeComponents memory components = rollup.getManaMinFeeComponentsAt(timestamp, true); ``` ### \[Aztec.js] Renamed base fee to min fee[​](#aztecjs-renamed-base-fee-to-min-fee "Direct link to \[Aztec.js] Renamed base fee to min fee") The Aztec Node API method for getting current fees has been renamed: * `getCurrentBaseFees` → `getCurrentMinFees` **Migration:** ``` - const fees = await node.getCurrentBaseFees(); + const fees = await node.getCurrentMinFees(); ``` ### \[Aztec.nr] Renamed fee context methods[​](#aztecnr-renamed-fee-context-methods "Direct link to \[Aztec.nr] Renamed fee context methods") The context methods for accessing fee information have been renamed: * `context.base_fee_per_l2_gas()` → `context.min_fee_per_l2_gas()` * `context.base_fee_per_da_gas()` → `context.min_fee_per_da_gas()` **Migration:** ``` - let l2_fee = context.base_fee_per_l2_gas(); - let da_fee = context.base_fee_per_da_gas(); + let l2_fee = context.min_fee_per_l2_gas(); + let da_fee = context.min_fee_per_da_gas(); ``` ### \[Aztec.nr] Cleaning up message sender functions[​](#aztecnr-cleaning-up-message-sender-functions "Direct link to \[Aztec.nr] Cleaning up message sender functions") There has been a design decision made to have low-level API exposed on `self.context` and a nicer higher-level API exposed directly on `self`. Currently the `msg_sender` function on `self` was a copy of that same function on `self.context`. The `msg_sender` function on `self` got modified to return the message sender address directly instead of having it be wrapped in an `Option<...>`. In case the underlying message sender is none the function panics. You need to update your code to no longer trigger the unwrap on the return value: ``` - let message_sender: AztecAddress = self.msg_sender().unwrap(); + let message_sender: AztecAddress = self.msg_sender(); ``` If you want to handle the `null` case use the lower level API of context: ``` - let maybe_message_sender: Option<AztecAddress> = self.msg_sender(); + let maybe_message_sender: Option<AztecAddress> = self.context.maybe_msg_sender(); ``` The `self.context.msg_sender_unsafe` method has been dropped as its use can be replaced with the standard `self.context.maybe_msg_sender` function. ### \[Aztec.nr] Renamed message delivery options[​](#aztecnr-renamed-message-delivery-options "Direct link to \[Aztec.nr] Renamed message delivery options") The following terms have been renamed: * `MessageDelivery::UNCONSTRAINED_OFFCHAIN` -> `MessageDelivery::OFFCHAIN` * `MessageDelivery::UNCONSTRAINED_ONCHAIN` -> `MessageDelivery::ONCHAIN_UNCONSTRAINED` * `MessageDelivery::CONSTRAINED_ONCHAIN` -> `MessageDelivery::ONCHAIN_CONSTRAINED` We believe these names will better convey the meaning of the concepts. ### \[Aztec Node] changes to `getLogsByTags` endpoint[​](#aztec-node-changes-to-getlogsbytags-endpoint "Direct link to aztec-node-changes-to-getlogsbytags-endpoint") `getLogsByTags` endpoint has been optimized for our new log sync algorithm and these are the changes: * The `logsPerTag` pagination argument has been removed. Pagination was unnecessary here, since multiple logs per tag typically only occur if several devices are sending logs from the same sender to a recipient, which is unlikely to generate enough logs to require pagination. * The structure of `TxScopedL2Log` has been revised to meet the requirements of our new log sync algorithm. * The endpoint has been separated into two versions: `getPrivateLogsByTags` and `getPublicLogsByTagsFromContract`. This change was made because it was never desirable in PXE to mix public and private logs. The public version requires both a `Tag` and a contract address as input. In contrast to the private version—which uses `SiloedTag` (a tag that hashes the raw tag with the emitting contract's address)—the public version uses the raw `Tag` type, since kernels do not hash the tag with the contract address for public logs. ### \[AVM] Gas cost multipliers for public execution to reach simulation/proving parity[​](#avm-gas-cost-multipliers-for-public-execution-to-reach-simulationproving-parity "Direct link to \[AVM] Gas cost multipliers for public execution to reach simulation/proving parity") Gas costs for several AVM opcodes have been adjusted with multipliers to better align public simulation costs with actual proving costs. | Opcode | Multiplier | Previous Cost | New Cost | | ------------------- | ---------- | ------------- | -------- | | FDIV | 25x | 9 | 225 | | SLOAD | 10x | 129 | 1,290 | | SSTORE | 20x | 1,657 | 33,140 | | NOTEHASHEXISTS | 4x | 126 | 504 | | EMITNOTEHASH | 15x | 1,285 | 19,275 | | NULLIFIEREXISTS | 7x | 132 | 924 | | EMITNULLIFIER | 20x | 1,540 | 30,800 | | L1TOL2MSGEXISTS | 5x | 108 | 540 | | SENDL2TOL1MSG | 2x | 209 | 418 | | CALL | 3x | 3,312 | 9,936 | | STATICCALL | 3x | 3,312 | 9,936 | | GETCONTRACTINSTANCE | 4x | 1,527 | 6,108 | | POSEIDON2 | 15x | 24 | 360 | | ECADD | 10x | 27 | 270 | **Impact**: Contracts with public bytecode performing any of these operations will see increased gas consumption. ### \[PXE] deprecated `getNotes`[​](#pxe-deprecated-getnotes "Direct link to pxe-deprecated-getnotes") This function serves only for debugging purposes so we are taking it out of the main PXE API. If you still need to consume it, you can do so through the new `debug` sub-module. ``` - this.pxe.getNotes(filter); + this.pxe.debug.getNotes(filter); ``` ## 3.0.0-devnet.20251212[​](#300-devnet20251212 "Direct link to 3.0.0-devnet.20251212") ### \[Aztec node, archiver] Deprecated `getPrivateLogs`[​](#aztec-node-archiver-deprecated-getprivatelogs "Direct link to aztec-node-archiver-deprecated-getprivatelogs") Aztec node no longer offers a `getPrivateLogs` method. If you need to process the logs of a block, you can instead use `getBlock` and call `getPrivateLogs` on an `L2BlockNew` instance. See the diff below for before/after equivalent code samples. ``` - const logs = await aztecNode.getPrivateLogs(blockNumber, 1); + const logs = (await aztecNode.getBlock(blockNumber))?.toL2Block().getPrivateLogs(); ``` ### \[Aztec.nr] Private event emission API changes[​](#aztecnr-private-event-emission-api-changes "Direct link to \[Aztec.nr] Private event emission API changes") Private events are still emitted via the `emit` function, but this now returns an `EventMessage` type that must have `deliver_to` called on it in order to deliver the event message to the intended recipients. This allows for multiple recipients to receive the same event. ``` - self.emit(event, recipient, delivery_method) + self.emit(event).delivery(recipient, delivery_method) ``` ### \[Aztec.nr] History proof functions no longer require `storage_slot` parameter[​](#aztecnr-history-proof-functions-no-longer-require-storage_slot-parameter "Direct link to aztecnr-history-proof-functions-no-longer-require-storage_slot-parameter") The `HintedNote` struct now includes a `storage_slot` field, making it self-contained for proving note inclusion and validity. As a result, the history proof functions in the `aztec::history` module no longer require a separate `storage_slot` parameter. **Affected functions:** * `BlockHeader::prove_note_inclusion` - removed `storage_slot: Field` parameter * `BlockHeader::prove_note_validity` - removed `storage_slot: Field` parameter * `BlockHeader::prove_note_is_nullified` - removed `storage_slot: Field` parameter * `BlockHeader::prove_note_not_nullified` - removed `storage_slot: Field` parameter **Migration:** The `storage_slot` is now read from `hinted_note.storage_slot` internally. Simply remove the `storage_slot` argument from all calls to these functions: ``` let header = context.get_anchor_block_header(); - header.prove_note_inclusion(hinted_note, storage_slot); + header.prove_note_inclusion(hinted_note); let header = context.get_anchor_block_header(); - header.prove_note_validity(hinted_note, storage_slot, context); + header.prove_note_validity(hinted_note, context); let header = context.get_anchor_block_header(); - header.prove_note_is_nullified(hinted_note, storage_slot, context); + header.prove_note_is_nullified(hinted_note, context); let header = context.get_anchor_block_header(); - header.prove_note_not_nullified(hinted_note, storage_slot, context); + header.prove_note_not_nullified(hinted_note, context); ``` ### \[Aztec.nr] Note fields are now public[​](#aztecnr-note-fields-are-now-public "Direct link to \[Aztec.nr] Note fields are now public") All note struct fields are now public, and the `new()` constructor methods and getter methods have been removed. Notes should be instantiated using struct literal syntax, and fields should be accessed directly. The motivation for this change has been enshrining of randomness which lead to the `new` method being unnecessary boilerplate. **Affected notes:** * `UintNote` - `value` is now public, `new()` and `get_value()` removed * `AddressNote` - `address` is now public, `new()` and `get_address()` removed * `FieldNote` - `value` is now public, `new()` and `value()` removed **Migration:** ``` - let note = UintNote::new(100); + let note = UintNote { value: 100 }; - let value = note.get_value(); + let value = note.value; - let address_note = AddressNote::new(owner); + let address_note = AddressNote { address: owner }; - let address = address_note.get_address(); + let address = address_note.address; - let field_note = FieldNote::new(42); + let field_note = FieldNote { value: 42 }; - let value = field_note.value(); + let value = field_note.value; ``` ### \[Aztec.nr] `emit` renamed to `deliver`[​](#aztecnr-emit-renamed-to-deliver "Direct link to aztecnr-emit-renamed-to-deliver") Private state variable functions that created notes and returned their messages no longer return a `NoteEmission` but instead a `NoteMessage`. These messages are delivered to their owner via `deliver` instead of `emit`. The verb 'emit' remains for things like emitting events. ``` - self.storage.balances.at(owner).add(5).emit(owner); + self.storage.balances.at(owner).add(5).deliver(); ``` To deliver a message to a different recipient, use `deliver_to`: ``` - self.storage.balances.at(owner).add(5).emit(other); + self.storage.balances.at(owner).add(5).deliver_to(other); ``` ### \[Aztec.nr] `ValueNote` renamed to `FieldNote` and `value-note` crate renamed to `field-note`[​](#aztecnr-valuenote-renamed-to-fieldnote-and-value-note-crate-renamed-to-field-note "Direct link to aztecnr-valuenote-renamed-to-fieldnote-and-value-note-crate-renamed-to-field-note") The `ValueNote` struct has been renamed to `FieldNote` to better reflect that it stores a `Field` value. The crate has also been renamed from `value-note` to `field-note`. **Migration:** * Update your `Nargo.toml` dependencies: `value_note = { path = "..." }` → `field_note = { path = "..." }` * Update imports: `use value_note::value_note::ValueNote` → `use field_note::field_note::FieldNote` * Update type references: `ValueNote` → `FieldNote` * Update generic parameters: `PrivateSet<ValueNote, ...>` → `PrivateSet<FieldNote, ...>` ### \[Aztec.nr] New `balance-set` library for managing token balances[​](#aztecnr-new-balance-set-library-for-managing-token-balances "Direct link to aztecnr-new-balance-set-library-for-managing-token-balances") A new `balance-set` library has been created that provides `BalanceSet<Context>` for managing u128 token balances with `UintNote`. This consolidates balance management functionality that was previously duplicated across contracts. **Features:** * `add(amount: u128)` - Add to balance * `sub(amount: u128)` - Subtract from balance (with change note) * `try_sub(amount: u128, max_notes: u32)` - Attempt to subtract with configurable note limit * `balance_of()` - Get total balance (unconstrained) **Usage:** ``` use balance_set::BalanceSet; #[storage] struct Storage<Context> { balances: Owned<BalanceSet<Context>, Context>, } // In a private function: self.storage.balances.at(owner).add(amount).deliver(owner, MessageDelivery.CONSTRAINED_ONCHAIN); self.storage.balances.at(owner).sub(amount).deliver(owner, MessageDelivery.CONSTRAINED_ONCHAIN); // In an unconstrained function: let balance = self.storage.balances.at(owner).balance_of(); ``` ### \[Aztec.nr] `EasyPrivateUint` deprecated and removed[​](#aztecnr-easyprivateuint-deprecated-and-removed "Direct link to aztecnr-easyprivateuint-deprecated-and-removed") The `EasyPrivateUint` type and `easy-private-state` crate have been deprecated and removed. Use `BalanceSet` from the `balance-set` crate instead. **Migration:** * Remove `easy_private_state` dependency from `Nargo.toml` * Add `balance_set = { path = "../../../../aztec-nr/balance-set" }` to `Nargo.toml` * Update storage: `EasyPrivateUint<Context>` → `Owned<BalanceSet<Context>, Context>` * Update method calls: <!-- --> * `add(amount, owner)` → `at(owner).add(amount).deliver(owner, MessageDelivery.CONSTRAINED_ONCHAIN)` * `sub(amount, owner)` → `at(owner).sub(amount).deliver(owner, MessageDelivery.CONSTRAINED_ONCHAIN)` * `get_value(owner)` → `at(owner).balance_of()` (returns `u128` instead of `Field`) ### \[Aztec.nr] `balance_utils` removed from `value-note` (now `field-note`)[​](#aztecnr-balance_utils-removed-from-value-note-now-field-note "Direct link to aztecnr-balance_utils-removed-from-value-note-now-field-note") The `balance_utils` module has been removed from the `field-note` crate (formerly `value-note`). If you need similar functionality, implement it locally in your contract or use `BalanceSet` for u128 balances. ### \[Aztec.nr] `filter_notes_min_sum` removed from `value-note` (now `field-note`)[​](#aztecnr-filter_notes_min_sum-removed-from-value-note-now-field-note "Direct link to aztecnr-filter_notes_min_sum-removed-from-value-note-now-field-note") The `filter_notes_min_sum` function has been removed from the `field-note` crate (formerly in `value-note`). If you need this functionality, copy it to your contract locally. This function was only used in specific test contracts and doesn't belong in the general-purpose note library. ### \[Aztec.nr] `derive_ecdh_shared_secret_using_aztec_address` removed[​](#aztecnr-derive_ecdh_shared_secret_using_aztec_address-removed "Direct link to aztecnr-derive_ecdh_shared_secret_using_aztec_address-removed") This function made it annoying to deal with invalid addresses in circuits. If you were using it, replace it with `derive_ecdh_shared_secret` instead: ``` -let shared_secret = derive_ecdh_shared_secret_using_aztec_address(secret, address).unwrap(); +let shared_secret = derive_ecdh_shared_secret(secret, address.to_address_point().unwrap().inner); ``` ### \[Aztec.nr] Note owner is now enshrined[​](#aztecnr-note-owner-is-now-enshrined "Direct link to \[Aztec.nr] Note owner is now enshrined") It turns out that in all cases a note always has a logical owner. For this reason we have decided to enshrine the concept of a note owner and you should drop the field from your note: ``` #[derive(Deserialize, Eq, Packable, Serialize)] #[note] pub struct ValueNote { value: Field, - owner: AztecAddress, } ``` The owner being enshrined means that our API explicitly expects it on the input. The `NoteHash` trait got modified as follows: ``` pub trait NoteHash { fn compute_note_hash( self, + owner: AztecAddress, storage_slot: Field, randomness: Field, ) -> Field; fn compute_nullifier( self, context: &mut PrivateContext, + owner: AztecAddress, note_hash_for_nullification: Field, ) -> Field; unconstrained fn compute_nullifier_unconstrained( self, + owner: AztecAddress, note_hash_for_nullification: Field, ) -> Field; } ``` Our low-level note utilities now also accept owner as a parameter: ``` pub fn create_note<Note>( context: &mut PrivateContext, + owner: AztecAddress, storage_slot: Field, note: Note, ) -> NoteEmission<Note> where Note: NoteType + NoteHash + Packable, { ... } ``` Signature of some functions like `destroy_note_unsafe` is unchanged: ``` pub fn destroy_note_unsafe<Note>( context: &mut PrivateContext, hinted_note: HintedNote<Note>, note_hash_read: NoteHashRead, ) where Note: NoteHash, { ... } ``` because `HintedNote` now contains owner. `PrivateImmutable`, `PrivateMutable` and `PrivateSet` got modified to directly contain the owner instead of implicitly "containing it" by including it in the storage slot via a `Map`. These state variables now implement a newly introduced `OwnedStateVariable` trait (see docs of `OwnedStateVariable` for explanation of what it is). These changes make the state variables incompatible with `Map` and now instead these should be wrapped in new `Owned` state variable: ``` #[storage] struct Storage<Context> { - private_nfts: Map<AztecAddress, PrivateSet<NFTNote, Context>, Context>, + private_nfts: Owned<PrivateSet<NFTNote, Context>, Context>, } ``` Note that even though the types of your state variables are changing from `Map<AztecAddress, T, Context>` to `Owned<T, Context>`, usage remains unchanged: ``` let nft_notes = self.storage.private_nfts.at(from).pop_notes(NoteGetterOptions::new().select(NFTNote::properties().token_id, Comparator.EQ, token_id).set_limit(1)); ``` With this change the underlying notes will inherit the storage slot of the `Owned` state variable. This is unlike `Map` where the nested state variable got the storage slot computed as `hash([map_storage_slot, key])`. if you had `PrivateImmutable` or `PrivateMutable` defined out of a `Map`, e.g.: ``` #[storage] struct Storage<Context> { signing_public_key: PrivateImmutable<PublicKeyNote, Context>, } ``` you were most likely dealing with some kind of admin flow where only the admin can modify the state variable. Now, unfortunately, there is a bit of a regression and you will need to wrap the state variable in `Owned` and call `at` on the state var: ``` + use aztec::state_vars::Owned; #[storage] struct Storage<Context> { - signing_public_key: PrivateImmutable<PublicKeyNote, Context>, + signing_public_key: Owned<PrivateImmutable<PublicKeyNote, Context>, Context>, } #[external("private")] fn my_external_function() { - self.storage.signing_public_key.initialize(pub_key_note) + self.storage.signing_public_key.at(self.address).initialize(pub_key_note) .emit(self.address, MessageDelivery.CONSTRAINED_ONCHAIN); } ``` We are likely to come up with a concept of admin state variables in the future. None of the reference notes now contain the owner so if you manually construct `AddressNote`, `UintNote` or `ValueNote` you need to update the call to `new` method: ``` - let note = UintNote::new(156, owner); + let note = UintNote::new(156); ``` ### \[Aztec.nr] Note randomness is now handled internally[​](#aztecnr-note-randomness-is-now-handled-internally "Direct link to \[Aztec.nr] Note randomness is now handled internally") In order to prevent pre-image attacks, it is necessary to inject randomness to notes. Aztec.nr users were previously expected to add said randomness to their custom note types. From now on, Aztec.nr takes care of handling randomness as built-in note metadata, making it impossible to miss for library users. This change breaks backwards compatibility as we'll discuss below. #### Changes to Aztec.nr note types[​](#changes-to-aztecnr-n
프로젝트로 돌아가기