Skip to content

feat: fastForwardContractUpdate cheatcode for simulating contract updates#22905

Merged
dbanks12 merged 2 commits into
merge-train/fairiesfrom
db/fastforward-contract-update
May 8, 2026
Merged

feat: fastForwardContractUpdate cheatcode for simulating contract updates#22905
dbanks12 merged 2 commits into
merge-train/fairiesfrom
db/fastforward-contract-update

Conversation

@dbanks12
Copy link
Copy Markdown
Contributor

@dbanks12 dbanks12 commented May 1, 2026

Adds fastForwardContractUpdate to aztec.js — a high-level cheatcode that returns a SimulationOverrides blob simulating a deployed instance as if it had already been upgraded to a new contract class.

The blob covers both pieces required for a coherent upgrade simulation:

  • overrides.publicStorage rewrites the ContractInstanceRegistry's delayed-public-mutable storage so the AVM's UpdateCheck resolves to the new class id.
  • overrides.contracts swaps the deployed instance for one whose currentContractClassId is bumped to the new class. Drives both AVM-side public dispatch and PXE-side ACIR private dispatch.

Both pieces are required: a storage-only override would not redirect the AVM's class dispatch (which reads currentContractClassId from the contract DB); an instance-only override would cause the witgen UpdateCheck to throw on inconsistency. The new class must already be registered on chain.

import { fastForwardContractUpdate } from '@aztec/aztec.js';

const overrides = await fastForwardContractUpdate({ instanceAddress, newClassId, node });
const result = await contract.methods.upgraded_method().simulate({ overrides });

Test plan

  • Unit tests in fastforward_contract_update.test.ts cover validation and override shape.
  • E2E coverage in e2e_contract_updates for both public and private dispatch under override (private dispatch needs wallet.registerContractClass from upstack and the sync-skip narrowing from upstack).
  • migration_notes.md and how_to_test.md updated.

