#Automated Tests ZKProgram Very Slow

17 messages · Page 1 of 1 (latest)

tight dome
#

Good evening,

Is there any way to run automated tests on Experimental.ZKProgram without generating the proofs? I found tutorials indicating how to disable proofs on Mina, but there seemed to be nothing about ZKPrograms directly. Is there any way to mock the "security" part of the proof, and just operate on the side-effects?

Thank you.

fossil delta
#

A pattern I've used is write a JS class with all the logic, and just call those methods in the proof as a wrapper.

e.g.

https://github.com/mina-arena/Contracts/blob/a069d7600d9b515df435cb91a8c57305bcc5bb33/src/game/GameState.ts#L64

and

https://github.com/mina-arena/Contracts/blob/a069d7600d9b515df435cb91a8c57305bcc5bb33/src/game/GameProof.ts#L15

All of the logic lives in GameState and can be tested out of a proof. But I also have tests for GameProof to confirm that the proof logic still works. I run that test less often because it takes so long.

spring sage
#

Unfortunately testing zk-pograms without generating the proofs isn't as straightforward as it is for smart-contracts.

You need to create dummy proofs manually and adapt your test code to conditionally use dummy proofs or not (depending on if you set proofsEnabled to true or false).

See:
https://discord.com/channels/484437221055922177/1167926894373634098

tight dome
tight dome
fossil delta
outer shadow
#

@fossil delta if you use recursion you need mock proofs for your out-of-circuit functions to be composable

fossil delta
# outer shadow <@201337099700535297> if you use recursion you need mock proofs for your out-of-...

But if you use dummy proofs you aren't actually testing anything related to the recursion.

With a pattern like

proofA.verify();
proofB.verify();
expectedState = performLogic();
newState.assertEquals(expectedState);

You can write a test for performLogic without using dummy proofs, and with dummy proofs, you're not actually testing anything about the verify calls. That's why I have one set of tests with no proofs that tests the code in performLogic, and another set of tests with proofs enabled that tests the actual zk program and calls verify.

outer shadow
#

you're testing access to public inputs & outputs of your dummy proofs

#

otherwise the recursion is pointless

fossil delta
#

Going based off of @tight dome 's comment of "The core of the application is based on proofs though :/ It's mostly mathematical operations and assertions on ifs.", I am imagining they are interested in testing at least the unit-level of their math operations and assertions. They mention proofs, but not necessarily recursion.

So I'm just pointing out that you can pull your logic out of the proof and write unit tests for it that don't care about recursion. You can write tests that your math is right and your ifs are right (to the extent that js tests catch issues with circuit ifs) without compiling any proof.

If what they actually want is to test that the public output of some proof is accessible after some number of rounds of proving, that's another story, but that's not the question I interpreted.

analog verge
#

It sounds valuable to just expose the original functions in zkprogram, without proof creation? That would be easy to add to zkprogram.
PRs welcome!

tight dome
#

Hello, after having written the base set of tests that attest the correct functionality of the system, I am back here, since the execution of all tests is taking in the realm of 40 minutes 😆

tight dome
tight dome
# analog verge It sounds valuable to just expose the original functions in zkprogram, without p...

Can you please provide me with a short overview of which modules I should look into, and which nature of changes would be required for this? I need to invest time into a proper solution for my project in either case, because running property-based tests with such slow execution times is not feasible, and spending a litte more time on a solution from which all of the community can benefit would be amazing.

tight dome
# fossil delta A pattern I've used is write a JS class with all the logic, and just call those ...

Just to ensure that I'm correct: what you are saying is that you test the applyTurn method direclty, instead of doing it on an instance of a zk program? This is what I've gathered from the tests in your repository. Thanks!

https://github.com/mina-arena/Contracts/blob/a069d7600d9b515df435cb91a8c57305bcc5bb33/src/game/GameState.ts#L64

https://github.com/mina-arena/Contracts/blob/a069d7600d9b515df435cb91a8c57305bcc5bb33/tests/non-proof/game/GameState.test.ts

GitHub

ZkPrograms and Smart Contracts to be used in Mina Arena - mina-arena/Contracts

GitHub

ZkPrograms and Smart Contracts to be used in Mina Arena - mina-arena/Contracts