Skip to content

Commit 8c6a7df

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 14c427f commit 8c6a7df

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
@@ -275,7 +275,7 @@ export class CLIWallet extends BaseWallet {
275275
} else {
276276
const { account, instance } = await this.getFakeAccountDataFor(from);
277277
overrides = {
278-
contracts: { [from.toString()]: { instance } },
278+
contracts: { [from.toString()]: { instance, skipSync: true } },
279279
};
280280
const executionOptions: DefaultAccountEntrypointOptions = {
281281
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
@@ -165,6 +165,7 @@ export class TestWallet extends BaseWallet {
165165

166166
contracts[address.toString()] = {
167167
instance: { ...contractInstance, currentContractClassId: stubClassId },
168+
skipSync: true,
168169
};
169170
}
170171

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
@@ -246,6 +246,7 @@ export class EmbeddedWallet extends BaseWallet {
246246

247247
contracts[address.toString()] = {
248248
instance: { ...contractInstance, currentContractClassId: stubClassId },
249+
skipSync: true,
249250
};
250251
}
251252

0 commit comments

Comments
 (0)