Skip to content

Commit d4a7469

Browse files
committed
prototype(pxe): skipSync flag on contract overrides
Alternative to inferring intent via on-chain class registration: declare it explicitly per-override. Stub-builders (TestWallet, EmbeddedWallet, cli-wallet) opt in with skipSync: true; real-class overrides (e.g. fastForwardContractUpdate) leave it unset and sync runs as usual. Not for merge — comparison branch only.
1 parent 713e7c5 commit d4a7469

5 files changed

Lines changed: 31 additions & 6 deletions

File tree

yarn-project/cli-wallet/src/utils/wallet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ export class CLIWallet extends BaseWallet {
267267
} else {
268268
const { account, instance } = await this.getFakeAccountDataFor(from);
269269
overrides = {
270-
contracts: { [from.toString()]: { instance } },
270+
contracts: { [from.toString()]: { instance, skipSync: true } },
271271
};
272272
const executionOptions: DefaultAccountEntrypointOptions = {
273273
txNonce: Fr.random(),

yarn-project/end-to-end/src/test-wallet/test_wallet.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ export class TestWallet extends BaseWallet {
157157

158158
contracts[address.toString()] = {
159159
instance: { ...contractInstance, currentContractClassId: stubClassId },
160+
skipSync: true,
160161
};
161162
}
162163

yarn-project/pxe/src/pxe.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,9 +1013,18 @@ export class PXE {
10131013
const contractFunctionSimulator = this.#getSimulatorForTx(overrides);
10141014

10151015
if (hasOverriddenContracts) {
1016-
// Overridden contracts don't have a sync function, so calling sync on them would fail.
1017-
// We exclude them so the sync service skips them entirely.
1018-
this.contractSyncService.setExcludedFromSync(jobId, overriddenContracts);
1016+
// Skip sync only for overrides that explicitly opt out (typically mock/stub overrides whose
1017+
// artifact doesn't model the address's real notes). Real-class overrides (e.g. upgrade
1018+
// simulations via fastForwardContractUpdate) leave skipSync unset so sync runs as usual
1019+
// and pre-existing notes get discovered.
1020+
const skipSyncAddresses = new Set(
1021+
Object.entries(overrides!.contracts!)
1022+
.filter(([_addr, override]) => override.skipSync)
1023+
.map(([addr]) => addr),
1024+
);
1025+
if (skipSyncAddresses.size > 0) {
1026+
this.contractSyncService.setExcludedFromSync(jobId, skipSyncAddresses);
1027+
}
10191028
}
10201029

10211030
// Execution of private functions only; no proving, and no kernel logic.

yarn-project/stdlib/src/tx/simulated_tx.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,17 @@ import { Tx } from './tx.js';
2929
* overriding your own account contract so that valid signatures don't have to be provided while
3030
* simulating. The override's `currentContractClassId` resolves through PXE's locally registered
3131
* classes, so pre-register the target artifact via `pxe.registerContractClass(...)`.
32+
*
33+
* `skipSync` declares that PXE should not run contract sync (note discovery + nullifier sync) for
34+
* this address while the override is in effect. Set this for mock/stub overrides whose artifact
35+
* doesn't model the address's real notes (e.g. account stubs that mock auth without holding the
36+
* real signing key storage). Leave unset (default false) for overrides that target full, on-chain
37+
* classes where pre-existing notes still need to be discoverable (e.g. upgrade simulations).
3238
*/
33-
export type ContractOverrides = Record<string /* AztecAddress as string */, { instance: ContractInstanceWithAddress }>;
39+
export type ContractOverrides = Record<
40+
string /* AztecAddress as string */,
41+
{ instance: ContractInstanceWithAddress; skipSync?: boolean }
42+
>;
3443

3544
/*
3645
* Optional values that can be overridden during simulation. `publicStorage` writes to the public-data
@@ -51,7 +60,12 @@ export class SimulationOverrides {
5160
return z
5261
.object({
5362
publicStorage: optional(z.array(PublicStorageOverrideSchema)),
54-
contracts: optional(z.record(z.string(), z.object({ instance: ContractInstanceWithAddressSchema }))),
63+
contracts: optional(
64+
z.record(
65+
z.string(),
66+
z.object({ instance: ContractInstanceWithAddressSchema, skipSync: optional(z.boolean()) }),
67+
),
68+
),
5569
})
5670
.transform(args => new SimulationOverrides(args));
5771
}

yarn-project/wallets/src/embedded/embedded_wallet.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ export class EmbeddedWallet extends BaseWallet {
239239

240240
contracts[address.toString()] = {
241241
instance: { ...contractInstance, currentContractClassId: stubClassId },
242+
skipSync: true,
242243
};
243244
}
244245

0 commit comments

Comments
 (0)