Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: proofread requester-producer flow and mina pipeline #97

Merged
merged 1 commit into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 31 additions & 24 deletions gitbook-docs/guides-1/mina-proof-pipeline-example/1.-setup.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,48 @@
# 1. Setup
# Part 1. Setup

MINA proofs are computationally heavy; hence, users need to use the proof market to generate proofs to have a MINA state proof validated in EVM.
Mina proofs are computationally heavy; hence, proof producers can benefit from
using Proof Market to generate Mina state proofs for their further in-EVM validation.

You need to set up the following environments to follow along with this guide.
You're going to need the following environments ready for this guide.

## 1. Proof Market 
## Step 1: Proof Market

Please ensure you have done the following steps:
Prerequisites from the Proof Market side are:

* [Installation](../../guides/installation.md): Clone the repository. You don't need to build anything, as we will only be using Python scripts.
* [Authentication](../../market/user-guides/sign-up.md): Set up the `proof-market-toolchain` authentication as a user. You do not need to create a Proof Producer profile.
* [Environment setup](../getting-started/environment-setup.md).
* [Proof Market toolchain installation and setup](../../getting-started/installation.md).
You don't need to set up a virtual environment for the Proof Market toolchain,
we will only be using its Python scripts.
This directory will be referred to as `proof-market-toolchain` home in the guide.
* [Authentication on Proof Market](../../market/user-guides/sign-up.md).
There's no need to register as a producer, any account will suffice.

This will be referred to as `proof-market-toolchain` the home in the guide
## Step 2: Mina state proof

## 2. Mina State Proof 
Mina state proof repository maintained by `=nil;` Foundation
comprises the following artifacts:
* Solidity EVM verifier;
* C++ circuits;
* scripts to fetch Mina state (ledger) and Mina account state (user/zkApp).

