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
Plumbs the existing PXE-side SimulationOverrides.contracts mechanism through
wallet.simulateTx and aztec.js .simulate() options as 'contractOverrides'.
This covers private-function dispatch during simulation against an upgraded
class - the PXE's ACIR simulator uses the override artifact for the given
address instead of its registered one.
Together with the existing node-side stateOverrides, .simulate() now handles
both private and public call flavors when simulating against an upgraded
contract.
fastForwardContractUpdate now takes a ContractArtifact and returns both
override layers in one blob so callers can spread it across .simulate():
const overrides = await fastForwardContractUpdate({
instanceAddress, newArtifact, node,
});
await updatedContract.methods.X().simulate({ ...overrides });
Adds e2e coverage for the private-call path (set_private_value, which only
exists on the upgraded class) to demonstrate the full flow.
Copy file name to clipboardExpand all lines: docs/docs-developers/docs/aztec-js/how_to_test.md
+21-7Lines changed: 21 additions & 7 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
+11-5Lines changed: 11 additions & 5 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 second override flavor, `contractInstances`, shadows 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 produces a coherent set of `publicStorage` and `contractInstances` overrides:
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