circomkit icon indicating copy to clipboard operation
circomkit copied to clipboard

Add `recompile` option to witness tester

Open erhant opened this issue 2 years ago • 2 comments

For larger circuits, otherwise recompiling everytime is not cool.

erhant avatar Jul 21 '23 06:07 erhant

Caching .witnessTester() if the underlying .circom file hasn't changed would be great to speed up test development.

Do you have an idea in mind already for implementation?

dsernst avatar May 04 '25 23:05 dsernst

It seems like 99% of the logic for this was already in place.

It's now working for me locally, required just one simple change to let WitnessTester use the buildDir: https://github.com/dsernst/circomkit/commit/3c8e94b3c7d7add5ac8b612eed69a2a501299dfc

Then, I can call it like:

const circuit: WitnessTester<['in1', 'in2'], ['out']> =
  await circomkit.WitnessTester('MyCircuit', {
    ...circuitConfig,
    recompile: false,
  })

This requires manually commenting out recompile: false on the initial run, and anytime the underlying circuit has changed.

A nice UX improvement would be to automatically recompile if the underlying build artifacts are missing, or if the hash of the .circom file has changed. But even without this, this manual way to enable using a cache between runs already improves development ergonomics massively for big circuits.

Update:

I got an automatic shouldRecompile() function working, see details here: https://github.com/erhant/circomkit/issues/120#issuecomment-2933519763

@erhant Open to a PR for automatic recompilation?

dsernst avatar May 05 '25 02:05 dsernst