Skip to content

feat: merge-train/barretenberg#23560

Merged
AztecBot merged 2 commits into
nextfrom
merge-train/barretenberg
May 26, 2026
Merged

feat: merge-train/barretenberg#23560
AztecBot merged 2 commits into
nextfrom
merge-train/barretenberg

Conversation

@AztecBot
Copy link
Copy Markdown
Collaborator

@AztecBot AztecBot commented May 26, 2026

BEGIN_COMMIT_OVERRIDE
fix: revert extract Constantine signed-Booth window recoder (#23561)
END_COMMIT_OVERRIDE

…zzer

Adds pippenger_constantine.hpp as a standalone primitive carved out of the
upcoming round-parallel Pippenger MSM rewrite. Self-contained header in
bb::scalar_multiplication::round_parallel_detail with no callers on this
branch — landed first so the recoder gets reviewed and CI-gated as a
mathematical primitive rather than buried inside the larger MSM PR.

The recoder implements Constantine's signedWindowEncoding / getSignedFullWindowAt
(constantine/math/arithmetic/bigints.nim): each window reads (c+1) bits including
the previous window's top bit and lets that shared boundary bit substitute for an
explicit carry, producing a (sign | bucket) packed digit. Two parallel families:

  * Scalar path  — ConstantineSliceParams + get_constantine_packed_digit
                   (uint64-indexed limbs)
  * SIMD x4 path — ConstantineSliceParamsU32 + three specialised stores
                   (uint32-indexed limbs, GCC vector_size, 4 scalars/call)

The SIMD helpers split on slice-path (Localised / Bottom / Boundary) so the
per-window branch hoists out of the per-scalar inner loop.

Tests (pippenger_constantine.test.cpp, ~48 ms native / ~46 ms WASM):

  1. ScalarMatchesReferenceOracleAllWindowBits — production scalar path vs a
     textbook signed-window reference oracle. Sweeps window_bits in [1, 19]
     (covers the [2, 19] choose_window_bits range plus the wb=1 final window
     that build_var_window_schedule can emit) and bit_offset in [0, 255].
  2. SimdX4MatchesScalarPathLanewise — SIMD x4 ≡ scalar lane-by-lane across
     all three specialisations, with a coverage assertion that each fires.
  3. RoundTripIdentityMatchesScalarMod2N — sum_w (-1)^{sign_w} · bucket_w ·
     2^{B_w} ≡ scalar (mod 2^256). The load-bearing algebraic invariant.
  4. EdgeCases — zero scalar, bottom-window classifier, top-window limb
     clamp (incl. bit_offset 255), localised/boundary flag boundaries.
  5. NamedSliceShapes — 12 named structural cases (bottom_wb*, local_*,
     boundary_u64_at_{63,127,191}, boundary_u32_at_31, top_clamped,
     top_wb1_final) so a regression at one shape shows up as a named failure.
  6. ParamClassifierU64U32Consistency — asserts the u64 / u32 param structs
     encode the same lookback bit position and bottom-window classification,
     so a bug in one classifier alone is not masked by the final-digit oracle.

Fuzzer (pippenger_constantine.fuzzer.cpp):

  Differential libFuzzer target — for each (window_bits, bit_offset, 4 random
  scalars) checks (a) scalar path == reference oracle, (b) SIMD x4 == scalar
  per lane. Verified clean under both `fuzzing` (30M iters / 30s) and
  `fuzzing-asan` (30M iters / 46s) presets with a boundary-biased seed corpus
  pinned to {0, 1, 31/32/33, 63/64/65, 127/128, 191/192, 253/254/255}.

Minor follow-on cleanup: extracted simd_u32x4_store() helper to dedupe the
three `#ifdef __wasm_simd128__` blocks across the SIMD specialisations.
[[gnu::always_inline]] makes it post-inline byte-identical to the previous
open-coded form.
Reverts d76a316 which was pushed directly to
merge-train/barretenberg without a PR. Will re-land via proper PR from
`si/pippenger-constantine`.
Copy link
Copy Markdown
Collaborator

@ludamad ludamad left a comment

Choose a reason for hiding this comment

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

🤖 Auto-approved

@AztecBot
Copy link
Copy Markdown
Collaborator Author

🤖 Auto-merge enabled after 4 hours of inactivity. This PR will be merged automatically once all checks pass.

@AztecBot AztecBot added this pull request to the merge queue May 26, 2026
@AztecBot
Copy link
Copy Markdown
Collaborator Author

Flakey Tests

🤖 says: This CI run detected 1 tests that failed, but were tolerated due to a .test_patterns.yml entry.

\033FLAKED\033 (8;;http://ci.aztec-labs.com/057bbf0b12bff181�057bbf0b12bff1818;;�):  yarn-project/end-to-end/scripts/run_test.sh simple src/e2e_p2p/duplicate_proposal_slash.test.ts (237s) (code: 0) group:e2e-p2p-epoch-flakes

@AztecBot
Copy link
Copy Markdown
Collaborator Author

🤖 Auto-merge enabled after 4 hours of inactivity. This PR will be merged automatically once all checks pass.

Merged via the queue into next with commit 83b5c8c May 26, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants