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

[trivial] Transaction_snark/README: enforcing 80 characters limits #16428

Open
wants to merge 1 commit into
base: dw/remove-useless-warning-ignore
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 30 additions & 10 deletions src/lib/transaction_snark/test/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
# Tests for the transaction snark

This directory and its subdirectories contain tests for the transaction snark, including consistency checks for the 'in snark' logic with the 'out of snark' version used by block application, and tests for the 'merge' rule for combining transaction snark statements in the scan state.
This directory and its subdirectories contain tests for the transaction snark,
including consistency checks for the 'in snark' logic with the 'out of snark'
version used by block application, and tests for the 'merge' rule for combining
transaction snark statements in the scan state.

### Performance considerations

These tests are run on CI for any PR that changes the daemon OCaml code. As such, the tests added here should add value for the time they take, and should not take too long.
These tests are run on CI for any PR that changes the daemon OCaml code. As
such, the tests added here should add value for the time they take, and should
not take too long.

#### Caching proofs

The largest performance impact of these tests is the time spent generating proofs; especially for zkApp transactions, where we generate merge proofs as well as the transaction proofs. In order to mitigate this, pickles provides a mode where it will generate the circuit witness, but skips the expensive proving step, using a cache.
The largest performance impact of these tests is the time spent generating
proofs; especially for zkApp transactions, where we generate merge proofs as
well as the transaction proofs. In order to mitigate this, pickles provides a
mode where it will generate the circuit witness, but skips the expensive proving
step, using a cache.

The recommended way to enable this cache is:
* add the lines
Expand All @@ -19,7 +28,8 @@ The recommended way to enable this cache is:

let () = Transaction_snark.For_tests.set_proof_cache proof_cache
```
to the top of the first `%test_module` in the file, to load a proof cache from the `proof_cache.json` file in the directory;
to the top of the first `%test_module` in the file, to load a proof cache from
the `proof_cache.json` file in the directory;
* add the lines
```ocaml
let () =
Expand All @@ -29,21 +39,28 @@ The recommended way to enable this cache is:
| None ->
()
```
to the bottom of the last `%test_module` in the file, to output the updated proof cache to the path given in the `PROOF_CACHE_OUT` environment variable, when provided;
to the bottom of the last `%test_module` in the file, to output the updated
proof cache to the path given in the `PROOF_CACHE_OUT` environment variable,
when provided;
* update the `dune` file in the test directory to include the libraries
```
ppx_deriving_yojson.runtime
result
```
* update the same `dune` file's `inline_tests` stanza to include `(deps proof_cache.json)`, for example
* update the same `dune` file's `inline_tests` stanza to include `(deps
proof_cache.json)`, for example
```diff
- (inline_tests (flags -verbose -show-counts))
+ (inline_tests (flags -verbose -show-counts) (deps proof_cache.json))
```

For a concrete example, see commit [61afcaee844d5966331ddaee11fd8820f6dc1c8a](https://github.com/MinaProtocol/mina/commit/61afcaee844d5966331ddaee11fd8820f6dc1c8a).
For a concrete example, see commit
[61afcaee844d5966331ddaee11fd8820f6dc1c8a](https://github.com/MinaProtocol/mina/commit/61afcaee844d5966331ddaee11fd8820f6dc1c8a).

Then, to update the cache for a set of tests, we can run the tests to update
their contents. For example, to update the tests in all of the directories
containing a `proof_cache.json` file, we can run:

Then, to update the cache for a set of tests, we can run the tests to update their contents. For example, to update the tests in all of the directories containing a `proof_cache.json` file, we can run:
```bash
for DIR in $(find -name proof_cache.json | sed 's/\/proof_cache.json//'); do
# Initialize the target file
Expand All @@ -58,6 +75,9 @@ for DIR in $(find -name proof_cache.json | sed 's/\/proof_cache.json//'); do
done
```

**In case an error *is* generated, you should not commit the cache before making the test deterministic.**
**In case an error *is* generated, you should not commit the cache before making
the test deterministic.**

If none of the updates generated an error, the results can be committed to the repository, and future CI runs will benefit from the speed-up of using the cached proofs.
If none of the updates generated an error, the results can be committed to the
repository, and future CI runs will benefit from the speed-up of using the
cached proofs.