|
| 1 | +This document provides guidelines on how to run Polygon Type-1 prover, specifically for proving transactions, but with the option to test full blocks of less than 4M gas. |
| 2 | +So, it is similar to [`eth-proof`](https://github.com/wborgeaud/eth-proof) but for transaction proofs. |
| 3 | + |
| 4 | +## Quick start |
| 5 | + |
| 6 | +There are two ways to run this prover. The simplest way to get started is |
| 7 | +to use the `in-memory` runtime of |
| 8 | +[Paladin](https://github.com/0xPolygonZero/paladin). This requires |
| 9 | +very little setup, but it's not really suitable for large scale |
| 10 | +testing. |
| 11 | + |
| 12 | +The other method for testing the prover is to leverage an |
| 13 | +[AMQP](https://en.wikipedia.org/wiki/Advanced_Message_Queuing_Protocol) |
| 14 | +like [RabbitMQ](https://en.wikipedia.org/wiki/RabbitMQ) to distribute |
| 15 | +workload over many workers. |
| 16 | + |
| 17 | +!!!info |
| 18 | + |
| 19 | + It's worth noting that you'll need at least 40GB of physical memory to run the prover. |
| 20 | + |
| 21 | + |
| 22 | +### Setup |
| 23 | + |
| 24 | +Start by cloning this repo [here](https://github.com/0xPolygonZero/eth-tx-proof/tree/jhilliard/deployment). |
| 25 | + |
| 26 | +Before running the prover, you'll need to compile the |
| 27 | +application. This command should do the trick: |
| 28 | + |
| 29 | +```bash |
| 30 | +env RUSTFLAGS='-C target-cpu=native' cargo build --release |
| 31 | +``` |
| 32 | + |
| 33 | +You should end up with two binaries in your `target/release` |
| 34 | +folder. One is called `worker` and the other is `leader`. Typically, |
| 35 | +we'll install these somewhere in our `$PATH` for convenience. |
| 36 | + |
| 37 | +Once you have application available, you'll need to create a block |
| 38 | +[witness](https://nmohnblatt.github.io/zk-jargon-decoder/definitions/witness.html) |
| 39 | +which essentially serves as the input for the prover. |
| 40 | + |
| 41 | +Assuming you've deployed the `leader` binary, you should be able to generate a witness |
| 42 | +like this: |
| 43 | + |
| 44 | +```bash |
| 45 | +paladin-leader rpc -u $RPC_URL -t 0x2f0faea6778845b02f9faf84e7e911ef12c287ce7deb924c5925f3626c77906e > 0x2f0faea6778845b02f9faf84e7e911ef12c287ce7deb924c5925f3626c77906e.json |
| 46 | +``` |
| 47 | + |
| 48 | +You'll need access to an Ethereum RPC in order to run this |
| 49 | +command. The input argument is a transaction hash and in particular it |
| 50 | +is the _last_ transaction hash in the block. |
| 51 | + |
| 52 | +Once you've successfully generated a witness, you're ready to start |
| 53 | +proving either with the `in-memory` run time or the `amqp` runtime. |
| 54 | + |
| 55 | +### In-memory proving |
| 56 | + |
| 57 | +Running the prover with the `in-memory` setup requires no setup. You |
| 58 | +can attempt to generate a proof with a command like this. |
| 59 | + |
| 60 | +```bash |
| 61 | +env RUST_MIN_STACK=33554432 \ |
| 62 | +ARITHMETIC_CIRCUIT_SIZE="15..28" \ |
| 63 | +BYTE_PACKING_CIRCUIT_SIZE="9..28" \ |
| 64 | +CPU_CIRCUIT_SIZE="12..28" \ |
| 65 | +KECCAK_CIRCUIT_SIZE="14..28" \ |
| 66 | +KECCAK_SPONGE_CIRCUIT_SIZE="9..28" \ |
| 67 | +LOGIC_CIRCUIT_SIZE="12..28" \ |
| 68 | +MEMORY_CIRCUIT_SIZE="17..30" \ |
| 69 | +paladin-leader prove \ |
| 70 | +--runtime in-memory \ |
| 71 | +--num-workers 1 \ |
| 72 | +--input-witness 0x2f0faea6778845b02f9faf84e7e911ef12c287ce7deb924c5925f3626c77906e.json |
| 73 | +``` |
| 74 | + |
| 75 | +The circuit parameters here are meant to be compatible with virtually |
| 76 | +all Ethereum blocks. This will create a block proof from an input |
| 77 | +state root of the preceding block. You can adjust the `--num-workers` |
| 78 | +flag based on the number of available compute resources. As a rule of |
| 79 | +thumb, you'd probably want at least 8 cores per worker. |
| 80 | + |
| 81 | +### AMQP proving |
| 82 | + |
| 83 | +Proving in a distributed compute environment depends on an AMQP |
| 84 | +server. We're not going to cover the setup of RabbitMQ, but assuming |
| 85 | +you have something like that available you can run a "leader" which |
| 86 | +distributes proving tasks to a collection of "workers" which actually |
| 87 | +do the proving work. |
| 88 | + |
| 89 | +In order to run the workers, you'll use a command like: |
| 90 | + |
| 91 | +```bash |
| 92 | +env RUST_MIN_STACK=33554432 \ |
| 93 | +ARITHMETIC_CIRCUIT_SIZE="15..28" \ |
| 94 | +BYTE_PACKING_CIRCUIT_SIZE="9..28" \ |
| 95 | +CPU_CIRCUIT_SIZE="12..28" \ |
| 96 | +KECCAK_CIRCUIT_SIZE="14..28" \ |
| 97 | +KECCAK_SPONGE_CIRCUIT_SIZE="9..28" \ |
| 98 | +LOGIC_CIRCUIT_SIZE="12..28" \ |
| 99 | +MEMORY_CIRCUIT_SIZE="17..30" \ |
| 100 | +paladin-worker --runtime amqp --amqp-uri=amqp://localhost:5672 |
| 101 | +``` |
| 102 | + |
| 103 | +This will start the worker and have it await tasks. Depending on your machine's system capacity, you can run several workers on the |
| 104 | +same operating system. An example [systemd |
| 105 | +service](https://github.com/0xPolygonZero/eth-tx-proof/blob/jhilliard/deployment/deploy/paladin-worker@.service) is included. Once that |
| 106 | +service is installed, you'll be able to enable up to 16 workers on the |
| 107 | +same VM like this: |
| 108 | + |
| 109 | +```bash |
| 110 | +seq 0 15 | xargs -I xxx systemctl enable paladin-worker@xxx |
| 111 | +seq 0 15 | xargs -I xxx systemctl start paladin-worker@xxx |
| 112 | +``` |
| 113 | + |
| 114 | +Now that you have your pool of paladin workers, you can start proving |
| 115 | +with a command like this: |
| 116 | + |
| 117 | +```bash |
| 118 | +paladin-leader prove \ |
| 119 | +--runtime amqp \ |
| 120 | +--amqp-uri=amqp://localhost:5672 \ |
| 121 | +--input-witness 0x2f0faea6778845b02f9faf84e7e911ef12c287ce7deb924c5925f3626c77906e.json |
| 122 | +``` |
| 123 | + |
| 124 | +This command will run the same way as the `in-memory` mode except that |
| 125 | +the leader itself isn't doing the work. The separate worker processes |
| 126 | +are doing the heavy lifting. |
0 commit comments