Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding debugging & testing utils #343

Closed
ed255 opened this issue May 29, 2024 · 1 comment
Closed

Adding debugging & testing utils #343

ed255 opened this issue May 29, 2024 · 1 comment
Assignees

Comments

@ed255
Copy link
Member

ed255 commented May 29, 2024

I would like to propose introducing a new crate with debugging and testing utilities.

I constantly find myself rewriting the same debugging functions and boilerplate for cases like:

  • You have an assigned column Vec<F> and you want to print it. If you use print!("{:?}", column) where F is bn256::Fr you get this:
[0x0000000000000000000000000000000000000000000000000000000000000001, 0x0000000000000000000000000000000000000000000000000000000000000001, 0x0000000000000000000000000000000000000000000000000000000000000001, ...

Which is super annoying to read. I would like to see this instead

[1, 1, 1, 0, 0, ...
  • Another example, maybe I want to print a list of columns as a table.

  • Another example, maybe I want to do setup, proof + verify given a circuit, and I don't care about the transcript hash, or the engine, the commitment scheme, the prover strategy, etc.

@zemse actually made a repository with utilities like this: https://github.com/zemse/halo2-utils?tab=readme-ov-file#print-assignments

My proposal is to have an implementation of these utilities in a new crate but they don't need to be super clean, they could be targeted to debugging and development, so we don't put high bar on their API or stability (that would be a plus but not a requirement). The main goal would be to be useful.

Here's a list of particular things I would like

  • PrettyF type that wraps F or &F and implements Display in a smart way:
    • If the number is small, format it in decimal
    • If the number is a power of two, format it as 2^k
    • If the number is big, format it as hex (without leading zeroes)
    • If the number is equivalent to a small negative number, show it as -x
  • Type that wraps Vec<F> or &[F] and implements Display using PrettyF
  • Function to print a table out of multiple Vec<F> or &[F] with names per column, and using PrettyF.
  • Set of functions to generate setup, prove and verify only taking as inputs the value k and circuit (and making choices for the rest). Compatible with the frontend-backend split API.
@adria0
Copy link
Member

adria0 commented Jun 10, 2024

Merged

@adria0 adria0 closed this as completed Jun 10, 2024
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

No branches or pull requests

2 participants