Coder Social home page Coder Social logo

nilfoundation / proof-market-toolchain Goto Github PK

View Code? Open in Web Editor NEW
22.0 16.0 4.0 2.76 MB

A toolchain for interaction with the Proof Market protocol.

Home Page: https://docs.nil.foundation/proof-market

License: MIT License

C++ 90.09% CMake 1.85% Python 4.53% LLVM 3.10% Dockerfile 0.33% Shell 0.09%
zkproof-prover proof-market

proof-market-toolchain's Introduction

=nil; Proof Market Toolchain

Discord Telegram Twitter

Table of Contents

Introduction

This repository provides a set of scripts and tools required to participate in the =nil; Foundation's Proof Market.

There are three primary roles (parties) in the Proof Market:

  • Proof requesters are applications that require zero-knowledge proofs, and make requests for them on the Proof Market.
  • Proof producers are owners of computational infrastructure, who generate proofs for the requests made by proof requesters.
  • Circuit developers make zero-knowledge circuits, that are used to generate requests and subsequent proofs.

The Proof Market toolchain has tools for proof requesters and producers. To learn more about the Proof Market and these roles, read the Proof Market documentation.

If you're interested in circuit development, check out the zkLLVM compiler and zkLLVM template project.

Proof Systems Compatibility

Proof Maket Toolchain is tested with the following versions of the circuit development tools:

Tool Version
zkLLVM 0.0.79

Starting with a ready Docker image

The quickest way to start working with the Proof Market toolchain is to use the Docker image ghcr.io/nilfoundation/proof-market-toolchain:latest. It has all the parts of the toolchain:

  • All required dependencies.
  • Scripts for interaction with Proof Market API.
  • The proof-generator binary for building proofs.
cd /your/zk/project
docker run -it \
  --volume $(pwd):/opt/project \
  --user $(id -u ${USER}):$(id -g ${USER}) \
  ghcr.io/nilfoundation/proof-market-toolchain:latest

# --volume mounts your project's directory into the container
# --user solves issues with file permissions

root@abc123:/proof-market-toolchain proof-producer -h
root@abc123:/proof-market-toolchain python3 scripts/prepare_statement.py --help

Remember to pull the image often to get the latest release:

docker pull ghcr.io/nilfoundation/proof-market-toolchain:latest .

Building the toolchain

Cloning the repository

Clone the repo with submodules:

git clone --recurse-submodules [email protected]:NilFoundation/proof-market-toolchain.git
cd proof-market-toolchain

When you pull newer commits, always checkout the submodules as well:

git submodule update --init --recursive

If you have errors on cloning submodules, setup the SSH keys on GitHub and try cloning again.

Building with Docker

Note: If you just need the latest release version, use the Docker image at ghcr.io/nilfoundation/proof-market-toolchain:latest.

You can build a Docker image from a particular commit:

docker build -t ghcr.io/nilfoundation/proof-market-toolchain:latest .

Now you can run a container based on this image:

docker run -it \
  -v $(pwd):/opt/project \
  --user $(id -u ${USER}):$(id -g ${USER}) \
  ghcr.io/nilfoundation/proof-market-toolchain:latest

root@abc123:/proof-market-toolchain proof-producer -h
root@abc123:/proof-market-toolchain python3 scripts/prepare_statement.py --help

When you build the image, tag can be anything. For example, you can use the current commit's hash as the tag:

docker build -t ghcr.io/nilfoundation/proof-market-toolchain:$(git rev-parse --short HEAD) .

The final image is built from a base image tagged ghcr.io/nilfoundation/proof-market-toolchain:base. It has precompiled Boost and all other required dependencies. If you want to update dependencies, change them in the Dockerfile.base, and then rebuild the base image:

docker build -t ghcr.io/nilfoundation/proof-market-toolchain:base --file Dockerfile.base .

To use proof market binaries, run them from the same container.

Building on host

Dependencies

On *nix systems, the following dependencies need to be installed:

apt install \
    build-essential \
    libssl-dev \
    cmake \
    clang-12 \
    git \
    autoconf \
    libc-ares-dev \
    libfmt-dev \
    gnutls-dev \
    liblz4-dev \
    libprotobuf-dev \
    libyaml-cpp-dev \
    libhwloc-dev \
    pkg-config \
    xfslibs-dev \
    systemtap-sdt-dev

