Skip to content

Commit

Permalink
Merge pull request #50 from ora-io/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
murongg authored Feb 27, 2024
2 parents a65ced9 + 0462c61 commit d9658cc
Show file tree
Hide file tree
Showing 140 changed files with 3,647 additions and 1,790 deletions.
4 changes: 2 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
packages/create-zkgraph/template-*/**/*
packages/create-cle/template-*/**/*
test/fixtures/**/*
packages/create-zkgraph/templates/**/**/*
packages/create-cle/templates/**/**/*
127 changes: 53 additions & 74 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@

<p align="center">
<a href="https://www.hyperoracle.io" target="_blank" rel="noopener noreferrer">
<img width="180" src="https://github.com/hyperoracle/media-kit/blob/main/Logos/Colored_Logo.png?raw=true" alt="HyperOracle logo">
<a href="https://www.ora.io" target="_blank" rel="noopener noreferrer">
<img width="180" src="https://github.com/ora-io/media-kit/blob/main/Logos/logo%20type_blue_V1.png?raw=true" alt="ORA logo">
</a>
</p>
<br/>
<p align="center">
<a href="https://npmjs.com/package/@hyperoracle/zkgraph-cli"><img src="https://img.shields.io/npm/v/@hyperoracle/zkgraph-cli/latest.svg" alt="npm package"></a>
<a href="https://github.com/hyperoracle/zkgraph-cli/actions/workflows/ci.yml"><img src="https://github.com/hyperoracle/zkgraph-cli/actions/workflows/ci.yml/badge.svg?branch=main" alt="build status"></a>
<a href="https://www.npmjs.com/package/@hyperoracle/zkgraph-lib"><img alt="npm peer dependency version (scoped)" src="https://img.shields.io/npm/dependency-version/%40hyperoracle%2Fzkgraph-cli/peer/%40hyperoracle%2Fzkgraph-lib"></a>
<a href="https://npmjs.com/package/@ora-io/cle-cli"><img src="https://img.shields.io/npm/v/@ora-io/cle-cli/latest.svg" alt="npm package"></a>
<a href="https://github.com/ora-io/cle-cli/actions/workflows/ci.yml"><img src="https://github.com/ora-io/cle-cli/actions/workflows/ci.yml/badge.svg?branch=main" alt="build status"></a>
<a href="https://www.npmjs.com/package/@ora-io/cle-lib"><img alt="npm peer dependency version (scoped)" src="https://img.shields.io/npm/dependency-version/%ora-io%2Fcle-cli/peer/%ora-io%2Fcle-lib"></a>
</p>
<br/>

# zkGraph CLI
# CLE CLI

## Getting Started

### Scaffolding Your First zkGraph Project
### Scaffolding Your First CLE Project

With NPM:
```bash
npm create zkgraph@latest
npm create cle@latest
```

With Yarn:

```bash
yarn create zkgraph@latest
yarn create cle@latest
```

With PNPM:

```bash
pnpm create zkgraph@latest
pnpm create cle@latest
```

Then follow the prompts!
Expand All @@ -41,25 +41,25 @@ To scaffold a **uniswapprice** template, you can directly specify the project na

```sh
# npm 6.x
npm create zkgraph@latest my-zkgraph-uniswapprice --template uniswapprice
npm create cle@latest my-cle-uniswapprice --template uniswapprice

# npm 7+, extra double-dash is needed:
npm create zkgraph@latest my-zkgraph-uniswapprice -- --template uniswapprice
npm create cle@latest my-cle-uniswapprice -- --template uniswapprice

# yarn
yarn create zkgraph@latest my-zkgraph-uniswapprice --template uniswapprice
yarn create cle@latest my-cle-uniswapprice --template uniswapprice

# pnpm
pnpm create zkgraph@latest my-zkgraph-uniswapprice --template uniswapprice
pnpm create cle@latest my-cle-uniswapprice --template uniswapprice
```

## CLI

> Note: Only `full` image will be processed by zkOracle node. `local` (generated by commands ending with `--local` option) means the zkGraph is compiled locally and only contains partial computation (so that proving and executing will be faster).
> Note: Only `full` image will be processed by zkOracle node. `unsafe` (define `unsafe: true` in the `cle.yaml`) means the CLE is compiled locally and only contains partial computation (so that proving and executing will be faster).
The workflow of local zkGraph development must follow: `Develop` (code in /src) -> `Compile` (get compiled wasm image) -> `Execute` (get expected output) -> `Prove` (generate input and pre-test for actual proving in zkOracle) -> `Verify` (verify proof on-chain).
The workflow of local CLE development must follow: `Develop` (code in /src) -> `Compile` (get compiled wasm image) -> `Execute` (get expected output) -> `Prove` (generate input and pre-test for actual proving in zkOracle) -> `Verify` (verify proof on-chain).

To upload and publish your zkGraph, you should `Upload` (upload code to IPFS), and then `Publish` (register zkGraph on onchain zkGraph Registry).
To upload and publish your CLE, you should `Upload` (upload code to IPFS), and then `Publish` (register CLE on onchain CLE Registry).

### Compile

Expand All @@ -68,32 +68,31 @@ Compile for Full Image (Link Compiled with Compiler Server).
#### Usage

```bash
zkgraph compile [root]
cle compile [root]
```

#### Options

| Options | Description |
| ----------------------- | ----------------------- |
| `--local` | Compile for Local Image |
| `--yaml-path <path>` | Path to yaml file |
| `--mapping-path <path>` | Path to mapping file |
| Options | Description |
| -------------------- | ------------------------------------- |
| `--yaml-path <path>` | Path to yaml file |
| `--dir <path>` | Path to directory containing cle.yaml |

### Execute

Execute Full Image.

Please save the `ZKGRAPH_STATE_OUTPUT` string for following prove steps.
Please save the `CLE_STATE_OUTPUT` string for following prove steps.

#### Usage
```bash
zkgraph exec [...params] [root]
cle exec [...params] [root]
```

#### Usage cases
```bash
zkgraph exec <blockId> [root]
zkgraph exec <blockId> <offchainData> [root]
cle exec <blockId> [root]
cle exec <blockId> <offchainData> [root]
```


Expand All @@ -105,28 +104,21 @@ zkgraph exec <blockId> <offchainData> [root]
| `<offchainData>` | offchain data |


#### Options

| Options | Description |
| --------- | ------------------- |
| `--local` | Execute Local Image |

### Set Up

Set Up Full Image

- `circuit-size`: Specify the circuit size of image instead of the default recommended. eg. `zkgraph setup -- --circuit-size <size> (eg. 22)`.
- `circuit-size`: Specify the circuit size of image instead of the default recommended. eg. `cle setup -- --circuit-size <size> (eg. 22)`.

#### Usage
```bash
zkgraph setup [root]
cle setup [root]
```

#### Options

| Options | Description |
| --------------------------- | -------------------------------- |
| `--local` | Set Up Local Image |
| `-k, --circuit-size <size>` | Circuit size (k in 2^k) of image |

### Prove
Expand All @@ -135,58 +127,51 @@ Prove Full Image

#### Usage
```bash
zkgraph prove [...params] [root]
cle prove [...params] [root]
```

#### Usage cases
```bash
zkgraph prove <blockId> <expectedStateStr> [root]
zkgraph prove <blockId> <offchainData> <expectedStateStr> [root]
cle prove <blockId> <expectedStateStr> [root]
cle prove <blockId> <offchainData> <expectedStateStr> [root]
```

#### Arguments

| Arguments | Description |
| ------------------ | ----------------------------------------------- |
| `<block id>` | Block number (or block hash) as runtime context |
| `<expected state>` | State output of the zkGraph execution |
| `<expected state>` | State output of the CLE execution |
| `<offchainData>` | offchain data |


#### Options

| Options | Description |
| ---------------- | ---------------------------- |
| `--local` | Prove Local Image |
| `-i, --inputgen` | Run in input generation Mode |
| `-t, --test` | Run in test Mode |
| `-p, --prove` | Run in prove Mode |

### Upload

Upload zkGraph (Code and Full Image).
Upload CLE (Code and Full Image).

Please save the `ipfs_hash` from the output dialog for following publish steps.

#### Usage
```bash
zkgraph upload [root]
cle upload [root]
```

#### Options

| Options | Description |
| --------- | ------------------------------------------- |
| `--local` | Upload Local zkGraph (Code and Local Image) |


### Verify

Verify Proof Onchain.

#### Usage
```bash
zkgraph verify <prove task id>
cle verify <prove task id>
```

#### Arguments
Expand All @@ -198,29 +183,29 @@ zkgraph verify <prove task id>

### Publish

Publish and Register zkGraph Onchain.
Publish and Register CLE Onchain.

See also: [Verifier Contract Interface](https://github.com/DelphinusLab/halo2aggregator-s/blob/main/sol/contracts/AggregatorVerifier.sol#L40).

#### Usage
```bash
zkgraph publish <ipfs_hash> <bounty_reward_per_trigger>
cle publish <ipfs_hash> [bounty_reward_per_trigger]
```

#### Arguments

| Arguments | Description |
| ----------------------------- | ---------------------------------------------------------- |
| `<ipfs hash>` | IPFS hash of uploaded zkGraph |
| `<bounty reward per trigger>` | Bounty reward per trigger in ETH |
| Arguments | Description |
| ----------------------------- | -------------------------------- |
| `<ipfs hash>` | IPFS hash of uploaded CLE |
| `[bounty reward per trigger]` | Bounty reward per trigger in ETH |

### Deposit

Publish and register zkGraph Onchain.
Publish and register CLE Onchain.

#### Usage
```bash
zkgraph deposit <deployed contract address> <deposit amount>
cle deposit <deployed contract address> <deposit amount>
```

#### Arguments
Expand All @@ -232,14 +217,14 @@ zkgraph deposit <deployed contract address> <deposit amount>

## Config

### Configuring zkGraph
### Configuring CLE

When running zkGraph from the command line, the tool will automatically attempt to locate a configuration file named zkgraph.config.js in the project’s root directory. It also supports other file extensions such as JS and TS.
When running CLE from the command line, the tool will automatically attempt to locate a configuration file named cle.config.js in the project’s root directory. It also supports other file extensions such as JS and TS.

The most basic config file looks like this:

```js
// zkgraph.config.js
// cle.config.js
export default {
// config options
}
Expand All @@ -248,30 +233,30 @@ export default {
You can also explicitly specify a config file to use with the --config CLI option (resolved relative to cwd):

```bash
zkgraph --config my-config.js
cle --config my-config.js
```

### Config Intellisense

Since zkGraph ships with TypeScript typings, you can leverage your IDE's intellisense with jsdoc type hints:
Since CLE ships with TypeScript typings, you can leverage your IDE's intellisense with jsdoc type hints:

```js
/** @type {import('@hyperoracle/zkgraph-cli').UserConfig} */
/** @type {import('@ora-io/cle-cli').UserConfig} */
export default {
// ...
}
```
Alternatively, you can use the defineConfig helper which should provide intellisense without the need for jsdoc annotations:

```js
import { defineConfig } from '@hyperoracle/zkgraph-cli'
import { defineConfig } from '@ora-io/cle-cli'

