Commit a176d96
perf(e2e): seed standard contracts at genesis (#24568)
Round-4 e2e speedup, PR 1b (adoption half of the AuthRegistry prize).
**Stacked on #24567** (`spl/genesis-prefilled-nullifiers`, the
genesis-nullifier mechanism). This PR targets that branch; retarget to
`merge-train/spartan-v5` once #24567 merges.
## What
Make e2e environments start with the standard contracts (AuthRegistry,
PublicChecks, HandshakeRegistry) already "published", so
`ensureAuthRegistryPublished` and its two siblings skip their two
publish txs each. At production cadence `setup:auth-registry` alone was
~16 min/run (2 sequential txs per process, paid per-process across the
suite). This collapses that span to sub-second.
## Mechanism (three parts, all default-off outside e2e)
- **Genesis nullifiers.** Per standard contract, seed
`siloNullifier(ContractClassRegistry, classId)` and
`siloNullifier(ContractInstanceRegistry, instanceAddress)` (the real
derived address — standard contracts are not magic-address protocol
contracts) into the fixtures' `getGenesisValues` call, via PR 1a's new
5th param. These are exactly the nullifiers the publish txs would emit,
so the AVM's deployment-nullifier check passes when the contracts are
called publicly. A single helper
(`getStandardContractGenesisNullifiers`) feeds all four e2e genesis
builders (`fixtures/setup.ts`, `e2e_prover_test.ts`,
`p2p/p2p_network.ts`, `multi-node/governance/add_rollup.test.ts`) — the
latter three recompute a genesis that must reproduce the L1-deployed
archive root, so they must seed the identical set. Non-e2e callers (cli,
sandbox/local-network) are untouched.
- **Archiver preload.** `registerStandardContracts` mirrors
`registerProtocolContracts`: it seeds each contract's class (with
recomputed `publicBytecodeCommitment`), instance, and public-function
signatures into the contract store at block 0, reading the bundled
`@aztec/standard-contracts` artifacts. It is idempotent (skips
already-registered classes on restart) and gated behind a new archiver
config flag `testPreloadStandardContracts` (env
`TEST_PRELOAD_STANDARD_CONTRACTS`, default **false**). The flag is set
from the e2e node config so every spawned node (validators, prover
nodes) picks it up through the normal config path. This adds
`@aztec/standard-contracts` as an archiver dependency.
- **Guard short-circuit.** The `ensure*Published` helpers are unchanged.
Their guards read
`wallet.getContractClassMetadata(id).isContractClassPubliclyRegistered`
(to `aztecNode.getContractClass`) and
`wallet.getContractMetadata(addr).isContractPublished` (to
`aztecNode.getContract`) — both are archiver-store reads, not
nullifier-tree reads. The store preload alone makes both short-circuit;
the genesis nullifiers are what make the contract actually callable in
the AVM afterwards. Keeping the helpers doubles as a regression check:
if seeding ever breaks, the tx path re-engages and tests still pass,
just slow.
## Why the flag is test-only (A-1257 rationale)
Preloading unconditionally in production would recreate the A-1257
collision #24254 fixed: a real on-chain publish of a preloaded class
would collide with the block-0 preload, because production genesis will
**not** carry the matching nullifiers. The flag is only set by the e2e
fixtures, which also seed the nullifiers, keeping the store and the
nullifier tree consistent. A single source of truth
(`getPublishableStandardContracts`) drives both the preloaded set and
the seeded-nullifier set so they cannot drift.
## State-write verification
Inspected the two publish txs on this base:
- `ContractClassRegistry.publish` pushes one nullifier (`classId`,
siloed to the class-registry address) and broadcasts a
`ContractClassPublished` contract-class log carrying the packed
bytecode. No public-data writes.
- `ContractInstanceRegistry.publish_for_public_execution` asserts the
class-registration nullifier exists, then pushes one nullifier
(`address`, siloed to the instance-registry address) and broadcasts a
`ContractInstancePublished` private log. No public-data writes.
So the full state-write set is two nullifiers + two broadcast logs. The
nullifiers are replicated via genesis `prefilledNullifiers`; the
archiver normally learns the class/instance from those two logs
(`data_store_updater.ts`), and the block-0 preload replaces that path
exactly. No `genesisPublicData` is required. PXE-side registration
(`wallet.registerContract`) is unaffected and still runs in the helpers.
## Local verification
- `automine/accounts/authwit.test.ts` (public-authwit path against the
standard AuthRegistry), timing on: passes; `setup:auth-registry` span =
**10 ms** (was ~33 s at production cadence). No on-chain AuthRegistry
publish (the only `ContractClassRegistry.publish` executions are the
test's own AuthWitTest/GenericProxy deploys); the public AuthRegistry
contract executes fine against the seeded nullifier.
`testPreloadStandardContracts: true` confirmed in the node config dump.
- `single-node/fees/account_init.test.ts` (production sequencer +
simulated prover node), timing on: 5/5 pass; `setup:auth-registry` span
= **10 ms**. Prover node syncs against the seeded genesis (no root
divergence), and the flag propagates to it. No duplicate-nullifier
errors.
- New unit test in `archiver/src/modules/data_store_updater.test.ts`:
`registerStandardContracts` preloads each publishable standard
contract's class + instance into the store and is idempotent on a second
call.
## Expected impact
~14–16 min/run from auth-registry alone, plus more from the two untagged
siblings (PublicChecks / HandshakeRegistry) wherever used.
## Measured impact
`setup:auth-registry` collapses from 702.2s of setup time run-wide (39
occurrences, 5–35s each) to
482ms total (max 87ms per occurrence) — sub-second run-wide, every shard
clean, no seeding or
flag-propagation slow path.
- The measured beforeHooks reduction is larger than the auth-registry
span alone, because the two
untagged sibling publishes (PublicChecks, HandshakeRegistry) are removed
too. Example: account_init
beforeHooks −49.6s vs a 30.9s tagged auth-registry span; the extra ~19s
is the two siblings.
- Per-suite beforeHooks deltas: account_init −49.6s, fee_settings
−49.5s, failures −48.7s,
private_payments.parallel −41.8s/shard (×8), gas_estimation.parallel
−41.5s/shard (×3),
l1_to_l2 −38.1s, l2_to_l1 −37.5s, l1_to_l2_inbox_drift −38.2s,
token_bridge −37.7s,
fee_juice_payments −37.4s, bot −34.3s; automine/parallel suites shed
5–15s each (their
fast-cadence publishes).
- Total beforeHooks reduction over the suites present in both runs:
−1,649.7s summed across shards
(wall-clock benefit is smaller, since shards run in parallel across
workers).
Baseline CI run 1783389062016888 (#24567 `ci/x-fast`; mechanism-only, so
timing-neutral vs
merge-base). PR CI run 1783391194852197 (#24568 `ci/x-fast`).
## Notes for downstream
- **PR 6 (fees harness):** `applyEnsureAuthRegistryPublished` now
short-circuits; the fees setup chain loses the ~32 s/shard auth-registry
step, so rebase the overlap/batch shape onto what remains (token deploy,
FPC, mints).
- **Fix phase / timing capture:** expected span assertion is
`setup:auth-registry` around sub-second across the run (10 ms observed
locally per process). Any shard still showing tens of seconds means the
guards took the slow path (a seeding or flag-propagation bug), not
noise.
Fixes A-1404
(cherry picked from commit f320049)1 parent 915501a commit a176d96
15 files changed
Lines changed: 156 additions & 2 deletions
File tree
- yarn-project
- archiver
- src
- modules
- end-to-end/src
- fixtures
- multi-node/governance
- p2p
- foundation/src/config
- standard-contracts/src
- stdlib/src/interfaces
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
93 | 101 | | |
94 | 102 | | |
95 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
71 | 75 | | |
72 | 76 | | |
73 | 77 | | |
| |||
227 | 231 | | |
228 | 232 | | |
229 | 233 | | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
Lines changed: 28 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | | - | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
149 | 150 | | |
150 | 151 | | |
151 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
152 | 179 | | |
153 | 180 | | |
154 | 181 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
36 | 39 | | |
37 | 40 | | |
38 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
229 | 230 | | |
230 | 231 | | |
231 | 232 | | |
| 233 | + | |
232 | 234 | | |
233 | 235 | | |
234 | 236 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| |||
474 | 475 | | |
475 | 476 | | |
476 | 477 | | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
477 | 485 | | |
478 | 486 | | |
479 | 487 | | |
480 | 488 | | |
481 | 489 | | |
482 | 490 | | |
| 491 | + | |
483 | 492 | | |
484 | 493 | | |
485 | 494 | | |
| |||
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
136 | 137 | | |
137 | 138 | | |
138 | 139 | | |
139 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
140 | 147 | | |
141 | 148 | | |
142 | 149 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
415 | 416 | | |
416 | 417 | | |
417 | 418 | | |
| 419 | + | |
418 | 420 | | |
419 | 421 | | |
420 | 422 | | |
| |||
0 commit comments