bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 74쪽
placed
let auth = Auth::at(auth_contract_address);
assert_eq(env.view_public(auth.get_authorized()), AztecAddress::zero()); // .view_public() instead of .public()
}
#[test(should_fail_with = "caller is not admin")]
unconstrained fn non_admin_cannot_set_unauthorized() {
let mut env = TestEnvironment::new();
let admin = env.create_light_account();
let other = env.create_light_account();
let auth_contract_address =
env.deploy("Auth").with_public_initializer(admin, Auth::interface().constructor(admin)); // deploy_self replaced
let auth = Auth::at(auth_contract_address);
env.call_public(other, auth.set_authorized(other)); // .call_public(), should_fail_with
}
```
## \[Aztec.js][](#aztecjs-1 "Direct link to \[Aztec.js]")
### Cheatcodes[](#cheatcodes "Direct link to Cheatcodes")
Cheatcodes where moved out of the `@aztec/aztec.js` package to `@aztec/ethereum` and `@aztec/aztec` packages. While all of the cheatcodes can be imported from the `@aztec/aztec` package `EthCheatCodes` and `RollupCheatCodes` reside in `@aztec/ethereum` package and if you need only those importing only that package should result in a lighter build.
### Note exports dropped from artifact[](#note-exports-dropped-from-artifact "Direct link to Note exports dropped from artifact")
Notes are no longer exported in the contract artifact. Exporting notes was technical debt from when we needed to interpret notes in TypeScript.
The following code will no longer work since `notes` is no longer available on the artifact:
```
const valueNoteTypeId = StatefulTestContractArtifact.notes['ValueNote'].id;
```
## \[core protocol, Aztec.nr, Aztec.js] Max block number property changed to be seconds based[](#core-protocol-aztecnr-aztecjs-max-block-number-property-changed-to-be-seconds-based "Direct link to \[core protocol, Aztec.nr, Aztec.js] Max block number property changed to be seconds based")
### `max_block_number` -> `include_by_timestamp`[](#max_block_number---include_by_timestamp "Direct link to max_block_number---include_by_timestamp")
The transaction expiration mechanism has been updated to use seconds rather than number of blocks. As part of this change, the transaction property `max_block_number` has been renamed to `include_by_timestamp`.
This change significantly impacts the `SharedMutable` state variable in `Aztec.nr`, which now operates on a seconds instead of number of blocks. If your contract uses `SharedMutable`, you'll need to:
1. Update the `INITIAL_DELAY` numeric generic to use seconds instead of blocks
2. Modify any related logic to account for timestamp-based timing
3. Note that timestamps use `u64` values while block numbers use `u32`
### Removed `prelude`, so your `dep::aztec::prelude::...` imports will need to be amended.[](#removed-prelude-so-your-depaztecprelude-imports-will-need-to-be-amended "Direct link to removed-prelude-so-your-depaztecprelude-imports-will-need-to-be-amended")
Instead of importing common types from `dep::aztec::prelude...`, you'll now need to import them from their lower-level locations. The Noir Language Server vscode extension is now capable of autocompleting imports: just type some of the import and press 'tab' when it pops up with the correct item, and the import will be inserted at the top of the file.
As a quick reference, here are the paths to the types that were previously in the `prelude`. So, for example, if you were previously using `dep::aztec::prelude::AztecAddress`, you'll need to replace it with `dep::aztec::protocol::address::AztecAddress`. Apologies for any pain this brings. The reasoning is that these types were somewhat arbitrary, and it was unclear which types were worthy enough to be included here.
```
use dep::aztec::{
context::{PrivateCallInterface, PrivateContext, PublicContext, UtilityContext, ReturnsHash},
note::{
note_getter_options::NoteGetterOptions,
note_interface::{NoteHash, NoteType},
note_viewer_options::NoteViewerOptions,
hinted_note::HintedNote,
},
state_vars::{
map::Map, private_immutable::PrivateImmutable, private_mutable::PrivateMutable,
private_set::PrivateSet, public_immutable::PublicImmutable, public_mutable::PublicMutable,
shared_mutable::SharedMutable,
},
};
use dep::aztec::protocol::{
abis::function_selector::FunctionSelector,
address::{AztecAddress, EthAddress},
point::Point,
traits::{Deserialize, Serialize},
};
```
### `include_by_timestamp` is now mandatory[](#include_by_timestamp-is-now-mandatory "Direct link to include_by_timestamp-is-now-mandatory")
Each transaction must now include a valid `include_by_timestamp` that satisfies the following conditions:
* It must be greater than the historical block’s timestamp.
* The duration between the `include_by_timestamp` and the historical block’s timestamp must not exceed the maximum allowed (currently 24 hours).
* It must be greater than or equal to the timestamp of the block in which the transaction is included.
The protocol circuits compute the `include_by_timestamp` for contract updates during each private function iteration. If a contract does not explicitly specify a value, the default will be the maximum allowed duration. This ensures that `include_by_timestamp` is never left unset.
No client-side changes are required. However, please note that transactions now have a maximum lifespan of 24 hours and will be removed from the transaction pool once expired.
## 0.88.0[](#0880 "Direct link to 0.88.0")
## \[Aztec.nr] Deprecation of the `authwit` library[](#aztecnr-deprecation-of-the-authwit-library "Direct link to aztecnr-deprecation-of-the-authwit-library")
It is now included in `aztec-nr`, so imports must be updated:
```
-dep::authwit::...
+dep::aztec::authwit...
```
and stale dependencies removed from `Nargo.toml`
```
-authwit = { path = "../../../../aztec-nr/authwit" }
```
## 0.87.0[](#0870 "Direct link to 0.87.0")
## \[Aztec.js/TS libraries][](#aztecjsts-libraries "Direct link to \[Aztec.js/TS libraries]")
We've bumped our minimum supported node version to v20, as v18 is now EOL. As a consequence, the deprecated type assertion syntax has been replaced with modern import attributes whenever contract artifact JSONs are loaded:
```
-import ArtifactJson from '../artifacts/contract-Contract.json' assert { type: 'json' };
+import ArtifactJson from '../artifacts/contract-Contract.json' with { type: 'json' };
```
## \[Aztec.js/PXE] `simulateUtility` return type[](#aztecjspxe-simulateutility-return-type "Direct link to aztecjspxe-simulateutility-return-type")
`pxe.simulateUtility()` now returns a complex object (much like `.simulateTx()`) so extra information can be provided such as simulation timings.
This information can be accessed setting the `includeMetadata` flag in `SimulateMethodOptions` to `true`, but not providing it (which is the default) will NOT change the behavior of the current code.
```
-const result = await pxe.simulateUtility(...);
+const { meta, result } = await pxe.simulateUtility(...);
const result = await Contract.methods.myFunction(...).simulate();
const { result, meta} = await Contract.methods.myFunction(...).simulate({ includeMetadata: true });
```
## \[Aztec.js] Removed mandatory simulation before proving in contract interfaces[](#aztecjs-removed-mandatory-simulation-before-proving-in-contract-interfaces "Direct link to \[Aztec.js] Removed mandatory simulation before proving in contract interfaces")
Previously, our autogenerated contract classes would perform a simulation when calling `.prove` or `.send` on them. This could potentially catch errors earlier, but took away control from the app/wallets on how to handle network interactions. Now this process has to be triggered manually, which means just proving an interaction (or proving and sending it to the network in one go via `.send`) is much faster.
*WARNING:* This means users can incurr in network fees if a transaction that would otherwise be invalid is sent without sanity checks. To ensure this, it is recommended to do:
```
+await Contract.method.simulate();
await Contract.method.send().wait();
```
## 0.86.0[](#0860 "Direct link to 0.86.0")
### \[PXE] Removed PXE\_L2\_STARTING\_BLOCK environment variable[](#pxe-removed-pxe_l2_starting_block-environment-variable "Direct link to \[PXE] Removed PXE_L2_STARTING_BLOCK environment variable")
PXE now fast-syncs by skipping finalized blocks and never downloads all blocks, so there is no longer a need to specify a starting block.
### \[Aztec.nr] Logs and messages renaming[](#aztecnr-logs-and-messages-renaming "Direct link to \[Aztec.nr] Logs and messages renaming")
The following renamings have taken place:
* `encrypted_logs` to `messages`: this module now handles much more than just encrypted logs (including unconstrained message delivery, message encoding, etc.)
* `log_assembly_strategies` to `logs`
* `discovery` moved to `messages`: given that what is discovered are messages
* `default_aes128` removed
Most contracts barely used these modules directly. The frequently used `encode_and_encrypt` function imports remain unchanged:
```
use dep::aztec::messages::logs::note::encode_and_encrypt_note;
```
### \[noir-contracts] Reference Noir contracts directory structure change[](#noir-contracts-reference-noir-contracts-directory-structure-change "Direct link to \[noir-contracts] Reference Noir contracts directory structure change")
`noir-projects/noir-contracts/contracts` directory became too cluttered so we grouped contracts into `account`, `app`, `docs`, `fees`, `libs`, `protocol` and `test` dirs. If you import contract from the directory make sure to update the paths accordingly. E.g. for a token contract:
```
#[dependencies]
-token = { git = "https://github.com/aztec-labs-eng/aztec-node/", tag = "v0.83.0", directory = "noir-projects/noir-contracts/contracts/src/token_contract" }
+token = { git = "https://github.com/aztec-labs-eng/aztec-node/", tag = "v0.83.0", directory = "noir-projects/noir-contracts/contracts/app/src/token_contract" }
```
### \[Aztec.nr] #\[utility] contract functions[](#aztecnr-utility-contract-functions "Direct link to \[Aztec.nr] #\[utility] contract functions")
Aztec contracts have three kinds of functions: `#[private]`, `#[public]` and what was sometimes called 'top-level unconstrained': an unmarked unconstrained function in the contract module. These are now called `[#utility]` functions, and must be explicitly marked as such:
```
+ #[utility]
unconstrained fn balance_of_private(owner: AztecAddress) -> u128 {
storage.balances.at(owner).balance_of()
}
```
Utility functions are standalone unconstrained functions that cannot be called from private or public functions: they are meant to be called by *applications* to perform auxiliary tasks: query contract state (e.g. a token balance), process messages received offchain, etc.
All functions in a `contract` block must now be marked as one of either `#[private]`, `#[public]`, `#[utility]`, `#[contract_library_method]`, or `#[test]`.
Additionally, the `UnconstrainedContext` type has been renamed to `UtilityContext`. This led us to rename the `unkonstrained` method on `TestEnvironment` to `utility`, so any tests using it also need updating:
```
- SharedMutable::new(env.unkonstrained(), storage_slot)
+ SharedMutable::new(env.utility(), storage_slot)
```
### \[AuthRegistry] function name change[](#authregistry-function-name-change "Direct link to \[AuthRegistry] function name change")
As part of the broader transition from "top-level unconstrained" to "utility" name (detailed in the note above), the `unconstrained_is_consumable` function in AuthRegistry has been renamed to `utility_is_consumable`. The function's signature and behavior remain unchanged - only the name has been updated to align with the new convention. If you're currently using this function, a simple rename in your code will suffice.
## 0.83.0[](#0830 "Direct link to 0.83.0")
### \[aztec.js] AztecNode.getPrivateEvents API change[](#aztecjs-aztecnodegetprivateevents-api-change "Direct link to \[aztec.js] AztecNode.getPrivateEvents API change")
The `getPrivateEvents` method signature has changed to require an address of a contract that emitted the event and use recipient addresses instead of viewing public keys:
```
- const events = await wallet.getPrivateEvents<Transfer>(TokenContract.events.Transfer, 1, 1, [recipient.getCompleteAddress().publicKeys.masterIncomingViewingPublicKey()]);
+ const events = await wallet.getPrivateEvents<Transfer>(token.address, TokenContract.events.Transfer, 1, 1, [recipient.getAddress()]);
```
### \[portal contracts] Versions and Non-following message boxes[](#portal-contracts-versions-and-non-following-message-boxes "Direct link to \[portal contracts] Versions and Non-following message boxes")
The version number is no longer hard-coded to be `1` across all deployments (it not depends on where it is deployed to and with what genesis and logic). This means that if your portal were hard-coding `1` it will now fail when inserting into the `inbox` or consuming from the `outbox` because of a version mismatch. Instead you can get the real version (which don't change for a deployment) by reading the `VERSION` on inbox and outbox, or using `getVersion()` on the rollup.
New Deployments of the protocol do not preserve former state/across each other. This means that after a new deployment, any "portal" following the registry would try to send messages into this empty rollup to non-existent contracts. To solve, the portal should be linked to a specific deployment, e.g., a specific inbox. This can be done by storing the inbox/outbox/version at the time of deployment or initialize and not update them.
Both of these issues were in the token portal and the uniswap portal, so if you used them as a template it is very likely that you will also have it.
## 0.82.0[](#0820 "Direct link to 0.82.0")
### \[aztec.js] AztecNode.findLeavesIndexes returns indexes with block metadata[](#aztecjs-aztecnodefindleavesindexes-returns-indexes-with-block-metadata "Direct link to \[aztec.js] AztecNode.findLeavesIndexes returns indexes with block metadata")
It's common that we need block metadata of a block in which leaves were inserted when querying indexes of these tree leaves. For this reason we now return that information along with the indexes. This allows us to reduce the number of individual AztecNode queries.
Along with this change, `findNullifiersIndexesWithBlock` and `findBlockNumbersForIndexes` functions were removed as all their uses can now be replaced with the newly modified `findLeavesIndexes` function.
### \[aztec.js] AztecNode.getPublicDataTreeWitness renamed as AztecNode.getPublicDataWitness[](#aztecjs-aztecnodegetpublicdatatreewitness-renamed-as-aztecnodegetpublicdatawitness "Direct link to \[aztec.js] AztecNode.getPublicDataTreeWitness renamed as AztecNode.getPublicDataWitness")
This change was done to have consistent naming across codebase.
### \[aztec.js] Wallet interface and Authwit management[](#aztecjs-wallet-interface-and-authwit-management "Direct link to \[aztec.js] Wallet interface and Authwit management")
The `Wallet` interface in `aztec.js` is undergoing transformations, trying to be friendlier to wallet builders and reducing the surface of its API. This means `Wallet` no longer extends `PXE`, and instead just implements a subset of the methods of the former. This is NOT going to be its final form, but paves the way towards better interfaces and starts to clarify what the responsibilities of the wallet are:
```
/**
* The wallet interface.
*/
export type Wallet = AccountInterface &
Pick<
PXE,
// Simulation
| "simulateTx"
| "simulateUnconstrained"
| "profileTx"
// Sending
| "sendTx"
// Contract management (will probably be collapsed in the future to avoid instance and class versions)
| "getContractClassMetadata"
| "getContractMetadata"
| "registerContract"
| "registerContractClass"
// Likely to be removed
| "proveTx"
// Will probably be collapsed
| "getNodeInfo"
| "getPXEInfo"
// Fee info
| "getCurrentMinFees"
// Still undecided, kept for the time being
| "updateContract"
// Sender management
| "registerSender"
| "getSenders"
| "removeSender"
// Tx status
| "getTxReceipt"
// Events. Kept since events are going to be reworked and changes will come when that's done
| "getPrivateEvents"
| "getPublicEvents"
> & {
createAuthWit(intent: IntentInnerHash | IntentAction): Promise<AuthWitness>;
};
```
As a side effect, a few debug only features have been removed
```
// Obtain tx effects
const { txHash, debugInfo } = await contract.methods
.set_constant(value)
.send()
-- .wait({ interval: 0.1, debug: true });
++ .wait({ interval: 0.1 })
-- // check that 1 note hash was created
-- expect(debugInfo!.noteHashes.length).toBe(1);
++ const txEffect = await aztecNode.getTxEffect(txHash);
++ const noteHashes = txEffect?.data.noteHashes;
++ // check that 1 note hash was created
++ expect(noteHashes?.length).toBe(1);
// Wait for a tx to be proven
-- tx.wait({ timeout: 300, interval: 10, proven: true, provenTimeout: 3000 })));
++ const receipt = await tx.wait({ timeout: 300, interval: 10 });
++ await waitForProven(aztecNode, receipt, { provenTimeout: 3000 });
```
Authwit management has changed, and PXE no longer stores them. This is unnecessary because now they can be externally provided to simulations and transactions, making sure no stale authorizations are kept inside PXE's db.
```
const witness = await wallet.createAuthWit({ caller, action });
--await callerWallet.addAuthWitness(witness);
--await action.send().wait();
++await action.send({ authWitnesses: [witness] }).wait();
```
Another side effect of this is that the interface of the `lookupValidity` method has changed, and now the authwitness has to be provided:
```
const witness = await wallet.createAuthWit({ caller, action });
--await callerWallet.addAuthWitness(witness);
--await wallet.lookupValidity(wallet.getAddress(), { caller, action });
++await wallet.lookupValidity(wallet.getAddress(), { caller, action }, witness);
```
## 0.80.0[](#0800 "Direct link to 0.80.0")
### \[PXE] Concurrent contract function simulation disabled[](#pxe-concurrent-contract-function-simulation-disabled "Direct link to \[PXE] Concurrent contract function simulation disabled")
PXE is no longer be able to execute contract functions concurrently (e.g. by collecting calls to `simulateTx` and then using `await Promise.all`). They will instead be put in a job queue and executed sequentially in order of arrival.
## 0.79.0[](#0790 "Direct link to 0.79.0")
### \[aztec.js] Changes to `BatchCall` and `BaseContractInteraction`[](#aztecjs-changes-to-batchcall-and-basecontractinteraction "Direct link to aztecjs-changes-to-batchcall-and-basecontractinteraction")
The constructor arguments of `BatchCall` have been updated to improve usability. Previously, it accepted an array of `FunctionCall`, requiring users to manually set additional data such as `authwit` and `capsules`. Now, `BatchCall` takes an array of `BaseContractInteraction`, which encapsulates all necessary information.
```
class BatchCall extends BaseContractInteraction {
- constructor(wallet: Wallet, protected calls: FunctionCall[]) {
+ constructor(wallet: Wallet, protected calls: BaseContractInteraction[]) {
...
}
```
The `request` method of `BaseContractInteraction` now returns `ExecutionPayload`. This object includes all the necessary data to execute one or more functions. `BatchCall` invokes this method on all interactions to aggregate the required information. It is also used internally in simulations for fee estimation.
Declaring a `BatchCall`:
```
new BatchCall(wallet, [
- await token.methods.transfer(alice, amount).request(),
- await token.methods.transfer_to_private(bob, amount).request(),
+ token.me프로젝트로 돌아가기