fluidex / snarkit

A toolkit to compile and debug circom circuit.
23 stars 1 forks source link

feature: add a new cli option to disable '-DSANITY_CHECK' for the native backend #6

Closed lispc closed 3 years ago

lispc commented 3 years ago

If a constraint fails, '-DSANITY_CHECK' will print which line of circom code (that contains a '===') fails. But we cannot know the parent module/conponent. So if a common lib fails, we cannot know the root cause of this failure.

On the other hand, without -DSANITY_CHECK, we can use the checker.ts to check constraints, then if any constraint fails, related signals and their name like 'main.componentA.componentB.in[3]' will be printed. So we know which conponent goes wrong.

Both err msgs are helpful. So it is better to add a cli option to enable/disable SANITY_CHECK.

weijiekoh commented 3 years ago

Thank you for this solution!

I encountered this issue as well while writing the MACI circuits. I resorted to trial-and-error but it was a pain to recompile every time. Another method I used was to place the constraint in the parent component, so the error message would show the specific line number, but this is not very flexible for deeply nested circuits...

I might borrow the functionality of checker.ts - again, thank you for putting this out there!!

lispc commented 3 years ago

Haha~ Would you like to implement this feature? Maybe helpful for the whole community. ( I am doing rollup state manager stuff myself so may not have time to finish this at least next 1-2 weeks )