Skip to content

refactor: split stage provers, deduplicate helpers, extract witness types#73

Merged
MatteoMer merged 3 commits into
mainfrom
refactor/split-stage3-preprocessing-mod
Apr 5, 2026
Merged

refactor: split stage provers, deduplicate helpers, extract witness types#73
MatteoMer merged 3 commits into
mainfrom
refactor/split-stage3-preprocessing-mod

Conversation

@MatteoMer

@MatteoMer MatteoMer commented Apr 5, 2026

Copy link
Copy Markdown
Owner

Summary

Split oversized files into focused modules and deduplicate shared patterns across the codebase.

File splits

  • stage3_prover.zig (3,133 → 1,248 LOC): Extract ShiftPrefixSuffixProver and RegistersPrefixSuffixProver into stage3_instances.zig, and InstructionInputProver into stage3_instruction_input.zig
  • preprocessing.zig (2,250 → 205 LOC): Extract JoltInstruction to jolt_instruction.zig and BytecodePreprocessing to bytecode_preprocessing.zig. Breaks the preprocessing ↔ instruction_decoder import cycle
  • mod.zig (1,800 → 397 LOC): Extract JoltProver wrapper, proveJoltCompatibleWithDoryAndSrsAtAddress, serialization, and helpers into proving_pipeline.zig
  • constraints.zig: Extract R1CSInputIndex, Term, LinearCombination, LC, UniformConstraint into witness_types.zig

Deduplication

  • Remove ~230 lines of dead pairing code (millerLoop, PairingInput, multiPairing, pairingCheck and supporting private functions/tests — zero external callers)
  • Add deriveBatchingCoeffs comptime helper to sumcheck_helpers.zig, adopt in stage2/stage3/stage6 provers
  • Add extrapolateLinearTo2 helper with test
  • Adopt parallelReduceOptional/parallelForOptional at 8 call sites in ram/ modules

All external import sites work through re-exports — no API changes.

Test plan

  • zig build test — all tests pass
  • zig build — clean in Debug and ReleaseFast

🤖 Generated with Claude Code

MatteoMer and others added 2 commits April 5, 2026 18:15
…d modules

Split three oversized files into smaller, focused modules for navigability:

- stage3_prover.zig (3,133 → 1,248 LOC): Extract ShiftPrefixSuffixProver
  and RegistersPrefixSuffixProver into stage3_instances.zig, and
  InstructionInputProver into stage3_instruction_input.zig.

- preprocessing.zig (2,250 → 205 LOC): Extract JoltInstruction to
  jolt_instruction.zig and BytecodePreprocessing to
  bytecode_preprocessing.zig. Breaks the preprocessing ↔
  instruction_decoder import cycle.

- mod.zig (1,800 → 397 LOC): Extract JoltProver wrapper,
  proveJoltCompatibleWithDoryAndSrsAtAddress, serialization, and
  helper functions into proving_pipeline.zig.

All external import sites work through re-exports — no API changes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… witness types

- Remove ~230 lines of dead pairing code (millerLoop, PairingInput,
  multiPairing, pairingCheck, and supporting private functions/tests)
- Add deriveBatchingCoeffs comptime helper to sumcheck_helpers.zig,
  adopt in stage2/stage3/stage6 provers (replaces manual loops)
- Add extrapolateLinearTo2 helper with test
- Adopt parallelReduceOptional/parallelForOptional at 8 call sites
  in ram/ modules (read_write_checking, raf_checking, output_check,
  val_evaluation)
- Extract R1CS witness types (R1CSInputIndex, Term, LinearCombination,
  LC, UniformConstraint) into witness_types.zig; constraints.zig
  re-exports for backward compatibility

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@MatteoMer MatteoMer changed the title refactor: split stage3_prover, preprocessing, and mod.zig into focuse… refactor: split stage provers, deduplicate helpers, extract witness types Apr 5, 2026
…t stage6 bytecode_raf

- Adopt pool_helpers.parallel*Optional across 53 call sites (75% of null-check patterns)
- Add parallelReduceForceOptional to zolt-pool helpers
- Extract finishSumcheckRound, addInactiveToMonomial, deriveBatchingCoeffs, deriveGammaPowers
  into sumcheck_helpers.zig and adopt across stage3/5/6
- Extract bytecode Val poly computation from stage6_prover into stage6_bytecode_raf.zig (-900 LOC from stage6_prover)
- Gate bench_timing behind comptime debug flag
- Add dbgFieldLE/dbgFieldLE8 debug helpers
- Extract stage6_debug.zig for diagnostic output
- Update refactoring plan with revised estimates and status

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@MatteoMer MatteoMer merged commit f265f5c into main Apr 5, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant