Merge pull request #847 from lanzafame/feat/accept-human-sizes

accept humanized size values to cli flags
This commit is contained in:
Łukasz Magiera 2019-12-11 13:18:05 +01:00 committed by GitHub
commit 43f5ba1eb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 161 additions and 34 deletions

View File

@ -1,6 +1,7 @@
package cli
import (
"github.com/docker/go-units"
"github.com/filecoin-project/lotus/build"
"golang.org/x/xerrors"
"gopkg.in/urfave/cli.v2"
@ -10,13 +11,18 @@ var fetchParamCmd = &cli.Command{
Name: "fetch-params",
Usage: "Fetch proving parameters",
Flags: []cli.Flag{
&cli.Uint64Flag{
&cli.StringFlag{
Name: "proving-params",
Usage: "download params used creating proofs for given size",
Usage: "download params used creating proofs for given size, i.e. 32GiB",
},
},
Action: func(cctx *cli.Context) error {
err := build.GetParams(cctx.Uint64("proving-params"))
sectorSizeInt, err := units.FromHumanSize(cctx.String("proving-params"))
if err != nil {
return err
}
sectorSize := uint64(sectorSizeInt)
err = build.GetParams(sectorSize)
if err != nil {
return xerrors.Errorf("fetching proof parameters: %w", err)
}

View File

@ -6,6 +6,7 @@ import (
"crypto/sha256"
"encoding/json"
"fmt"
"github.com/docker/go-units"
"io/ioutil"
"math/big"
"math/rand"
@ -65,9 +66,10 @@ func main() {
Value: "~/.lotus-bench",
Usage: "Path to the storage directory that will store sectors long term",
},
&cli.Uint64Flag{
&cli.StringFlag{
Name: "sector-size",
Value: 1024,
Value: "1GiB",
Usage: "size of the sectors in bytes, i.e. 32GiB",
},
&cli.BoolFlag{
Name: "no-gpu",
@ -127,7 +129,11 @@ func main() {
return err
}
sectorSize := c.Uint64("sector-size")
sectorSizeInt, err := units.FromHumanSize(c.String("sector-size"))
if err != nil {
return err
}
sectorSize := uint64(sectorSizeInt)
mds := datastore.NewMapDatastore()
cfg := &sectorbuilder.Config{

View File

@ -0,0 +1,3 @@
# API Scripting Support
工作正在进行中

View File

@ -0,0 +1,3 @@
# Updating Lotus
工作正在进行中

View File

@ -0,0 +1,31 @@
# API Scripting Support
You may want to delegate the work **Lotus Storage Miner** or **Lotus Node** perform to other machines. Here is how to setup the necessary authorization and environment variables.
## Generate a JWT
To generate a JWT for your environment variables, use this command:
```sh
lotus auth create-token --perm admin
lotus-storage-miner auth create-token --perm admin
```
## Environment variables
Environmental variables are variables that are defined for the current shell and are inherited by any child shells or processes. Environmental variables are used to pass information into processes that are spawned from the shell.
Using the JWT you generated, you can assign it and the **multiaddr** to the appropriate environment variable.
```sh
# Lotus Node
FULLNODE_API_INFO="JWT_TOKEN:/ip4/127.0.0.1/tcp/1234/http"
# Lotus Storage Miner
STORAGE_API_INFO="JWT_TOKEN:/ip4/127.0.0.1/tcp/2345/http"
```
* The **Lotus Node**'s `mutliaddr` is in `~/.lotus/api`.
* The default token is in `~/.lotus/token`.
* The **Lotus Storage Miner**'s `multiaddr` is in `~/.lotusstorage/config`.
* The default token is in `~/.lotusstorage/token`.

View File

@ -17,7 +17,7 @@ curl -X POST \
## Sending a CID
If you do not serialize the CID as a JSON IPLD link, you will receive an error. Here is an example of a broken CURL request:
If you do not serialize the CID as a [JSON IPLD link](https://did-ipid.github.io/ipid-did-method/#txref), you will receive an error. Here is an example of a broken CURL request:
```sh
curl -X POST \

View File

@ -6,7 +6,7 @@ Implementation details for the **JSON-RPC** package are [here](https://github.co
## Overview
API requests are made against `127.0.0.1:1234` unless you modify `~/.lotus/api`.
API requests are made against `127.0.0.1:1234` unless you modify `.lotus/config.toml`.
Options:
@ -16,7 +16,11 @@ Options:
## What methods can I use?
Every `method` is available in [api/api.go](https://github.com/filecoin-project/lotus/blob/master/api/api_full.go).
For now, you can look into different files to find methods available to you based on your needs:
* [Both Lotus node + storage miner APIs](https://github.com/filecoin-project/lotus/blob/master/api/api_common.go)
* [Lotus node API](https://github.com/filecoin-project/lotus/blob/master/api/api_full.go)
* [Storage miner API](https://github.com/filecoin-project/lotus/blob/master/api/api_storage.go)
The necessary permissions for each are in [api/struct.go](https://github.com/filecoin-project/lotus/blob/master/api/struct.go).
@ -49,7 +53,7 @@ curl -X POST \
> In the future we will add a playground to make it easier to build and experiment with API requests.
## Authorization
## CURL authorization
To authorize your request, you will need to include the **JWT** in a HTTP header, for example:
@ -59,23 +63,23 @@ To authorize your request, you will need to include the **JWT** in a HTTP header
Admin token is stored in `~/.lotus/token` for the **Lotus Node** or `~/.lotusstorage/token` for the **Lotus Storage Miner**.
## Authorization types
## How do I generate a token?
To generate a JWT with custom permissions, use this command:
```sh
# Lotus Node
lotus auth create-token --perm admin
# Lotus Storage Miner
lotus-storage-miner auth create-token --perm admin
```
## What authorization level should I use?
When viewing [api/struct.go](https://github.com/filecoin-project/lotus/blob/master/api/struct.go), you will encounter these types:
- `read` - Read node state, no private data.
- `write` - Write to local store / chain, read private data.
- `sign` - Use private keys stored in wallet for signing.
- `admin` - Manage permissions.
Payload
```json
{
"Allow": [
"read",
"write",
/* other options */
]
}
```
- `write` - Write to local store / chain, and `read` permissions.
- `sign` - Use private keys stored in wallet for signing, `read` and `write` permissions.
- `admin` - Manage permissions, `read`, `write`, and `sign` permissions.

View File

@ -1,5 +1,46 @@
# Mining Hardware
> This page is a work in progress. EVERYTHING HERE CAN CHANGE AND WILL CHANGE. PURCHASE HARDWARE AT YOUR OWN RISK.
> This documentation page describes the standard testing configuration the Protocol Labs team has used to test **Lotus Storage Miner**s on Lotus. There is no guarantee this testing configuration will be suitable for Filecoin storage mining at MainNet launch. If you need to buy new hardware to join the Filecoin TestNet, we recommend to buy no more hardware than you require for testing. To learn more please read this [hardware blog post](https://filecoin.io/blog/filecoin-testnet-mining/)
Please check out this [GitHub issue](https://github.com/filecoin-project/lotus/issues/694) to see benchmarks from existing hardware setups if you plan on participating in the **Filecoin TestNet**
**Sector sizes** and **minimum pledged storage** required to mine blocks are two very important Filecoin TestNet parameters that impact hardware decisions. We will continue to refine all parameters during TestNet.
BECAUSE OF THIS, OUR STANDARD TESTING CONFIGURATION FOR FILECOIN MAINNET CAN AND WILL CHANGE. YOU HAVE BEEN WARNED.
## Example configuration
The setup below is a minimal example for sealing 32 GiB sectors on Lotus:
* 3 TB of hard drive space.
* 8 to 12 core CPU
* 256 GB of RAM
## Benchmarked GPUs
GPUs are a must for getting **block rewards**. Here are a few that have been tried in the past:
* GeForce RTX 2080 Ti
* GeForce RTX 2080 SUPER
* GeForce RTX 2080
* GeForce GTX 1080 Ti
* GeForce GTX 1080
* GeForce GTX 1060
## Testing other GPUs
If you want to test other GPUs, such as the GeForce GTX 1660, you can use the following configuration flag:
```sh
BELLMAN_CUSTOM_GPU="<NAME>:<NUMBER_OF_CORES>"
```
Here is an example of trying a GeForce GTX 1660 ti with 1536 cores.
```sh
BELLMAN_CUSTOM_GPU="GeForce GTX 1660 Ti:1536"
```
To get the number of cores for your GPU, you will need to check your cards specifications.
## Benchmarking
Here is a [benchmarking tool](https://github.com/filecoin-project/lotus/tree/testnet-staging/cmd/lotus-bench) and a [GitHub issue thread](https://github.com/filecoin-project/lotus/issues/694) for those who wish to experiment with and contribute hardware setups for the **Filecoin TestNet**.

View File

@ -49,13 +49,13 @@ Here is an example of the response
t3vhfme4qfvegqaz7m7q6o6afjcs67n6kpzv7t2eozio4chwpafwa2y4l7zhwd5eom7jmihzdg4s52dpvnclza
```
- Visit the [faucet](https://lotus-faucet.kittyhawk.wtf/funds.html)
- Visit the [faucet](https://lotus-faucet.kittyhawk.wtf/funds.html) to add funds.
- Paste the address you created.
- Press the send button.
## Check wallet address balance
Wallet balances in the devnet are in **FIL**, the smallest denomination of FIL is an **attoFil**, where 1 attoFil = 10^-18 FIL.
Wallet balances in the Lotus DevNet are in **FIL**, the smallest denomination of FIL is an **attoFil**, where 1 attoFil = 10^-18 FIL.
```sh
lotus wallet balance <YOUR_NEW_ADDRESS>
@ -63,6 +63,14 @@ lotus wallet balance <YOUR_NEW_ADDRESS>
You will not see any attoFIL in your wallet if your **chain** is not fully synced.
## Send FIL to another wallet
To send FIL to another wallet, use this command:
```
lotus send <target> <amount>
```
## Monitor the dashboard
To see the latest network activity, including **chain block height**, **block height**, **blocktime**, **total network power**, largest **block producer miner**, check out the [monitoring dashboard](https://lotus-metrics.kittyhawk.wtf).

View File

@ -17,7 +17,7 @@ lotus wallet list
With your wallet address:
- Visit the [faucet](https://lotus-faucet.kittyhawk.wtf/miner.html)
- Click "Create Miner
- Click "Create Miner"
- DO NOT REFRESH THE PAGE. THIS OPERATION CAN TAKE SOME TIME.
The task will be complete when you see:
@ -50,6 +50,8 @@ To mine:
lotus-storage-miner run
```
If you are downloading **Filecoin Proof Parameters**, the download can take some time.
Get information about your miner:
```sh

View File

@ -2,7 +2,7 @@
> There are recent bug reports with these instructions. If you happen to encounter any problems, please create a [GitHub issue](https://github.com/filecoin-project/lotus/issues/new) and a maintainer will address the problem as soon as they can.
Here are the operations you can perform after you have stored a **Data CID** with the **Lotus Storage Miner** in the network.
Here are the operations you can perform after you have stored and sealed a **Data CID** with the **Lotus Storage Miner** in the network.
If you would like to learn how to store a **Data CID** on a miner, read the instructions [here](https://docs.lotu.sh/en+storing-data).

View File

@ -23,6 +23,12 @@ ERROR hello hello/hello.go:81 other peer has different genesis!
* Try deleting your file system's `~/.lotus` directory. Check that it exists with `ls ~/.lotus`.
```sh
- repo is already locked
```
* You already have another lotus deamon running.
## Failed messages
Some errors will occur that do not prevent Lotus from working:

View File

@ -11,3 +11,13 @@ WARN main lotus/main.go:72 failed to start deal: computing commP failed: gene
```
* There is a minimum file size of 127 bytes.
## Troubleshooting Sealing
Miners can check sealing progress with this command:
```sh
lotus-storage-miner sectors list
```
When sealing is complete, `pSet: NO` will become `pSet: YES`. From now on the **Data CID** is [retrievable](https://docs.lotu.sh/en+retrieving-data) from the **Lotus Storage Miner**.

View File

@ -52,4 +52,4 @@ lotus client deal <Data CID> <miner> <price> <duration>
Upon success, this command will return a **Deal CID**.
From now on the **Data CID** is [retrievable](https://docs.lotu.sh/en+retrieving-data) from the **Lotus Storage Miner**.
To retrieve this file it must be sealed. If the **Lotus Storage Miner** is not running on a machine designed for sealing, the process will take a very long time.

View File

@ -3,7 +3,11 @@
If you installed Lotus on your machine, you can upgrade to the latest version by doing the following:
```sh
# get the latest
git pull origin master
# clean and remake the binaries
make clean build
```
Sometimes when you run Lotus after a pull, certain commands such as `lotus daemon` may break.

1
go.mod
View File

@ -8,6 +8,7 @@ require (
github.com/GeertJohan/go.rice v1.0.0
github.com/Gurpartap/async v0.0.0-20180927173644-4f7f499dd9ee
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
github.com/docker/go-units v0.4.0
github.com/fatih/color v1.7.0 // indirect
github.com/filecoin-project/chain-validation v0.0.3
github.com/filecoin-project/filecoin-ffi v0.0.0-20191204125133-ebb3e13addf1

2
go.sum
View File

@ -68,6 +68,8 @@ github.com/dgraph-io/badger v1.6.0-rc1/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhY
github.com/dgryski/go-farm v0.0.0-20190104051053-3adb47b1fb0f/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA=
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw=
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=