Open
Conversation
Cross-validation: compare 40 intermediate values (20 assertions x LHS/RHS) between Rust AST evaluator and Go gnark circuit. Auto-generates crossval circuit via --crossval flag, eliminating manual copy desync risk. Codegen fixes from review: - global CSE only hoists by ref_count, not MAX_INLINE_EXPR_LEN - assert cse_counter == num_global after global codegen - unify rewrite_cse_to_slice / rewrite_cse_refs_to_slice - Don't skip constant constraints in crossval mode
- Inline variables in format! macros (ast_evaluator, gnark_codegen) - Remove [[bin]] entry for deleted export_assertion_components.rs - cargo fmt on cross_validation.rs and ast_bundle.rs
…ount) Replace usize::MAX sentinel with CseContext enum for type-safe global vs per-constraint CSE distinction. Make crossval_test.go parse assertion count dynamically from circuit output instead of hardcoding 20.
Contributor
|
Warning This PR has more than 500 changed lines and does not include a spec. Large features and architectural changes benefit from a spec-driven workflow. If this PR is a bug fix, refactor, or doesn't warrant a spec, feel free to ignore this message. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extends the transpiler's existing per-constraint CSE to global scope, detecting shared
TranscriptHashchains across constraints and hoisting them into global variables. Previously each constraint had its own isolated CSE context, duplicating identical Poseidon hash computations. Also adds a Rust/Go cross-validation system for verifying codegen correctness. Builds on #1322 .Changes
TranscriptHashchains across constraints and hoist them into global variables, computed once and reused. Previously each constraint had isolated CSE, duplicating identical Poseidon hash computations.--crossvalto auto-generate a cross-validation circuit and witness.ast_evaluator.rs(concrete AST evaluation),cross_validation.rs(Rust test),crossval_test.go(Go test)usize::MAXsentinel for CSE scope trackingcrossval_test.go.gitignorefor generated Groth16 artifactsTesting
On the fibonacci test example, global CSE reduces constraints from ~2.7M to ~621K–677K. Proof size remains 164 bytes. Cross-validation Rust/Go passes on all intermediate values.
Security Considerations
CSE is a pure optimization: it deduplicates constraint computation but does not change the constraint system's semantics. Each hoisted variable is assigned exactly once and referenced by the same constraints that previously computed it inline, so proof soundness is unaffected. The cross-validation system is test-only infrastructure and does not affect the proof pipeline.
Breaking Changes
None