Skip to content

Conversation

@hawkadrian
Copy link
Contributor

@hawkadrian hawkadrian commented Nov 5, 2025

Adds example showing how to print constraints from compiled constraint system using type assertion and GetR1Cs()/GetSparseR1Cs() methods.

Fixes #1640


Note

Adds concise examples under examples/print_constraints to print R1CS and SparseR1CS constraints from compiled circuits using type assertions.

  • Examples:
    • New package examples/print_constraints:
      • doc.go: package documentation for printing constraints from compiled systems.
      • print_constraints_r1cs_test.go: adds CubicCircuit and Example_printR1CS demonstrating compilation with r1cs.NewBuilder, type-asserting GetR1Cs(), and printing system stats and each R1C.
      • print_constraints_scs_test.go: adds Example_printSparseR1CS demonstrating compilation with scs.NewBuilder (PLONK), type-asserting GetSparseR1Cs(), and printing system stats and each SparseR1C.

Written by Cursor Bugbot for commit 6590f5e. This will update automatically on new commits. Configure here.

@ivokub ivokub requested review from Copilot and ivokub November 25, 2025 15:11
@ivokub ivokub added type: doc src: community Community originating PRs and issues labels Nov 25, 2025
Copilot finished reviewing on behalf of ivokub November 25, 2025 15:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds comprehensive examples demonstrating how to print constraints from compiled constraint systems, addressing issue #1640. The examples show developers how to introspect and debug their circuits by accessing and printing the underlying constraints.

Key Changes:

  • New print_constraints package with examples for both R1CS and SparseR1CS (PLONK) constraint systems
  • Demonstrates type assertion patterns to access constraint-specific methods (GetR1Cs() and GetSparseR1Cs())
  • Includes detailed documentation and example outputs showing constraint structure

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
examples/print_constraints/doc.go Package documentation explaining the purpose and usage of constraint printing examples
examples/print_constraints/print_constraints_r1cs_test.go Defines CubicCircuit and demonstrates printing R1CS constraints with example output
examples/print_constraints/print_constraints_scs_test.go Demonstrates printing SparseR1CS (PLONK) constraints using the shared CubicCircuit definition

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@ivokub ivokub merged commit 85d2dbc into Consensys:master Nov 25, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

src: community Community originating PRs and issues type: doc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: add example how to print constraints in compiled constraint system

2 participants