Mina state-proof repository maintains the following artifcats
Clone the [Mina state proof repository](https://github.com/NilFoundation/mina-state-proof)
and run `npm i` from the project's directory to install all its dependencies.
This directory will be referred to as `mina-state-proof` home in the guide.

* Solidity EVM verifier 
* C++ circuits
* Scripts to fetch mina state (ledger) , mina account state (user/zkApp)
## Step 3: Mina zkApp

 Please clone the repository located [here](https://github.com/NilFoundation/mina-state-proof) and install any dependencies. 
Mina zkApp project consists of a sample zkApp located at `mina-state-proof/examples/mina-add-zkapp`
with 8 state variables that are updated on each interaction.
This directory will be referred to as `mina-add-zkApp` home in the guide.

This will be referred to as `mina-state-proof` home in the guide
Follow the steps from
[`mina-add-zkapp/README.md`](https://github.com/NilFoundation/mina-state-proof/tree/master/examples/mina-add-zkapp)
to install the project dependencies.

## 3. Mina zkApp
After that, you should have the following three directories ready:

Mina zkApp project consists of a sample zkApp with 8 state variables that are updated on each interaction. This is located at `mina-state-proof/examples/mina-add-zkapp` . Please follow the steps to Install the project dependencies present at `mina-state-proof/examples/mina-add-zkapp/README.md`. 

This will be referred to as `mina-add-zkApp` home in the guide

At the end of this step, you should have 3 folders representing the three repositories above as follows

```
```bash
proof-market-toolchain/
mina-state-proof/
mina-state-proof/examples/mina-add-zkapp/
```

112 changes: 84 additions & 28 deletions gitbook-docs/guides-1/mina-proof-pipeline-example/2.-deploy-zkapp.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
# 2. Deploy zkApp
# Part 2. Deploying zkApp

Please navigate to the `mina-add-zkapp` home directory.
The following steps, performed from `mina-add-zkapp` home directory,
deploy the test zkApp to the `Berkeley` test net.

The following steps deploy the zkApp to `Berkeley` testnet
## Step 1: generate a key pair

## 1. Generate key-pair 
Let's start with generating test keys:

```
npm run build && node build/src/generateKeyPairs.js
```
```console
$ npm run build && node build/src/generateKeyPairs.js

This command outputs :

```
--------WARNING: UNSECURE KEYS DO NOT USE IN PRODUCTION ENV----------------

--------------------------------------------------------------------------
Expand All @@ -24,47 +21,106 @@ user public key : B62xxxxxxxxxxxxxxxxxxxxxxxx
--------------------------------------------------------------------------
```

The user should update 
Copy these keys to the corresponding paths:
* `zkApp` key pair to `keys/berkeley.json`;
* `user` key pair to `keys/user.json`.

* `zkApp` key pair to `keys/berkeley.json`
* `user` key pair to `keys/user.json`
The format for these JSON files is:
```json
{
"privateKey": "YOUR_PRIVATE_KEY",
"publicKey": "YOUR_PUBLIC_KEY"
}
```

Only the user wallet **must** be funded by requesting faucet funds on `BERKELEY` network here by providing the public key: [https://faucet.minaprotocol.com/](https://faucet.minaprotocol.com/)
On https://faucet.minaprotocol.com you can fund your Mina wallet on `Berkeley` network
by requesting faucet funds using your **public** key.
**Only your wallets** should be funded this way.

{% hint style="warning" %}
You must wait for your user wallet to be funded before progressing. This can take approximately 3-5 minutes.
You must wait for your wallet to be funded before progressing.
This depends on your transaction appearing in a completed block, which can take approximately 3-5 minutes.
{% endhint %}

## Step 2: build the project


## 2. Build Project

```
To build the project, run:
```bash
npm run build
```

## 3. Deploy Project
## Step 3: deploy the project

```
Upon deployment, zkApp's 8 state variables will be initialized to `1,2,3,4,5,6,7,8`.

```bash
zk deploy berkeley
```

zkApp 8 state variables initialized to `1,2,3,4,5,6,7,8` The contract has a method `update` which increments the zkApp state fields by `1,2,3,4,5,6,7,8` each of them respectively.
The test `Add` contract has the only method, `update`, that increments the zkApp state fields
by `1,2,3,4,5,6,7,8` each of them respectively.
Note that state values are represented in the hexadecimal numeral system.

## 4. Interact with zkApp
## Step 4: check the account state

```
node build/src/interact.js berkeley
To fetch zkApp or user data, you're going to need the `get_mina_state.py` script
located in `mina-state-proof/scripts`.
You can either navigate to the `mina-state-proof` home or add `../../` before `scripts/get_mina_state.py`.

```bash
$ python3 scripts/get_mina_state.py \
--output mina_zkapp_state.json \
account --address YOUR_PUBLIC_KEY
```

Every interaction calls the `update` method which increments values as follows:
The output file you provided will be populated with JSON
detailing the account/zkApp state:

```json
{
"public_key": "YOUR_PUBLIC_KEY",
"balance": {
"liquid": "0",
"locked": "0"
},
"state":
"0x0000000000000000000000000000000000000000000000000000000000000001,
0x0000000000000000000000000000000000000000000000000000000000000002,
0x0000000000000000000000000000000000000000000000000000000000000003,
0x0000000000000000000000000000000000000000000000000000000000000004,
0x0000000000000000000000000000000000000000000000000000000000000005,
0x0000000000000000000000000000000000000000000000000000000000000006,
0x0000000000000000000000000000000000000000000000000000000000000007,
0x0000000000000000000000000000000000000000000000000000000000000008",
"proof_extension": "..."
}
```

* `update#1` values changed to `2,4,6,8,10,12,14,16`
* `update#2` values changed to `3,6,9,12,15,18,21,24`.
## Step 5: interacting with zkApp

This step is performed from `mina-add-zkapp` home.
It will compile the contract and call its method `update`.
This may take some time, but if successful you will see a link to your transaction on `Berkeley`:

```console
$ node build/src/interact.js berkeley

compile the contract...
build transaction and create proof...
send transaction...

Success! Update transaction sent.

Your smart contract state will be updated
as soon as the transaction is included in a block:
https://berkeley.minaexplorer.com/transaction/...
```

Every interaction through this script calls the contract's `update` method,
incrementing the values as follows:
* after the first update state values will be changed to `2,4,6,8,a,c,e,10`;
* after the second update state values will be changed to `3,6,9,c,f,12,15,18`;
* and so on.

Once your transaction is included in a block, in approximately 3-5 minutes,
you can [check the state values](#step-4-check-your-state-values) again and see if they changed.
Loading