Problem
When debugging circuits, it is very useful to see what constraints haven't been met and why.
Details
This should be possible with ConstraintLayer
but I haven't managed to get to work properly:
In poseidon_tornado
with
RUST_LOG="poseidon_tornado=TRACE,ark_relations=TRACE" cargo run
We get
Constraint trace requires enabling `ConstraintLayer`
thread 'main' panicked at 'assertion failed: {\n use ark_relations::r1cs::{ConstraintSynthesizer, ConstraintSystem};\n let cs = ConstraintSystem::<E::Fr>::new_ref();\n circom.clone().generate_constraints(cs.clone()).unwrap();\n cs.is_satisfied().unwrap()\n}', /home/oskarth/repos/github.com/gakonst/ark-circom/src/circom/builder.rs:82:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
The panic happens because constraints aren't met, which is expected. This then panics because of the debug_assert
here https://github.com/gakonst/ark-circom/blob/master/src/circom/builder.rs#L82-L87
The problem is the lack of tracing, even with https://github.com/vacp2p/zerokit/commit/9b1fa85e46fc1d37f2f3e201ea6624940582925a
Tracing instrumentation based on example here https://github.com/arkworks-rs/r1cs-tutorial/blob/main/merkle-tree-example/src/constraints.rs#L109-L113
Same when trying to do tracing instrumentation in various ways directly in ark-circom etc.
Error from https://github.com/arkworks-rs/snark/blob/master/relations/src/r1cs/constraint_system.rs#L609
Probably missing something simple here but haven't been to figure out what's wrong.
Acceptance criteria
Failing constraints should produce some form of useful debugging information re which constraints are failing.