Commit cf0fc39
feat(avm): granular destination selectors for precomputed subtraces
Introduce committed granular destination selectors so the log-derivative inverse of each
lookup into a precomputed table is materialised only over the rows actually read, instead of
the full table region:
- sel_bitwise (boolean, subset of sel_range_16): destination of #[BYTE_OPERATIONS].
- sel_range_16_active (boolean, subset of sel_range_16): destination of every 16-bit
range-check lookup (memory limbs, range_check u16 registers, public-data clk diffs).
- sel_addressing_gas is changed from a precomputed constant to a committed selector and used
as the granular destination of #[ADDRESSING_GAS_READ]. Its outer selector is sel_range_16:
this is sound because the addressing_gas value column is populated across the entire
[0, 2^16) range, so any toggled row carries a valid gas value. A static assertion in
precomputed_trace.cpp guarantees the table spans 2^16 rows.
The lookup builders (LookupIntoBitwise, LookupIntoIndexedByRow) and the strict-mode
AddChecksToBuilder forward the base constructors so each interaction is registered with
sel_range_16 as the outer_dst_selector; the base process() then toggles the fine-grained
selector on used rows.
Proof length 15516 -> 15530. Pinned values (fixed VK hash, NUM_AVM_ULTRA_OPS, mock circuits)
are intentionally NOT refreshed at this stage.
feat(avm): horizontal bitwise subtrace + SIMD-64 (on top of granular selectors) (#471)
* feat(avm): horizontal bitwise subtrace + SIMD-64 (rebased onto jean/precomputed-granular)
Re-applies PR #471 (commit cc1fc796) on top of the current
jean/precomputed-granular head (3a5a5849), squashed into one commit.
The horizontal bitwise subtrace migration + SIMD-64 keccak bitwise lookups:
- bitwise subtrace becomes horizontal (one row per AND/OR/XOR op, 16 per-limb
byte-operation lookups) instead of one row per byte;
- keccak uses SIMD-64 bitwise lookups (BitwiseOperation::SIMD_AND_64 / SIMD_XOR_64);
- the per-byte bitwise dynamic-gas dimension is dropped (AVM_DYN_GAS_ID_BITWISE /
AVM_BITWISE_DYN_L2_GAS removed);
- the granular destination selectors from the base are preserved.
Proof length 15530 -> 15598 (verified: vm2 flavor static_assert passes with
AVM_V2_PROOF_LENGTH_IN_FIELDS = 15598).
Regeneration done in this commit:
- vm2 generated files regenerated from the ported .pil via bb_pil + clang-format-20
(includes the precomputed.{hpp,impl.hpp,cpp} that #469/#510 needs).
- constants.nr + aztec_constants.hpp updated (proof length, dropped bitwise gas ids).
The deleted yarn-project simulator avm_gas.ts (removed in the new base) is dropped.
Verified locally: barretenberg vm2_objects builds clean (C++/PIL/Noir half).
NOT yet refreshed (require full noir+yarn+e2e bootstrap, not available in this
container): TS constants.gen.ts / Solidity ConstantsGen.sol mirrors
(yarn remake-constants), the mock-protocol-circuits pinned tarball, Prover.toml
fixtures, and the fixed-VK hash / NUM_AVM_ULTRA_OPS.
* refactor(avm): flag bitwise SIMD-64 via event boolean, not op enum
Drop the SIMD_AND_64/SIMD_XOR_64 values from BitwiseOperation and carry the
SIMD-64 distinction in a new BitwiseEvent::simd_64 boolean (folded into the
dedup key). The operation enum is now always a real AND/OR/XOR, so tracegen
decomposes it to the op_id selector directly instead of remapping the SIMD
values back to their base operation first.
* refactor(avm): split SIMD-64 bitwise into BitwiseSimdInterface
Move the SIMD-64 operations out of BitwiseInterface into a derived
BitwiseSimdInterface, since pure simulation never uses them. The witgen
Bitwise gadget now implements BitwiseSimdInterface and the KeccakF1600 gadget
(the sole SIMD consumer) depends on it; PureBitwise and MockBitwise drop the
SIMD methods and stay on the scalar BitwiseInterface.
* to squash
* Bitwise trace review
* refactor(avm): rename bitwise acc_i{a,b,c}[_simd] columns to i{a,b,c}[_simd]
Pure column rename across PIL (bitwise/keccakf1600/sha256/execution), the
regenerated C++, tracegen, and tests. No behavior change.
* Comments on SIMD invocation in circuit
* feat(avm): granular destination selector for execution->bitwise dispatch
Add a committed sel_bitwise_opcode selector marking the bitwise rows claimed by
the execution #[DISPATCH_TO_BITWISE] lookup, so that lookup's log-derivative
inverse is sparse (execution-originated rows only) instead of dense over the
whole bitwise trace. Unify all bitwise lookup builders on bitwise.sel as the
shared outer index selector.
Add #[BITW_SIMD_64_EXCLUSIVE]: (sel_keccak + sel_sha256 + sel_bitwise_opcode) *
sel_simd_64 = 0, enforcing that no scalar consumer claims a SIMD-64 row.
Bumps AVM_V2_PROOF_LENGTH_IN_FIELDS (15598->15603) and NUM_AVM_ULTRA_OPS
(3131->3132) for the added column.
* refactor(avm): drop redundant bitwise sel_u8 column
sel_u8 was defined as an alias of sel_compute (sel_u8 = sel_compute), carrying
no independent information. Use sel_compute directly as the limb-0 width
selector in #[BYTE_OPERATIONS_0] and the recomposition, and remove the sel_u8
column. Regenerated C++ and updated tracegen and tests.
The removed column offsets the sel_bitwise_opcode addition, so
AVM_V2_PROOF_LENGTH_IN_FIELDS (15598) and NUM_AVM_ULTRA_OPS (3131) return to
their prior values.
* Comments and review of keccak simulation gadget
* fix(avm): drop SIMD-64 bitwise mutual exclusion and tag passing
Remove #[BITW_SIMD_64_EXCLUSIVE]. It was defense-in-depth but caused an
order-dependent completeness failure: a U128 non-SIMD op whose low 64 bits
coincide with a SIMD row's lane 0 could make a lookup toggle both a scalar
dedup selector and sel_simd_64 onto one row, violating the exclusion. With it
gone the coincidence is benign (the rows are value-identical on the looked-up
tuple and every other relation holds).
SIMD keccak lookups now index over sel_simd_64 directly (set intrinsically by
tracegen), with no outer selector, so a SIMD lookup can only match a genuine
SIMD row. They also no longer pass the double U128 tag: sel_simd_64 is a term of
sel_simd_64 => sel_u128 => tag_a = U128 = tag_b pins the tags anyway. The dead
keccakf1600.tag_u128 column is removed.
Migrate VulnerabilityFakeKeccakXorOutput to a scalar keccak lookup (THETA_XOR_41),
where the double-tag error-row protection still applies.
AVM_V2_PROOF_LENGTH_IN_FIELDS 15598->15593 and NUM_AVM_ULTRA_OPS 3131->3130 for
the removed column.
* New mock protocol circuits
* refactor(avm): gate bitwise RES_TAG_SHOULD_MATCH_INPUT on sel_compute
Rewrite #[RES_TAG_SHOULD_MATCH_INPUT] as sel_compute * (tag_c - tag_a) = 0
(equivalent to the previous (1 - err) * sel * (tag_c - tag_a) = 0, since
sel_compute = sel * (1 - err)), moved below the sel_compute definition, and
clarify the surrounding width-selector / error-handling comments.
* Remove wrong comment in bitwise.pil
* Further editorial changes in pil comments
* Addressing review comments
---------
Co-authored-by: AztecBot <tech@aztec-labs.com>
Co-authored-by: jeanmon <jean@aztec-labs.com>1 parent 0fbf179 commit cf0fc39
85 files changed
Lines changed: 8622 additions & 9324 deletions
File tree
- barretenberg/cpp
- pil/vm2
- trees
- scripts
- src/barretenberg
- avm_fuzzer/harness
- aztec
- vm2
- common
- constraining
- recursion
- relations
- generated
- relations
- simulation
- events
- gadgets
- interfaces
- tracegen
- lib
- noir-projects
- mock-protocol-circuits
- noir-protocol-circuits
- crates
- private-kernel-init-2
- private-kernel-init-3
- private-kernel-init-4
- private-kernel-init-5
- private-kernel-init
- private-kernel-inner-2
- private-kernel-inner-3
- private-kernel-inner-4
- private-kernel-inner-5
- private-kernel-inner
- private-kernel-reset-tail-to-public
- private-kernel-reset-tail
- rollup-block-root-first-single-tx
- rollup-block-root-first
- rollup-checkpoint-merge
- rollup-checkpoint-root-single-block
- rollup-root
- rollup-tx-base-private
- rollup-tx-base-public
- types/src
- yarn-project/constants/src
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
64 | | - | |
65 | | - | |
| 63 | + | |
| 64 | + | |
66 | 65 | | |
67 | 66 | | |
68 | 67 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
135 | 134 | | |
136 | 135 | | |
137 | 136 | | |
| |||
586 | 585 | | |
587 | 586 | | |
588 | 587 | | |
589 | | - | |
590 | 588 | | |
591 | 589 | | |
592 | 590 | | |
593 | 591 | | |
594 | 592 | | |
595 | 593 | | |
596 | 594 | | |
597 | | - | |
598 | 595 | | |
599 | 596 | | |
600 | 597 | | |
601 | 598 | | |
602 | 599 | | |
603 | 600 | | |
604 | 601 | | |
605 | | - | |
606 | 602 | | |
607 | 603 | | |
608 | 604 | | |
609 | 605 | | |
610 | 606 | | |
611 | 607 | | |
612 | | - | |
613 | | - | |
614 | | - | |
615 | | - | |
616 | | - | |
617 | | - | |
618 | | - | |
619 | | - | |
620 | | - | |
621 | 608 | | |
622 | 609 | | |
623 | 610 | | |
| |||
734 | 721 | | |
735 | 722 | | |
736 | 723 | | |
737 | | - | |
| 724 | + | |
738 | 725 | | |
739 | | - | |
| 726 | + | |
740 | 727 | | |
741 | 728 | | |
742 | 729 | | |
| |||
1087 | 1074 | | |
1088 | 1075 | | |
1089 | 1076 | | |
1090 | | - | |
| 1077 | + | |
1091 | 1078 | | |
1092 | | - | |
1093 | | - | |
1094 | | - | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
1095 | 1082 | | |
1096 | 1083 | | |
1097 | 1084 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
283 | 283 | | |
284 | 284 | | |
285 | 285 | | |
286 | | - | |
| 286 | + | |
287 | 287 | | |
288 | | - | |
| 288 | + | |
289 | 289 | | |
290 | | - | |
| 290 | + | |
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
36 | 43 | | |
37 | 44 | | |
38 | 45 | | |
| |||
112 | 119 | | |
113 | 120 | | |
114 | 121 | | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
115 | 127 | | |
116 | 128 | | |
117 | 129 | | |
| |||
137 | 149 | | |
138 | 150 | | |
139 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
140 | 157 | | |
141 | 158 | | |
142 | 159 | | |
| |||
342 | 359 | | |
343 | 360 | | |
344 | 361 | | |
345 | | - | |
| 362 | + | |
346 | 363 | | |
347 | 364 | | |
348 | 365 | | |
| |||
352 | 369 | | |
353 | 370 | | |
354 | 371 | | |
355 | | - | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
356 | 380 | | |
357 | 381 | | |
358 | 382 | | |
| |||
444 | 468 | | |
445 | 469 | | |
446 | 470 | | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| |||
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
277 | | - | |
| 277 | + | |
278 | 278 | | |
279 | 279 | | |
280 | 280 | | |
| |||
312 | 312 | | |
313 | 313 | | |
314 | 314 | | |
315 | | - | |
| 315 | + | |
316 | 316 | | |
317 | | - | |
| 317 | + | |
318 | 318 | | |
319 | | - | |
| 319 | + | |
320 | 320 | | |
321 | | - | |
| 321 | + | |
322 | 322 | | |
323 | | - | |
| 323 | + | |
324 | 324 | | |
325 | | - | |
| 325 | + | |
326 | 326 | | |
327 | | - | |
| 327 | + | |
328 | 328 | | |
329 | | - | |
| 329 | + | |
0 commit comments