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
feat: contractOverrides for private-call simulation
Extends `contractOverrides` (introduced downstack) to also drive PXE-side ACIR dispatch, so private function calls on an overridden instance simulate against the override's class instead of the deployed one.
- Translates aztec.js's `contractOverrides: ContractInstanceWithAddress[]` into PXE's existing `SimulationOverrides.contracts` record at the wallet boundary.
- Relaxes the PXE-internal `ContractOverrides` type so `artifact` is optional; `proxied_contract_data_source` falls through to the regular `ContractStore` when the override has no artifact.
- Exposes `wallet.registerContractClass(artifact)` so users can register the new class artifact locally before the override is used.
Copy file name to clipboardExpand all lines: docs/docs-developers/docs/aztec-js/how_to_test.md
+20-6Lines changed: 20 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,9 +67,12 @@ Test that invalid operations revert as expected:
67
67
68
68
Use `.simulate()` to test reverts without spending gas. The simulation will throw if the transaction would fail onchain.
69
69
70
-
## Simulating with state overrides
70
+
## Simulating with state and contract overrides
71
71
72
-
`.simulate()` accepts a `stateOverrides` option that injects values into the simulator's ephemeral world-state fork before the call runs. The override is scoped to that single simulation; the real chain state is untouched.
72
+
`.simulate()` accepts two override options that are scoped to that single simulation; real chain state is untouched.
-`contractOverrides`: an array of `ContractInstanceWithAddress` to override deployed contract instances. Register the new class artifact locally first via `wallet.registerContractClass(artifact)`.
73
76
74
77
Override a public-storage slot:
75
78
@@ -81,26 +84,37 @@ const result = await contract.methods.read_balance(account).simulate({
81
84
});
82
85
```
83
86
84
-
Use this to:
87
+
Use these to:
85
88
86
89
- Set up state preconditions without running a full setup transaction
87
90
- Reproduce a bug from production by pinning storage to the values seen at a specific block
91
+
- Simulate a contract instance as if it had been upgraded
88
92
- Test branches that depend on rare values without orchestrating the contract calls that produce them
89
93
90
94
### Fast-forwarding a contract update
91
95
92
-
`fastForwardContractUpdate` builds the full set of overrides needed to simulate a deployed instance as if it had already been upgraded to a new contract class. The new class must already be registered on chain. The cheat mirrors a real `pxe.updateContract` followed by waiting out the upgrade delay: the instance's `currentContractClassId` is bumped, and the `ContractInstanceRegistry`'s delayed-public-mutable storage is rewritten to look like the upgrade was scheduled in the past.
96
+
`fastForwardContractUpdate` builds the override blobs needed to simulate a deployed instance as if it had already been upgraded to a new contract class. The new class must already be registered on chain. Mirrors a real `pxe.updateContract` followed by waiting out the upgrade delay.
97
+
98
+
It returns `stateOverrides` (registry storage rewrites) and `contractOverrides` (instance with bumped class id). A single spread covers any mix of private and public function calls on the upgraded contract.
99
+
100
+
Register the new class artifact in your local PXE first via `wallet.registerContractClass(artifact)`.
Copy file name to clipboardExpand all lines: docs/docs-developers/docs/resources/migration_notes.md
+10-4Lines changed: 10 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,17 +23,23 @@ const result = await contract.methods.read_balance(account).simulate({
23
23
24
24
The same option flows through `wallet.simulateTx` and eventually to `simulatePublicCalls` RPC on `AztecNode`.
25
25
26
-
A separate top-level option, `contractOverrides`, 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 on-chain upgrade flow, use the `fastForwardContractUpdate` helper which returns both `stateOverrides` and `contractOverrides`:
26
+
`.simulate(...)` also accepts `contractOverrides` - an array of `ContractInstanceWithAddress` that override deployed instances at their addresses. Applied on both the AVM (public dispatch) and PXE (private dispatch via ACIR) sides. Register the new class artifact locally first via `wallet.registerContractClass(artifact)` (newly exposed for this purpose) so PXE has the ACIR.
27
+
28
+
To simulate a complete on-chain upgrade flow, use the `fastForwardContractUpdate` helper. It returns both `stateOverrides` (registry storage rewrites) and `contractOverrides` (instance with bumped class id). Register the new artifact locally via `wallet.registerContractClass(artifact)` first:
0 commit comments