Skip to content

Commit

Permalink
Merge pull request #237 from filecoin-project/fatman13-patch2
Browse files Browse the repository at this point in the history
add market doc
  • Loading branch information
Joss-Hua authored Oct 20, 2021
2 parents 8b8cd1a + 7390d1f commit e7453cb
Show file tree
Hide file tree
Showing 3 changed files with 354 additions and 45 deletions.
8 changes: 6 additions & 2 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ module.exports = {
['', 'Overview'],
['How-To-Deploy-MingPool.md', 'Deploy a storage pool'],
['Using-venus-Shared-Modules.md', 'Join a storage pool'],
['Using-venus-market.md', 'Deal making'],
['fil_withdraw_and_send.md', 'Retrieve rewards'],
['Chain.md', 'Chain management'],
['How-To-Connect-Network.md', 'Connect to different network'],
Expand All @@ -116,6 +117,7 @@ module.exports = {
['Venus-Worker.md', 'Venus worker'],
['Venus-Gateway.md', 'Venus gateway'],
['Venus-Auth.md', 'Venus auth'],
['Venus-Market.md', 'Venus market'],
]
}
],
Expand Down Expand Up @@ -213,8 +215,9 @@ module.exports = {
collapsable: false,
children: [
['', '启明星概要'],
['How-To-Deploy-MingPool.md', '如何部署存储池'],
['Using-venus-Shared-Modules.md', '如何加入存储池'],
['How-To-Deploy-MingPool.md', '部署存储池'],
['Using-venus-Shared-Modules.md', '加入存储池'],
['Using-venus-market.md', '发送接收订单'],
['fil_withdraw_and_send.md', '提取奖励'],
['chain.md', '链维护'],
['How-To-Connect-Network.md', '加入不同网络'],
Expand All @@ -234,6 +237,7 @@ module.exports = {
['Venus-Worker.md', 'Venus worker'],
['Venus-Gateway.md', 'Venus gateway'],
['Venus-Auth.md', 'Venus auth'],
['Venus-Market.md', 'Venus market'],
['Venus-Messager-Design-Spec.md', 'Venus Messager 设计说明书'],
]
}
Expand Down
202 changes: 159 additions & 43 deletions docs/guide/Using-venus-market.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# venus-market

venus-market is responsible for deal making for a venus storage system. It compiles into venus-market (provider side) and market-client (lightweight client). Both need chain services and a local wallet to function.
venus-market is responsible for deal making for a venus storage system. It compiles into venus-market (provider side) and market-client (lightweight client). Both need chain services and a local venus-wallet to function.

## Quick deployment
## Install

Download source code.

Expand All @@ -17,82 +17,198 @@ $ make deps
$ make
```

:::tip

Please use commit later than f3c3eb27b05652b1ba5d463afdf3d78f67982a79.

:::

## Start venus-market

Start venus-market.

```shell script
$ ./venus-market run \
# URL of venus node (part of chain services); Ex, /ip4/47.88.31.65/tcp/6666/ws
--node-url <NODE_URL> \
# URL of messafer (part of chain services); Ex, /ip4/47.88.31.65/tcp/39812/ws
--messager-url <MESSAGER_URL> \
# auth token generated by chain services; Ex, eyJhbGciOiJIUzI1NiIsInCJ9.eyJuYW1lIjoieXotY2J9.oQmfNysESCAOI43Wo2kQ_6sY
--auth-token <AUTH_TOKEN> \
# URL of your local wallet; Ex, /ip4/10.10.11.43/tcp/5678/http
--signer-url <WALLET_URL> \
# token generated by your wallet
--signer-token <WALLET_TOKEN> \
# Ex, fs:/mnt/filestore
--piecestorage fs:<PIECE_STORAGE_PATH> \
--miner <MINER_ID> >> market.log 2>$1 &
```

:::tip

`signer-url` and `signer-token` refers to your local venus-wallet. All messages from venus-market needs to be signed directly by your local wallet. Get `signer-url` and `signer-token` by the following command.

```bash
$ ./venus-wallet auth api-info --perm sign
eyJhbGciOiJIUzI1NiIsInCJ9.eyJBbGxvdyI6FkIiwidIl19.lM9FA462FONHN806SlKZw:/ip4/0.0.0.0/tcp/5678/http
```

:::

:::tip

venus-wallet listens to local port by default. To listen to communications from other machines, please change the following configurations.

```bash
$ cat .venus_wallet/config.toml
[API]
ListenAddress = "/ip4/0.0.0.0/tcp/5678/http"
```

:::

:::tip

Default message publish period for venus-market is an hour which means it waits for an hour before send out PublishStorageDeal message. For testing, you can reduce this waiting period to, for example, 10 seconds.

```bash
$ cat .venusmarket/config.toml
PublishMsgPeriod = "10s"

$ ./venus-market run >> market.log 2>&1 &
```

:::

### Configure listening address

Get your <PEER_ID>.

```bash
$ ./venus-market net listen
<PEER_ID>
# Ex return
# /ip4/10.10.8.16/tcp/58418/p2p/12D3KooWMk8nBpKXgRVBqkw45rc2pvRs9RhAZsFXFQGEqwuStMq
```

Configure venus-market to allow discovery.

```bash
$ ./venus-market --repo <REPO_PATH> actor set-addrs <MARKET_URL>
# Ex <MARKET_URL>, /ip4/10.10.8.16/tcp/58418
$ ./venus-market actor set-addrs <MARKET_URL>
# Ex <PEER_ID>, 12D3KooWMk8nBpKXgRVBqkw45rc2pvRs9RhAZsFXFQGEqwuStMq
$ ./venus-market actor set-peer-id <PEER_ID>
```

Start venus-market.
Check all are properly set.

```shell script
$ ./venus-market run
# URL of venus node (part of chain services)
--node-url <NODE_URL>
# URL of messafer (part of chain services)
--messager-url <MESSAGER_URL>
# auth token generated by chain services
--auth-token <AUTH_TOKEN>
# URL of your local wallet
--signer-url <WALLET_URL>
# token generated by your wallet
--signer-token <WALLET_TOKEN>
--piecestorage fs:<PIECE_STORAGE_PATH>
--miner <MINER_ID>
```bash
$ ./venus-market actor info
/root/.venusmarket
peers: 12D3KooWMk8nBpKXgRVBqkw45rc2pvRs9RhCAZsFXFQGEqwuStMq
addr:
/ip4/10.10.8.16/tcp/58418
```

## Start market client

Start client.

```shell script
$ ./market-client run
# URL of venus node (part of chain services)
--node-url <NODE_URL>
$ ./market-client run \
# URL of venus node (part of chain services); Ex, /ip4/47.88.31.65/tcp/6666/ws
--node-url <NODE_URL> \
# URL of messafer (part of chain services)
--messager-url <MESSAGER_URL>
--messager-url <MESSAGER_URL> \
# auth token generated by chain services
--auth-token <AUTH_TOKEN>
--auth-token <AUTH_TOKEN> \
# URL of your local wallet
--signer-url <WALLET_URL>
--signer-url <WALLET_URL> \
# token generated by your wallet
--signer-token <WALLET_TOKEN>
--addr <CLIENT_ADDR>
--signer-token <WALLET_TOKEN> \
# Ex addr, t3v5shsytrnz7ycr7ou4yxq2nf2xm34idnvfgnom6wyru7lrmu2ykuvtte2hq6brk2v3qttrsysvssr42cxt6a
--addr <CLIENT_ADDR> \
>> client.log 2>&1 &
```

Query price
## Make a storage deal

Import file for a storage deal.

```bash
$ ./market-client --repo <CLIENT_REPO_PATH> query-ask <MINER_ID>
/data/lotus-data/venus-market-client-calib/
Ask: <MINER_ID>
Price per GiB: 0.0000000005 FIL
Verified Price per GiB: 0.00000000005 FIL
Max Piece size: 32 GiB
Min Piece size: 256 B
$ ./market-client import </path/to/file>
/root/.marketclient
Import 1634298060645056875, Root bafykbzacedj3oowcc22kt5qmpebil3szmes5c3l64ls2qtmx45ej43dvgylsw
```

## Initiate a deal

Initiate a deal.

```shell script
$ ./market-client generate-car <file> <car file>
$ ./market-client import <file>
```bash
$ ./market-client deal

/root/.marketclient
Data CID (from lotus client import):
# Enter CID here
bafykbzacedj3oowcc22kt5qmpebil3szmes5c3l64ls2qtmx45ej43dvgylsw
.. calculating data size
PieceCid: baga6ea4seaqpwx4dldvtojugowvm7ete4rgghsbwvbli37ovaqk7eg4pfrld6nq PayLoadSize: 302017178 PieceSize: 536870912
# Enter deal duration
Deal duration (days): 190
# Enter miner id
Miner Addresses (f0.. f0..), none to find: f019411

.. querying miner asks

Proposing from f3v5shsytrnz7ycr7ou4yxq2nf2xm34idnvfgnom6wyru7lrmu2ykuvtte2hq6brk2v3qttrsysvssr42cxt6a
Balance: 12362.167968899390936035 FIL

Piece size: 512MiB (Payload size: 288MiB)
Duration: 4560h0m0s
Total price: ~0.0001368 FIL (0.00000000025 FIL per epoch)
Verified: false

# Accept deal?
Accept (yes/no): yes
.. executing
Deal (f019411) CID: bafyreifbfpaayuwdd42pxgpql7fqo7bpjdccb7wscqn6tkix6qd5gni6xe
```

## Retrieve a deal
It will take up to 15 minutes for the deal status to be changed into `StorageDealAwaitingPreCommit` and ready for venus-sealer to seal.

Retrieve a deal.
```bash
$ ./market-client list-deals
DealCid DealId Provider State On Chain? Slashed? PieceCID Size Price Duration Verified
...d5gni6xe 33177 f019411 StorageDealAwaitingPreCommit N N ...pfrld6nq 508 MiB 0.00013739625 FIL 549585 false
```

### Seal deal data with venus-sealer

List deals use `deals list` command of venus-sealer.

```bash
$ ./venus-sealer deals list
DealId PieceCID PieceSize Client Provider StartEpoch EndEpoch Price Verified Packed FastRetrieval Status
33177 baga6ea4seaqpwx4dldvtojugowvm7ete4rgghsbwvbli37ovaqk7eg4pfrld6nq 536870912 f3v5shsytrnz7ycr7ou4yxq2nf2xm34idnvfgnom6wyru7lrmu2ykuvtte2hq6brk2v3qttrsysvssr42cxt6a f019411 375049 924634 250000000 false false true Undefine
```

:::tip

```shell
./market-client retrieve --miner <MINER_ID> <data-cid> <dst path>
For testing purpose, you can change `WaitDealsDelay` of venus-sealer to, for example, 10 seconds to speed up the process.

```bash
$ cat .venussealer/config.toml
WaitDealsDelay = "10s"
```

:::

Use `venus-sealer sectors deal` command to start the sealing of the deal.

```bash
$ ./venus-sealer sectors deal

$ ./venus-sealer sectors list
454 Packing NO NO n/a
# Once sealing is done, you will see...
454 Proving YES NO 957273 (in 30 weeks 3 hours) 1 116MiB
```
Loading

0 comments on commit e7453cb

Please sign in to comment.