Merge branch 'testnet-staging' of https://github.com/filecoin-project/lotus into testnet-staging

This commit is contained in:
Pooja 2019-12-11 16:01:14 +01:00
commit b2dd284a14
32 changed files with 1033 additions and 625 deletions

View File

@ -68,7 +68,7 @@ jobs:
- run: sudo apt-get install npm - run: sudo apt-get install npm
- restore_cache: - restore_cache:
name: restore go mod cache name: restore go mod cache
key: v1-go-deps-{{ arch }}-{{ checksum "/home/circleci/project/lotus/go.mod" }} key: v1-go-deps-{{ arch }}-{{ checksum "/home/circleci/project/go.mod" }}
- run: - run:
command: make buildall command: make buildall
- store_artifacts: - store_artifacts:

View File

@ -1,3 +1,5 @@
SHELL=/usr/bin/env bash
all: build all: build
.PHONY: all .PHONY: all
@ -77,6 +79,9 @@ lotus-shed: $(BUILD_DEPS)
BINS+=lotus-seal-worker BINS+=lotus-seal-worker
build: lotus lotus-storage-miner lotus-seal-worker build: lotus lotus-storage-miner lotus-seal-worker
@[[ $$(type -P "lotus") ]] && echo "Caution: you have \
an existing lotus binary in your PATH. This may cause problems if you don't run 'sudo make install'" || true
.PHONY: build .PHONY: build
install: install:

View File

