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

Add methods to get info about ConstraintSystem #19

Open
Pratyush opened this issue Mar 10, 2018 · 4 comments
Open

Add methods to get info about ConstraintSystem #19

Pratyush opened this issue Mar 10, 2018 · 4 comments

Comments

@Pratyush
Copy link

Pratyush commented Mar 10, 2018

It would be useful to add num_constraints, num_inputs and num_aux methods to the ConstraintSystem trait to get a quick sense of its cost. I think these methods are general enough to apply to all implementors of ConstraintSystem. If you'd like I can send in a pull request for this as well.

@Pratyush Pratyush changed the title Add num_constraints method to ConstraintSystem Trait Add num_constraints method to ConstraintSystem trait Mar 10, 2018
@Pratyush Pratyush changed the title Add num_constraints method to ConstraintSystem trait Add methods to get info about ConstraintSystem Mar 10, 2018
@ebfull
Copy link
Collaborator

ebfull commented Mar 22, 2018

I've created a test framework for simulating synthesis and getting statistics like this. The bellman API allows it to be implemented independently from this library:

https://github.com/zcash-hackworks/sapling-crypto/tree/master/src/circuit/test

The kinds of checks you're mentioning can be done using this, it even has constraint system hashing for integrity checking (useful for refactoring circuit code without intending to change its contents) and some printing of the constraint system and other stuff.

@Pratyush
Copy link
Author

Pratyush commented Apr 7, 2018

I've seen (and used!) your TestConstraintSystem, and it's great for finding information about the ConstraintSystem in an offline setting (like in tests). But my usecase for these functions would be print this information at runtime, for example during setup or proving, and the existing constraint system interface doesn't provide that information at runtime. But perhaps since we're going to implement GM17 anyway we can make our implementation provide that information. Thanks!

@ebfull
Copy link
Collaborator

ebfull commented Apr 7, 2018

Hm, I see what you mean. Maybe we can do this, but I have another idea.

I also wanted to attach something to the API which allowed you to pass in an abstract Profiler kind of object. The object would be given timings and other information for various operations, for benchmarking and optimization both of bellman and your own circuits. If you pass in () for the profiler, there's no runtime cost. If you pass in some kind of profiler tool, it'll have access to a lot of useful stats.

I suppose that could be hooked up to get info about the constraint system also!

@Pratyush
Copy link
Author

Pratyush commented Apr 9, 2018

That's a good idea, it sounds more general-purpose and informative! Let me know if I can help with implementing it.

str4d pushed a commit that referenced this issue Aug 25, 2020
str4d added a commit that referenced this issue Aug 25, 2020
Add interface and computation of Sapling note nullifier
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 a pull request may close this issue.

2 participants