Skip to content

feat: public data tree overrides for simulation#22830

Merged
dbanks12 merged 2 commits into
merge-train/fairiesfrom
db/public-data-overrides-plumbing
May 8, 2026
Merged

feat: public data tree overrides for simulation#22830
dbanks12 merged 2 commits into
merge-train/fairiesfrom
db/public-data-overrides-plumbing

Conversation

@dbanks12
Copy link
Copy Markdown
Contributor

@dbanks12 dbanks12 commented Apr 28, 2026

Extends SimulationOverrides with a publicStorage field, plumbed through .simulate({ overrides }) on aztec.js → wallet → PXE → AztecNode.simulatePublicCalls. Each entry writes a (contract, slot, value) into the public-data tree of the ephemeral world-state fork before the tx runs; real chain state is untouched.

const result = await contract.methods.read_balance(account).simulate({
  overrides: {
    publicStorage: [{ contract: contract.address, slot: BALANCE_SLOT, value: new Fr(1_000_000n) }],
  },
});

Test plan

  • Unit tests in aztec-node/src/aztec-node/public_data_overrides.test.ts.
  • E2E e2e_avm_simulator publicDataOverrides describe block.
  • migration_notes.md and how_to_test.md updated.

Copy link
Copy Markdown
Contributor Author

dbanks12 commented Apr 28, 2026

@dbanks12 dbanks12 force-pushed the db/public-data-overrides-plumbing branch from eeea6a6 to 7c70c29 Compare April 28, 2026 20:42
@dbanks12 dbanks12 changed the title feat: public data tree overrides for simulation (plumbing) feat: public data tree overrides for simulation Apr 28, 2026
@dbanks12 dbanks12 changed the base branch from db/public-data-overrides-core to merge-train/fairies April 28, 2026 20:42
@dbanks12 dbanks12 force-pushed the db/public-data-overrides-plumbing branch 3 times, most recently from bfce029 to 5ec5db9 Compare May 1, 2026 15:39
@dbanks12 dbanks12 force-pushed the db/public-data-overrides-plumbing branch 4 times, most recently from 9116033 to fe71850 Compare May 1, 2026 18:10
@dbanks12 dbanks12 marked this pull request as ready for review May 1, 2026 18:31
@dbanks12 dbanks12 marked this pull request as draft May 1, 2026 20:32
Comment on lines +1 to +16
import { z } from 'zod';

import { type PublicStorageOverride, PublicStorageOverrideSchema } from './public_storage_override.js';

/**
* Pre-simulation state overrides. Each field is optional and additive: the simulator applies all
* provided overrides to the ephemeral world-state fork (in order) before running the tx.
*/
export type StateOverrides = {
/** Public-storage writes to apply before simulation. */
publicStorage?: PublicStorageOverride[];
};

export const StateOverridesSchema = z.object({
publicStorage: z.array(PublicStorageOverrideSchema).optional(),
});
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

if we know for certain that we'll never want to override state from other trees, we could flatten this and just have "public storage overrides" instead of generic "state overrides"

@dbanks12 dbanks12 marked this pull request as ready for review May 5, 2026 01:37
@dbanks12 dbanks12 requested a review from Thunkar May 5, 2026 01:38
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.

Won't block, but as discussed I'd try to lean more into a consolidated overrides object, since very soon we'll be able to do contracts additionally to public state.

The rest LGTM, ty!

