Skip to content

Commit

Permalink
[doc] update readme&developer_guide&operator_guide doc (#543)
Browse files Browse the repository at this point in the history
  • Loading branch information
huangzhiran authored Jun 11, 2024
1 parent bfa3f63 commit bd5bb31
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 118 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@ The diagram represents the main components of the software and how they interact

## Running

For users who just want to give it a try, please refer to [Quick Start →](./docs/QUICK_START.md), which will guide you through how to interact with existing projects deployed on staging.
For users who just want to give it a try, please refer to [Quick Start →](./docs/QUICK_START.md), which will guide you through how to interact with existing projects deployed on testnet.

Developers looking to build circuits and deploy W3bstream projects should consult the [DEVELOPER_GUIDE →](./docs/DEVELOPER_GUIDE.md)

Developers who want to run a Sprout node could refer to the [OPERATOR_GUIDE →](./docs/OPERATOR_GUIDE.md)

## Sandbox
The DePIN Sandbox is an initial deployment of Layer 1 contracts that facilitate the deployment od DePIN Projects on IoTeX using W3bstream

Expand Down
90 changes: 49 additions & 41 deletions docs/DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,19 @@ Dapps looking to utilize W3bstream capabilities should:

1. [Create a W3bstream project](#create-a-w3bstream-project)
2. [Test the project](#test-your-w3bstream-project)
3. [Register it on the IoTeX blockchain](#register-your-project)
3. [Register it on the IoTeX blockchain](#registering-your-project)

### Prerequisites

- ioctl: The command-line interface for interacting with the IoTeX blockchain.

```bash
git clone https://github.com/iotexproject/iotex-core.git
cd iotex-core
make ioctl && mv bin/ioctl __YOUR_SYSTEM_PATH__
```

[More on the IoTeX ioctl client →](https://docs.iotex.io/the-iotex-stack/wallets/command-line-client)

### Create a W3bstream Project

Expand Down Expand Up @@ -51,7 +63,7 @@ Create the blockchain verifier (Solidity)

target/release/halo2-circuit solidity -f path/filename.sol

#### Create a ZK Circuit Using zkWASM
#### Create a W3bstream Project Using zkWASM

For more details on zkWASM circuits see the [zkWASM README](./examples/zkwasm-circuit/README.md).

Expand Down Expand Up @@ -81,7 +93,7 @@ Generate the W3bstream project:
ioctl ws code convert -t "zkwasm" -i "zkwasm_demo.wasm" -o "path/ID"`
```

#### Using RISC0
#### Create a W3bstream Project Using RISC0

More details and options for `Risc0 circuit` are given in [its README](./examples/risc0-circuit/README.md).

Expand Down Expand Up @@ -120,66 +132,62 @@ ioctl ws project config -s "postgres://test_user:test_passwd@localhost:5432/test
The values of `image_id` and `elf` are variable names, and will be found in the `methods.rs` file.
#### Manager your project to IPFS
### Test Your W3bstream Project
Once you have generated a W3bstream project file that includes a custom prover for your dApp, you might want to test it.
Please refer to the [OPERATOR GUIDE](./OPERATOR_GUIDE.md) for instructions on how to:
1. Run a W3bstream node locally.
2. Copy the W3bstream project file into the node's project directory (default location is ./test/project).
3. Run the node and send your test messages.
### Registering Your Project
To allow W3bstream node operators to download your project and compute ZK proofs for your dApp, you must register your W3bstream project on the IoTeX blockchain:
##### Set w3bstream sequencer endpoint and contract addresses
#### Acquire a Project ID
```bash
# set local w3bstream sequencer as w3bstream endpoint
ioctl config set wsEndpoint 'localhost:9000'
# set the default project register and project store contract address
ioctl config set wsProjectStoreContract 0x6AfCB0EB71B7246A68Bb9c0bFbe5cD7c11c4839f
ioctl config set wsProjectRegisterContract 0x4888bfbf39Dc83C19cbBcb307ccE8F7F93b72E38
ioctl ioid register "your project name"
```
##### Register and Upload project
#### Register Project
```bash
# register a new project to w3bstream
# note: this need you had mint a project NFT in ioID, see more: https://github.com/machinefi/ioID-contracts
ioctl ws project register --id "your project id"
# use the project config generated above and update project config
ioctl ws project update --id "your project id" --path "path/to/project_config" --hash "project config hash(optional)"
# you can retrieve project info by follow command
ioctl ws project query --id "your project id"
```
##### Set or get attributes of your project
#### Use the Project File Generated above and Update Project Config
```bash
# get attributes
ioctl ws project attributes get --id "your project id" --key "your key name"
# set attributes
ioctl ws project attributes set --id "your project id" --key "your key name" --val "your key val"
ioctl ws project update --id "your project id" --path "path/to/project_file"
```
##### Control project status
#### Start the Project
```bash
# pause project
ioctl ws project pause --id 'your project id'
# resume project
ioctl ws project resume --id 'your project id'
ioctl ws project resume --id "your project id"
```
### Testing your project
Once you have generated a W3bstream project file that includes a custom prover for your dApp, you might want to test it.
#### Retrieve Project Info
Please refer to the [OPERATOR GUIDE](./OPERATOR_GUIDE.md) for instructions on how to:
```bash
ioctl ws project query --id "your project id"
```
1. Run a W3bstream node locally.
2. Copy the W3bstream project file into the node's project directory (default location is ./test/project).
3. Run the node and send your test messages.
#### Set Required Prover Amount of the Project
### Registering your project
The default prover amount will process the project's tasks is one. And we can customize it by
To allow W3bstream node operators to download your project and compute ZK proofs for your dApp, you must register your W3bstream project on the IoTeX blockchain:
```bash
ioctl ws project attributes set --id "your project id" --key "RequiredProverAmount" --val "your expected amount"
```
[Register your project here → This is still WIP](WIP)
#### Stop the Project
The projects registration contract address on IoTeX is:
If you want to stop the project's task process, can use this cmd
- Mainnet: `To be determined`
- Testnet: `To be determined`
- ABI: `To be determined`
```bash
ioctl ws project pause --id "your project id"
```
121 changes: 47 additions & 74 deletions docs/OPERATOR_GUIDE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# IoTeX W3bstream Sprout Node Operator Guide

W3bstream is a permissionless, decentralized protocol within the IoTeX Network, where node operators contribute computing power to support verifiable computations for blockchain applications. These applications rely on insights from real-world data to trigger their token economies. Anyone can become a W3bstream Node Operator in the IoTeX Network, choosing which dApps to support in processing data and generating ZK (Zero Knowledge) Proofs. This guide covers how to operate a W3bstream node, register it in the IoTeX Network, join specific projects, and claim rewards.
W3bstream is a permissionless, decentralized protocol within the IoTeX Network, where node operators contribute computing power to support verifiable computations for blockchain applications. These applications rely on insights from real-world data to trigger their token economies. Anyone can become a W3bstream Node Operator in the IoTeX Network, choosing which dApps to support in processing data and generating ZK (Zero Knowledge) Proofs.

## Run a W3bstream Node

Expand Down Expand Up @@ -62,6 +62,11 @@ export BONSAI_KEY=${your bonsai key}

Refer to the W3bstream project documentation for the dApp you are joining to determine if Risc Zero proofs are required.

### Manage the project file

You can move your project file to a directory, and mount it to W3bstream node container. The environment variable used to indicate a directory is **PROJECT_FILE_DIRECTORY**
The default project directory is **./test/project**

### Manage the node

To start W3bstream, run the following command in the directory containing `docker-compose.yaml`:
Expand All @@ -82,72 +87,24 @@ To shut down the W3bstream instance:
docker-compose down
```

#### Set contract addresses

```bash
# set the default prover register and prover store contract address
ioctl config set wsFleetManagementContract 0xDBA78C8eCaeE2DB9DDE0c4168f7E8626d4Ff0010
ioctl config set wsProverStoreContract 0xAD480a9c1B9fA8dD118c26Ac26880727160D0448
```

### Prover Manager

#### Register and query prover

```bash
# register a new prover and this command will retrieve the prover id
ioctl ws prover register
# query prover info with prover id
ioctl ws prover query --id "prover id"
# update prover with node type and prover id
ioctl ws prover update --id "prover id" --node-type "node type"
```

#### Control prover status

```bash
# pause or resume prover with the follow commands
ioctl ws prover pause --id 'prover id'
ioctl ws prover resume --id 'prover id'
```

#### Transfer prover operator

```bash
# transfer prover operator with prover id and new owner address
ioctl ws prover transfer --id 'prover id' --operator 'operator wallet address'
```

### Interacting with the node

set the ioctl's wsEndpoint configuration option to your node endpoint:

```bash
ioctl config set wsEndpoint localhost:9000
```

[More on the IoTeX ioctl client →](https://docs.iotex.io/the-iotex-stack/wallets/command-line-client)

Test W3bstream projects are already registered into project contract.

#### Sending messages to the node

Send a message to a RISC0-based test project (ID 1):
Send a message to a RISC0-based test project (ID 10000):

```bash
ioctl ws message send --project-id 1 --project-version "0.1" --data "{\"private_input\":\"14\", \"public_input\":\"3,34\", \"receipt_type\":\"Snark\"}"
curl -X POST -H "Content-Type: application/json" -d '{"projectID": 10000,"projectVersion": "0.1","data": "{\"private_input\":\"14\", \"public_input\":\"3,34\", \"receipt_type\":\"Snark\"}"}' http://localhost:9000/message
```

Send a message to the Halo2-based test project (ID 2):
Send a message to the Halo2-based test project (ID 10001):

```bash
ioctl ws message send --project-id 2 --project-version "0.1" --data "{\"private_a\": 3, \"private_b\": 4}"
curl -X POST -H "Content-Type: application/json" -d '{"projectID": 10001,"projectVersion": "0.1","data": "{\"private_a\": 3, \"private_b\": 4}"}' http://localhost:9000/message
```

Send a message to a zkWasm-based test project (ID 3):
Send a message to a zkWasm-based test project (ID 10002):

```bash
ioctl ws message send --project-id 3 --project-version "0.1" --data "{\"private_input\": [1, 1] , \"public_input\": [] }"
curl -X POST -H "Content-Type: application/json" -d '{"projectID": 10002,"projectVersion": "0.1","data": "{\"private_input\": [1, 1] , \"public_input\": [] }"}' http://localhost:9000/message
```

#### Query the status of a proof request
Expand All @@ -156,37 +113,53 @@ After sending a message, you'll receive a message ID as a response from the node

```json
{
"messageID": "4abbc43a-798f-49e8-bc05-b6baeafec630"
"messageID": "8785a42c-9d6c-4780-910c-de0147aea243"
}
```

you can quesry the history of the proof request with:

```bash
ioctl ws message query --message-id "4abbc43a-798f-49e8-bc05-b6baeafec630"
curl http://localhost:9000/message/8785a42c-9d6c-4780-910c-de0147aea243 | jq -r '.'
```

example result:

```json
{
"messageID": "4abbc43a-798f-49e8-bc05-b6baeafec630",
"states": [{
"state": "received",
"time": "2023-12-06T16:11:03.498785+08:00",
"comment": ""
},
{
"state": "fetched",
"time": "2023-12-06T16:11:04.663608+08:00",
"comment": ""
},
{
"state": "proving",
"time": "2023-12-06T16:11:04.664008+08:00",
"comment": ""
}
]
"messageID": "8785a42c-9d6c-4780-910c-de0147aea243",
"states": [
{
"state": "received",
"time": "2024-06-10T09:30:05.790151Z",
"comment": "",
"result": ""
},
{
"state": "packed",
"time": "2024-06-10T09:30:05.793218Z",
"comment": "",
"result": ""
},
{
"state": "dispatched",
"time": "2024-06-10T09:30:10.87987Z",
"comment": "",
"result": ""
},
{
"state": "proved",
"time": "2024-06-10T09:30:11.193027Z",
"comment": "",
"result": "proof result"
},
{
"state": "outputted",
"time": "2024-06-10T09:30:11.20942Z",
"comment": "output type: stdout",
"result": ""
}
]
}
```

Expand Down

0 comments on commit bd5bb31

Please sign in to comment.