Install Boost either manually or from your distributive's repository. Please make sure you are installing the version 1.76. Follow the guide to install version 1.76 manually.

We have tested for the following set of versions of the libraries:

clang-12
clang++12
boost == 1.76
cmake >= 3.22.1
autoconf >= 2.71
automake >=  1.16.5
libc-ares-dev >= 1.18.1
libfmt-dev >= 8.1.1
liblz4-dev >= 1.9.3
gnutls-dev >= 7.81
libprotobuf-dev >= 3.12.4
libyaml-cpp-dev >= 0.2.2
libhwloc-dev >= 2.7.0
libsctp-dev >= 1.0.19
ragel >= 6.10

We are aware of compilation issues with boost > 1.76 and clang > 12.0. Please use the versions recommended above

Building

mkdir build
cd build
cmake -G "Unix Makefiles" \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_C_COMPILER=/usr/bin/clang-12 \
  -DCMAKE_CXX_COMPILER=/usr/bin/clang++-12 \
  ..
# Single-threaded version (recommended)
cmake --build . -t proof-generator

Proof Market Beta Access

Start with installing requirements. We recommend using virtualenv:

pip3 install --user virtualenv
python3 -m virtualenv venv
source venv/bin/activate
pip3 install -r requirements.txt

Please see the documentation on how to get access for proof market. Or navigate to scripts/ directory and run the following commands.

First, create a username and password. Store them in files .user and .secret:

$ cd scripts
$ echo '<username>' > .user
$ echo '<password>' > .secret

Signup to the proof market with the following command. You'll need to repeat your username and password here.

$ python3 signup.py user -u <username> -p <password> -e <e-mail>

This command will return user metadata in JSON format:

{
  "user": "username",
  "active": true,
  "extra": {},
  "error": false,
  "code": 201
}

If you wish to submit generated proofs to the Proof Market, you need to also register as a proof producer:

$ python3 signup.py producer --url https://example.com

It will return producer metadata in JSON format:

{
  "_key": "...",
  "_id": "producer/...",
  "_rev": "_fneT7J2---",
  "description": "Generic Producer",
  "url": "https://example.com",
  "name": "username",
  "createdOn": 1677588821180,
  "updatedOn": 1677588821180
}

Proof Market Interaction

Below we will list a set of operations a user can follow along which demonstrates the market operation interaction between the above entities.

1. Prepare zkLLVM (for circuit developers)

The easiest way to create a circuit definition for Proof Market is zkLLVM. All dependencies and build instructions are inside the zkLLVM's repository. If you wish to interact with existing circuits/statements, please go to step 3.

2. Circuit Generation/Publishing (for circuit developers)

Circuits can be generated by any one. They are serialised & published on the proof market. This allows for reuse of the circuits by all other proof requesters. Circuits need a set of public inputs.

2.1 Create a new circuit (using zkLLVM)

make -C ${ZKLLVM_BUILD:-build} <circuit target name> -j$(nproc)

2.2 Prepare a statement with circuit description for Proof Market (using this repository)

Circuits are stored as a statement structure on Proof Market. Statement description example can be found in example/statements/ directory

Please ensure you have selected the option to create *ll IR files in the zkLLVM setup.

python3 scripts/prepare_statement.py \
    -c <zkllvm output> \
    -o <statement description file> \
    -n <statement name> \
    -t <statement type> \
    --private | --public

The --private or --public parameters are mutually exclusive:

  • With --private, the statement will be accessible only by its ID. For experiments and development purposes, make your statements private.
  • With --public, the statement will be openly listed on the Proof Market.

Provide the necessary information listed in the output statement file

2.2 Publish it to Proof Market

This statement can now be pushed to the Proof market via python script

python3 scripts/statement_tools.py push --file <json file with statement description>

You will be returned an object containing a _key filed -- unique descriptor of the statement

2.3 Get all statements

A list of all available statements can be obtained by

python3 scripts/statement_tools.py get

3. Proof Market Request Creation

The proof requester can create a request order. It has additional details such as what are they willing to pay for it and public inputs.

python3 scripts/request_tools.py push --cost <cost of the request> --file <json file with public_input> --key <key of the statement> 

The proof requester can check their request with

python3 scripts/request_tools.py get --key <key of the request> 

4. Wait for proposals

Here the proof requester waits for matching engine to either match an existing order or wait for proposals to be submitted against this circuit/statement.

5. Submit proposal

While the proposal is up, we now view at the marketplace from the perspective of a proof producer. In steps 2-4 , the requester put out a request. Now the producer can observe them in the marketplace and start replying with an proposal.

python3 scripts/proposal_tools.py push --cost <cost of the proposal> --key <key of the statement> 

The proof producer can check their proposal with

python3 scripts/proposal_tools.py get --key <key of the proposal> 

6. Order Matching

Proof Market runs a matching algorithm between requests and proposals for each new request/proposal. It chooses the cheapest proposal that fits the requirements of the proof requester.

7. Proof Generation

Proposal's status 'processing' means that the proposal was matched with a request. Now it is time to generate a proof for the proof producer.

First of all, the proof producer needs circuit definition:

python3 scripts/statement_tools.py get --key <key of the statement> -o <output file> 

Next, public input of the request:

python3 scripts/public_input_get.py --key <request key> -o <output file path> 

Execute the below to generate a proof:

cd build
./bin/proof-generator/proof-generator --proof_out=<output file> --circuit_input=<statement from Proof Market> --public_input=<public input from Proof Market>

Readme for Proof Producer daemon in located here.

8. Proof Submission

The proof generator can now submit the proof to the marketplace, where if verified, they will get the reward.

python3 scripts/proof_tools.py push --request_key <key of the request> --proposal_key <key of the proposal> --file <file with the proof> 

You can provide only one of two possible keys

9. Get Proof

Now the proof requester is able to get their proof either by request key or proof key.

python3 scripts/proof_tools.py get --request_key <key of the request> 

Validation of the proof is not part of the tool chain. Validation flow is implemented in the lorem ipsum cli repository here.

Common issues

Compilation Errors

If you have more than one compiler installed i.e g++ & clang++. The make system might pick up the former. You can explicitly force usage of clang++ by finding the path and passing it in the variable below.

`which clang++`  
cmake .. -DCMAKE_CXX_COMPILER=<path to clang++ from above>

Submodule management