@dbanks12 dbanks12 force-pushed the db/public-data-overrides-plumbing branch 2 times, most recently from ce67508 to 1ca8868 Compare May 5, 2026 14:28
@dbanks12 dbanks12 changed the base branch from merge-train/fairies to graphite-base/22830 May 5, 2026 15:42
@dbanks12 dbanks12 force-pushed the graphite-base/22830 branch from 86096b6 to e73027d Compare May 5, 2026 15:42
@dbanks12 dbanks12 force-pushed the db/public-data-overrides-plumbing branch from 1ca8868 to b361b3c Compare May 5, 2026 15:42
@dbanks12 dbanks12 changed the base branch from graphite-base/22830 to db/sim-overrides-drop-artifacts May 5, 2026 15:43
@dbanks12 dbanks12 changed the base branch from db/sim-overrides-drop-artifacts to graphite-base/22830 May 5, 2026 16:15
@dbanks12 dbanks12 force-pushed the db/public-data-overrides-plumbing branch from 0fb7f88 to a63ac50 Compare May 6, 2026 18:56
@dbanks12 dbanks12 force-pushed the db/sim-overrides-drop-artifacts branch from 06fafc0 to a498f65 Compare May 6, 2026 18:56
@dbanks12 dbanks12 force-pushed the db/public-data-overrides-plumbing branch 2 times, most recently from a53f144 to d38afc5 Compare May 6, 2026 19:40
@dbanks12 dbanks12 force-pushed the db/sim-overrides-drop-artifacts branch from cf88b94 to a72d30a Compare May 6, 2026 19:44
@dbanks12 dbanks12 force-pushed the db/public-data-overrides-plumbing branch from d38afc5 to a0a1316 Compare May 6, 2026 19:44
@dbanks12 dbanks12 force-pushed the db/sim-overrides-drop-artifacts branch from a72d30a to 82138d4 Compare May 6, 2026 20:25
@dbanks12 dbanks12 force-pushed the db/public-data-overrides-plumbing branch from a0a1316 to 6e25dbc Compare May 6, 2026 20:25
@dbanks12 dbanks12 force-pushed the db/public-data-overrides-plumbing branch from a176344 to da09888 Compare May 7, 2026 14:41
@dbanks12 dbanks12 force-pushed the db/sim-overrides-drop-artifacts branch 2 times, most recently from 4d7ac18 to 386276c Compare May 7, 2026 14:44
@dbanks12 dbanks12 force-pushed the db/public-data-overrides-plumbing branch from da09888 to 5b272ac Compare May 7, 2026 14:44
@dbanks12 dbanks12 force-pushed the db/public-data-overrides-plumbing branch from 5b272ac to ea12e44 Compare May 7, 2026 18:43
@dbanks12 dbanks12 force-pushed the db/sim-overrides-drop-artifacts branch from 386276c to dd377eb Compare May 7, 2026 18:43
@dbanks12 dbanks12 force-pushed the db/public-data-overrides-plumbing branch from ea12e44 to e33392c Compare May 8, 2026 00:55
@dbanks12 dbanks12 force-pushed the db/sim-overrides-drop-artifacts branch 2 times, most recently from d48dbfe to aec497a Compare May 8, 2026 00:55
@dbanks12 dbanks12 force-pushed the db/public-data-overrides-plumbing branch from e33392c to 7936d76 Compare May 8, 2026 00:55
Base automatically changed from db/sim-overrides-drop-artifacts to merge-train/fairies May 8, 2026 01:19
dbanks12 added 2 commits May 8, 2026 01:19
Extends `SimulationOverrides` with a `publicStorage` field, plumbed through `.simulate({ overrides })` on aztec.js → wallet → PXE → `AztecNode.simulatePublicCalls`. Each entry writes a `(contract, slot, value)` into the public-data tree of the ephemeral world-state fork before the tx runs; real chain state is untouched.
EmbeddedWallet was still calling the old positional-argument form of the
SimulationOverrides constructor, so contract-instance overrides for the
stub account were silently dropped, and simulation re-entered the real
account entrypoint with no auth witness.
@dbanks12 dbanks12 force-pushed the db/public-data-overrides-plumbing branch from 7936d76 to 1b062ca Compare May 8, 2026 01:19
@dbanks12 dbanks12 merged commit eb2103c into merge-train/fairies May 8, 2026
14 checks passed
@dbanks12 dbanks12 deleted the db/public-data-overrides-plumbing branch May 8, 2026 01:24
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