You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore: backport DeployMethod refactor (#22985) to v4-next (#23029)
## Summary
Backport of
[#22985](#22985)
(`fix: better DeployMethod`) to `backport-to-v4-next-staging`.
The original PR refactors `DeployMethod` so that all address-affecting
parameters (`salt`, `deployer`, `universalDeploy`, `publicKeys`) are
locked in at construction time via a new `DeployInstantiationOptions`
argument, and removes the silent salt-cache poisoning bug where the
address could change between calls. See the migration notes added under
`## TBD` for the full API change.
## Commits
This backport preserves the standard 3-commit history so reviewers can
see exactly what conflicted and how it was resolved:
1. **`chore: cherry-pick #22985 ... with conflicts`** — raw `git
cherry-pick` result with conflict markers in place. Does not compile.
2. **`fix: resolve cherry-pick conflicts`** — resolution. Notable
choices:
- `migration_notes.md`: only the new DeployMethod note was added. Other
entries that came in via the cherry-pick (`getBlock` / `getCheckpoint`,
`feeAssetPriceModifier`, Domain separators, aztec-up table reformatting)
belong to PRs that have not been backported, so they were dropped to
avoid bringing in unrelated changes.
- `txe_oracles.nr`, `constants.nr`, `constants_tests.nr`: dropped
formatting-only diffs that depended on constants/types not present on
v4-next (`MAX_PRIVATE_LOGS_PER_TX`, `PRIVATE_LOG_SIZE_IN_FIELDS`,
`DOM_SEP__HANDSHAKE_SECRET_HASH`, `DOM_SEP__MERKLE_HASH`, etc.).
- `bot/src/factory.ts`: dropped the new
`setupTokenWithOptionalEarlyRefuel` /
`setupTokenContractWithOptionalEarlyRefuel` / `getTokenInstance` helpers
(introduced by an unrelated PR) and applied the new
`DeployInstantiationOptions` API to the existing `setupToken` flow.
- `e2e/composed/ha/e2e_ha_full.test.ts`: dropped the `should reload
keystore via admin API and keep building blocks after swapping
attesters` test that does not exist on v4-next.
- `docs/examples/ts/aave_bridge`, `docs/examples/ts/example_swap`: kept
deleted (modify/delete conflict — these examples don't exist on
v4-next).
- `docs/examples/ts/token_bridge/index.ts`: kept
`node.getProvenBlockNumber()` — the new `getBlockNumber('proven')` is
from a different PR.
- End-to-end tests, `aztec.js/src/api/contract.ts`, `bot`, etc.: adopted
the new `DeployInstantiationOptions` API; kept v4-next-only
`DeployTxReceipt` / `DeployWaitOptions` exports.
3. **`fix: restore DeployInteractionWaitOptions for v4-next
returnReceipt API`** — v4-next still supports `wait: { returnReceipt:
true }` (a feature added on v4-next that does not exist upstream). The
upstream PR removed `DeployInteractionWaitOptions` and tightened
`DeployOptions<W extends InteractionWaitOptions>`, which broke
type-checking for the existing `returnReceipt` callers. This commit
restores `DeployInteractionWaitOptions = NoWait | DeployWaitOptions |
undefined` and rewires `DeployOptions` / `DeployReturn` / `send` to use
it, so the v4-next-only `returnReceipt: true` callers keep
type-checking.
## Test plan
- [ ] CI green on this branch
- [ ] e2e_deploy_contract tests pass
ClaudeBox log: https://claudebox.work/s/2e03d384f1f73fd0?run=1
Copy file name to clipboardExpand all lines: docs/docs-developers/docs/resources/migration_notes.md
+91Lines changed: 91 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,97 @@ Aztec is in active development. Each version may introduce breaking changes that
9
9
10
10
## TBD
11
11
12
+
### [Aztec.js]`DeployMethod` address-affecting parameters move to construction time
13
+
14
+
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.
15
+
16
+
`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`).
17
+
18
+
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:
19
+
20
+
- Subsequent `send` / `simulate` / `profile` calls with a `from` that would imply a different deployer throw, instead of silently producing a different address.
21
+
- A lock to universal (`AztecAddress.ZERO`) is the only one compatible with any sender, since the universal address does not depend on `from`.
22
+
- A lock to a concrete address only accepts that exact `from` on subsequent calls.
`ContractDeployer.deploy(...)` now takes the instantiation argument as its first parameter (pass `{}` to use defaults and rely on lazy locking from `from`):
78
+
79
+
```diff
80
+
- const cd = new ContractDeployer(artifact, wallet);
81
+
- await cd.deploy(...ctorArgs).send({ from: alice, contractAddressSalt: salt });
82
+
+ const cd = new ContractDeployer(artifact, wallet);
83
+
+ await cd.deploy(ctorArgs, { salt }).send({ from: alice });
84
+
```
85
+
86
+
The synchronous `address` / `partialAddress` getters are gone:
### [Aztec.nr] TXE `call_public_incognito` no longer takes a `from` parameter
13
104
14
105
`TestEnvironment::call_public_incognito` previously accepted a `from` address that was silently ignored (the function always uses a null `msg_sender`). The `from` parameter has been removed.
0 commit comments