Commit 7f6b85e
refactor(stark): unify & clean up the commitment layer (#735)
* refactor(stark): extract Merkle commitment into a commitment module
Unifies the two near-identical bit-reversed leaf hashers (per-row + per-row-pair)
into one keccak_leaves_bit_reversed_grouped(columns, rows_per_leaf), and the two
near-identical commit fns (commit_columns_bit_reversed + commit_composition_polynomial)
into commit_bit_reversed(columns, rows_per_leaf), in a new crypto/stark/src/commitment.rs.
Removes them from the IsStarkProver trait (they used no self). prover.rs re-exports
the named leaf hashers for the math-cuda GPU parity test. Byte-identical (stark 128/128).
* perf(stark): row-pair the trace commitment (one Merkle path per query)
Every FRI query opens a value and its symmetric counterpart (LDE positions
2*iota, 2*iota+1). The composition-poly commitment already grouped that pair into
one leaf; the trace (main/aux/precomputed) committed one row per leaf and opened
TWO leaves (proof + proof_sym) per query. Commit the trace with rows_per_leaf=2
too, so each query opens ONE leaf/path; drop the now-redundant proof_sym from
PolynomialOpenings (also shrinks the composition opening, which stored the path
twice). verify_opening_pair now reconstructs the paired leaf and verifies once
(mirrors verify_composition_poly_opening); the dead verify_opening is removed.
Halves trace Merkle authentication-path data per query (smaller proofs + less
verifier hashing). stark 128/128 (prove+verify). NOTE: proof FORMAT change (not
byte-identical). cuda follow-up: the GPU trace leaf+tree builders
(gpu_lde::try_expand_leaf_and_tree_batched_keep/_ext3_keep + math-cuda kernels)
still build 1-row leaves and must switch to the row-pair pattern (the GPU
composition builder already pairs) or cuda proofs will fail verification.
* refactor(stark): prover cleanup — par helpers, ROWS_PER_LEAF, error propagation, doc/log fixes
* docs(stark): fix commitment.rs leaf-layout docs after trace pairing
The trace commitment now uses the row-pair leaf layout (ROWS_PER_LEAF=2), same as
composition; rows_per_leaf=1 is only kept for the GPU parity test. Update the
module/const/wrapper docs that still described the pre-pairing per-row trace.
* refactor(prover): dedup commit pipeline (commit_plain + spill_tree) (B)
Extract two helpers on IsStarkProver, collapsing the near-duplicate
main-trace and aux-trace commit code:
- spill_tree<C>: the identical-except-label disk-spill block, shared by
the main / preprocessed-split / aux commit sites (4 call sites).
- commit_plain<C>: commit_bit_reversed + spill_tree + TableCommit::plain,
shared by the main-trace (non-preprocessed None arm) and aux-trace
plain-commit paths.
Proof output is byte-identical (stark 128/128, +disk-spill 133/133).
The only behavioral delta is in the instruments profiling feature: the
aux commit's timing bucket now includes its (tiny) disk spill, matching
what the main path already measured.
clippy clean on default / disk-spill / instruments; builds on the
combined feature set.
* fix(prover): row-pair the preprocessed-table commitments (CI fix)
The trace Merkle commitment moved to a row-pair leaf layout
(ROWS_PER_LEAF=2), but the 5 preprocessed-table commitment computers
(bitwise/keccak_rc/page/decode/register) still built a 1-row-per-leaf
tree manually, so the prover's row-pair precomputed root no longer
matched the computed/hardcoded one -> PrecomputedCommitmentMismatch at
prove time.
- Route all 5 compute_*commitment fns through the shared
stark::commitment::commit_bit_reversed(.., ROWS_PER_LEAF), dropping the
manual bit-reverse + columns2rows + 1-row BatchedMerkleTree::build.
- Regenerate the hardcoded bitwise/keccak_rc/zero_page static commitments
for the row-pair layout (via compute_static_commitments).
- cargo fmt (prover.rs + touched tables).
Verified: static_commitments drift tests 5/5, stark 128/128, clippy +
fmt clean, no PrecomputedCommitmentMismatch. Full ELF prove/verify runs
in CI (guest artifacts absent locally).
* test(prover): regenerate SUB_DECODE_COMMITMENT_BLOWUP_2 for row-pair layout
The compile-time decode-commitment const for sub.elf shifted with the
row-pair preprocessed commitment; regenerated via commitment_from_elf
(the print_decode_commitment_for_sub regen path).
* test(prover): TEMP print actual decode commitment to regenerate const from CI
* test(prover): set SUB_DECODE_COMMITMENT_BLOWUP_2 to CI-computed row-pair value
Regenerated from CI's sub.elf (local riscv toolchain unavailable);
removed the temporary print instrumentation.
* mplement changes in GPU
* refactor
* Fix CUDA LDE clippy lint
* fix(cuda): align review cleanup with row-pair commits (#723)
* fix(stark): silence dead_code on par_for_each_mut (debug-checks-only after merge)
* style(stark): cargo fmt after merge resolution
* test(cuda): focused GPU row-pair commitment prove+verify test
* fix(cuda): drop stale R2 parts-LDE asserts (#700 fused path), silence GPU column-LDE dead_code
The R2 parts-LDE / comp-poly-tree GPU dispatches no longer fire since #699/#700
route degree-3 tables through the 2-part fused coset_lde_full path (no AIR has
number_of_parts > 2). try_expand_columns_batched* are debug-checks-only after
the #650 row-major LDE became production.
* review(stark): address PR #735 review — coverage, dead code, cleanups (#740)
Follow-up to the row-pair commitment PR. Excludes the intentional
proof-format break (proof_sym removal / leaf-count change), which is
by design.
Test coverage (in their own files under crypto/stark/src/tests/, per the
crate's test structure):
- tests/commitment_tests.rs: direct unit tests pinning the row-pair leaf
layout (R=1 and R=2) against an independent reference, wrapper
agreement, commit-root consistency, and empty-input short-circuit.
Previously the leaf layout was only covered transitively via full
prove->verify, and GPU parity tests compared against an inline reimpl
rather than this module.
- tests/row_pair_opening_tests.rs: two negative tests for the row-pair
verify_opening_pair — a tampered symmetric trace evaluation and a
corrupted Merkle authentication path must both be rejected. Removing
proof_sym deleted the old "symmetric opening mismatch" rejection class;
these restore it (an impl ignoring evaluations_sym / the auth path
would otherwise pass every existing test). Reuses the now pub(crate)
make_valid_simple_proof helper.
- cuda_path_integration.rs: restore assert!(gpu_comp_poly_tree_calls() > 0).
try_build_comp_poly_tree_gpu is dispatched unconditionally (round 2,
after the parts-count branch), so it fires for the common
number_of_parts == 2 (degree-3) case — it was NOT obsolete. Keep the
genuinely-dead parts-LDE assertion dropped.
Cleanups:
- Delete dead fn commit_plain (zero callers; main/aux commit inline
commit_rows_bit_reversed + spill_tree, which are row-major and
incompatible with its column-major signature — the dedup never landed).
- Delete orphaned pub fn columns2rows (all callers removed by #735).
- Add ProvingError::Fft and map FFTError to it instead of WrongParameter
(internal FFT failure is not a caller-supplied-parameter error).
- Fix stale profiler label commit_composition_poly -> commit_bit_reversed.
- Drop the rot-prone "// = 2" comment on the local ROWS_PER_LEAF alias.
* review(stark): tidy test layout + remove AGENTS.md (follow-up to #740) (#744)
Two items that landed too late for #740:
- Move the shared make_valid_simple_proof helper out of small_trace_tests.rs
into tests/trace_test_helpers.rs, where the crate keeps shared test
helpers (matching how prover_tests sources get_trace_evaluations).
row_pair_opening_tests.rs and small_trace_tests.rs now both import it
from there instead of one test file reaching sideways into another.
- Delete AGENTS.md (added by #735).
---------
Co-authored-by: Joaquin Carletti <joaquin.carletti@lambdaclass.com>
Co-authored-by: MauroFab <maurotoscano2@gmail.com>
Co-authored-by: Mauro Toscano <12560266+MauroToscano@users.noreply.github.com>1 parent 7974e45 commit 7f6b85e
30 files changed
Lines changed: 1082 additions & 616 deletions
File tree
- crypto
- math-cuda
- kernels
- src
- tests
- stark/src
- proof
- tests
- prover
- src
- tables
- tests
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
162 | | - | |
163 | | - | |
| 162 | + | |
| 163 | + | |
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
| |||
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
184 | 229 | | |
185 | 230 | | |
186 | 231 | | |
| |||
349 | 394 | | |
350 | 395 | | |
351 | 396 | | |
352 | | - | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
353 | 405 | | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
359 | 411 | | |
360 | | - | |
| 412 | + | |
361 | 413 | | |
362 | 414 | | |
363 | 415 | | |
364 | 416 | | |
365 | 417 | | |
366 | 418 | | |
367 | 419 | | |
368 | | - | |
369 | | - | |
370 | | - | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
371 | 427 | | |
372 | 428 | | |
373 | 429 | | |
374 | 430 | | |
375 | 431 | | |
376 | 432 | | |
| 433 | + | |
377 | 434 | | |
378 | | - | |
379 | | - | |
380 | | - | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
381 | 440 | | |
382 | 441 | | |
383 | 442 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
| 150 | + | |
151 | 151 | | |
| 152 | + | |
152 | 153 | | |
153 | 154 | | |
154 | 155 | | |
| |||
247 | 248 | | |
248 | 249 | | |
249 | 250 | | |
250 | | - | |
251 | | - | |
| 251 | + | |
| 252 | + | |
252 | 253 | | |
| 254 | + | |
| 255 | + | |
253 | 256 | | |
254 | 257 | | |
255 | 258 | | |
| |||
0 commit comments