Commit a4e3a44
authored
feat(world-state): support prefilled nullifiers in genesis state (#24567)
## What
Adds opt-in plumbing to seed nullifier leaves into the genesis nullifier
tree, threaded through the C++ world state and the TypeScript
world-state layer. The field is optional and defaults to empty, so
**production genesis is unchanged** — every existing genesis root stays
bit-identical to today.
- **C++**: `WorldState` constructors, the napi binding,
`create_canonical_fork`, and the standalone `aztec-wsdb` IPC server gain
a `prefilled_nullifiers` input, inserted as the nullifier tree's initial
leaves. The indexed nullifier tree requires those leaves to be unique
and strictly increasing (and distinct from the padding leaves), which
the tree already enforces; the TS side additionally checks it before the
native call for a friendlier error.
- **TS**: `GenesisData.prefilledNullifiers` (optional, defaults to `[]`)
threads through `native_world_state_instance.ts`. `getGenesisValues`
gains an optional `prefilledNullifiers` param (sorted ascending on the
way in), and the `GENESIS_ARCHIVE_ROOT` fast-path in
`generateGenesisValues` now also checks the nullifier list is empty, so
the short-circuit only fires for the canonical empty genesis.
## Why
Mechanism for round-4 e2e speedup PR 1b, which will seed the
standard-contract (AuthRegistry / PublicChecks / HandshakeRegistry)
registration nullifiers at genesis in the e2e fixtures so their publish
txs short-circuit. This PR carries no consumers and is intentionally
behavior- and timing-neutral: with the field empty (the only value ever
passed in production), the native tree, all genesis roots, and the
archive root are identical to before.
## Relationship to #24254
This is a deliberate subset port of #24254 ("seed protocol contract
registration nullifiers at genesis"), kept shape- and
signature-identical wherever it does not diverge, so that when #24254
itself reaches the v5 line the mechanism merges as "already applied".
The intentional divergences:
- `prefilledNullifiers` is **optional and defaults to empty** here
(#24254 made it required and non-empty by default via
`DEFAULT_GENESIS_DATA`).
- This PR does **not** port `DEFAULT_GENESIS_DATA`, the
protocol-contract nullifier generation
(`protocol-contracts/src/genesis_data.ts`, `scripts/generate_data.ts`),
or **any** constant recomputation (`GENESIS_ARCHIVE_ROOT`,
`constants.nr`, `constants.gen.ts`, `ConstantsGen.sol`,
`aztec_constants.hpp`, checkpoint / AVM golden fixtures). With the field
empty, every genesis root is unchanged, which is the invariant CI must
prove.
## Testing (local)
- C++ `world_state_tests`: `GetInitialTreeInfoForAllTrees` (unchanged —
still asserts the current empty-nullifier root `0x18935581…` and
`GENESIS_ARCHIVE_ROOT`, proving empty-field behavior is bit-identical),
`GetInitialTreeInfoWithPrefilledPublicData` (updated to pass an empty
nullifier vector), and a new `GetInitialTreeInfoWithPrefilledNullifiers`
(seeding changes the root, tree size stays 128, seeded leaves are
present) — 3/3 pass.
- `@aztec/world-state` `testing.test.ts` (7/7): empty genesis returns
`GENESIS_ARCHIVE_ROOT` via the fast path; the empty-genesis computed
root matches that constant; an explicit empty `prefilledNullifiers`
yields the same root as omitting the field; a non-empty sorted list
yields a deterministic root that differs from empty; `getGenesisValues`
sorts and seeds; and non-strictly-increasing (descending / duplicate)
lists are rejected by the defensive check.
- Regression: `@aztec/world-state` `native_world_state.test.ts` (53/53),
`@aztec/stdlib` `l2_block.test.ts` (3/3, confirms the genesis nullifier
root is unchanged), `@aztec/prover-client`
`lightweight_checkpoint_builder.test.ts` (7/7).
- Full `yarn build`, plus `yarn format`/`yarn lint` on the touched
packages, are clean.
## Notes
This PR is intentionally behavior- and timing-neutral; no e2e behavior
changes until PR 1b adopts the mechanism.
## Measured impact
None expected, and none observed. `prefilledNullifiers` defaults to
`[]`, so the production genesis
payload and roots are bit-identical (asserted by the unchanged C++
empty-nullifier root and
`GENESIS_ARCHIVE_ROOT` tests); no fixture opts into a non-empty list in
this PR.
CI timings confirm neutrality: per-suite beforeHooks deltas scatter in
both directions within the
per-suite noise floor — largest were runtime_config −12.8s, token_bridge
−12.7s, account_init +11.5s,
failures +11.0s — with the fees suites essentially flat
(private_payments −3.4s, gas_estimation
−0.2s) and no systematic direction. The summed beforeHooks delta over
all 276 suites present in both
runs is −122.8s (~−2%), well inside accumulated run-to-run variance.
Baseline CI run 1783374468714213 (merge-base e1711d3, full). PR CI
run 1783389062016888 (x-fast).
Part of A-14041 parent 5d2b6df commit a4e3a44
11 files changed
Lines changed: 280 additions & 17 deletions
File tree
- barretenberg/cpp/src/barretenberg
- nodejs_module/world_state
- world_state
- wsdb
- yarn-project
- stdlib/src/world-state
- world-state/src
- native
Lines changed: 28 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
112 | 113 | | |
113 | 114 | | |
114 | 115 | | |
115 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
116 | 138 | | |
117 | 139 | | |
118 | 140 | | |
119 | 141 | | |
120 | 142 | | |
121 | 143 | | |
122 | 144 | | |
123 | | - | |
| 145 | + | |
124 | 146 | | |
125 | 147 | | |
126 | 148 | | |
| |||
130 | 152 | | |
131 | 153 | | |
132 | 154 | | |
133 | | - | |
| 155 | + | |
134 | 156 | | |
135 | 157 | | |
136 | 158 | | |
| |||
160 | 182 | | |
161 | 183 | | |
162 | 184 | | |
163 | | - | |
| 185 | + | |
164 | 186 | | |
165 | 187 | | |
166 | 188 | | |
| |||
173 | 195 | | |
174 | 196 | | |
175 | 197 | | |
176 | | - | |
| 198 | + | |
177 | 199 | | |
178 | 200 | | |
179 | 201 | | |
| |||
187 | 209 | | |
188 | 210 | | |
189 | 211 | | |
| 212 | + | |
190 | 213 | | |
191 | 214 | | |
192 | 215 | | |
| |||
Lines changed: 14 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
54 | | - | |
| 55 | + | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| |||
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
| 77 | + | |
76 | 78 | | |
77 | 79 | | |
78 | 80 | | |
| |||
84 | 86 | | |
85 | 87 | | |
86 | 88 | | |
| 89 | + | |
87 | 90 | | |
88 | 91 | | |
89 | 92 | | |
| |||
99 | 102 | | |
100 | 103 | | |
101 | 104 | | |
| 105 | + | |
102 | 106 | | |
103 | 107 | | |
104 | 108 | | |
| |||
118 | 122 | | |
119 | 123 | | |
120 | 124 | | |
| 125 | + | |
121 | 126 | | |
122 | 127 | | |
123 | 128 | | |
| |||
126 | 131 | | |
127 | 132 | | |
128 | 133 | | |
| 134 | + | |
129 | 135 | | |
130 | 136 | | |
131 | 137 | | |
| |||
148 | 154 | | |
149 | 155 | | |
150 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
151 | 162 | | |
152 | 163 | | |
153 | | - | |
| 164 | + | |
| 165 | + | |
154 | 166 | | |
155 | 167 | | |
156 | 168 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
90 | 94 | | |
91 | 95 | | |
92 | 96 | | |
| |||
99 | 103 | | |
100 | 104 | | |
101 | 105 | | |
| 106 | + | |
102 | 107 | | |
103 | 108 | | |
104 | 109 | | |
| |||
326 | 331 | | |
327 | 332 | | |
328 | 333 | | |
| 334 | + | |
329 | 335 | | |
330 | 336 | | |
331 | 337 | | |
| |||
Lines changed: 52 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 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 | + | |
| 264 | + | |
214 | 265 | | |
215 | 266 | | |
216 | 267 | | |
| |||
225 | 276 | | |
226 | 277 | | |
227 | 278 | | |
| 279 | + | |
228 | 280 | | |
229 | 281 | | |
230 | 282 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
86 | 91 | | |
87 | 92 | | |
88 | 93 | | |
| |||
121 | 126 | | |
122 | 127 | | |
123 | 128 | | |
| 129 | + | |
124 | 130 | | |
125 | 131 | | |
126 | 132 | | |
| |||
Lines changed: 38 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
171 | 199 | | |
172 | 200 | | |
173 | 201 | | |
| |||
180 | 208 | | |
181 | 209 | | |
182 | 210 | | |
| 211 | + | |
183 | 212 | | |
184 | 213 | | |
185 | 214 | | |
| |||
211 | 240 | | |
212 | 241 | | |
213 | 242 | | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
214 | 251 | | |
215 | 252 | | |
216 | 253 | | |
| |||
219 | 256 | | |
220 | 257 | | |
221 | 258 | | |
| 259 | + | |
222 | 260 | | |
223 | 261 | | |
224 | 262 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | 4 | | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
7 | 16 | | |
8 | 17 | | |
9 | 18 | | |
10 | 19 | | |
11 | 20 | | |
12 | 21 | | |
13 | 22 | | |
| 23 | + | |
14 | 24 | | |
15 | 25 | | |
16 | 26 | | |
| |||
0 commit comments