@ -22,7 +22,7 @@ const (
MajorOnlyMask = 0xff0000 MajorOnlyMask = 0xff0000
MinorOnlyMask = 0x00ff00 MinorOnlyMask = 0x00ff00
PatchOnlyMask = 0x0000ff PatchOnlyMask = 0x0000ff
c) )
// VersionInts returns (major, minor, patch) versions // VersionInts returns (major, minor, patch) versions
func VersionInts(version uint32) (uint32, uint32, uint32) { func VersionInts(version uint32) (uint32, uint32, uint32) {

View File

@ -155,6 +155,8 @@ func (cs *ChainStore) SubHeadChanges(ctx context.Context) chan []*HeadChange {
go func() { go func() {
defer close(out) defer close(out)
var unsubOnce sync.Once
for { for {
select { select {
case val, ok := <-subch: case val, ok := <-subch:
@ -170,7 +172,9 @@ func (cs *ChainStore) SubHeadChanges(ctx context.Context) chan []*HeadChange {
case <-ctx.Done(): case <-ctx.Done():
} }
case <-ctx.Done(): case <-ctx.Done():
go cs.bestTips.Unsub(subch) unsubOnce.Do(func() {
go cs.bestTips.Unsub(subch)
})
} }
} }
}() }()

View File

@ -236,7 +236,7 @@ var clientRetrieveCmd = &cli.Command{
} }
if err := api.ClientRetrieve(ctx, offers[0].Order(payer), cctx.Args().Get(1)); err != nil { if err := api.ClientRetrieve(ctx, offers[0].Order(payer), cctx.Args().Get(1)); err != nil {
return err return xerrors.Errorf("Retrieval Failed: %w", err)
} }
fmt.Println("Success") fmt.Println("Success")

View File

@ -1,6 +1,7 @@
package cli package cli
import ( import (
"github.com/docker/go-units"
"github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/build"
"golang.org/x/xerrors" "golang.org/x/xerrors"
"gopkg.in/urfave/cli.v2" "gopkg.in/urfave/cli.v2"
@ -10,13 +11,18 @@ var fetchParamCmd = &cli.Command{
Name: "fetch-params", Name: "fetch-params",
Usage: "Fetch proving parameters", Usage: "Fetch proving parameters",
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.Uint64Flag{ &cli.StringFlag{
Name: "proving-params", 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 { 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 { if err != nil {
return xerrors.Errorf("fetching proof parameters: %w", err) return xerrors.Errorf("fetching proof parameters: %w", err)
} }

View File

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

View File

@ -47,6 +47,11 @@ var DaemonCmd = &cli.Command{
Name: "genesis", Name: "genesis",
Usage: "genesis file to use for first node run", Usage: "genesis file to use for first node run",
}, },
&cli.StringFlag{
Name: "genesis-timestamp",
Hidden: true,
Usage: "set the timestamp for the genesis block that will be created",
},
&cli.BoolFlag{ &cli.BoolFlag{
Name: "bootstrap", Name: "bootstrap",
Value: true, Value: true,
@ -84,7 +89,7 @@ var DaemonCmd = &cli.Command{
if cctx.String(preSealedSectorsFlag) == "" { if cctx.String(preSealedSectorsFlag) == "" {
return xerrors.Errorf("must also pass file with miner preseal info to `--%s`", preSealedSectorsFlag) return xerrors.Errorf("must also pass file with miner preseal info to `--%s`", preSealedSectorsFlag)
} }
genesis = node.Override(new(modules.Genesis), testing.MakeGenesis(cctx.String(makeGenFlag), cctx.String(preSealedSectorsFlag))) genesis = node.Override(new(modules.Genesis), testing.MakeGenesis(cctx.String(makeGenFlag), cctx.String(preSealedSectorsFlag), cctx.String("genesis-timestamp")))
} }
var api api.FullNode var api api.FullNode

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 ## 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 ```sh
curl -X POST \ curl -X POST \

View File

@ -6,7 +6,7 @@ Implementation details for the **JSON-RPC** package are [here](https://github.co
## Overview ## 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: Options:
@ -16,7 +16,11 @@ Options:
## What methods can I use? ## 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). 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. > 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: 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**. 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: 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. - `read` - Read node state, no private data.
- `write` - Write to local store / chain, read private data. - `write` - Write to local store / chain, and `read` permissions.
- `sign` - Use private keys stored in wallet for signing. - `sign` - Use private keys stored in wallet for signing, `read` and `write` permissions.
- `admin` - Manage permissions. - `admin` - Manage permissions, `read`, `write`, and `sign` permissions.
Payload
```json
{
"Allow": [
"read",
"write",
/* other options */
]
}
```

View File

@ -1,5 +1,46 @@
# Mining Hardware # 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 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. - Paste the address you created.
- Press the send button. - Press the send button.
## Check wallet address balance ## 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 ```sh
lotus wallet balance <YOUR_NEW_ADDRESS> 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. 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 ## 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). 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: With your wallet address:
- Visit the [faucet](https://lotus-faucet.kittyhawk.wtf/miner.html) - 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. - DO NOT REFRESH THE PAGE. THIS OPERATION CAN TAKE SOME TIME.
The task will be complete when you see: The task will be complete when you see:
@ -50,6 +50,8 @@ To mine:
lotus-storage-miner run lotus-storage-miner run
``` ```
If you are downloading **Filecoin Proof Parameters**, the download can take some time.
Get information about your miner: Get information about your miner:
```sh ```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. > 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). 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`. * 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 ## Failed messages
Some errors will occur that do not prevent Lotus from working: 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. * 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**. 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: If you installed Lotus on your machine, you can upgrade to the latest version by doing the following:
```sh ```sh
# get the latest
git pull origin master 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. 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/GeertJohan/go.rice v1.0.0
github.com/Gurpartap/async v0.0.0-20180927173644-4f7f499dd9ee github.com/Gurpartap/async v0.0.0-20180927173644-4f7f499dd9ee
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect 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/fatih/color v1.7.0 // indirect
github.com/filecoin-project/chain-validation v0.0.3 github.com/filecoin-project/chain-validation v0.0.3
github.com/filecoin-project/filecoin-ffi v0.0.0-20191204125133-ebb3e13addf1 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-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 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA=
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= 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 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= 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= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=

View File

@ -692,15 +692,15 @@ func fallbackPostChallengeCount(sectors uint64) uint64 {
} }
func (sb *SectorBuilder) ImportFrom(osb *SectorBuilder, symlink bool) error { func (sb *SectorBuilder) ImportFrom(osb *SectorBuilder, symlink bool) error {
if err := migrate(osb.cacheDir, sb.cacheDir, true); err != nil { if err := migrate(osb.cacheDir, sb.cacheDir, symlink); err != nil {
return err return err
} }
if err := migrate(osb.sealedDir, sb.sealedDir, true); err != nil { if err := migrate(osb.sealedDir, sb.sealedDir, symlink); err != nil {
return err return err
} }
if err := migrate(osb.stagedDir, sb.stagedDir, true); err != nil { if err := migrate(osb.stagedDir, sb.stagedDir, symlink); err != nil {
return err return err
} }

View File

@ -8,6 +8,7 @@ import (
"github.com/ipfs/go-datastore" "github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore/query" "github.com/ipfs/go-datastore/query"
cbg "github.com/whyrusleeping/cbor-gen" cbg "github.com/whyrusleeping/cbor-gen"
"go.uber.org/multierr"
"golang.org/x/xerrors" "golang.org/x/xerrors"
"github.com/filecoin-project/lotus/lib/cborutil" "github.com/filecoin-project/lotus/lib/cborutil"
@ -139,6 +140,8 @@ func (st *StateStore) List(out interface{}) error {
outT := reflect.TypeOf(out).Elem().Elem() outT := reflect.TypeOf(out).Elem().Elem()
rout := reflect.ValueOf(out) rout := reflect.ValueOf(out)
var errs error
for { for {
res, ok := res.NextSync() res, ok := res.NextSync()
if !ok { if !ok {
@ -151,7 +154,8 @@ func (st *StateStore) List(out interface{}) error {
elem := reflect.New(outT) elem := reflect.New(outT)
err := cborutil.ReadCborRPC(bytes.NewReader(res.Value), elem.Interface()) err := cborutil.ReadCborRPC(bytes.NewReader(res.Value), elem.Interface())
if err != nil { if err != nil {
return err errs = multierr.Append(errs, xerrors.Errorf("decoding state for key '%s': %w", res.Key, err))
continue
} }
rout.Elem().Set(reflect.Append(rout.Elem(), elem.Elem())) rout.Elem().Set(reflect.Append(rout.Elem(), elem.Elem()))

View File

@ -68,7 +68,7 @@ func MakeGenesisMem(out io.Writer, gmc *gen.GenMinerCfg) func(bs dtypes.ChainBlo
} }
} }
func MakeGenesis(outFile, presealInfo string) func(bs dtypes.ChainBlockstore, w *wallet.Wallet) modules.Genesis { func MakeGenesis(outFile, presealInfo, timestamp string) func(bs dtypes.ChainBlockstore, w *wallet.Wallet) modules.Genesis {
return func(bs dtypes.ChainBlockstore, w *wallet.Wallet) modules.Genesis { return func(bs dtypes.ChainBlockstore, w *wallet.Wallet) modules.Genesis {
return func() (*types.BlockHeader, error) { return func() (*types.BlockHeader, error) {
glog.Warn("Generating new random genesis block, note that this SHOULD NOT happen unless you are setting up new network") glog.Warn("Generating new random genesis block, note that this SHOULD NOT happen unless you are setting up new network")
@ -119,7 +119,18 @@ func MakeGenesis(outFile, presealInfo string) func(bs dtypes.ChainBlockstore, w
addrs[miner.Worker] = types.FromFil(100000) addrs[miner.Worker] = types.FromFil(100000)
} }
b, err := gen.MakeGenesisBlock(bs, addrs, gmc, uint64(time.Now().Unix())) ts := uint64(time.Now().Unix())
if timestamp != "" {
t, err := time.Parse(time.RFC3339, timestamp)
if err != nil {
return nil, xerrors.Errorf("parsing input genesis timestamp: %w", err)
}
glog.Infof("will use %s as the genesis timestamp", t)
ts = uint64(t.Unix())
}
b, err := gen.MakeGenesisBlock(bs, addrs, gmc, ts)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -100,7 +100,7 @@ type clientStream struct {
func (c *Client) RetrieveUnixfs(ctx context.Context, root cid.Cid, size uint64, total types.BigInt, miner peer.ID, client, minerAddr address.Address, out io.Writer) error { func (c *Client) RetrieveUnixfs(ctx context.Context, root cid.Cid, size uint64, total types.BigInt, miner peer.ID, client, minerAddr address.Address, out io.Writer) error {
s, err := c.h.NewStream(ctx, miner, ProtocolID) s, err := c.h.NewStream(ctx, miner, ProtocolID)
if err != nil { if err != nil {
return err return xerrors.Errorf("failed to open stream to miner for retrieval query: %w", err)
} }
defer s.Close() defer s.Close()
@ -149,7 +149,6 @@ func (c *Client) RetrieveUnixfs(ctx context.Context, root cid.Cid, size uint64,
cst.offset += toFetch cst.offset += toFetch
} }
log.Info("RETRIEVE SUCCESSFUL")
return nil return nil
} }
@ -173,13 +172,12 @@ func (cst *clientStream) doOneExchange(ctx context.Context, toFetch uint64, out
} }
if err := cborutil.WriteCborRPC(cst.stream, deal); err != nil { if err := cborutil.WriteCborRPC(cst.stream, deal); err != nil {
return err return xerrors.Errorf("sending incremental retrieval request: %w", err)
} }
var resp DealResponse var resp DealResponse
if err := cborutil.ReadCborRPC(cst.peeker, &resp); err != nil { if err := cborutil.ReadCborRPC(cst.peeker, &resp); err != nil {
log.Error(err) return xerrors.Errorf("reading retrieval response: %w", err)
return err
} }
if resp.Status != Accepted { if resp.Status != Accepted {

View File

@ -2,6 +2,8 @@ package sectorblocks
import ( import (
"context" "context"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/storage"
"io/ioutil" "io/ioutil"
blocks "github.com/ipfs/go-block-format" blocks "github.com/ipfs/go-block-format"
@ -72,11 +74,22 @@ func (s *SectorBlockStore) Get(c cid.Cid) (blocks.Block, error) {
return nil, blockstore.ErrNotFound return nil, blockstore.ErrNotFound
} }
best := refs[0] // TODO: better strategy (e.g. look for already unsealed) // TODO: better strategy (e.g. look for already unsealed)
var best api.SealedRef
si, err := s.sectorBlocks.Miner.GetSectorInfo(best.SectorID) var bestSi storage.SectorInfo
if err != nil { for _, r := range refs {
return nil, xerrors.Errorf("getting sector info: %w", err) si, err := s.sectorBlocks.Miner.GetSectorInfo(r.SectorID)
if err != nil {
return nil, xerrors.Errorf("getting sector info: %w", err)
}
if si.State == api.Proving {
best = r
bestSi = si
break
}
}
if bestSi.State == api.UndefinedSectorState {
return nil, xerrors.New("no sealed sector found")
} }
log.Infof("reading block %s from sector %d(+%d;%d)", c, best.SectorID, best.Offset, best.Size) log.Infof("reading block %s from sector %d(+%d;%d)", c, best.SectorID, best.Offset, best.Size)
@ -85,8 +98,8 @@ func (s *SectorBlockStore) Get(c cid.Cid) (blocks.Block, error) {
best.SectorID, best.SectorID,
best.Offset, best.Offset,
best.Size, best.Size,
si.Ticket.TicketBytes, bestSi.Ticket.TicketBytes,
si.CommD, bestSi.CommD,
) )
if err != nil { if err != nil {
return nil, xerrors.Errorf("unsealing block: %w", err) return nil, xerrors.Errorf("unsealing block: %w", err)

View File

@ -65,7 +65,7 @@ func (m *Miner) UpdateSectorState(ctx context.Context, sector uint64, snonce uin
func (m *Miner) sectorStateLoop(ctx context.Context) error { func (m *Miner) sectorStateLoop(ctx context.Context) error {
trackedSectors, err := m.ListSectors() trackedSectors, err := m.ListSectors()
if err != nil { if err != nil {
return xerrors.Errorf("loading sector list: %w", err) log.Errorf("loading sector list: %+v", err)
} }
go func() { go func() {

56
storage/sectors_test.go Normal file
View File

@ -0,0 +1,56 @@
package storage
import (
"bytes"
"testing"
"gotest.tools/assert"
"github.com/filecoin-project/lotus/lib/cborutil"
)
func TestSectorInfoSelialization(t *testing.T) {
si := &SectorInfo{
State: 123,
SectorID: 234,
Nonce: 345,
Pieces: []Piece{{
DealID: 1234,
Size: 5,
CommP: []byte{3},
}},
CommD: []byte{32, 4},
CommR: nil,
Proof: nil,
Ticket: SealTicket{
BlockHeight: 345,
TicketBytes: []byte{87, 78, 7, 87},
},
PreCommitMessage: nil,
Seed: SealSeed{},
CommitMessage: nil,
FaultReportMsg: nil,
LastErr: "hi",
}
b, err := cborutil.Dump(si)
if err != nil {
t.Fatal(err)
}
var si2 SectorInfo
if err := cborutil.ReadCborRPC(bytes.NewReader(b), &si); err != nil {
return
}
assert.Equal(t, si.State, si2.State)
assert.Equal(t, si.Nonce, si2.Nonce)
assert.Equal(t, si.SectorID, si2.SectorID)
assert.Equal(t, si.Pieces, si2.Pieces)
assert.Equal(t, si.CommD, si2.CommD)
assert.Equal(t, si.Ticket, si2.Ticket)
assert.Equal(t, si, si2)
}

File diff suppressed because it is too large Load Diff

View File

@ -14,6 +14,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/address" "github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
"github.com/multiformats/go-multihash"
_ "github.com/influxdata/influxdb1-client" _ "github.com/influxdata/influxdb1-client"
models "github.com/influxdata/influxdb1-client/models" models "github.com/influxdata/influxdb1-client/models"
@ -124,8 +125,11 @@ func RecordTipsetPoints(ctx context.Context, api api.FullNode, pl *PointList, ti
if err != nil { if err != nil {
return err return err
} }
p := NewPoint("chain.election", 1)
p.AddTag("miner", blockheader.Miner.String())
pl.AddPoint(p)
p := NewPoint("chain.blockheader_size", len(bs)) p = NewPoint("chain.blockheader_size", len(bs))
pl.AddPoint(p) pl.AddPoint(p)
} }
@ -212,7 +216,13 @@ func RecordTipsetMessagesPoints(ctx context.Context, api api.FullNode, pl *Point
} }
p = NewPoint("chain.message_count", 1) p = NewPoint("chain.message_count", 1)
p.AddTag("actor", actor.Code.String())
dm, err := multihash.Decode(actor.Code.Hash())
if err != nil {
continue
}
p.AddTag("actor", string(dm.Digest))
p.AddTag("method", fmt.Sprintf("%d", msg.Message.Method)) p.AddTag("method", fmt.Sprintf("%d", msg.Message.Method))
p.AddTag("exitcode", fmt.Sprintf("%d", recp[i].ExitCode)) p.AddTag("exitcode", fmt.Sprintf("%d", recp[i].ExitCode))
pl.AddPoint(p) pl.AddPoint(p)