Home

Awesome

zkEVM Prover

Built to interface with Ethereum Virtual Machines (EVM), the prover provides critical services through three primary RPC clients: the Aggregator client, Executor service, and StateDB service. The Aggregator client connects to an Aggregator server and harnesses multiple zkEVM Provers simultaneously, thereby maximizing proof generation efficiency. This involves a process where the Prover component calculates a resulting state by processing EVM transaction batches and subsequently generates a proof based on the PIL polynomials definition and their constraints. The Executor service offers a mechanism to validate the integrity of proposed EVM transaction batches, ensuring they adhere to specific workload requirements. The StateDB service interfaces with a system's state (represented as a Merkle tree) and the corresponding database, thus serving as a centralized state information repository.

Components

Aggregator client

Executor service

StateDB service

Compiling locally

Steps to compile zkevm-prover locally:

Clone repository

git clone --recursive https://github.com/0xPolygonHermez/zkevm-prover.git
cd zkevm-prover

Download necessary files

Download this very large archive (~75GB). It's a good idea to start this download now and have it running in the background:

./tools/download_archive.sh

The archive will take up an additional 115GB of space once extracted.

Install dependencies

The following packages must be installed.

Important dependency note: you must install libpqxx version 6.4.5. If your distribution installs a newer version, please compile libpqxx 6.4.5 and install it manually instead.

Ubuntu/Debian

apt update
apt install build-essential libbenchmark-dev libomp-dev libgmp-dev nlohmann-json3-dev postgresql libpqxx-dev libpqxx-doc nasm libsecp256k1-dev grpc-proto libsodium-dev libprotobuf-dev libssl-dev cmake libgrpc++-dev protobuf-compiler protobuf-compiler-grpc uuid-dev

openSUSE

zypper addrepo https://download.opensuse.org/repositories/network:cryptocurrencies/openSUSE_Tumbleweed/network:cryptocurrencies.repo
zypper refresh
zypper install -t pattern devel_basis
zypper install libbenchmark1 libomp16-devel libgmp10 nlohmann_json-devel postgresql libpqxx-devel ghc-postgresql-libpq-devel nasm libsecp256k1-devel grpc-devel libsodium-devel libprotobuf-c-devel libssl53 cmake libgrpc++1_57 protobuf-devel uuid-devel llvm llvm-devel libopenssl-devel

Fedora

dnf group install "C Development Tools and Libraries" "Development Tools"
dnf config-manager --add-repo https://terra.fyralabs.com/terra.repo
dnf install google-benchmark-devel libomp-devel gmp gmp-devel gmp-c++ nlohmann-json-devel postgresql libpqxx-devel nasm libsecp256k1-devel grpc-devel libsodium-devel cmake grpc grpc-devel grpc-cpp protobuf-devel protobuf-c-devel uuid-devel libuuid-devel uuid-c++ llvm llvm-devel openssl-devel 

Arch

pacman -S base-devel extra/protobuf community/grpc-cli community/nlohmann-json extra/libpqxx nasm extra/libsodium community/libsecp256k1

Compilation

You may first need to recompile the protobufs:

cd src/grpc
make
cd ../..

Run make to compile the main project:

make clean
make generate
make -j

To compile in debug mode, run make -j dbg=1.

Test vectors

./build/zkProver -c testvectors/config_runFile_BatchProof.json

HashDB service database

To use persistence in the HashDB (Merkle-tree) service you must create the database objects needed by the service. To do this run the shell script:

./tools/statedb/create_db.sh <database> <user> <password>

For example:

./tools/statedb/create_db.sh testdb statedb statedb

Docker

sudo docker build -t zkprover .
sudo docker run --rm --network host -ti -p 50051:50051 -p 50061:50061 -p 50071:50071 -v $PWD/testvectors:/usr/src/app zkprover input_executor.json

Usage

To run the Prover, supply a config.json file containing the parameters that help customize various Prover settings. By default, the Prover accesses the file config/config.json. You can specify a different config file location using the '-c <file>' argument. In order to know about the different available configuration parameters, please read the src/config/README.md file.

To execute a proof test:

  1. Modify the config.json file, setting the "runFileGenProof" parameter to "true". Ensure all other parameters are set to "false". If you prefer not to use a PostgreSQL database for the test, adjust the "databaseURL" to "local".
  2. For the "inputFile" parameter, specify the desired input test data file. As an example, use the file testvectors/batchProof/input_executor_0.json.
  3. Launch the Prover from the project root directory using the command: build/zkProver.
  4. The proof's result files will be saved in the directory defined by the "outputPath" configuration parameter.

Contact

For more discussions, please head to the R&D Discord