Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion yarn-project/cli-wallet/src/utils/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
1 change: 1 addition & 0 deletions yarn-project/end-to-end/src/test-wallet/test_wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export class TestWallet extends BaseWallet {

contracts[address.toString()] = {
instance: { ...contractInstance, currentContractClassId: stubClassId },
skipSync: true,
};
}

Expand Down
15 changes: 12 additions & 3 deletions yarn-project/pxe/src/pxe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 16 additions & 2 deletions yarn-project/stdlib/src/tx/simulated_tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string /* AztecAddress as string */, { instance: ContractInstanceWithAddress }>;
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
Expand All @@ -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));
}
Expand Down
1 change: 1 addition & 0 deletions yarn-project/wallets/src/embedded/embedded_wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ export class EmbeddedWallet extends BaseWallet {

contracts[address.toString()] = {
instance: { ...contractInstance, currentContractClassId: stubClassId },
skipSync: true,
};
}

Expand Down
Loading