diff --git a/yarn-project/cli-wallet/src/utils/wallet.ts b/yarn-project/cli-wallet/src/utils/wallet.ts index 2ace44debe9c..54a37e83a005 100644 --- a/yarn-project/cli-wallet/src/utils/wallet.ts +++ b/yarn-project/cli-wallet/src/utils/wallet.ts @@ -275,7 +275,7 @@ export class CLIWallet extends BaseWallet { } else { const { account, instance } = await this.getFakeAccountDataFor(from); overrides = { - contracts: { [from.toString()]: { instance } }, + contracts: { [from.toString()]: { instance, skipSync: true } }, }; const executionOptions: DefaultAccountEntrypointOptions = { txNonce: Fr.random(), diff --git a/yarn-project/end-to-end/src/test-wallet/test_wallet.ts b/yarn-project/end-to-end/src/test-wallet/test_wallet.ts index f559bdda136f..19de078d3e11 100644 --- a/yarn-project/end-to-end/src/test-wallet/test_wallet.ts +++ b/yarn-project/end-to-end/src/test-wallet/test_wallet.ts @@ -165,6 +165,7 @@ export class TestWallet extends BaseWallet { contracts[address.toString()] = { instance: { ...contractInstance, currentContractClassId: stubClassId }, + skipSync: true, }; } diff --git a/yarn-project/pxe/src/pxe.ts b/yarn-project/pxe/src/pxe.ts index 5c678f8cacfe..28ead692c893 100644 --- a/yarn-project/pxe/src/pxe.ts +++ b/yarn-project/pxe/src/pxe.ts @@ -1013,9 +1013,18 @@ export class PXE { const contractFunctionSimulator = this.#getSimulatorForTx(overrides); if (hasOverriddenContracts) { - // Overridden contracts don't have a sync function, so calling sync on them would fail. - // We exclude them so the sync service skips them entirely. - this.contractSyncService.setExcludedFromSync(jobId, overriddenContracts); + // Skip sync only for overrides that explicitly opt out (typically mock/stub overrides whose + // artifact doesn't model the address's real notes). Real-class overrides (e.g. upgrade + // simulations via fastForwardContractUpdate) leave skipSync unset so sync runs as usual + // and pre-existing notes get discovered. + const skipSyncAddresses = new Set( + Object.entries(overrides!.contracts!) + .filter(([_addr, override]) => override.skipSync) + .map(([addr]) => addr), + ); + if (skipSyncAddresses.size > 0) { + this.contractSyncService.setExcludedFromSync(jobId, skipSyncAddresses); + } } // Execution of private functions only; no proving, and no kernel logic. diff --git a/yarn-project/stdlib/src/tx/simulated_tx.ts b/yarn-project/stdlib/src/tx/simulated_tx.ts index 0ffd03c5674a..b043a180bc00 100644 --- a/yarn-project/stdlib/src/tx/simulated_tx.ts +++ b/yarn-project/stdlib/src/tx/simulated_tx.ts @@ -29,8 +29,17 @@ import { Tx } from './tx.js'; * overriding your own account contract so that valid signatures don't have to be provided while * simulating. The override's `currentContractClassId` resolves through PXE's locally registered * classes, so pre-register the target artifact via `pxe.registerContractClass(...)`. + * + * `skipSync` declares that PXE should not run contract sync (note discovery + nullifier sync) for + * this address while the override is in effect. Set this for mock/stub overrides whose artifact + * doesn't model the address's real notes (e.g. account stubs that mock auth without holding the + * real signing key storage). Leave unset (default false) for overrides that target full, on-chain + * classes where pre-existing notes still need to be discoverable (e.g. upgrade simulations). */ -export type ContractOverrides = Record; +export type ContractOverrides = Record< + string /* AztecAddress as string */, + { instance: ContractInstanceWithAddress; skipSync?: boolean } +>; /* * Optional values that can be overridden during simulation. `publicStorage` writes to the public-data @@ -51,7 +60,12 @@ export class SimulationOverrides { return z .object({ publicStorage: optional(z.array(PublicStorageOverrideSchema)), - contracts: optional(z.record(z.string(), z.object({ instance: ContractInstanceWithAddressSchema }))), + contracts: optional( + z.record( + z.string(), + z.object({ instance: ContractInstanceWithAddressSchema, skipSync: optional(z.boolean()) }), + ), + ), }) .transform(args => new SimulationOverrides(args)); } diff --git a/yarn-project/wallets/src/embedded/embedded_wallet.ts b/yarn-project/wallets/src/embedded/embedded_wallet.ts index bfddd9907030..495f008fdfc2 100644 --- a/yarn-project/wallets/src/embedded/embedded_wallet.ts +++ b/yarn-project/wallets/src/embedded/embedded_wallet.ts @@ -246,6 +246,7 @@ export class EmbeddedWallet extends BaseWallet { contracts[address.toString()] = { instance: { ...contractInstance, currentContractClassId: stubClassId }, + skipSync: true, }; }