Git maintains a few places where submodule details are cached. Sometimes updates do not come through. ex: Deletion , updating a url of a previously checked out submodule.It is advisable to check these locations for remains or try a new checkout.

  • .gitmodules
  • .git/config
  • .git/modules/*

Compilation errors for Proof generator

Please ensure you are using 1.76 version of boost as the higher versions have an incompatible API which will be updated in due course.

macOS

On macOS, these dependencies are required for compilation

fmt gnutls protobuf yaml-cpp ragel hwloc

Community

Join our community on Telegram and Discord.

proof-market-toolchain's People

Contributors

g-arakelov avatar hgedia avatar knazarov avatar makxenov avatar nemothenoone avatar nickvolynkin avatar sk0m0r0h avatar vitalylativ avatar x-mass avatar zerg1996 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

proof-market-toolchain's Issues

Update get query for public inputs

This change refers to the workflow where proof producers get public inputs from the order itself. JSON structuring requires changing as this was not compatible with the proof producer binary.

Make statements private by default

Statements have the field isPrivate, which is false by default. With active development, such as during our workshops, a lot of statements will be pushed to the Proof Market. We should make them private by default and let developers make them public explicitly.

prepare_statement.py --private
prepare_statement.py --public

Update PMT readme and PM docs to support the terminology change

Update dependencies

This is a recurring task for updating toolchain when the dependencies are updated.

Restructure readme: prefer containerized workflow

There's no need to go all the way with dependencies in the container-based workflow.

  • Put containter-based workflow to the top.
  • Add table of contents.
  • Run through the workflow with a real developer from the community.

./build.sh in Docker errors

Running sh ./build.sh in docker cause the following errors:

CMake Warning (dev) in CMakeLists.txt:
  No project() command is present.  The top-level CMakeLists.txt file must
  contain a literal, direct call to the project() command.  Add a line of
  code such as

    project(ProjectName)

  near the top of the file, but after cmake_minimum_required().

  CMake is pretending there is a "project(Project)" command on the first
  line.
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Error at CMakeLists.txt:26 (include):
  include could not find requested file:

    CMConfig


CMake Error at CMakeLists.txt:27 (include):
  include could not find requested file:

    CMDeploy


CMake Error at CMakeLists.txt:28 (include):
  include could not find requested file:

    CMSetupVersion


CMake Error at CMakeLists.txt:30 (cm_workspace):
  Unknown CMake command "cm_workspace".

Docker image doesn't have `requests` module

/proof-market-toolchain$ python3 scripts/auth_tools.py --help
Traceback (most recent call last):
  File "/proof-market-toolchain/scripts/auth_tools.py", line 5, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'

Short keys don't match long ones in proof_tools.py CLI

Keys were renamed recently, but the short versions were not. It makes CLI harder to understand and remember. What if we rename them accordingly?

https://github.com/NilFoundation/proof-market-toolchain/blob/master/scripts/proof_tools.py

-    parser_push.add_argument("-a", "--proposal_key", type=str, default=None, help="proposal_key")
+    parser_push.add_argument("-p", "--proposal_key", type=str, default=None, help="proposal_key")
-    parser_push.add_argument("-b", "--request_key", type=str, default=None, help="request_key")
+    parser_push.add_argument("-r", "--request_key", type=str, default=None, help="request_key")
     parser_push.add_argument(
         "-f", "--file", type=str, required=True, help="file with proof"
     )

-    parser_get.add_argument("-p", "--proof_key", type=str, help="key of the proof")
+    parser_get.add_argument("-k", "--proof_key", type=str, help="key of the proof")
     parser_get.add_argument("-f", "--file", type=str, help="file to write proof")
     parser_get.add_argument("-b", "--request_key", type=str, help="request_key")

Proofread the existing Proof Market documentation

The current docs have a few word choice, punctuation, and style issues. Let's fix them before making significant changes like #63.

Make branches from the branch https://github.com/nilfoundation/proof-market-toolchain/tree/00-gitbook-docs.

For each chunk of work, open a PR from your branch → 00-gitbook-docs. Make chunks small enough to make 2-3 PRs a day.

Ambiguous field names in response of `requrest_tools.py push`

On the market there's a statement with key 93843771:

    {
        "_key": "93843771",
        "createdOn": 1689098910158,
        "description": "description",
        "input_description": "input_description",
        "isPrivate": false,
        "name": "nickvolynkin_example_circuit",
        "sender": "nickvolynkin",
        "type": "placeholder-zkllvm",
        "updatedOn": 1689098910158,
        "url": "url"
    }

Pushing a proof proposal for this statement:

/proof-market-toolchain# python3 scripts/request_tools.py push --cost 2 --file /opt/zkllvm-template/src/main-input.json --key 93843771

returns the following data:

{
    "_key": "93846511",
    "statement_key": "93843771",
    "cost": 2,
    "sender": "nickvolynkin",
    "status": "created"
}

It's unclear what the _key is. Must be the proposal's ID.

Use base Docker image for building dev-mode proof producer images

The image built from ./scripts/proof_producer/build_scripts/Dockerfile can use ghcr.io/nilfoundation/proof-market-toolchain:base, built from ./Dockerfile.base. It will improve the build speed, mainly because it skips Boost compilation.

Things to do and check:

  • Build from the base image, not ubuntu:22.04
  • Check dependency lists. If there's something missing in the base image, we can put it there.
  • There's a requests==2.28.2 dependency manually installed in the dev-mode Dockerfile, and one in ./requirements.txt. Let's bring it to consistency and use one source.

Follow-up to #36

Running proof-generator without params or with -h/-v results in an attempt to find config.ini

When I run the proof-generator with empty input or with -h and -v, I get unexpected results:

root@5ffc715e5f63:/proof-market-toolchain# /proof-market-toolchain/build/bin/proof-generator/proof-generator
can not read options configuration file '/root/.config/config.ini'
terminate called after throwing an instance of 'boost::wrapexcept<boost::property_tree::ini_parser::ini_parser_error>'
  what():  /root/.config/config.ini: cannot open file
Aborted (core dumped)

root@5ffc715e5f63:/proof-market-toolchain# /proof-market-toolchain/build/bin/proof-generator/proof-generator -v
can not read options configuration file '/root/.config/config.ini'
terminate called after throwing an instance of 'boost::wrapexcept<boost::property_tree::ini_parser::ini_parser_error>'
  what():  /root/.config/config.ini: cannot open file
Aborted (core dumped)

# slightly different result, but still an error:
root@5ffc715e5f63:/proof-market-toolchain# /proof-market-toolchain/build/bin/proof-generator/proof-generator -h
Command_Line_Options:
  -h [ --help ]                         Display available command-line
                                        configuration arguments
  -c [ --configuration-files ] arg (=/root/.config/config.ini)
                                        Configuration files

NIL Proof Generator:
  -v [ --version ]                      Display version
  --proof_out arg                       Output file
  --circuit_input arg                   Circuit input file
  --public_input arg                    Public params input file

Json circuit description parsing failed: incomplete JSON
Json public_input parsing failed: incomplete JSON
terminate called after throwing an instance of 'boost::wrapexcept<std::invalid_argument>'
  what():  not an object
Aborted (core dumped)
root@5ffc715e5f63:/proof-market-toolchain# /proof-market-toolchain/build/bin/proof-generator/proof-generator
can not read options configuration file '/root/.config/config.ini'
terminate called after throwing an instance of 'boost::wrapexcept<boost::property_tree::ini_parser::ini_parser_error>'
  what():  /root/.config/config.ini: cannot open file
Aborted (core dumped)

The image is built from commit e7ac895, which is based on master branch commit 9008207

Add proof_key in response for bid_tools get.

$ python3 scripts/bid_tools.py get --key=84304538
Limit bid:       {
    "_key": "84304538",
    "cost": 7,
    "sender": "robertogomes",
    "statement_key": "79169223",
    "status": "completed"
}

Currently proof-key is not returned in the response and we should add this to prevent users from using the -v flag.

Implement standalone proof producer

It seems that proof-market toolchain would be more convenient to use if the user could easily substitute the proof-producer binaries.
Because many teams will inevitably do custom implementations and optimizations of our prover (including hardware-specific deployments), it may make sense to give them a separate repository, which they could fork and do their job there.

Separate prover can be moved to https://github.com/NilFoundation/proof-producer

Check this issue after proof-producer is separated: NilFoundation/zkLLVM#178

Pushing a proposal with `--key` value from anything except a statement should return an error

Pushed a proposal, providing a request ID instead of a statement ID by mistake. (I've formatted the JSON output):

root@61db058b84db:/proof-market-toolchain# python3 scripts/proposal_tools.py push --key 93846511 --cost 2
Limit proposal:
{
  '_key': '93849751',
  '_id': 'proposal/93849751',
  '_rev': '_gSXAKnm---',
  'statement_key': '93846511',
  'cost': 2,
  'sender': 'nickvolynkin',
  'wait_period': None,
  'eval_time': None,
  'createdOn': 1689100890776,
  'updatedOn': 1689100890776,
  'status': 'created'
}

As you can see, it has status=created. This request must return an error because there is no statement with this id.

Trying to find my proposal right after pushing it:

root@61db058b84db:/proof-market-toolchain# python3 scripts/proposal_tools.py get --key 93846511
Error: 204

93846511 is in fact a request for statement 93843771:

root@61db058b84db:/proof-market-toolchain# python3 scripts/request_tools.py get --key 93846511
Limit request:	 {
    "_key": "93846511",
    "cost": 2,
    "sender": "nickvolynkin",
    "statement_key": "93843771",
    "status": "created"
}

Make zkLLVM dependencies binary

Rewrite proof market toolchain logic and make it dependent on zkllvm binaries (zkllvm clang, assigner, transpiler) and proof-producer binary.

Remove descriptions for multithreaded proof generation

Since multithreaded proof generation is not working yet, we should remove this from documentation, so nobody would try using it.

This is how it was described and how it was supposed to work:

To generate proof using the multithreaded version, execute the following:

cd build
./bin/proof-generator/proof-generator-mt \
    --proof_out <output file> \
    --circuit_input <statement from Proof Market>
    --public_input <public input from Proof Market> \
    --smp <number of threads>
    ----shard0-mem-scale <scale>

Proof computation requires temporary space, always allocated to core0/shard0.
The following flags require attention for multithreaded use:

  • smp - number of threads.
    This is ideally the number of CPU cores on the system.
    If you have a 16-core CPU & 16 GB RAM, you can set smp to 16.
    Each core gets access to 1 GB of RAM, so core0/shard0 will have access to 1 GB of RAM.
  • shard0-mem-scale - weighted parameter (weight) to reserve memory for shard0.
    This is a natural number that allows for shard0 to have more access to RAM in comparison to others.
    If you have a 16-core CPU & 16 GB RAM, you can set smp to 8 and shard0-mem-scale to 9.

We first compute ram_per_shard variable as follows:

ram_per_shard = TOTAL_RAM / (smp + shard0-mem-scale -1)
              = 16 / (8 + 8)
              = 1

Which equates to the following:

  • shard0 RAM =shard0-mem-scale * ram_per_shard = 9 GB
  • shard1 .... shard7 = ram_per_shard = 1 GB/per core = 7 GB

You should tune these two variables for the architecture/circuit for which the proof is generated.

There's also a neat trick that we could recommend:

Linux

--smp $(nproc)

macOS

--smp $(sysctl -n hw.logicalcpu)

See for example:

https://github.com/NilFoundation/zkllvm/blob/master/.github/workflows/build_linux.yml#L105
https://github.com/NilFoundation/zkllvm/blob/master/.github/workflows/build_macos.yml#L77

proof_tools.py get returns IndexError when proof is not ready

Limit request:	 {
    "_key": "96804968",
    "cost": 10,
    "sender": "nickvolynkin",
    "statement_key": "96079532",
    "status": "created"
}
root@3ba82297fb2d:/proof-market-toolchain# python3 scripts/proof_tools.py get --request_key 96804968
Traceback (most recent call last):
  File "/proof-market-toolchain/scripts/proof_tools.py", line 89, in <module>
    args.func(args=args)
  File "/proof-market-toolchain/scripts/proof_tools.py", line 66, in get_parser
    get(args.auth, args.request_key, args.proof_key, args.file)
  File "/proof-market-toolchain/scripts/proof_tools.py", line 52, in get
    res_json = res.json()[0]
IndexError: list index out of range

statement_tools get: show statements in a neat table

statement_tools returns statements as a raw JSON output. There should be a way to see a neat table, like with docker image ls or

python3 scripts/statement_tools.py get 

KEY 		DESCRIPTION           			AVG_COST AVG_TIME URL	
79169223	Account state proof for Mina	6.32	 8.8s	  https://github.com/NilFoundation/mina-state-proof
32292		mina state proof				6.42	 9835s	  https://github.com/NilFoundation/mina-state-proof

Keep just `auth.json` but not the basic user credentials

Current workflow

  1. User registers with ./scripts/signup.py, script saves credentials in ./scripts/.user and ./scripts/.secret.
    • Alternatively, user registers in the Web UI and manually saves credentials in in ./scripts/.user and ./scripts/.secret.
  2. User authenticates with ./scripts/auth_tools.py, script saves JSON web token in ./auth.json
  3. Other scripts use the JSON web token from ./auth.json.

There's a number of problems here:

  1. It's very unsafe, and users can lose their credentials by committing them in git.
  2. Working with docker requires mounting a lot of files:
    docker run -it --rm \
      ...
      --volume $(pwd)/.config/.user:/proof-market-toolchain/scripts/.user \
      --volume $(pwd)/.config/.secret:/proof-market-toolchain/scripts/.secret \
      --volume $(pwd)/.config/auth.json:/proof-market-toolchain/auth.json \
      ...
    

Proposed workflow

  1. User registers with ./scripts/signup.py on in WebUI and saves their credentials elsewhere: in a password manager, in memory, on a sticky note, whatever.
  2. User runs ./scripts/auth_tools.py, the script prompts for credentials, gets a JSON web token, and saves it in ~/.config/proof-market/auth.json.
  3. Other scripts use the JSON web token from that location.

Further on and out of scope of this issue, we'll make the following changes:

  • The proof-producer binary will look for its configuration file somewhere under /etc/proof-market/config.ini
  • Everything with a configuration or auth file will have optional --config and --auth parameters.

`proof-generator` not working with input strings

Steps to reproduce:

Test File: charcpp_test.cpp

#include <cstddef>
[[circuit]] size_t strlen(const char *str) {
    size_t counter = 0;
    while (str[counter++] != '\0');
    return counter - 1;
}

Input File: charcpp_input.json

{
    "input": "abcdefgh"
}

Commands to reproduce

Getting the circuit with zkLLVM:

/home/robertorosmaninho/rv/zk-experiments/zkllvm/build/libs/circifier/llvm/bin/clang-16 -target assigner -Xclang -no-opaque-pointers -Xclang -fpreserve-vec3-type -std=c++20 -D__ZKLLVM__ -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/algebra/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/build/include -I /home/robertorosmaninho/rv/boost_1_76_0/build/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/block/include -I /home/robertorosmaninho/rv/boost_1_76_0/build/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/blueprint/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/codec/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/containers/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/hash/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/kdf/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/mac/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/marshalling/core/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/marshalling/algebra/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/marshalling/multiprecision/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/marshalling/zk/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/math/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/modes/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/multiprecision/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/passhash/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/pbkdf/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/pkmodes/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/pkpad/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/pubkey/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/random/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/stream/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/vdf/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/crypto3/zk/include -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/stdlib/libcpp -I /home/robertorosmaninho/rv/zk-experiments/zkllvm/libs/stdlib/libc/include -emit-llvm -O1 -S charcpp_test.cpp

Getting the circuit statement:

python ./scripts/prepare_statement.py -c=charcpp_test.ll -o=test_statement.json -n=test -t=placeholder-zkllvm

Generate the proof:

./build/bin/proof-generator/proof-generator --proof_out=test_output.bin --circuit_input=test_statement.json --public_input=charcpp_input.json

Current Output from proof-generator:

terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc

Expected output:

generatring zkllvm proof...
Proof is verified

Tools Version

zkLLVM

clang version 16.0.0 (https://github.com/NilFoundation/zkllvm-circifier.git 9e73aecf0f3db71cb1fb433f65d56a63654afd1a)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/robertorosmaninho/rv/zk-experiments/zkllvm/build/libs/circifier/llvm/bin

Proof Market

$> git log
commit 992025ddbf89a4dbd0c7c1512b25704846577daf (HEAD -> master, tag: v0.0.30, origin/master, origin/HEAD)

$> l
total 16K
drwxrwxr-x 4 robertorosmaninho robertorosmaninho 4.0K May 30 13:27 .
drwxrwxr-x 7 robertorosmaninho robertorosmaninho 4.0K Jun 15 16:20 ..
drwxrwxr-x 3 robertorosmaninho robertorosmaninho 4.0K Jun 15 16:25 proof-generator

I couldn't find a way to output the current version, so I just used git log and l.

Add ccache with preheated cache to the image

Add ccache to the build image. Build proof market in it once from the main branch, and save the cache in the image.

As a result, when folks build the proof market in a container, the build will be blazing fast.

Blocked by #35

Publish a ready-to-work docker image

Publish ready-to-work docker image:

  • All dependencies installed (apt, pip)
  • Proof-market-toolchain is precompiled
  • Correct working directory

Currently, users have to compile the project themselves, which takes a lot of time and reduces the success rate.
This image will help new users start working with Proof Market in several minutes.

Also, we will use this image in CI for checking integration between zkLLVM and Proof Market.

Image names:

# build-base image: all dependencies, but no compiled code
ghcr.io/nilfoundation/proof-market-toolchain:base

# ready-to-use image: all dependencies + compiled toolchain applications
ghcr.io/nilfoundation/proof-market-toolchain:latest

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.