Aztec 백서

Aztec

원문

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

: ${metadata.txHash}`); console.log(` Contract: ${metadata.contractAddress}`); } ``` ### \[Aztec.nr] `nophasecheck` renamed as `allow_phase_change`[​](#aztecnr-nophasecheck-renamed-as-allow_phase_change "Direct link to aztecnr-nophasecheck-renamed-as-allow_phase_change") ### \[AztecNode] Removed sibling path RPC methods[​](#aztecnode-removed-sibling-path-rpc-methods "Direct link to \[AztecNode] Removed sibling path RPC methods") The following methods have been removed from the `AztecNode` interface: * `getNullifierSiblingPath` * `getNoteHashSiblingPath` * `getArchiveSiblingPath` * `getPublicDataSiblingPath` These methods were not used by PXE and returned a subset of the information already available through the corresponding membership witness methods: | Removed Method | Use Instead | | -------------------------- | ------------------------------- | | `getNullifierSiblingPath` | `getNullifierMembershipWitness` | | `getNoteHashSiblingPath` | `getNoteHashMembershipWitness` | | `getArchiveSiblingPath` | `getBlockHashMembershipWitness` | | `getPublicDataSiblingPath` | `getPublicDataWitness` | The membership witness methods return both the sibling path and additional context (leaf index, preimage data) needed for proofs. ### \[Protocol] "Nullifier secret key" renamed to "nullifier hiding key" (nsk → nhk)[​](#protocol-nullifier-secret-key-renamed-to-nullifier-hiding-key-nsk--nhk "Direct link to \[Protocol] \"Nullifier secret key\" renamed to \"nullifier hiding key\" (nsk → nhk)") The nullifier secret key (`nsk_m` / `nsk_app`) has been renamed to nullifier hiding key (`nhk_m` / `nhk_app`). This is a protocol-breaking change: the domain separator string changes from `"az_nsk_m"` to `"az_nhk_m"`, producing a different constant value. **Noir changes:** ``` - context.request_nsk_app(npk_m_hash) + context.request_nhk_app(npk_m_hash) - get_nsk_app(npk_m_hash) + get_nhk_app(npk_m_hash) ``` **TypeScript changes:** ``` - import { computeAppNullifierSecretKey, deriveMasterNullifierSecretKey } from '@aztec/stdlib/keys'; + import { computeAppNullifierHidingKey, deriveMasterNullifierHidingKey } from '@aztec/stdlib/keys'; - const masterNullifierSecretKey = deriveMasterNullifierSecretKey(secret); + const masterNullifierHidingKey = deriveMasterNullifierHidingKey(secret); - const nskApp = await computeAppNullifierSecretKey(masterNullifierSecretKey, contractAddress); + const nhkApp = await computeAppNullifierHidingKey(masterNullifierHidingKey, contractAddress); ``` The `GeneratorIndex.NSK_M` enum member is now `GeneratorIndex.NHK_M`. ### \[AztecNode/Aztec.nr] `getArchiveMembershipWitness` renamed to `getBlockHashMembershipWitness`[​](#aztecnodeaztecnr-getarchivemembershipwitness-renamed-to-getblockhashmembershipwitness "Direct link to aztecnodeaztecnr-getarchivemembershipwitness-renamed-to-getblockhashmembershipwitness") The `getArchiveMembershipWitness` method has been renamed to `getBlockHashMembershipWitness` to better reflect its purpose. Block hashes are the leaves of the archive tree - each time a new block is added to the chain, its block hash is appended as a new leaf. This rename clarifies that the method finds a membership witness for a block hash in the archive tree. **TypeScript (AztecNode interface):** ``` - const witness = await aztecNode.getArchiveMembershipWitness(blockNumber, archiveLeaf); + const witness = await aztecNode.getBlockHashMembershipWitness(blockNumber, blockHash); ``` The second parameter type has also changed from `Fr` to `BlockHash`. **Noir (aztec-nr):** ``` - use dep::aztec::oracle::get_membership_witness::get_archive_membership_witness; + use dep::aztec::oracle::get_membership_witness::get_block_hash_membership_witness; - let witness = get_archive_membership_witness(block_header, leaf_value); + let witness = get_block_hash_membership_witness(anchor_block_header, block_hash); ``` ### \[Aztec.nr] `protocol_types` renamed to `protocol`[​](#aztecnr-protocol_types-renamed-to-protocol "Direct link to aztecnr-protocol_types-renamed-to-protocol") The `protocol_types` re-export from the `aztec` crate has been renamed to `protocol`. Update all imports accordingly: ``` - use dep::aztec::protocol_types::address::AztecAddress; + use dep::aztec::protocol::address::AztecAddress; ``` ### Protocol contract interface separate from protocol contracts[​](#protocol-contract-interface-separate-from-protocol-contracts "Direct link to Protocol contract interface separate from protocol contracts") We've stripped protocol contract of `aztec-nr` macros in order for auditors to not need to audit them (protocol contracts are to be audited during the protocol circuits audit). This results in the nice Noir interface no longer being generated. For context, this is the interface I am talking about: ``` let update_delay = self.view(MyContract::at(my_contract_address).my_fn()); ``` where the macros generate the `MyContract` struct. For this reason we've created place holder protocol contracts in `noir-projects/noir-contracts/contracts/protocol_interface` that still have these macros applied and hence you can use them to get the interface. On your side all you need to do is update the dependency in `Nargo.toml`: ``` -instance_contract = { path = "../../protocol/contract_instance_registry" } +instance_contract = { path = "../../protocol_interface/contract_instance_registry_interface" } ``` ### \[aztec-nr] History module refactored to use standalone functions[​](#aztec-nr-history-module-refactored-to-use-standalone-functions "Direct link to \[aztec-nr] History module refactored to use standalone functions") The `aztec::history` module has been refactored to use standalone functions instead of traits. This changes the calling convention from method syntax to function syntax. ``` - use dep::aztec::history::note_inclusion::ProveNoteInclusion; + use dep::aztec::history::note::assert_note_existed_by; let block_header = context.get_anchor_block_header(); - let confirmed_note = block_header.prove_note_inclusion(hinted_note); + let confirmed_note = assert_note_existed_by(block_header, hinted_note); ``` **Function name and module mapping:** | Old (trait method) | New (standalone function) | | ----------------------------------------------------------------- | -------------------------------------------------------------------- | | `history::note_inclusion::prove_note_inclusion` | `history::note::assert_note_existed_by` | | `history::note_validity::prove_note_validity` | `history::note::assert_note_was_valid_by` | | `history::nullifier_inclusion::prove_nullifier_inclusion` | `history::nullifier::assert_nullifier_existed_by` | | `history::nullifier_inclusion::prove_note_is_nullified` | `history::note::assert_note_was_nullified_by` | | `history::nullifier_non_inclusion::prove_nullifier_non_inclusion` | `history::nullifier::assert_nullifier_did_not_exist_by` | | `history::nullifier_non_inclusion::prove_note_not_nullified` | `history::note::assert_note_was_not_nullified_by` | | `history::contract_inclusion::prove_contract_deployment` | `history::deployment::assert_contract_bytecode_was_published_by` | | `history::contract_inclusion::prove_contract_non_deployment` | `history::deployment::assert_contract_bytecode_was_not_published_by` | | `history::contract_inclusion::prove_contract_initialization` | `history::deployment::assert_contract_was_initialized_by` | | `history::contract_inclusion::prove_contract_non_initialization` | `history::deployment::assert_contract_was_not_initialized_by` | | `history::public_storage::public_storage_historical_read` | `history::storage::public_storage_historical_read` | ### \[Aztec.js] Transaction sending API redesign[​](#aztecjs-transaction-sending-api-redesign "Direct link to \[Aztec.js] Transaction sending API redesign") The old chained `.send().wait()` pattern has been replaced with a single `.send(options)` call that handles both sending and waiting. ``` + import { Contract, NO_WAIT } from '@aztec/aztec.js/contracts'; - const receipt = await contract.methods.transfer(recipient, amount).send().wait(); // Send now waits by default + const receipt = await contract.methods.transfer(recipient, amount).send({ from: sender }); // getTxHash() would confusingly send the transaction too - const txHash = await contract.methods.transfer(recipient, amount).send().getTxHash(); // NO_WAIT to send the transaction and return TxHash immediately + const txHash = await contract.methods.transfer(recipient, amount).send({ + from: sender, + wait: NO_WAIT + }); ``` #### Deployment changes[​](#deployment-changes "Direct link to Deployment changes") The old `.send().deployed()` method has been removed. Deployments now return the contract instance by default, or you can request the full receipt with `returnReceipt: true`: ``` - const contract = await MyContract.deploy(wallet, ...args).send().deployed(); - const { contract, instance } = await MyContract.deploy(wallet, ...args).send().wait(); + const contract = await MyContract.deploy(wallet, ...args).send({ from: deployer }); + const { contract, instance } = await MyContract.deploy(wallet, ...args).send({ + from: deployer, + wait: { returnReceipt: true }, + }); ``` #### Breaking changes to `Wallet` interface[​](#breaking-changes-to-wallet-interface "Direct link to breaking-changes-to-wallet-interface") `getTxReceipt()` has been removed from the interface. `sendTx` method signature has changed to support the new wait behavior: ``` - sendTx(payload: ExecutionPayload, options: SendOptions): Promise<TxReceipt> + sendTx<W extends InteractionWaitOptions = undefined>( + payload: ExecutionPayload, + options: SendOptions<W> + ): Promise<SendReturn<W>> ``` #### Manual waiting with `waitForTx`[​](#manual-waiting-with-waitfortx "Direct link to manual-waiting-with-waitfortx") When using `NO_WAIT` to send transactions, you can manually wait for confirmation using the `waitForTx` utility: ``` import { waitForTx } from "@aztec/aztec.js/node"; const txHash = await contract.methods.transfer(recipient, amount).send({ from: sender, wait: NO_WAIT, }); const receipt = await waitForTx(node, txHash, { timeout: 60000, // Optional: timeout in ms interval: 1000, // Optional: polling interval in ms dontThrowOnRevert: true, // Optional: return receipt even if tx reverted }); ``` ### \[aztec-nr] Removal of intermediate modules[​](#aztec-nr-removal-of-intermediate-modules "Direct link to \[aztec-nr] Removal of intermediate modules") Lots of unnecessary modules have been removed from the API, making imports shorter. These are the modules that contain just a single struct, in which the module has the same name as the struct. ``` - use aztec::state_vars::private_mutable::PrivateMutable; + use aztec::state_vars::PrivateMutable; ``` Affected structs include all state variables, notes, contexts, messages, etc. ### \[L1 Contracts] Fee asset pricing direction inverted[​](#l1-contracts-fee-asset-pricing-direction-inverted "Direct link to \[L1 Contracts] Fee asset pricing direction inverted") The fee model now uses `ethPerFeeAsset` instead of the previous `feeAssetPerEth`. This change inverts how the exchange rate is represented: values now express how much ETH one fee asset (AZTEC) is worth, with 1e12 precision. **Key changes:** * `FeeHeader.feeAssetPerEth` → `FeeHeader.ethPerFeeAsset` * `RollupConfigInput` now requires `initialEthPerFeeAsset` parameter at deployment * Default value: `1e7` (0.00001 ETH per AZTEC) * Valid range: `100` (1e-10 ETH/AZTEC) to `1e11` (0.1 ETH/AZTEC) **New environment variable for node operators:** * `AZTEC_INITIAL_ETH_PER_FEE_ASSET` - Sets the initial ETH per fee asset price with 1e12 precision ### \[L1 Contracts] Fee asset price modifier now in basis points[​](#l1-contracts-fee-asset-price-modifier-now-in-basis-points "Direct link to \[L1 Contracts] Fee asset price modifier now in basis points") The `OracleInput.feeAssetPriceModifier` field now expects values in basis points (BPS) instead of the previous representation. The modifier is applied as a percentage change to the ETH/AZTEC price each checkpoint. **Key changes:** * Valid range: `-100` to `+100` BPS (±1% max change per checkpoint) * A value of `+100` increases the price by 1%, `-100` decreases by 1% * Validated by `MAX_FEE_ASSET_PRICE_MODIFIER_BPS = 100` ### \[Aztec.js] Wallet batching now supports all methods[​](#aztecjs-wallet-batching-now-supports-all-methods "Direct link to \[Aztec.js] Wallet batching now supports all methods") The `BatchedMethod` type is now a discriminated union that ensures type safety: the `args` must match the specific method `name`. This prevents runtime errors from mismatched arguments. ``` - // Before: Only 5 methods could be batched - const results = await wallet.batch([ - { name: "registerSender", args: [address, "alias"] }, - { name: "sendTx", args: [payload, options] }, - ]); + // After: All methods can be batched + const results = await wallet.batch([ + { name: "getChainInfo", args: [] }, + { name: "getContractMetadata", args: [contractAddress] }, + { name: "registerSender", args: [address, "alias"] }, + { name: "simulateTx", args: [payload, options] }, + { name: "sendTx", args: [payload, options] }, + ]); ``` ### \[Aztec.js] Refactored `getContractMetadata` and `getContractClassMetadata` in Wallet[​](#aztecjs-refactored-getcontractmetadata-and-getcontractclassmetadata-in-wallet "Direct link to aztecjs-refactored-getcontractmetadata-and-getcontractclassmetadata-in-wallet") The contract metadata methods in the `Wallet` interface have been refactored to provide more granular information and avoid expensive round-trips. **`ContractMetadata`:** ``` { - contractInstance?: ContractInstanceWithAddress, + instance?: ContractInstanceWithAddress; // Instance registered in the Wallet, if any isContractInitialized: boolean; // Is the init nullifier onchain? (already there) isContractPublished: boolean; // Has the contract been published? (already there) + isContractUpdated: boolean; // Has the contract been updated? + updatedContractClassId?: Fr; // If updated, the new class ID } ``` **`ContractClassMetadata`:** This method loses the ability to request the contract artifact via the `includeArtifact` flag ``` { - contractClass?: ContractClassWithId; - artifact?: ContractArtifact; isContractClassPubliclyRegistered: boolean; // Is the class registered onchain? + isArtifactRegistered: boolean; // Does the Wallet know about this artifact? } ``` * Removes expensive artifact/class transfers between wallet and app * Separates PXE storage info (`instance`, `isArtifactRegistered`) from public chain info (`isContractPublished`, `isContractClassPubliclyRegistered`) * Makes it easier to determine if actions like `registerContract` are needed ### \[Aztec.js] Removed `UnsafeContract` and protocol contract helper functions[​](#aztecjs-removed-unsafecontract-and-protocol-contract-helper-functions "Direct link to aztecjs-removed-unsafecontract-and-protocol-contract-helper-functions") The `UnsafeContract` class and async helper functions (`getFeeJuice`, `getClassRegistryContract`, `getInstanceRegistryContract`) have been removed. Protocol contracts are now accessed via auto-generated type-safe wrappers with only the ABI (no bytecode). Since PXE always has protocol contract artifacts available, importing and using these contracts from `aztec.js` is very lightweight and follows the same pattern as regular user contracts. **Migration:** ``` - import { getFeeJuice, getClassRegistryContract, getInstanceRegistryContract } from '@aztec/aztec.js/contracts'; + import { FeeJuiceContract, ContractClassRegistryContract, ContractInstanceRegistryContract } from '@aztec/aztec.js/protocol'; - const feeJuice = await getFeeJuice(wallet); + const feeJuice = FeeJuiceContract.at(wallet); await feeJuice.methods.check_balance(feeLimit).send().wait(); - const classRegistry = await getClassRegistryContract(wallet); + const classRegistry = ContractClassRegistryContract.at(wallet); await classRegistry.methods.publish(...).send().wait(); - const instanceRegistry = await getInstanceRegistryContract(wallet); + const instanceRegistry = ContractInstanceRegistryContract.at(wallet); await instanceRegistry.methods.publish_for_public_execution(...).send().wait(); ``` **Note:** The higher-level utilities like `publishInstance`, `publishContractClass`, and `broadcastPrivateFunction` from `@aztec/aztec.js/deployment` are still available and unchanged. These utilities use the new wrappers internally. ### \[Aztec.nr] Renamed Router contract[​](#aztecnr-renamed-router-contract "Direct link to \[Aztec.nr] Renamed Router contract") `Router` contract has been renamed as `PublicChecks` contract. The name of the contract became stale as its use changed from routing public calls through it to simply having public functions that can be called by anyone. Having these "standard checks" on one contract results in a potentially large privacy set for apps that use it. ### \[Aztec Node] `getBlockByHash` and `getBlockHeaderByHash` removed[​](#aztec-node-getblockbyhash-and-getblockheaderbyhash-removed "Direct link to aztec-node-getblockbyhash-and-getblockheaderbyhash-removed") The `getBlockByHash` and `getBlockHeaderByHash` methods have been removed. Use `getBlock` and `getBlockHeader` with a block hash instead. **Migration:** ``` - const block = await node.getBlockByHash(blockHash); + const block = await node.getBlock(blockHash); - const header = await node.getBlockHeaderByHash(blockHash); + const header = await node.getBlockHeader(blockHash); ``` ### \[Aztec.nr] Oracle functions now take `BlockHeader` instead of block number[​](#aztecnr-oracle-functions-now-take-blockheader-instead-of-block-number "Direct link to aztecnr-oracle-functions-now-take-blockheader-instead-of-block-number") The low-level oracle functions for fetching membership witnesses and storage now take a `BlockHeader` instead of a `block_number: u32`. This change improves type safety and ensures the correct block state is queried. **Affected functions:** * `get_note_hash_membership_witness(block_header, leaf_value)` - was `(block_number, leaf_value)` * `get_archive_membership_witness(block_header, leaf_value)` - was `(block_number, leaf_value)` * `get_nullifier_membership_witness(block_header, nullifier)` - was `(block_number, nullifier)` * `get_low_nullifier_membership_witness(block_header, nullifier)` - was `(block_number, nullifier)` * `get_public_data_witness(block_header, public_data_tree_index)` - was `(block_number, public_data_tree_index)` * `storage_read(block_header, address, storage_slot)` - was `(address, storage_slot, block_number)` **Migration:** If you were calling these oracle functions directly (which is uncommon), update your code to pass a `BlockHeader` instead of a block number: ``` - let witness = get_note_hash_membership_witness(self.global_variables.block_number, note_hash); + let witness = get_note_hash_membership_witness(self, note_hash); - let witness = get_nullifier_membership_witness(block_number, nullifier); + let witness = get_nullifier_membership_witness(block_header, nullifier); - let value: T = storage_read(address, slot, block_number); + let value: T = storage_read(block_header, address, slot); ``` Note: The high-level history proof functions on `BlockHeader` (such as `prove_note_inclusion`, `prove_nullifier_inclusion`, etc.) are **not affected** by this change. They continue to work the same way. ### \[Toolchain] Node.js upgraded to v24[​](#toolchain-nodejs-upgraded-to-v24 "Direct link to \[Toolchain] Node.js upgraded to v24") Node.js minimum version changed from v22 to v24.12.0. ### \[L1 Contracts] Renamed base fee to min fee[​](#l1-contracts-renamed-base-fee-to-min-fee "Direct link to \[L1 Contracts] Renamed base fee to min fee") The L1 rollup contract functions and types related to fee calculation
프로젝트로 돌아가기