export default defineConfig({
// ...
})
```

ZkGraph also directly supports TS config files. You can use zkgraph.config.ts with the defineConfig helper as well.
CLE also directly supports TS config files. You can use cle.config.ts with the defineConfig helper as well.

### Config Options

Expand Down Expand Up @@ -313,14 +298,8 @@ Please note that (during testnet phrase) your address balance (in zkwasm server)
#### WasmBinPath

- **Type:** `string`
- **Default**: `[root]/build/zkgraph_full.wasm`
- **Default**: `[root]/build/cle.wasm`

zkGraph CLI Build-In a tag name is `root`.
CLE CLI Build-In a tag name is `root`.
The `root` is user project root path.
Of course, you can also place this tag at any position within the string.
`LocalWasmBinPath` is the same.

#### LocalWasmBinPath

- **Type:** `string`
- **Default**: `[root]/build/zkgraph_local.wasm`
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hyperoracle/monorepo",
"version": "1.0.0",
"name": "@ora-io/monorepo",
"version": "0.1.0",
"private": true,
"packageManager": "[email protected]",
"keywords": [],
Expand All @@ -17,13 +17,13 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@hyperoracle/zkgraph-cli": "workspace:*"
"@ora-io/cle-cli": "workspace:*"
},
"devDependencies": {
"@antfu/ni": "^0.21.8",
"@antfu/utils": "^0.7.6",
"@hyperoracle/zkgraph-lib": "^1.0.0",
"@murongg/eslint-config": "^0.2.1",
"@ora-io/cle-lib": "^0.1.0",
"@types/fs-extra": "^11.0.2",
"@types/node": "^18.18.4",
"assemblyscript": "^0.27.12",
Expand Down
Loading

0 comments on commit d9658cc

Please sign in to comment.