|
| 1 | +# Running SNARK Proofs Tests |
| 2 | + |
| 3 | +This guide walks you through running SNARK proof tests for Mithril, covering both unit tests and the full end-to-end test suite. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +- **Operating System**: Linux (Ubuntu 24.04 or later) |
| 8 | +- **Rust toolchain**: latest stable version |
| 9 | + |
| 10 | +## Getting Started |
| 11 | + |
| 12 | +Clone the Mithril repository: |
| 13 | + |
| 14 | +```bash |
| 15 | +git clone git@github.com:input-output-hk/mithril.git |
| 16 | +cd mithril |
| 17 | +``` |
| 18 | + |
| 19 | +### Branch Setup |
| 20 | + |
| 21 | +Switch to the dedicated SNARK end-to-end test branch: |
| 22 | + |
| 23 | +```bash |
| 24 | +git switch jpraynaud/3107-snark-e2e-test |
| 25 | +``` |
| 26 | + |
| 27 | +## Unit Tests |
| 28 | + |
| 29 | +Run the full workspace unit tests with the `future_snark` feature enabled: |
| 30 | + |
| 31 | +```bash |
| 32 | +cargo test --all-features --features future_snark |
| 33 | +``` |
| 34 | + |
| 35 | +## End-to-End Test |
| 36 | + |
| 37 | +### Working Directory Configuration |
| 38 | + |
| 39 | +> **Important**: The working directory path must be kept short because the Cardano node uses local socket files with path length limitations. Use an absolute path such as the example below. **Do not** use `.` as the working directory, this could delete your entire repository. |
| 40 | +
|
| 41 | +Set the working directory environment variable: |
| 42 | + |
| 43 | +```bash |
| 44 | +WORK_DIRECTORY=~/Desktop/mithril/artifacts |
| 45 | +``` |
| 46 | + |
| 47 | +### Running the Test |
| 48 | + |
| 49 | +The following command compiles all required nodes and runs the end-to-end test with SNARK proofs. Expect the full process to take approximately **10 to 20 minutes** depending on your machine: |
| 50 | + |
| 51 | +```bash |
| 52 | +cargo build --release --features future_snark \ |
| 53 | + -p mithril-aggregator \ |
| 54 | + -p mithril-signer \ |
| 55 | + -p mithril-client-cli \ |
| 56 | + -p mithril-relay \ |
| 57 | + -p mithril-end-to-end \ |
| 58 | +&& RUST_BACKTRACE=1 ./target/release/mithril-end-to-end -vvvv \ |
| 59 | + --bin-directory ./target/release/ \ |
| 60 | + --work-directory=$WORK_DIRECTORY \ |
| 61 | + --devnet-scripts-directory=./mithril-test-lab/mithril-devnet \ |
| 62 | + --cardano-node-version=11.0.1 \ |
| 63 | + --mithril-era=lagrange \ |
| 64 | + --aggregate-signature-type=Snark \ |
| 65 | + --cardano-epoch-length=50 \ |
| 66 | + --cardano-slot-length=1.0 \ |
| 67 | + --mithril-run-interval 500 |
| 68 | +``` |
| 69 | + |
| 70 | +## Devnet |
| 71 | + |
| 72 | +### Run the devnet |
| 73 | + |
| 74 | +Switch to the devnet directory: |
| 75 | + |
| 76 | +```bash |
| 77 | +cd mithril-test-lab/mithril-devnet |
| 78 | +``` |
| 79 | + |
| 80 | +Start the devnet with the SNARK proofs configuration: |
| 81 | + |
| 82 | +```bash |
| 83 | +MITHRIL_NODE_DOCKER_BUILD_TYPE=ci \ |
| 84 | +MITHRIL_ERA=Lagrange \ |
| 85 | +MITHRIL_AGGREGATE_SIGNATURE_TYPE=Snark \ |
| 86 | +MITHRIL_RUN_INTERVAL=500 \ |
| 87 | +MITHRIL_PROTOCOL_PARAMETERS_K=5 \ |
| 88 | +MITHRIL_PROTOCOL_PARAMETERS_M=9 \ |
| 89 | +MITHRIL_PROTOCOL_PARAMETERS_PHI_F=0.95 \ |
| 90 | +CARDANO_NODE_VERSION=11.0.1 \ |
| 91 | +SLOT_LENGTH=1.0 \ |
| 92 | +EPOCH_LENGTH=50 \ |
| 93 | +./devnet-run.sh |
| 94 | +``` |
| 95 | + |
| 96 | +## Explorer |
| 97 | + |
| 98 | +In a separate terminal, you can run the explorer to visualize the devnet by switching to the `mithril-explorer` directory: |
| 99 | + |
| 100 | +```bash |
| 101 | +cd mithril-explorer |
| 102 | +``` |
| 103 | + |
| 104 | +Then build the WASM client with the `future_snark` feature enabled: |
| 105 | + |
| 106 | +```bash |
| 107 | +WASM_PACK_ARGS="-- --features future_snark" make -C ../mithril-client-wasm build |
| 108 | +``` |
| 109 | + |
| 110 | +Then, run the development server: |
| 111 | + |
| 112 | +```bash |
| 113 | +make dev |
| 114 | +``` |
| 115 | + |
| 116 | +Open [http://localhost:3000/explorer/?aggregator=https%3A%2F%2Faggregator.dev-follower-preview.api.mithril.network%2Faggregator](http://localhost:3000/explorer/?aggregator=https%3A%2F%2Faggregator.dev-follower-preview.api.mithril.network%2Faggregator) with your browser to see the result. |
0 commit comments