Coder Social home page Coder Social logo

zkevm-prover's Introduction

zkEVM Prover

zkEVM proof generator

General info

The zkEVM Prover process can provide up to 3 RPC services:

Prover service

  • It calls the Prover component that executes the input data (a batch of EVM transactions), calculates the resulting state, and generates the proof of the calculation based on the PIL polynomials definition and their constrains.
  • When called by the Prover service, the Executor component combines 14 state machines that process the input data to generate the evaluations of the committed polynomials, required to generate the proof. Every state machine generates their computation evidence data, and the more complex calculus demonstrations are delegated to the next state machine.
  • The Prover component calls the Stark component to generate a proof of the Executor state machines committed polynomials.
  • The interface of this service is defined by the file zk-prover.proto.

Executor service

  • It calls the Executor component that executes the input data (a batch of EVM transactions) and calculates the resulting state. The proof is not generated.
  • It provides a fast way to check if the proposed batch of transactions is properly built and it fits the amount of work that can be proven in one single batch.
  • When called by the Executor service, the Executor component only uses the Main state machine, since the committed polynomials are not required as the proof will not be generated.
  • The interface of this service is defined by the file executor.proto.

StateDB service

  • It provides an interface to access the state of the system (a Merkle tree) and the database where the state is stored.
  • It is used by the executor and the prover, as the single source of state. It can be used to get state details, e.g. account balances.
  • The interface of this service is defined by the file statedb.proto.

Setup

Clone repository

$ git clone [email protected]:0xPolygonHermez/zkevm-prover.git
$ cd zkevm-prover
$ git submodule init
$ git submodule update --remote

Compile

The following packages must be installed.

$ sudo 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

The following files must be downloaded and added manually to the testvectors folder.

File Link
constants.bin https://de012a78750e59b808d922b39535e862.s3.eu-west-1.amazonaws.com/testvectors002/constants.bin

Run make to compile the project.

$ make clean
$ make -j

StateDB service database

To use persistence in the StateDB (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

Build & run 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

The config.json file contains the parameters that allow us to configure the different Prover options. The most relevant parameters are commented below.

Parameter Default Description
runProverServer true Enable Prover GRPC service
runExecutorServer true Enable Executor server
runStateDBServer true Enable StateDB (Merkle-tree) GRPC service
runFile false Execute the Prover using as input a test file defined in "inputFile" parameter
inputFile input_executor.json Test input file. It must be located in the testvectors folder
outputPath output Output path folder to store the result files. It must be located in the testvectors folder
databaseURL local Connection string for the PostgreSQL database used by the StateDB service. If the value is "local" then the service will not use a database and the data will be stored only in memory (no persistence). The PostgreSQL database connection string has the following format: "postgresql://<user>:<password>@<ip>:<port>/<database>". For example: "postgresql://statedb:[email protected]:5432/testdb"
stateDBURL local Connection string for the StateDB service. If the value is "local" then the GRPC StateDB service will not be used and local StateDB client will be used instead. The StateDB service connection string has the following format: "<ip>:<port>". For example: "127.0.0.1:50061"

To run a proof test you must perform the following steps:

  • Edit the config.json file and set the parameter "runFile" to "true". The rest of the parameters must be "false"
  • Indicate in the "inputFile" parameter the file with the input test data. You can find a test file input_executor.json in the testvectors folder
  • Run the Prover from the testvectors folder using the command $ ../build/zkProver
  • The result files of the proof will be stored in the folder specified in the "outputPath" config parameter

License

Copyright

Polygon zkevm-prover was developed by Polygon. While we plan to adopt an open source license, we haven’t selected one yet, so all rights are reserved for the time being. Please reach out to us if you have thoughts on licensing.

Disclaimer

This code has not yet been audited, and should not be used in any production systems.

zkevm-prover's People

Contributors

fractasy avatar eduadiez avatar jbaylina avatar agnusmor avatar zkronos73 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.