Aztec 백서

Aztec

원문

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

hod-address-affecting-parameters-move-to-construction-time "Direct link to aztecjs-deploymethod-address-affecting-parameters-move-to-construction-time") Salt, deployer, and public keys are now passed when the `DeployMethod` is constructed, not on every call to `send` / `simulate` / `request` / `getInstance`. This locks the contract address once it is determined and prevents the silent salt-cache poisoning bug where the address could change between calls. `contractAddressSalt`, `deployer`, and `universalDeploy` have been removed from `DeployOptions`, `RequestDeployOptions`, and `SimulateDeployOptions`. They now live on a new `DeployInstantiationOptions` argument passed at construction. `deployer` and `universalDeploy` are mutually exclusive; passing both throws. `Contract.deployWithPublicKeys` and the generated `MyContract.deployWithPublicKeys(...)` factories have been removed; pass `publicKeys` via the `instantiation` argument of `deploy(...)` instead. The buggy synchronous `address` and `partialAddress` getters have been removed and replaced with `getAddress()` and `getPartialAddress()` (both `async`). The compact form keeps working: `MyContract.deploy(wallet, ...args).send({ from: alice })` deploys with `deployer = alice` and `salt = random()`, exactly as before. The deployer is locked the first time `send` / `simulate` / `profile` is called (from `options.from`, with `NO_FROM` or undefined → universal) and cannot change after that: * Subsequent `send` / `simulate` / `profile` calls with a `from` that would imply a different deployer throw, instead of silently producing a different address. * A lock to universal (`AztecAddress.ZERO`) is the only one compatible with any sender, since the universal address does not depend on `from`. * A lock to a concrete address only accepts that exact `from` on subsequent calls. **Migration:** Universal deployment with a fixed salt: ``` - const deploy = MyContract.deploy(wallet, ...args); - await deploy.send({ - from: alice, - contractAddressSalt: salt, - universalDeploy: true, - }); + const deploy = MyContract.deploy(wallet, ...args, { salt, universalDeploy: true }); + await deploy.send({ from: alice }); ``` Non-universal deploy where `from` doubles as the deployer: ``` - const deploy = MyContract.deploy(wallet, ...args); - await deploy.send({ from: alice, contractAddressSalt: salt }); + const deploy = MyContract.deploy(wallet, ...args, { salt }); + await deploy.send({ from: alice }); ``` If you need to read the address before sending, lock the deployer at construction: ``` const deploy = MyContract.deploy(wallet, ...args, { salt, deployer: alice }); const address = await deploy.getAddress(); // resolves; deployer was locked at construction await deploy.send({ from: alice }); // deploys at the address `getAddress` returned ``` Universal deploys can be sent by any account, since the universal address does not depend on `from`: ``` const deploy = MyContract.deploy(wallet, ...args, { universalDeploy: true }); await deploy.send({ from: bob }); // OK, universal accepts any sender ``` A lock to a concrete deployer rejects sending from a different account, instead of silently deploying at a different address: ``` const deploy = MyContract.deploy(wallet, ...args, { deployer: alice }); await deploy.send({ from: bob }); // throws: deployer is locked to alice ``` `deployWithPublicKeys` is gone; pass `publicKeys` in the instantiation options instead: ``` - const deploy = MyContract.deployWithPublicKeys(publicKeys, wallet, ...args); + const deploy = MyContract.deploy(wallet, ...args, { publicKeys }); ``` `ContractDeployer.deploy(...)` now takes the instantiation argument as its first parameter (pass `{}` to use defaults and rely on lazy locking from `from`): ``` - const cd = new ContractDeployer(artifact, wallet); - await cd.deploy(...ctorArgs).send({ from: alice, contractAddressSalt: salt }); + const cd = new ContractDeployer(artifact, wallet); + await cd.deploy(ctorArgs, { salt }).send({ from: alice }); ``` The synchronous `address` / `partialAddress` getters are gone: ``` - const address = deploy.address; // sync, possibly undefined - const partial = await deploy.partialAddress; // sync getter wrapping async value + const address = await deploy.getAddress(); // requires the deployer to be locked + const partial = await deploy.getPartialAddress(); // requires the deployer to be locked ``` `getInstance()` no longer takes options; use the construction-time instantiation instead: ``` - const instance = await deploy.getInstance({ contractAddressSalt: salt }); + const deploy = MyContract.deploy(wallet, ...args, { salt, deployer: alice }); + const instance = await deploy.getInstance(); ``` ### \[aztec-up] Bundled binaries are no longer exposed under bare names on `PATH`[​](#aztec-up-bundled-binaries-are-no-longer-exposed-under-bare-names-on-path "Direct link to aztec-up-bundled-binaries-are-no-longer-exposed-under-bare-names-on-path") The Aztec installer previously placed bundled binaries directly into `$HOME/.aztec/current/bin` under bare names (`forge`, `nargo`, `bb`, `pxe`, ...). Anything with the same name in your own `PATH` was silently shadowed in unrelated projects. Every bundled binary is now exposed only under an `aztec-` prefixed name in `$HOME/.aztec/current/bin`. Bare names are not on `PATH` at all and resolve to your own install (if any). | Was on `PATH` | Now | | ------------------ | ------------------------ | | `forge` | `aztec-forge` | | `cast` | `aztec-cast` | | `anvil` | `aztec-anvil` | | `chisel` | `aztec-chisel` | | `nargo` | `aztec-nargo` | | `noir-profiler` | `aztec-noir-profiler` | | `bb` | `aztec-bb` | | `bb-cli` | `aztec-bb-cli` | | `pxe` | `aztec-pxe` | | `txe` | `aztec-txe` | | `validator-client` | `aztec-validator-client` | | `blob-client` | `aztec-blob-client` | `aztec`, `aztec-wallet`, and `aztec-up` keep their existing names. If you relied on a bundled bare-name binary for general use: * For Aztec contract work, prefer `aztec compile` and `aztec test`. * For other Noir / Foundry commands, invoke the `aztec-*` symlink directly (e.g. `aztec-nargo fmt`, `aztec-forge build`). * Or install Foundry / nargo separately via `foundryup` / `noirup`. If you set `Noir: Nargo Path` in the VS Code Noir extension to `$HOME/.aztec/current/bin/nargo`, change it to `$HOME/.aztec/current/bin/aztec-nargo` (the symlink is a drop-in for `nargo`). See the [Noir VSCode Extension guide](/developers/testnet/docs/aztec-nr/installation.md) for details. ### \[Stdlib] `SimulationOverrides.contracts` entries no longer carry an artifact[​](#stdlib-simulationoverridescontracts-entries-no-longer-carry-an-artifact "Direct link to stdlib-simulationoverridescontracts-entries-no-longer-carry-an-artifact") `ContractOverrides` entries are now `{ instance }` only. To override a contract's artifact, pre-register the target class via `pxe.registerContractClass(artifact)` and set the override instance's `currentContractClassId` to that class id: ``` - const instance = await getContractInstanceFromInstantiationParams(stubArtifact, { salt: Fr.random() }); + const instance = await pxe.getContractInstance(addr); + await pxe.registerContractClass(stubArtifact); + const stubClassId = (await getContractClassFromArtifact(stubArtifact)).id; - overrides = { contracts: { [addr.toString()]: { instance, artifact: stubArtifact } } }; + overrides = { contracts: { [addr.toString()]: { instance: { ...instance, currentContractClassId: stubClassId } } } }; ``` ### \[Aztec.js] `simulate` accepts `overrides` for testing "what if storage value was X?"[​](#aztecjs-simulate-accepts-overrides-for-testing-what-if-storage-value-was-x "Direct link to aztecjs-simulate-accepts-overrides-for-testing-what-if-storage-value-was-x") `Contract.methods.foo(...).simulate(...)` now accepts an `overrides` option that injects values into the simulator's (ephemeral) world-state fork and contract DB before the call runs. The supported field is `publicStorage`, which writes a `(contract, slot, value)` into the public-data tree as if a previous tx had set it. Overrides are thrown away after simulation completes. ``` const result = await contract.methods.read_balance(account).simulate({ overrides: { publicStorage: [ { contract: contract.address, slot: BALANCE_SLOT, value: new Fr(1_000_000n), }, ], }, }); ``` The same option flows through `wallet.simulateTx` and eventually to `simulatePublicCalls` RPC on `AztecNode`. Direct callers of the `SimulationOverrides` constructor must switch from a positional `contracts` argument to an options bag: ``` - new SimulationOverrides(contracts); + new SimulationOverrides({ contracts }); ``` `overrides.contracts` swaps contract instances in the simulator's contract DB — useful for simulating a contract being on a different class than the one it was deployed with. To simulate a complete onchain upgrade flow, use the `fastForwardContractUpdate` helper which returns a `SimulationOverrides` covering both registry storage rewrites and the upgraded instance entry: ``` import { fastForwardContractUpdate } from "@aztec/aztec.js"; const overrides = await fastForwardContractUpdate({ instanceAddress: contract.address, newClassId: upgradedClass.id, node, }); const result = await contract.methods.upgraded_method().simulate({ overrides }); ``` ### \[PXE] `proveTx` takes an options bag[​](#pxe-provetx-takes-an-options-bag "Direct link to pxe-provetx-takes-an-options-bag") `PXE.proveTx` used to accept `scopes` as a positional argument; it now takes an options bag consistent with `simulateTx` and `profileTx`, and adds an optional `senderForTags` field. Update direct callers: ``` - pxe.proveTx(txRequest, scopes); + pxe.proveTx(txRequest, { scopes }); ``` The new `senderForTags` field sets the address recipients use to find private messages (notes, events, logs) emitted by this tx. Most wallets don't need to set it; the wallet SDK derives it from the tx's `from` address: ``` // Most callers: just migrate scopes pxe.proveTx(txRequest, { scopes }); // When from === NO_FROM (e.g. self-paid account deploy), supply the tag sender explicitly: pxe.proveTx(txRequest, { scopes, senderForTags: deployedAddress }); ``` ### \[Aztec.nr] `set_sender_for_tags` is now scoped to the calling contract[​](#aztecnr-set_sender_for_tags-is-now-scoped-to-the-calling-contract "Direct link to aztecnr-set_sender_for_tags-is-now-scoped-to-the-calling-contract") `set_sender_for_tags` previously persisted through nested calls. It is now scoped to the contract that calls it: nested calls, siblings, and parents are unaffected and always start from the initial default. This closes a silent note-discovery DoS vector where any nested callee could overwrite the tag sender for legitimate contracts called below it. The wallet SDK now supplies the default sender-for-tags from the transaction's `from` address, with an optional `sendMessagesAs` override for flows that don't have a signing account (e.g. self-paid deploys, which `DeployAccountMethod` sets automatically). Account contracts therefore no longer need to call `set_sender_for_tags(self.address)` in their entrypoints; those calls have been removed from the standard schnorr and ECDSA account contracts, and you can drop the equivalent call in any custom account contract. The save/restore idiom previously used in account-contract constructors (`get` → `set(self.address)` → work → `set(prev)`) is also no longer needed and has been removed: the override never leaks out of the constructor, so there is nothing to restore. ### \[Aztec Node] Unified `getBlock` / `getCheckpoint` RPC API[​](#aztec-node-unified-getblock--getcheckpoint-rpc-api "Direct link to aztec-node-unified-getblock--getcheckpoint-rpc-api") The Aztec Node JSON-RPC surface for fetching blocks and checkpoints has been consolidated. The unified `getBlock` and `getCheckpoint` methods return uniform `BlockResponse` / `CheckpointResponse` shapes. The extra fields a caller cares about (tx bodies, L1 publish info, committee attestations, nested blocks) are now controlled by an `options` argument rather than by picking the right method. `getBlocks` and `getCheckpoints` retain their names but now return the new response shapes. **Removed methods:** | Removed | Replacement | | ---------------------------------- | -------------------------------------------- | | `getBlockByHash(hash)` | `getBlock(hash)` or `getBlock({ hash })` | | `getBlockByArchive(archive)` | `getBlock({ archive })` | | `getBlockHeaderByArchive(archive)` | `getBlock({ archive }).then(r => r?.header)` | | `getProvenBlockNumber()` | `getBlockNumber('proven')` | | `getCheckpointedBlockNumber()` | `getBlockNumber('checkpointed')` | **Deprecated but still present** (scheduled for removal once internal consumers of the archiver shape are rewired): `getL2Tips` (use `getChainTips`), `getBlockHeader` (use `getBlock(param).then(r => r?.header)`), `getCheckpointedBlocks` (use `getBlocks(from, limit, { includeL1PublishInfo: true, includeAttestations: true })`). Do not adopt these in new code. (`getCheckpointsDataForEpoch` was previously listed here; see the dedicated checkpoint-API entry below for its removal.) **New response shapes:** `BlockResponse` always carries `header`, `archive`, `hash`, `number`, `checkpointNumber`, and `indexWithinCheckpoint`. `body`, `l1` (an `L1PublishInfo` discriminated union), and `attestations` are present only when the matching include option is set. `CheckpointResponse` mirrors this for checkpoints, with `blocks` gated on `includeBlocks`, and always carries `feeAssetPriceModifier` as a base field. The response types are generic over the options object, so passing a literal `{ includeTransactions: true }` narrows the return type and `response.body` becomes non-optional. **Nested blocks on `getCheckpoint`:** only `includeTransactions` is forwarded to the blocks embedded by `includeBlocks: true`. `includeL1PublishInfo` and `includeAttestations` on a checkpoint request attach L1 / attestation data to the checkpoint itself, not to its nested blocks. **Return type changes for `getBlocks` / `getCheckpoints`:** the return type is now `BlockResponse[]` / `CheckpointResponse[]` instead of `L2Block[]` / `PublishedCheckpoint[]`. Callers that previously consumed fields of `L2Block` (e.g. `.body`) must now opt in via `{ includeTransactions: true }`; callers that consumed `PublishedCheckpoint.checkpoint.blocks` must opt in via `{ includeBlocks: true }`. **Migration for wallet/SDK consumers (`@aztec/aztec.js`, `@aztec/wallet-sdk`):** ``` - const block = await node.getBlockByHash(hash); + const block = await node.getBlock(hash, { includeTransactions: true }); - const archiveBlock = await node.getBlockByArchive(archive); + const archiveBlock = await node.getBlock({ archive }, { includeTransactions: true }); - const provenNumber = await node.getProvenBlockNumber(); + const provenNumber = await node.getBlockNumber('proven'); - const checkpointedNumber = await node.getCheckpointedBlockNumber(); + const checkpointedNumber = await node.getBlockNumber('checkpointed'); - const tips = await node.getL2Tips(); + const tips = await node.getChainTips(); ``` `getBlockHeader`, `getCheckpointedBlocks`, `getCheckpointsDataForEpoch`, and `getL2Tips` continue to work in this release but are deprecated; migrate to the replacements above. **Chain-tip selectors:** `getBlockNumber` and `getCheckpointNumber` now accept an optional `ChainTip` argument (`'proposed' | 'checkpointed' | 'proven' | 'finalized'`). The `'proposed'` semantics are described in the dedicated checkpoint-API entry below — they were tightened in this release to mean "the proposed-tip checkpoint" rather than "the latest L1-confirmed checkpoint." **Block parameter variants:** `BlockParameter` now also accepts a block hash, an archive root, and chain-tip names. The existing `number | 'latest'` forms continue to work — `'latest'` is an alias for `'proposed'`. **Impact**: Source changes are required anywhere the removed methods are called. Type changes are required anywhere `L2Block` / `BlockHeader` / `CheckpointedL2Block` were consumed from the RPC — those call sites now receive `BlockResponse` / `CheckpointResponse` and must request the fields they need via `options`. Production nodes will reject JSON-RPC calls to the removed method names. ### \[Aztec Node] Checkpoint RPC: `'proposed'` is now strictly proposed; `'latest'` removed; `getCheckpointsData` takes a query[​](#aztec-node-checkpoint-rpc-proposed-is-now-strictly-proposed-latest-removed-getcheckpointsdata-takes-a-query "Direct link to aztec-node-checkpoint-rpc-proposed-is-now-strictly-proposed-latest-removed-getcheckpointsdata-takes-a-query") Follow-up to the unified-RPC change above. Tightens the checkpoint-side API surface: removes the old positional / per-shape entrypoints, drops the wire-level alias that conflated proposed and confirmed checkpoints, and replaces the deprecated epoch-only `getCheckpointsDataForEpoch` method with a unified query-shaped `getCheckpointsData` that mirrors the block-side API. **`getCheckpointsDataForEpoch(epoch)` removed.** The previously-deprecated method is gone. Use `getCheckpointsData({ epoch })` instead. The new `getCheckpointsData` also accepts a contiguous range: ``` - const cps = await node.getCheckpointsDataForEpoch(epoch); + const cps = await node.getCheckpointsData({ epoch }); // New: contiguous range + const cps = await node.getCheckpointsData({ from: 1, limit: 5 }); ``` **`'latest'` removed from `CheckpointParameter`.** The `'latest'` literal previously accepted by `getCheckpoint('latest', options)` is no longer valid. Use `'checkpointed'` to address the latest confirmed checkpoint, or `'proposed'` for the proposed-tip semantics described below. (Block-side `'latest'` in `BlockParameter` is unaffected.) ``` - await node.getCheckpoint('latest'); + await node.getCheckpoint('checkpointed'); ``` **`'proposed'` semantics changed.** Previously `'proposed'` on the checkpoint side aliased to "latest L1-confirmed checkpoint" — a documented foot-gun. After this release: * `getCheckpoint('proposed')` resolves to the proposed-tip checkpoint number and looks it up confirmed-first, then falls back to the proposed-checkpoint store. When a proposed entry exists at that number it is returned; when none exists, the proposed-tip falls back to the confirmed tip and the call returns the latest confirmed checkpoint. Returns `undefined` only when neither store has the resolved number. * `getCheckpointNumber('proposed')` returns the proposed-tip checkpoint number, falling back to the latest confirmed checkpoint number when no proposed entry exists. Return type stays `Promise<CheckpointNumber>`. If you want the latest L1-confirmed checkpoint regardless of proposed state, switch the call to `'checkpointed'`: ``` - const cp = await node.getCheckpoint('proposed'); - const n = await node.getCheckpointNumber('proposed'); + const cp = await node.getCheckpoint('checkpointed'); + const n = await node.getCheckpointNumber('checkpointed'); ``` **By-number / by-slot lookups gain a confirmed→proposed fallback.** `getCheckpoint({ number: N })` and `getCheckpoint({ slot: S })` now check the confirmed store first, then fall back to the proposed store. Tag-based lookups (`'checkpointed'`, `'proven'`, `'finalized'`) do not fall back — those tags name confirmed-only positions. **Throws on a proposed match + L1/attestations.** Proposed checkpoints have no L1 publish info or committee attestations (those data points only exist after L1 confirmation). The throw fires only when the lookup actually lands on a proposed entry — i.e. the confirmed store missed and the proposed store hit. When the proposed-tip falls back to the confirmed tip (no proposed entry exists), `'proposed' + includeAttestations` returns the latest confirmed checkpoint with attestatio
프로젝트로 돌아가기