@dbanks12 dbanks12 marked this pull request as draft May 1, 2026 20:32
@dbanks12 dbanks12 force-pushed the db/fastforward-contract-update branch 2 times, most recently from 97c2111 to 7e12172 Compare May 4, 2026 15:14
@dbanks12 dbanks12 force-pushed the db/fastforward-contract-update branch from 7e12172 to 043c852 Compare May 5, 2026 01:22
@dbanks12 dbanks12 force-pushed the db/public-data-overrides-plumbing branch from 43d10a4 to ce67508 Compare May 5, 2026 12:49
@dbanks12 dbanks12 force-pushed the db/fastforward-contract-update branch 2 times, most recently from 85cfaae to 5add18a Compare May 5, 2026 14:28
@dbanks12 dbanks12 force-pushed the db/public-data-overrides-plumbing branch 2 times, most recently from 1ca8868 to b361b3c Compare May 5, 2026 15:42
@dbanks12 dbanks12 force-pushed the db/fastforward-contract-update branch from 5add18a to 2f092e4 Compare May 5, 2026 15:43
@dbanks12 dbanks12 force-pushed the db/public-data-overrides-plumbing branch from b361b3c to 7ca547d Compare May 5, 2026 16:16
@dbanks12 dbanks12 force-pushed the db/fastforward-contract-update branch from 2f092e4 to 4a6e4a1 Compare May 5, 2026 16:16
@dbanks12 dbanks12 force-pushed the db/public-data-overrides-plumbing branch from 7ca547d to 5368aef Compare May 5, 2026 16:35
@dbanks12 dbanks12 force-pushed the db/fastforward-contract-update branch from 4a6e4a1 to 04ea57f Compare May 5, 2026 16:35
@dbanks12 dbanks12 force-pushed the db/public-data-overrides-plumbing branch from 5368aef to df229d1 Compare May 5, 2026 16:36
@dbanks12 dbanks12 force-pushed the db/fastforward-contract-update branch 2 times, most recently from e87c61a to fcf1c77 Compare May 5, 2026 16:46
@dbanks12 dbanks12 force-pushed the db/public-data-overrides-plumbing branch from df229d1 to d71c0c2 Compare May 5, 2026 16:46
@dbanks12 dbanks12 force-pushed the db/fastforward-contract-update branch from fcf1c77 to 3d0b675 Compare May 5, 2026 17:57
@dbanks12 dbanks12 force-pushed the db/public-data-overrides-plumbing branch from d71c0c2 to 93230bb Compare May 5, 2026 17:57
@dbanks12 dbanks12 force-pushed the db/fastforward-contract-update branch from 3d0b675 to 6a0ff71 Compare May 5, 2026 18:05
@dbanks12 dbanks12 force-pushed the db/fastforward-contract-update branch from 153b4f1 to 59b94a3 Compare May 7, 2026 01:49
@dbanks12 dbanks12 force-pushed the db/fastforward-contract-update branch from 59b94a3 to f5a0071 Compare May 7, 2026 01:51
@dbanks12 dbanks12 changed the base branch from db/public-data-overrides-plumbing to graphite-base/22905 May 7, 2026 02:30
@dbanks12 dbanks12 force-pushed the db/fastforward-contract-update branch from f5a0071 to cf63e74 Compare May 7, 2026 02:30
@dbanks12 dbanks12 force-pushed the graphite-base/22905 branch from b1759f1 to c6a9a2a Compare May 7, 2026 02:43
@dbanks12 dbanks12 force-pushed the db/fastforward-contract-update branch from cf63e74 to 721ca99 Compare May 7, 2026 02:43
@dbanks12 dbanks12 marked this pull request as draft May 7, 2026 03:29
@dbanks12 dbanks12 force-pushed the db/fastforward-contract-update branch from 721ca99 to 7b2bf7e Compare May 7, 2026 04:03
@dbanks12 dbanks12 force-pushed the db/fastforward-contract-update branch from 7b2bf7e to f752939 Compare May 7, 2026 14:41
@dbanks12 dbanks12 changed the base branch from graphite-base/22905 to db/sync-stub-overrides-only May 7, 2026 14:41
@dbanks12 dbanks12 force-pushed the db/sync-stub-overrides-only branch from 028f86a to ff6e112 Compare May 7, 2026 14:44
@dbanks12 dbanks12 force-pushed the db/fastforward-contract-update branch from f752939 to 5eab42b Compare May 7, 2026 14:44
@dbanks12 dbanks12 marked this pull request as ready for review May 7, 2026 14:44
@dbanks12 dbanks12 changed the base branch from db/sync-stub-overrides-only to graphite-base/22905 May 7, 2026 17:38
@dbanks12 dbanks12 force-pushed the graphite-base/22905 branch from ff6e112 to fd5d974 Compare May 7, 2026 17:39
@dbanks12 dbanks12 force-pushed the db/fastforward-contract-update branch from 5eab42b to bad11ee Compare May 7, 2026 17:39
@dbanks12 dbanks12 force-pushed the db/fastforward-contract-update branch from bad11ee to 6ee0009 Compare May 7, 2026 18:43
@dbanks12 dbanks12 force-pushed the graphite-base/22905 branch from fd5d974 to 49d9722 Compare May 7, 2026 18:43
@dbanks12 dbanks12 changed the base branch from graphite-base/22905 to db/flesh-out-stubs May 7, 2026 18:43
@dbanks12 dbanks12 force-pushed the db/fastforward-contract-update branch from 6ee0009 to bc31ce0 Compare May 8, 2026 00:55
@dbanks12 dbanks12 force-pushed the db/flesh-out-stubs branch from 49d9722 to 4f39410 Compare May 8, 2026 00:55
@dbanks12 dbanks12 force-pushed the db/fastforward-contract-update branch from bc31ce0 to 1f320fd Compare May 8, 2026 00:55
@dbanks12 dbanks12 force-pushed the db/flesh-out-stubs branch from 4f39410 to 392cab1 Compare May 8, 2026 00:55
Copy link
Copy Markdown
Contributor

@Thunkar Thunkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

dbanks12 added 2 commits May 8, 2026 13:30
Mirrors the real-account note storage (signing_public_key) on the simulated
Schnorr/ECDSA account stubs and removes the manual sync_state() override so
the #[aztec] macro generates a sync_state matching the real contract's
selector. With matching note storage, the macro-generated _compute_note_hash
can decode the real account's signing_public_key note during simulation sync.

Removes the PXE setExcludedFromSync plumbing that previously skipped
overridden contracts from sync. Required for fastForwardContractUpdate's
private-call simulation to discover notes through the override.
…ates

Adds a high-level helper that returns a `SimulationOverrides` blob simulating a deployed instance as if it had already been upgraded to a new contract class:

- `overrides.publicStorage` rewrites the `ContractInstanceRegistry`'s delayed-public-mutable storage so the AVM's `UpdateCheck` resolves to the new class id.

- `overrides.contracts` swaps the deployed instance for one whose `currentContractClassId` is bumped to the new class. Drives both AVM-side public dispatch and PXE-side ACIR private dispatch.

Both pieces are required: a storage-only override would not redirect the AVM's class dispatch (which reads `currentContractClassId` from the contract DB); an instance-only override would cause the witgen `UpdateCheck` to throw on inconsistency. The new class must already be registered on chain.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants