Compare commits
53
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
06670f4cae | ||
|
|
c6b6c2990c | ||
|
|
a49dc90386 | ||
|
|
64f4e80446 | ||
|
|
e67253b6a8 | ||
|
|
c73326e96d | ||
|
|
7003960fdd | ||
|
|
ad4712b593 | ||
|
|
b753cd4503 | ||
|
|
ee29a92021 | ||
|
|
cd2bf04a6b | ||
|
|
f7a71f4be7 | ||
|
|
e5c24ff32b | ||
|
|
1cf9b9a67f | ||
|
|
7dd25c3ac5 | ||
|
|
241c3fa673 | ||
|
|
785eeb1eee | ||
|
|
30d82ba962 | ||
|
|
002d021eb7 | ||
|
|
71eb41b9aa | ||
|
|
f06369166e | ||
|
|
5129fed7c8 | ||
|
|
f06794ae84 | ||
|
|
fa69adf45c | ||
|
|
fa04da2995 | ||
|
|
e2a554c2e6 | ||
|
|
91da81c8bc | ||
|
|
7bd18290db | ||
|
|
8e55c91cd2 | ||
|
|
514339e855 | ||
|
|
9f8ecb0ac4 | ||
|
|
be1bbe88b0 | ||
|
|
f1ccbe496a | ||
|
|
495554e565 | ||
|
|
17c378c18a | ||
|
|
6e63ea6cce | ||
|
|
10753f14d0 | ||
|
|
0af7cd1448 | ||
|
|
de3edc2ec7 | ||
|
|
8639409f74 | ||
|
|
b372881e91 | ||
|
|
fc351d08b0 | ||
|
|
7232e5481c | ||
|
|
f26a336afb | ||
|
|
d6615b6286 | ||
|
|
4604b60fb1 | ||
|
|
6986204657 | ||
|
|
3f9cde28fc | ||
|
|
aa682a377d | ||
|
|
6386107b80 | ||
|
|
218b2b82c1 | ||
|
|
b06b0147a9 | ||
|
|
fa4ff89dca |
+12
-3
@@ -134,6 +134,9 @@ jobs:
|
|||||||
type: string
|
type: string
|
||||||
default: "./..."
|
default: "./..."
|
||||||
description: Import paths of packages to be tested.
|
description: Import paths of packages to be tested.
|
||||||
|
winpost-test:
|
||||||
|
type: string
|
||||||
|
default: "0"
|
||||||
test-suite-name:
|
test-suite-name:
|
||||||
type: string
|
type: string
|
||||||
default: unit
|
default: unit
|
||||||
@@ -171,6 +174,7 @@ jobs:
|
|||||||
environment:
|
environment:
|
||||||
GOTESTSUM_JUNITFILE: /tmp/test-reports/<< parameters.test-suite-name >>/junit.xml
|
GOTESTSUM_JUNITFILE: /tmp/test-reports/<< parameters.test-suite-name >>/junit.xml
|
||||||
GOTESTSUM_FORMAT: << parameters.gotestsum-format >>
|
GOTESTSUM_FORMAT: << parameters.gotestsum-format >>
|
||||||
|
LOTUS_TEST_WINDOW_POST: << parameters.winpost-test >>
|
||||||
command: |
|
command: |
|
||||||
mkdir -p /tmp/test-reports/<< parameters.test-suite-name >>
|
mkdir -p /tmp/test-reports/<< parameters.test-suite-name >>
|
||||||
gotestsum -- \
|
gotestsum -- \
|
||||||
@@ -199,6 +203,8 @@ jobs:
|
|||||||
|
|
||||||
test-short:
|
test-short:
|
||||||
<<: *test
|
<<: *test
|
||||||
|
test-window-post:
|
||||||
|
<<: *test
|
||||||
|
|
||||||
build-macos:
|
build-macos:
|
||||||
description: build darwin lotus binary
|
description: build darwin lotus binary
|
||||||
@@ -331,11 +337,14 @@ workflows:
|
|||||||
ci:
|
ci:
|
||||||
jobs:
|
jobs:
|
||||||
- lint-changes:
|
- lint-changes:
|
||||||
args: "--new-from-rev origin/master"
|
args: "--new-from-rev origin/next"
|
||||||
- test:
|
|
||||||
codecov-upload: true
|
|
||||||
- mod-tidy-check
|
- mod-tidy-check
|
||||||
- gofmt
|
- gofmt
|
||||||
|
- test:
|
||||||
|
codecov-upload: true
|
||||||
|
- test-window-post:
|
||||||
|
go-test-flags: "-run=TestWindowedPost"
|
||||||
|
winpost-test: "1"
|
||||||
- test-short:
|
- test-short:
|
||||||
go-test-flags: "--timeout 10m --short"
|
go-test-flags: "--timeout 10m --short"
|
||||||
filters:
|
filters:
|
||||||
|
|||||||
+11
-1
@@ -22,13 +22,23 @@ issues:
|
|||||||
- "func name will be used as test\\.Test.* by other packages, and that stutters; consider calling this"
|
- "func name will be used as test\\.Test.* by other packages, and that stutters; consider calling this"
|
||||||
- "Potential file inclusion via variable"
|
- "Potential file inclusion via variable"
|
||||||
- "should have( a package)? comment"
|
- "should have( a package)? comment"
|
||||||
|
- "Error return value of `logging.SetLogLevel` is not checked"
|
||||||
|
|
||||||
exclude-use-default: false
|
exclude-use-default: false
|
||||||
exclude-rules:
|
exclude-rules:
|
||||||
|
- path: lotuspond
|
||||||
|
linters:
|
||||||
|
- errcheck
|
||||||
|
|
||||||
- path: node/modules/lp2p
|
- path: node/modules/lp2p
|
||||||
linters:
|
linters:
|
||||||
- golint
|
- golint
|
||||||
- path: ".*_test.go"
|
|
||||||
|
- path: build/params_.*\.go
|
||||||
|
linters:
|
||||||
|
- golint
|
||||||
|
|
||||||
|
- path: .*_test.go
|
||||||
linters:
|
linters:
|
||||||
- gosec
|
- gosec
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ MODULES:=
|
|||||||
CLEAN:=
|
CLEAN:=
|
||||||
BINS:=
|
BINS:=
|
||||||
|
|
||||||
ldflags=-X=github.com/filecoin-project/lotus/build.CurrentCommit='+git$(subst -,.,$(shell git describe --always --match=NeVeRmAtCh --dirty 2>/dev/null || git rev-parse --short HEAD 2>/dev/null))'
|
ldflags=-X=github.com/filecoin-project/lotus/build.CurrentCommit=+git.$(subst -,.,$(shell git describe --always --match=NeVeRmAtCh --dirty 2>/dev/null || git rev-parse --short HEAD 2>/dev/null))
|
||||||
ifneq ($(strip $(LDFLAGS)),)
|
ifneq ($(strip $(LDFLAGS)),)
|
||||||
ldflags+=-extldflags=$(LDFLAGS)
|
ldflags+=-extldflags=$(LDFLAGS)
|
||||||
endif
|
endif
|
||||||
@@ -132,7 +132,7 @@ benchmarks:
|
|||||||
@curl -X POST 'http://benchmark.kittyhawk.wtf/benchmark' -d '@bench.json' -u "${benchmark_http_cred}"
|
@curl -X POST 'http://benchmark.kittyhawk.wtf/benchmark' -d '@bench.json' -u "${benchmark_http_cred}"
|
||||||
.PHONY: benchmarks
|
.PHONY: benchmarks
|
||||||
|
|
||||||
pond: build
|
pond: 2k
|
||||||
go build -o pond ./lotuspond
|
go build -o pond ./lotuspond
|
||||||
(cd lotuspond/front && npm i && CI=false npm run build)
|
(cd lotuspond/front && npm i && CI=false npm run build)
|
||||||
.PHONY: pond
|
.PHONY: pond
|
||||||
|
|||||||
@@ -34,9 +34,6 @@ type Common interface {
|
|||||||
|
|
||||||
LogList(context.Context) ([]string, error)
|
LogList(context.Context) ([]string, error)
|
||||||
LogSetLevel(context.Context, string, string) error
|
LogSetLevel(context.Context, string, string) error
|
||||||
|
|
||||||
// trigger graceful shutdown
|
|
||||||
Shutdown(context.Context) error
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Version provides various build-time information
|
// Version provides various build-time information
|
||||||
|
|||||||
@@ -154,6 +154,7 @@ type FullNode interface {
|
|||||||
StateMinerInitialPledgeCollateral(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (types.BigInt, error)
|
StateMinerInitialPledgeCollateral(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (types.BigInt, error)
|
||||||
StateMinerAvailableBalance(context.Context, address.Address, types.TipSetKey) (types.BigInt, error)
|
StateMinerAvailableBalance(context.Context, address.Address, types.TipSetKey) (types.BigInt, error)
|
||||||
StateSectorPreCommitInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error)
|
StateSectorPreCommitInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error)
|
||||||
|
StateSectorGetInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error)
|
||||||
StatePledgeCollateral(context.Context, types.TipSetKey) (types.BigInt, error)
|
StatePledgeCollateral(context.Context, types.TipSetKey) (types.BigInt, error)
|
||||||
StateWaitMsg(context.Context, cid.Cid) (*MsgLookup, error)
|
StateWaitMsg(context.Context, cid.Cid) (*MsgLookup, error)
|
||||||
StateSearchMsg(context.Context, cid.Cid) (*MsgLookup, error)
|
StateSearchMsg(context.Context, cid.Cid) (*MsgLookup, error)
|
||||||
|
|||||||
+1
-2
@@ -8,11 +8,10 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
||||||
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/sector-storage/stores"
|
"github.com/filecoin-project/sector-storage/stores"
|
||||||
"github.com/filecoin-project/sector-storage/storiface"
|
"github.com/filecoin-project/sector-storage/storiface"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// StorageMiner is a low-level interface to the Filecoin network storage miner node
|
// StorageMiner is a low-level interface to the Filecoin network storage miner node
|
||||||
|
|||||||
+9
-2
@@ -2,6 +2,9 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"github.com/ipfs/go-cid"
|
||||||
|
|
||||||
"github.com/filecoin-project/sector-storage/sealtasks"
|
"github.com/filecoin-project/sector-storage/sealtasks"
|
||||||
"github.com/filecoin-project/sector-storage/stores"
|
"github.com/filecoin-project/sector-storage/stores"
|
||||||
@@ -12,7 +15,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
)
|
)
|
||||||
|
|
||||||
type WorkerApi interface {
|
type WorkerAPI interface {
|
||||||
Version(context.Context) (build.Version, error)
|
Version(context.Context) (build.Version, error)
|
||||||
// TODO: Info() (name, ...) ?
|
// TODO: Info() (name, ...) ?
|
||||||
|
|
||||||
@@ -21,7 +24,11 @@ type WorkerApi interface {
|
|||||||
Info(context.Context) (storiface.WorkerInfo, error)
|
Info(context.Context) (storiface.WorkerInfo, error)
|
||||||
|
|
||||||
storage.Sealer
|
storage.Sealer
|
||||||
Fetch(context.Context, abi.SectorID, stores.SectorFileType, bool) error
|
|
||||||
|
UnsealPiece(context.Context, abi.SectorID, storiface.UnpaddedByteIndex, abi.UnpaddedPieceSize, abi.SealRandomness, cid.Cid) error
|
||||||
|
ReadPiece(context.Context, io.Writer, abi.SectorID, storiface.UnpaddedByteIndex, abi.UnpaddedPieceSize) error
|
||||||
|
|
||||||
|
Fetch(context.Context, abi.SectorID, stores.SectorFileType, bool, stores.AcquireMode) error
|
||||||
|
|
||||||
Closing(context.Context) (<-chan struct{}, error)
|
Closing(context.Context) (<-chan struct{}, error)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ func PermissionedFullAPI(a api.FullNode) api.FullNode {
|
|||||||
return &out
|
return &out
|
||||||
}
|
}
|
||||||
|
|
||||||
func PermissionedWorkerAPI(a api.WorkerApi) api.WorkerApi {
|
func PermissionedWorkerAPI(a api.WorkerAPI) api.WorkerAPI {
|
||||||
var out WorkerStruct
|
var out WorkerStruct
|
||||||
auth.PermissionedProxy(AllPermissions, DefaultPerms, a, &out.Internal)
|
auth.PermissionedProxy(AllPermissions, DefaultPerms, a, &out.Internal)
|
||||||
return &out
|
return &out
|
||||||
|
|||||||
+36
-25
@@ -2,6 +2,7 @@ package apistruct
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"io"
|
||||||
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
"github.com/libp2p/go-libp2p-core/network"
|
||||||
@@ -47,8 +48,6 @@ type CommonStruct struct {
|
|||||||
|
|
||||||
LogList func(context.Context) ([]string, error) `perm:"write"`
|
LogList func(context.Context) ([]string, error) `perm:"write"`
|
||||||
LogSetLevel func(context.Context, string, string) error `perm:"write"`
|
LogSetLevel func(context.Context, string, string) error `perm:"write"`
|
||||||
|
|
||||||
Shutdown func(context.Context) error `perm:"admin"`
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,6 +129,7 @@ type FullNodeStruct struct {
|
|||||||
StateMinerInitialPledgeCollateral func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (types.BigInt, error) `perm:"read"`
|
StateMinerInitialPledgeCollateral func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (types.BigInt, error) `perm:"read"`
|
||||||
StateMinerAvailableBalance func(context.Context, address.Address, types.TipSetKey) (types.BigInt, error) `perm:"read"`
|
StateMinerAvailableBalance func(context.Context, address.Address, types.TipSetKey) (types.BigInt, error) `perm:"read"`
|
||||||
StateSectorPreCommitInfo func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) `perm:"read"`
|
StateSectorPreCommitInfo func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) `perm:"read"`
|
||||||
|
StateSectorGetInfo func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error) `perm:"read"`
|
||||||
StateCall func(context.Context, *types.Message, types.TipSetKey) (*api.InvocResult, error) `perm:"read"`
|
StateCall func(context.Context, *types.Message, types.TipSetKey) (*api.InvocResult, error) `perm:"read"`
|
||||||
StateReplay func(context.Context, types.TipSetKey, cid.Cid) (*api.InvocResult, error) `perm:"read"`
|
StateReplay func(context.Context, types.TipSetKey, cid.Cid) (*api.InvocResult, error) `perm:"read"`
|
||||||
StateGetActor func(context.Context, address.Address, types.TipSetKey) (*types.Actor, error) `perm:"read"`
|
StateGetActor func(context.Context, address.Address, types.TipSetKey) (*types.Actor, error) `perm:"read"`
|
||||||
@@ -203,16 +203,16 @@ type StorageMinerStruct struct {
|
|||||||
WorkerConnect func(context.Context, string) error `perm:"admin"` // TODO: worker perm
|
WorkerConnect func(context.Context, string) error `perm:"admin"` // TODO: worker perm
|
||||||
WorkerStats func(context.Context) (map[uint64]storiface.WorkerStats, error) `perm:"admin"`
|
WorkerStats func(context.Context) (map[uint64]storiface.WorkerStats, error) `perm:"admin"`
|
||||||
|
|
||||||
StorageList func(context.Context) (map[stores.ID][]stores.Decl, error) `perm:"admin"`
|
StorageList func(context.Context) (map[stores.ID][]stores.Decl, error) `perm:"admin"`
|
||||||
StorageLocal func(context.Context) (map[stores.ID]string, error) `perm:"admin"`
|
StorageLocal func(context.Context) (map[stores.ID]string, error) `perm:"admin"`
|
||||||
StorageStat func(context.Context, stores.ID) (stores.FsStat, error) `perm:"admin"`
|
StorageStat func(context.Context, stores.ID) (stores.FsStat, error) `perm:"admin"`
|
||||||
StorageAttach func(context.Context, stores.StorageInfo, stores.FsStat) error `perm:"admin"`
|
StorageAttach func(context.Context, stores.StorageInfo, stores.FsStat) error `perm:"admin"`
|
||||||
StorageDeclareSector func(context.Context, stores.ID, abi.SectorID, stores.SectorFileType) error `perm:"admin"`
|
StorageDeclareSector func(context.Context, stores.ID, abi.SectorID, stores.SectorFileType, bool) error `perm:"admin"`
|
||||||
StorageDropSector func(context.Context, stores.ID, abi.SectorID, stores.SectorFileType) error `perm:"admin"`
|
StorageDropSector func(context.Context, stores.ID, abi.SectorID, stores.SectorFileType) error `perm:"admin"`
|
||||||
StorageFindSector func(context.Context, abi.SectorID, stores.SectorFileType, bool) ([]stores.StorageInfo, error) `perm:"admin"`
|
StorageFindSector func(context.Context, abi.SectorID, stores.SectorFileType, bool) ([]stores.SectorStorageInfo, error) `perm:"admin"`
|
||||||
StorageInfo func(context.Context, stores.ID) (stores.StorageInfo, error) `perm:"admin"`
|
StorageInfo func(context.Context, stores.ID) (stores.StorageInfo, error) `perm:"admin"`
|
||||||
StorageBestAlloc func(ctx context.Context, allocate stores.SectorFileType, spt abi.RegisteredProof, sealing bool) ([]stores.StorageInfo, error) `perm:"admin"`
|
StorageBestAlloc func(ctx context.Context, allocate stores.SectorFileType, spt abi.RegisteredProof, sealing stores.PathType) ([]stores.StorageInfo, error) `perm:"admin"`
|
||||||
StorageReportHealth func(ctx context.Context, id stores.ID, report stores.HealthReport) error `perm:"admin"`
|
StorageReportHealth func(ctx context.Context, id stores.ID, report stores.HealthReport) error `perm:"admin"`
|
||||||
|
|
||||||
DealsImportData func(ctx context.Context, dealPropCid cid.Cid, file string) error `perm:"write"`
|
DealsImportData func(ctx context.Context, dealPropCid cid.Cid, file string) error `perm:"write"`
|
||||||
DealsList func(ctx context.Context) ([]storagemarket.StorageDeal, error) `perm:"read"`
|
DealsList func(ctx context.Context) ([]storagemarket.StorageDeal, error) `perm:"read"`
|
||||||
@@ -237,7 +237,10 @@ type WorkerStruct struct {
|
|||||||
SealCommit2 func(context.Context, abi.SectorID, storage.Commit1Out) (storage.Proof, error) `perm:"admin"`
|
SealCommit2 func(context.Context, abi.SectorID, storage.Commit1Out) (storage.Proof, error) `perm:"admin"`
|
||||||
FinalizeSector func(context.Context, abi.SectorID) error `perm:"admin"`
|
FinalizeSector func(context.Context, abi.SectorID) error `perm:"admin"`
|
||||||
|
|
||||||
Fetch func(context.Context, abi.SectorID, stores.SectorFileType, bool) error `perm:"admin"`
|
UnsealPiece func(context.Context, abi.SectorID, storiface.UnpaddedByteIndex, abi.UnpaddedPieceSize, abi.SealRandomness, cid.Cid) error `perm:"admin"`
|
||||||
|
ReadPiece func(context.Context, io.Writer, abi.SectorID, storiface.UnpaddedByteIndex, abi.UnpaddedPieceSize) error `perm:"admin"`
|
||||||
|
|
||||||
|
Fetch func(context.Context, abi.SectorID, stores.SectorFileType, bool, stores.AcquireMode) error `perm:"admin"`
|
||||||
|
|
||||||
Closing func(context.Context) (<-chan struct{}, error) `perm:"admin"`
|
Closing func(context.Context) (<-chan struct{}, error) `perm:"admin"`
|
||||||
}
|
}
|
||||||
@@ -295,10 +298,6 @@ func (c *CommonStruct) LogSetLevel(ctx context.Context, group, level string) err
|
|||||||
return c.Internal.LogSetLevel(ctx, group, level)
|
return c.Internal.LogSetLevel(ctx, group, level)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CommonStruct) Shutdown(ctx context.Context) error {
|
|
||||||
return c.Internal.Shutdown(ctx)
|
|
||||||
}
|
|
||||||
|
|
||||||
// FullNodeStruct
|
// FullNodeStruct
|
||||||
|
|
||||||
func (c *FullNodeStruct) ClientListImports(ctx context.Context) ([]api.Import, error) {
|
func (c *FullNodeStruct) ClientListImports(ctx context.Context) ([]api.Import, error) {
|
||||||
@@ -567,6 +566,10 @@ func (c *FullNodeStruct) StateSectorPreCommitInfo(ctx context.Context, maddr add
|
|||||||
return c.Internal.StateSectorPreCommitInfo(ctx, maddr, n, tsk)
|
return c.Internal.StateSectorPreCommitInfo(ctx, maddr, n, tsk)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *FullNodeStruct) StateSectorGetInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk types.TipSetKey) (*miner.SectorOnChainInfo, error) {
|
||||||
|
return c.Internal.StateSectorGetInfo(ctx, maddr, n, tsk)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) StateCall(ctx context.Context, msg *types.Message, tsk types.TipSetKey) (*api.InvocResult, error) {
|
func (c *FullNodeStruct) StateCall(ctx context.Context, msg *types.Message, tsk types.TipSetKey) (*api.InvocResult, error) {
|
||||||
return c.Internal.StateCall(ctx, msg, tsk)
|
return c.Internal.StateCall(ctx, msg, tsk)
|
||||||
}
|
}
|
||||||
@@ -763,15 +766,15 @@ func (c *StorageMinerStruct) StorageAttach(ctx context.Context, si stores.Storag
|
|||||||
return c.Internal.StorageAttach(ctx, si, st)
|
return c.Internal.StorageAttach(ctx, si, st)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *StorageMinerStruct) StorageDeclareSector(ctx context.Context, storageId stores.ID, s abi.SectorID, ft stores.SectorFileType) error {
|
func (c *StorageMinerStruct) StorageDeclareSector(ctx context.Context, storageId stores.ID, s abi.SectorID, ft stores.SectorFileType, primary bool) error {
|
||||||
return c.Internal.StorageDeclareSector(ctx, storageId, s, ft)
|
return c.Internal.StorageDeclareSector(ctx, storageId, s, ft, primary)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *StorageMinerStruct) StorageDropSector(ctx context.Context, storageId stores.ID, s abi.SectorID, ft stores.SectorFileType) error {
|
func (c *StorageMinerStruct) StorageDropSector(ctx context.Context, storageId stores.ID, s abi.SectorID, ft stores.SectorFileType) error {
|
||||||
return c.Internal.StorageDropSector(ctx, storageId, s, ft)
|
return c.Internal.StorageDropSector(ctx, storageId, s, ft)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *StorageMinerStruct) StorageFindSector(ctx context.Context, si abi.SectorID, types stores.SectorFileType, allowFetch bool) ([]stores.StorageInfo, error) {
|
func (c *StorageMinerStruct) StorageFindSector(ctx context.Context, si abi.SectorID, types stores.SectorFileType, allowFetch bool) ([]stores.SectorStorageInfo, error) {
|
||||||
return c.Internal.StorageFindSector(ctx, si, types, allowFetch)
|
return c.Internal.StorageFindSector(ctx, si, types, allowFetch)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -791,8 +794,8 @@ func (c *StorageMinerStruct) StorageInfo(ctx context.Context, id stores.ID) (sto
|
|||||||
return c.Internal.StorageInfo(ctx, id)
|
return c.Internal.StorageInfo(ctx, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *StorageMinerStruct) StorageBestAlloc(ctx context.Context, allocate stores.SectorFileType, spt abi.RegisteredProof, sealing bool) ([]stores.StorageInfo, error) {
|
func (c *StorageMinerStruct) StorageBestAlloc(ctx context.Context, allocate stores.SectorFileType, spt abi.RegisteredProof, pt stores.PathType) ([]stores.StorageInfo, error) {
|
||||||
return c.Internal.StorageBestAlloc(ctx, allocate, spt, sealing)
|
return c.Internal.StorageBestAlloc(ctx, allocate, spt, pt)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *StorageMinerStruct) StorageReportHealth(ctx context.Context, id stores.ID, report stores.HealthReport) error {
|
func (c *StorageMinerStruct) StorageReportHealth(ctx context.Context, id stores.ID, report stores.HealthReport) error {
|
||||||
@@ -865,8 +868,16 @@ func (w *WorkerStruct) FinalizeSector(ctx context.Context, sector abi.SectorID)
|
|||||||
return w.Internal.FinalizeSector(ctx, sector)
|
return w.Internal.FinalizeSector(ctx, sector)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WorkerStruct) Fetch(ctx context.Context, id abi.SectorID, fileType stores.SectorFileType, b bool) error {
|
func (w *WorkerStruct) UnsealPiece(ctx context.Context, id abi.SectorID, index storiface.UnpaddedByteIndex, size abi.UnpaddedPieceSize, randomness abi.SealRandomness, c cid.Cid) error {
|
||||||
return w.Internal.Fetch(ctx, id, fileType, b)
|
return w.Internal.UnsealPiece(ctx, id, index, size, randomness, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *WorkerStruct) ReadPiece(ctx context.Context, writer io.Writer, id abi.SectorID, index storiface.UnpaddedByteIndex, size abi.UnpaddedPieceSize) error {
|
||||||
|
return w.Internal.ReadPiece(ctx, writer, id, index, size)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *WorkerStruct) Fetch(ctx context.Context, id abi.SectorID, fileType stores.SectorFileType, b bool, am stores.AcquireMode) error {
|
||||||
|
return w.Internal.Fetch(ctx, id, fileType, b, am)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WorkerStruct) Closing(ctx context.Context) (<-chan struct{}, error) {
|
func (w *WorkerStruct) Closing(ctx context.Context) (<-chan struct{}, error) {
|
||||||
@@ -876,4 +887,4 @@ func (w *WorkerStruct) Closing(ctx context.Context) (<-chan struct{}, error) {
|
|||||||
var _ api.Common = &CommonStruct{}
|
var _ api.Common = &CommonStruct{}
|
||||||
var _ api.FullNode = &FullNodeStruct{}
|
var _ api.FullNode = &FullNodeStruct{}
|
||||||
var _ api.StorageMiner = &StorageMinerStruct{}
|
var _ api.StorageMiner = &StorageMinerStruct{}
|
||||||
var _ api.WorkerApi = &WorkerStruct{}
|
var _ api.WorkerAPI = &WorkerStruct{}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ func NewStorageMinerRPC(addr string, requestHeader http.Header) (api.StorageMine
|
|||||||
return &res, closer, err
|
return &res, closer, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWorkerRPC(addr string, requestHeader http.Header) (api.WorkerApi, jsonrpc.ClientCloser, error) {
|
func NewWorkerRPC(addr string, requestHeader http.Header) (api.WorkerAPI, jsonrpc.ClientCloser, error) {
|
||||||
var res apistruct.WorkerStruct
|
var res apistruct.WorkerStruct
|
||||||
closer, err := jsonrpc.NewMergeClient(addr, "Filecoin",
|
closer, err := jsonrpc.NewMergeClient(addr, "Filecoin",
|
||||||
[]interface{}{
|
[]interface{}{
|
||||||
|
|||||||
@@ -320,6 +320,7 @@ func main() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
for _, g := range groupslice {
|
for _, g := range groupslice {
|
||||||
|
g := g
|
||||||
fmt.Printf("## %s\n", g.GroupName)
|
fmt.Printf("## %s\n", g.GroupName)
|
||||||
fmt.Printf("%s\n\n", g.Header)
|
fmt.Printf("%s\n\n", g.Header)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -193,7 +193,7 @@ func testRetrieval(t *testing.T, ctx context.Context, err error, client *impl.Fu
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(rpath)
|
defer os.RemoveAll(rpath) //nolint:errcheck
|
||||||
|
|
||||||
caddr, err := client.WalletDefaultAddress(ctx)
|
caddr, err := client.WalletDefaultAddress(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
+6
-4
@@ -4,9 +4,11 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type TestNode struct {
|
type TestNode struct {
|
||||||
@@ -21,6 +23,8 @@ type TestStorageNode struct {
|
|||||||
|
|
||||||
var PresealGenesis = -1
|
var PresealGenesis = -1
|
||||||
|
|
||||||
|
const GenesisPreseals = 2
|
||||||
|
|
||||||
type StorageMiner struct {
|
type StorageMiner struct {
|
||||||
Full int
|
Full int
|
||||||
Preseal int
|
Preseal int
|
||||||
@@ -60,9 +64,7 @@ func (ts *testSuite) testVersion(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if v.Version != build.BuildVersion {
|
require.Equal(t, v.Version, build.BuildVersion)
|
||||||
t.Error("Version didn't work properly")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ts *testSuite) testID(t *testing.T) {
|
func (ts *testSuite) testID(t *testing.T) {
|
||||||
|
|||||||
@@ -0,0 +1,169 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"github.com/filecoin-project/lotus/api"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
|
miner2 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
|
sealing "github.com/filecoin-project/storage-fsm"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
"github.com/filecoin-project/lotus/node/impl"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestPledgeSector(t *testing.T, b APIBuilder, blocktime time.Duration, nSectors int) {
|
||||||
|
os.Setenv("BELLMAN_NO_GPU", "1")
|
||||||
|
|
||||||
|
ctx := context.Background()
|
||||||
|
n, sn := b(t, 1, oneMiner)
|
||||||
|
client := n[0].FullNode.(*impl.FullNodeAPI)
|
||||||
|
miner := sn[0]
|
||||||
|
|
||||||
|
addrinfo, err := client.NetAddrsListen(ctx)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := miner.NetConnect(ctx, addrinfo); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
time.Sleep(time.Second)
|
||||||
|
|
||||||
|
mine := true
|
||||||
|
done := make(chan struct{})
|
||||||
|
go func() {
|
||||||
|
defer close(done)
|
||||||
|
for mine {
|
||||||
|
time.Sleep(blocktime)
|
||||||
|
if err := sn[0].MineOne(ctx, func(bool) {}); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
pledgeSectors(t, ctx, miner, nSectors)
|
||||||
|
|
||||||
|
mine = false
|
||||||
|
<-done
|
||||||
|
}
|
||||||
|
|
||||||
|
func pledgeSectors(t *testing.T, ctx context.Context, miner TestStorageNode, n int) {
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
err := miner.PledgeSector(ctx)
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for {
|
||||||
|
s, err := miner.SectorsList(ctx) // Note - the test builder doesn't import genesis sectors into FSM
|
||||||
|
require.NoError(t, err)
|
||||||
|
fmt.Printf("Sectors: %d\n", len(s))
|
||||||
|
if len(s) >= n {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("All sectors is fsm\n")
|
||||||
|
|
||||||
|
s, err := miner.SectorsList(ctx)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
toCheck := map[abi.SectorNumber]struct{}{}
|
||||||
|
for _, number := range s {
|
||||||
|
toCheck[number] = struct{}{}
|
||||||
|
}
|
||||||
|
|
||||||
|
for len(toCheck) > 0 {
|
||||||
|
for n := range toCheck {
|
||||||
|
st, err := miner.SectorsStatus(ctx, n)
|
||||||
|
require.NoError(t, err)
|
||||||
|
if st.State == api.SectorState(sealing.Proving) {
|
||||||
|
delete(toCheck, n)
|
||||||
|
}
|
||||||
|
if strings.Contains(string(st.State), "Fail") {
|
||||||
|
t.Fatal("sector in a failed state", st.State)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
fmt.Printf("WaitSeal: %d\n", len(s))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWindowPost(t *testing.T, b APIBuilder, blocktime time.Duration, nSectors int) {
|
||||||
|
os.Setenv("BELLMAN_NO_GPU", "1")
|
||||||
|
|
||||||
|
ctx := context.Background()
|
||||||
|
n, sn := b(t, 1, oneMiner)
|
||||||
|
client := n[0].FullNode.(*impl.FullNodeAPI)
|
||||||
|
miner := sn[0]
|
||||||
|
|
||||||
|
addrinfo, err := client.NetAddrsListen(ctx)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := miner.NetConnect(ctx, addrinfo); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
time.Sleep(time.Second)
|
||||||
|
|
||||||
|
mine := true
|
||||||
|
done := make(chan struct{})
|
||||||
|
go func() {
|
||||||
|
defer close(done)
|
||||||
|
for mine {
|
||||||
|
time.Sleep(blocktime)
|
||||||
|
if err := sn[0].MineOne(ctx, func(bool) {}); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
pledgeSectors(t, ctx, miner, nSectors)
|
||||||
|
|
||||||
|
maddr, err := miner.ActorAddress(ctx)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
di, err := client.StateMinerProvingDeadline(ctx, maddr, types.EmptyTSK)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
fmt.Printf("Running one proving periods\n")
|
||||||
|
|
||||||
|
for {
|
||||||
|
head, err := client.ChainHead(ctx)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
if head.Height() > di.PeriodStart+(miner2.WPoStProvingPeriod)+2 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if head.Height()%100 == 0 {
|
||||||
|
fmt.Printf("@%d\n", head.Height())
|
||||||
|
}
|
||||||
|
time.Sleep(blocktime)
|
||||||
|
}
|
||||||
|
|
||||||
|
p, err := client.StateMinerPower(ctx, maddr, types.EmptyTSK)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
ssz, err := miner.ActorSectorSize(ctx, maddr)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
require.Equal(t, p.MinerPower, p.TotalPower)
|
||||||
|
require.Equal(t, p.MinerPower.RawBytePower, types.NewInt(uint64(ssz)*uint64(nSectors+GenesisPreseals)))
|
||||||
|
|
||||||
|
// TODO: Inject faults here
|
||||||
|
|
||||||
|
mine = false
|
||||||
|
<-done
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// TODO: check if this exists anywhere else
|
// TODO: check if this exists anywhere else
|
||||||
|
|
||||||
type MultiaddrSlice []ma.Multiaddr
|
type MultiaddrSlice []ma.Multiaddr
|
||||||
|
|
||||||
func (m *MultiaddrSlice) UnmarshalJSON(raw []byte) (err error) {
|
func (m *MultiaddrSlice) UnmarshalJSON(raw []byte) (err error) {
|
||||||
|
|||||||
@@ -1,12 +1,6 @@
|
|||||||
/dns4/bootstrap-0-sin.fil-test.net/tcp/1347/p2p/12D3KooWKNF7vNFEhnvB45E9mw2B5z6t419W3ziZPLdUDVnLLKGs
|
/dns4/t01000.miner.interopnet.kittyhawk.wtf/tcp/1347/p2p/12D3KooWNMVRk3KkMANV67A4zPxB83FtvLouwsYGitEofY1ympJs
|
||||||
/ip4/86.109.15.57/tcp/1347/p2p/12D3KooWKNF7vNFEhnvB45E9mw2B5z6t419W3ziZPLdUDVnLLKGs
|
/ip4/34.217.110.132/tcp/1347/p2p/12D3KooWNMVRk3KkMANV67A4zPxB83FtvLouwsYGitEofY1ympJs
|
||||||
/dns4/bootstrap-0-dfw.fil-test.net/tcp/1347/p2p/12D3KooWECJTm7RUPyGfNbRwm6y2fK4wA7EB8rDJtWsq5AKi7iDr
|
/dns4/peer0.interopnet.kittyhawk.wtf/tcp/1347/p2p/12D3KooWM1ufVLkBAyyf8Jn5DMdmW5gA7upSvCUatoneHp6yUEtd
|
||||||
/ip4/139.178.84.45/tcp/1347/p2p/12D3KooWECJTm7RUPyGfNbRwm6y2fK4wA7EB8rDJtWsq5AKi7iDr
|
/ip4/54.187.182.170/tcp/1347/p2p/12D3KooWM1ufVLkBAyyf8Jn5DMdmW5gA7upSvCUatoneHp6yUEtd
|
||||||
/dns4/bootstrap-0-fra.fil-test.net/tcp/1347/p2p/12D3KooWC7MD6m7iNCuDsYtNr7xVtazihyVUizBbhmhEiyMAm9ym
|
/dns4/peer1.interopnet.kittyhawk.wtf/tcp/1347/p2p/12D3KooWLxMPSbs7XEPhyUiSo6RpTTRAkRiD1bp6uKYxyZx4QSZR
|
||||||
/ip4/136.144.49.17/tcp/1347/p2p/12D3KooWC7MD6m7iNCuDsYtNr7xVtazihyVUizBbhmhEiyMAm9ym
|
/ip4/52.24.84.39/tcp/1347/p2p/12D3KooWLxMPSbs7XEPhyUiSo6RpTTRAkRiD1bp6uKYxyZx4QSZR
|
||||||
/dns4/bootstrap-1-sin.fil-test.net/tcp/1347/p2p/12D3KooWD8eYqsKcEMFax6EbWN3rjA7qFsxCez2rmN8dWqkzgNaN
|
|
||||||
/ip4/86.109.15.55/tcp/1347/p2p/12D3KooWD8eYqsKcEMFax6EbWN3rjA7qFsxCez2rmN8dWqkzgNaN
|
|
||||||
/dns4/bootstrap-1-dfw.fil-test.net/tcp/1347/p2p/12D3KooWLB3RR8frLAmaK4ntHC2dwrAjyGzQgyUzWxAum1FxyyqD
|
|
||||||
/ip4/139.178.84.41/tcp/1347/p2p/12D3KooWLB3RR8frLAmaK4ntHC2dwrAjyGzQgyUzWxAum1FxyyqD
|
|
||||||
/dns4/bootstrap-1-fra.fil-test.net/tcp/1347/p2p/12D3KooWGPDJAw3HW4uVU3JEQBfFaZ1kdpg4HvvwRMVpUYbzhsLQ
|
|
||||||
/ip4/136.144.49.131/tcp/1347/p2p/12D3KooWGPDJAw3HW4uVU3JEQBfFaZ1kdpg4HvvwRMVpUYbzhsLQ
|
|
||||||
|
|||||||
Binary file not shown.
+1
-1
@@ -2,6 +2,6 @@ package build
|
|||||||
|
|
||||||
import rice "github.com/GeertJohan/go.rice"
|
import rice "github.com/GeertJohan/go.rice"
|
||||||
|
|
||||||
func ParametersJson() []byte {
|
func ParametersJSON() []byte {
|
||||||
return rice.MustFindBox("proof-params").MustBytes("parameters.json")
|
return rice.MustFindBox("proof-params").MustBytes("parameters.json")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ func init() {
|
|||||||
abi.RegisteredProof_StackedDRG2KiBSeal: {},
|
abi.RegisteredProof_StackedDRG2KiBSeal: {},
|
||||||
}
|
}
|
||||||
verifreg.MinVerifiedDealSize = big.NewInt(256)
|
verifreg.MinVerifiedDealSize = big.NewInt(256)
|
||||||
|
|
||||||
|
BuildType |= Build2k
|
||||||
}
|
}
|
||||||
|
|
||||||
// Seconds
|
// Seconds
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ package build
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
InsecurePoStValidation = true
|
InsecurePoStValidation = true
|
||||||
|
BuildType |= BuildDebug
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: Also includes settings from params_2k
|
// NOTE: Also includes settings from params_2k
|
||||||
|
|||||||
@@ -118,11 +118,6 @@ const VerifSigCacheSize = 32000
|
|||||||
|
|
||||||
// TODO: If this is gonna stay, it should move to specs-actors
|
// TODO: If this is gonna stay, it should move to specs-actors
|
||||||
const BlockMessageLimit = 512
|
const BlockMessageLimit = 512
|
||||||
const BlockGasLimit = 100_000_000
|
const BlockGasLimit = 100_000_000_000
|
||||||
|
|
||||||
var DrandCoeffs = []string{
|
var DrandChain = `{"public_key":"922a2e93828ff83345bae533f5172669a26c02dc76d6bf59c80892e12ab1455c229211886f35bb56af6d5bea981024df","period":25,"genesis_time":1590445175,"hash":"138a324aa6540f93d0dad002aa89454b1bec2b6e948682cde6bd4db40f4b7c9b"}`
|
||||||
"82c279cce744450e68de98ee08f9698a01dd38f8e3be3c53f2b840fb9d09ad62a0b6b87981e179e1b14bc9a2d284c985",
|
|
||||||
"82d51308ad346c686f81b8094551597d7b963295cbf313401a93df9baf52d5ae98a87745bee70839a4d6e65c342bd15b",
|
|
||||||
"94eebfd53f4ba6a3b8304236400a12e73885e5a781509a5c8d41d2e8b476923d8ea6052649b3c17282f596217f96c5de",
|
|
||||||
"8dc4231e42b4edf39e86ef1579401692480647918275da767d3e558c520d6375ad953530610fd27daf110187877a65d0",
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -12,10 +12,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
power.ConsensusMinerMinPower = big.NewInt(1024 << 30)
|
power.ConsensusMinerMinPower = big.NewInt(1024 << 20)
|
||||||
miner.SupportedProofTypes = map[abi.RegisteredProof]struct{}{
|
miner.SupportedProofTypes = map[abi.RegisteredProof]struct{}{
|
||||||
abi.RegisteredProof_StackedDRG32GiBSeal: {},
|
abi.RegisteredProof_StackedDRG512MiBSeal: {},
|
||||||
abi.RegisteredProof_StackedDRG64GiBSeal: {},
|
abi.RegisteredProof_StackedDRG32GiBSeal: {},
|
||||||
|
abi.RegisteredProof_StackedDRG64GiBSeal: {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+25
-2
@@ -3,11 +3,33 @@ package build
|
|||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
var CurrentCommit string
|
var CurrentCommit string
|
||||||
|
var BuildType int
|
||||||
|
|
||||||
|
const (
|
||||||
|
BuildDefault = 0
|
||||||
|
Build2k = 0x1
|
||||||
|
BuildDebug = 0x3
|
||||||
|
)
|
||||||
|
|
||||||
|
func buildType() string {
|
||||||
|
switch BuildType {
|
||||||
|
case BuildDefault:
|
||||||
|
return ""
|
||||||
|
case BuildDebug:
|
||||||
|
return "+debug"
|
||||||
|
case Build2k:
|
||||||
|
return "+2k"
|
||||||
|
default:
|
||||||
|
return "+huh?"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// BuildVersion is the local build version, set by build system
|
// BuildVersion is the local build version, set by build system
|
||||||
const BuildVersion = "0.3.0"
|
const BuildVersion = "0.4.0"
|
||||||
|
|
||||||
var UserVersion = BuildVersion + CurrentCommit
|
func UserVersion() string {
|
||||||
|
return BuildVersion + buildType() + CurrentCommit
|
||||||
|
}
|
||||||
|
|
||||||
type Version uint32
|
type Version uint32
|
||||||
|
|
||||||
@@ -33,6 +55,7 @@ func (ve Version) EqMajorMinor(v2 Version) bool {
|
|||||||
// APIVersion is a semver version of the rpc api exposed
|
// APIVersion is a semver version of the rpc api exposed
|
||||||
var APIVersion Version = newVer(0, 3, 0)
|
var APIVersion Version = newVer(0, 3, 0)
|
||||||
|
|
||||||
|
//nolint:varcheck
|
||||||
const (
|
const (
|
||||||
majorMask = 0xff0000
|
majorMask = 0xff0000
|
||||||
minorMask = 0xffff00
|
minorMask = 0xffff00
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ func Newf(retCode exitcode.ExitCode, format string, args ...interface{}) ActorEr
|
|||||||
}
|
}
|
||||||
|
|
||||||
// todo: bit hacky
|
// todo: bit hacky
|
||||||
|
|
||||||
func NewfSkip(skip int, retCode exitcode.ExitCode, format string, args ...interface{}) ActorError {
|
func NewfSkip(skip int, retCode exitcode.ExitCode, format string, args ...interface{}) ActorError {
|
||||||
if retCode == 0 {
|
if retCode == 0 {
|
||||||
return &actorError{
|
return &actorError{
|
||||||
|
|||||||
+74
-116
@@ -1,45 +1,45 @@
|
|||||||
package drand
|
package drand
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"math/rand"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
dchain "github.com/drand/drand/chain"
|
||||||
|
dclient "github.com/drand/drand/client"
|
||||||
|
gclient "github.com/drand/drand/cmd/relay-gossip/client"
|
||||||
|
dlog "github.com/drand/drand/log"
|
||||||
|
"github.com/drand/kyber"
|
||||||
|
kzap "github.com/go-kit/kit/log/zap"
|
||||||
|
"go.uber.org/zap/zapcore"
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
|
logging "github.com/ipfs/go-log"
|
||||||
|
pubsub "github.com/libp2p/go-libp2p-pubsub"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/lotus/chain/beacon"
|
"github.com/filecoin-project/lotus/chain/beacon"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"golang.org/x/xerrors"
|
|
||||||
|
|
||||||
logging "github.com/ipfs/go-log"
|
|
||||||
|
|
||||||
dbeacon "github.com/drand/drand/beacon"
|
|
||||||
"github.com/drand/drand/core"
|
|
||||||
dkey "github.com/drand/drand/key"
|
|
||||||
dnet "github.com/drand/drand/net"
|
|
||||||
dproto "github.com/drand/drand/protobuf/drand"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var log = logging.Logger("drand")
|
var log = logging.Logger("drand")
|
||||||
|
|
||||||
var drandServers = []string{
|
var drandServers = []string{
|
||||||
"nicolas.drand.fil-test.net:443",
|
"https://pl-eu.testnet.drand.sh",
|
||||||
"philipp.drand.fil-test.net:443",
|
"https://pl-us.testnet.drand.sh",
|
||||||
"mathilde.drand.fil-test.net:443",
|
"https://pl-sin.testnet.drand.sh",
|
||||||
"ludovic.drand.fil-test.net:443",
|
|
||||||
"gabbi.drand.fil-test.net:443",
|
|
||||||
"linus.drand.fil-test.net:443",
|
|
||||||
"jeff.drand.fil-test.net:443",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var drandPubKey *dkey.DistPublic
|
var drandChain *dchain.Info
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
drandPubKey = new(dkey.DistPublic)
|
|
||||||
err := drandPubKey.FromTOML(&dkey.DistPublicTOML{Coefficients: build.DrandCoeffs})
|
var err error
|
||||||
|
drandChain, err = dchain.InfoFromJSON(bytes.NewReader([]byte(build.DrandChain)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic("could not unmarshal chain info: " + err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,13 +57,9 @@ func (dp *drandPeer) IsTLS() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type DrandBeacon struct {
|
type DrandBeacon struct {
|
||||||
client dnet.Client
|
client dclient.Client
|
||||||
|
|
||||||
peers []dnet.Peer
|
pubkey kyber.Point
|
||||||
peersIndex int
|
|
||||||
peersIndexMtx sync.Mutex
|
|
||||||
|
|
||||||
pubkey *dkey.DistPublic
|
|
||||||
|
|
||||||
// seconds
|
// seconds
|
||||||
interval time.Duration
|
interval time.Duration
|
||||||
@@ -76,120 +72,83 @@ type DrandBeacon struct {
|
|||||||
localCache map[uint64]types.BeaconEntry
|
localCache map[uint64]types.BeaconEntry
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDrandBeacon(genesisTs, interval uint64) (*DrandBeacon, error) {
|
func NewDrandBeacon(genesisTs, interval uint64, ps *pubsub.PubSub) (*DrandBeacon, error) {
|
||||||
if genesisTs == 0 {
|
if genesisTs == 0 {
|
||||||
panic("what are you doing this cant be zero")
|
panic("what are you doing this cant be zero")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dlogger := dlog.NewKitLoggerFrom(kzap.NewZapSugarLogger(
|
||||||
|
log.SugaredLogger.Desugar(), zapcore.InfoLevel))
|
||||||
|
opts := []dclient.Option{
|
||||||
|
dclient.WithChainInfo(drandChain),
|
||||||
|
dclient.WithHTTPEndpoints(drandServers),
|
||||||
|
dclient.WithCacheSize(1024),
|
||||||
|
dclient.WithLogger(dlogger),
|
||||||
|
}
|
||||||
|
|
||||||
|
if ps != nil {
|
||||||
|
opts = append(opts, gclient.WithPubsub(ps))
|
||||||
|
} else {
|
||||||
|
log.Info("drand beacon without pubsub")
|
||||||
|
}
|
||||||
|
|
||||||
|
client, err := dclient.New(opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, xerrors.Errorf("creating drand client")
|
||||||
|
}
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
// Explicitly Watch until that is fixed in drand
|
||||||
|
ch := client.Watch(context.Background())
|
||||||
|
for range ch {
|
||||||
|
}
|
||||||
|
log.Error("dranch Watch bork")
|
||||||
|
}()
|
||||||
|
|
||||||
db := &DrandBeacon{
|
db := &DrandBeacon{
|
||||||
client: dnet.NewGrpcClient(),
|
client: client,
|
||||||
localCache: make(map[uint64]types.BeaconEntry),
|
localCache: make(map[uint64]types.BeaconEntry),
|
||||||
}
|
}
|
||||||
for _, ds := range drandServers {
|
|
||||||
db.peers = append(db.peers, &drandPeer{addr: ds, tls: true})
|
|
||||||
}
|
|
||||||
|
|
||||||
db.peersIndex = rand.Intn(len(db.peers))
|
db.pubkey = drandChain.PublicKey
|
||||||
|
db.interval = drandChain.Period
|
||||||
groupResp, err := db.client.Group(context.TODO(), db.peers[db.peersIndex], &dproto.GroupRequest{})
|
db.drandGenTime = uint64(drandChain.GenesisTime)
|
||||||
if err != nil {
|
|
||||||
return nil, xerrors.Errorf("failed to get group response from beacon peer: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
kgroup, err := core.ProtoToGroup(groupResp)
|
|
||||||
if err != nil {
|
|
||||||
return nil, xerrors.Errorf("failed to parse group response: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: verify these values are what we expect them to be
|
|
||||||
if !kgroup.PublicKey.Equal(drandPubKey) {
|
|
||||||
return nil, xerrors.Errorf("public key does not match")
|
|
||||||
}
|
|
||||||
// fmt.Printf("Drand Pubkey:\n%#v\n", kgroup.PublicKey.TOML()) // use to print public key
|
|
||||||
db.pubkey = drandPubKey
|
|
||||||
db.interval = kgroup.Period
|
|
||||||
db.drandGenTime = uint64(kgroup.GenesisTime)
|
|
||||||
db.filRoundTime = interval
|
db.filRoundTime = interval
|
||||||
db.filGenTime = genesisTs
|
db.filGenTime = genesisTs
|
||||||
|
|
||||||
// TODO: the stream currently gives you back *all* values since drand genesis.
|
|
||||||
// Having the stream in the background is merely an optimization, so not a big deal to disable it for now
|
|
||||||
// go db.handleStreamingUpdates()
|
|
||||||
|
|
||||||
return db, nil
|
return db, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *DrandBeacon) rotatePeersIndex() {
|
|
||||||
db.peersIndexMtx.Lock()
|
|
||||||
nval := rand.Intn(len(db.peers))
|
|
||||||
db.peersIndex = nval
|
|
||||||
db.peersIndexMtx.Unlock()
|
|
||||||
|
|
||||||
log.Warnf("rotated to drand peer %d, %q", nval, db.peers[nval].Address())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (db *DrandBeacon) getPeerIndex() int {
|
|
||||||
db.peersIndexMtx.Lock()
|
|
||||||
defer db.peersIndexMtx.Unlock()
|
|
||||||
return db.peersIndex
|
|
||||||
}
|
|
||||||
|
|
||||||
func (db *DrandBeacon) handleStreamingUpdates() {
|
|
||||||
for {
|
|
||||||
p := db.peers[db.getPeerIndex()]
|
|
||||||
ch, err := db.client.PublicRandStream(context.Background(), p, &dproto.PublicRandRequest{})
|
|
||||||
if err != nil {
|
|
||||||
log.Warnf("failed to get public rand stream to peer %q: %s", p.Address(), err)
|
|
||||||
log.Warnf("trying again in 10 seconds")
|
|
||||||
db.rotatePeersIndex()
|
|
||||||
time.Sleep(time.Second * 10)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
for e := range ch {
|
|
||||||
db.cacheValue(types.BeaconEntry{
|
|
||||||
Round: e.Round,
|
|
||||||
Data: e.Signature,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Warnf("drand beacon stream to peer %q broke, reconnecting in 10 seconds", p.Address())
|
|
||||||
db.rotatePeersIndex()
|
|
||||||
time.Sleep(time.Second * 10)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (db *DrandBeacon) Entry(ctx context.Context, round uint64) <-chan beacon.Response {
|
func (db *DrandBeacon) Entry(ctx context.Context, round uint64) <-chan beacon.Response {
|
||||||
// check cache, it it if there, otherwise query the endpoint
|
|
||||||
cres := db.getCachedValue(round)
|
|
||||||
if cres != nil {
|
|
||||||
out := make(chan beacon.Response, 1)
|
|
||||||
out <- beacon.Response{Entry: *cres}
|
|
||||||
close(out)
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
|
|
||||||
out := make(chan beacon.Response, 1)
|
out := make(chan beacon.Response, 1)
|
||||||
|
if round != 0 {
|
||||||
|
be := db.getCachedValue(round)
|
||||||
|
if be != nil {
|
||||||
|
out <- beacon.Response{Entry: *be}
|
||||||
|
close(out)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
p := db.peers[db.getPeerIndex()]
|
start := time.Now()
|
||||||
resp, err := db.client.PublicRand(ctx, p, &dproto.PublicRandRequest{Round: round})
|
log.Infow("start fetching randomness", "round", round)
|
||||||
|
resp, err := db.client.Get(ctx, round)
|
||||||
|
|
||||||
var br beacon.Response
|
var br beacon.Response
|
||||||
if err != nil {
|
if err != nil {
|
||||||
db.rotatePeersIndex()
|
br.Err = xerrors.Errorf("drand failed Get request: %w", err)
|
||||||
br.Err = xerrors.Errorf("drand peer %q failed publicRand request: %w", p.Address(), err)
|
|
||||||
} else {
|
} else {
|
||||||
br.Entry.Round = resp.GetRound()
|
br.Entry.Round = resp.Round()
|
||||||
br.Entry.Data = resp.GetSignature()
|
br.Entry.Data = resp.Signature()
|
||||||
}
|
}
|
||||||
|
log.Infow("done fetching randomness", "round", round, "took", time.Since(start))
|
||||||
out <- br
|
out <- br
|
||||||
close(out)
|
close(out)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *DrandBeacon) cacheValue(e types.BeaconEntry) {
|
func (db *DrandBeacon) cacheValue(e types.BeaconEntry) {
|
||||||
db.cacheLk.Lock()
|
db.cacheLk.Lock()
|
||||||
defer db.cacheLk.Unlock()
|
defer db.cacheLk.Unlock()
|
||||||
@@ -211,13 +170,12 @@ func (db *DrandBeacon) VerifyEntry(curr types.BeaconEntry, prev types.BeaconEntr
|
|||||||
// TODO handle genesis better
|
// TODO handle genesis better
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
b := &dbeacon.Beacon{
|
b := &dchain.Beacon{
|
||||||
PreviousSig: prev.Data,
|
PreviousSig: prev.Data,
|
||||||
Round: curr.Round,
|
Round: curr.Round,
|
||||||
Signature: curr.Data,
|
Signature: curr.Data,
|
||||||
}
|
}
|
||||||
//log.Warnw("VerifyEntry", "beacon", b)
|
err := dchain.VerifyBeacon(db.pubkey, b)
|
||||||
err := dbeacon.VerifyBeacon(db.pubkey.Key(), b)
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
db.cacheValue(curr)
|
db.cacheValue(curr)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,22 @@
|
|||||||
package drand
|
package drand
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
dchain "github.com/drand/drand/chain"
|
||||||
|
dclient "github.com/drand/drand/client"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPrintDrandPubkey(t *testing.T) {
|
func TestPrintGroupInfo(t *testing.T) {
|
||||||
bc, err := NewDrandBeacon(1, 1)
|
c, err := dclient.NewHTTPClient(drandServers[0], nil, nil)
|
||||||
if err != nil {
|
assert.NoError(t, err)
|
||||||
t.Fatal(err)
|
cg := c.(interface {
|
||||||
}
|
FetchChainInfo(groupHash []byte) (*dchain.Info, error)
|
||||||
fmt.Printf("Drand Pubkey:\n%#v\n", bc.pubkey.TOML())
|
})
|
||||||
|
chain, err := cg.FetchChainInfo(nil)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
err = chain.ToJSON(os.Stdout)
|
||||||
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ func (bss *BlockSyncService) HandleStream(s inet.Stream) {
|
|||||||
ctx, span := trace.StartSpan(context.Background(), "blocksync.HandleStream")
|
ctx, span := trace.StartSpan(context.Background(), "blocksync.HandleStream")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
defer s.Close()
|
defer s.Close() //nolint:errcheck
|
||||||
|
|
||||||
var req BlockSyncRequest
|
var req BlockSyncRequest
|
||||||
if err := cborutil.ReadCborRPC(bufio.NewReader(s), &req); err != nil {
|
if err := cborutil.ReadCborRPC(bufio.NewReader(s), &req); err != nil {
|
||||||
@@ -107,7 +107,7 @@ func (bss *BlockSyncService) HandleStream(s inet.Stream) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
writeDeadline := 60 * time.Second
|
writeDeadline := 60 * time.Second
|
||||||
s.SetDeadline(time.Now().Add(writeDeadline))
|
_ = s.SetDeadline(time.Now().Add(writeDeadline))
|
||||||
if err := cborutil.WriteCborRPC(s, resp); err != nil {
|
if err := cborutil.WriteCborRPC(s, resp); err != nil {
|
||||||
log.Warnw("failed to write back response for handle stream", "err", err, "peer", s.Conn().RemotePeer())
|
log.Warnw("failed to write back response for handle stream", "err", err, "peer", s.Conn().RemotePeer())
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -283,14 +283,14 @@ func (bs *BlockSync) fetchBlocksBlockSync(ctx context.Context, p peer.ID, req *B
|
|||||||
bs.RemovePeer(p)
|
bs.RemovePeer(p)
|
||||||
return nil, xerrors.Errorf("failed to open stream to peer: %w", err)
|
return nil, xerrors.Errorf("failed to open stream to peer: %w", err)
|
||||||
}
|
}
|
||||||
s.SetWriteDeadline(time.Now().Add(5 * time.Second))
|
_ = s.SetWriteDeadline(time.Now().Add(5 * time.Second))
|
||||||
|
|
||||||
if err := cborutil.WriteCborRPC(s, req); err != nil {
|
if err := cborutil.WriteCborRPC(s, req); err != nil {
|
||||||
s.SetWriteDeadline(time.Time{})
|
_ = s.SetWriteDeadline(time.Time{})
|
||||||
bs.syncPeers.logFailure(p, time.Since(start))
|
bs.syncPeers.logFailure(p, time.Since(start))
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
s.SetWriteDeadline(time.Time{})
|
_ = s.SetWriteDeadline(time.Time{})
|
||||||
|
|
||||||
var res BlockSyncResponse
|
var res BlockSyncResponse
|
||||||
r := incrt.New(s, 50<<10, 5*time.Second)
|
r := incrt.New(s, 50<<10, 5*time.Second)
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ func NewEvents(ctx context.Context, api eventApi) *Events {
|
|||||||
heightEvents: heightEvents{
|
heightEvents: heightEvents{
|
||||||
tsc: tsc,
|
tsc: tsc,
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
gcConfidence: abi.ChainEpoch(gcConfidence),
|
gcConfidence: gcConfidence,
|
||||||
|
|
||||||
heightTriggers: map[uint64]*heightHandler{},
|
heightTriggers: map[uint64]*heightHandler{},
|
||||||
htTriggerHeights: map[abi.ChainEpoch][]uint64{},
|
htTriggerHeights: map[abi.ChainEpoch][]uint64{},
|
||||||
|
|||||||
+5
-1
@@ -104,7 +104,7 @@ func NewGeneratorWithSectors(numSectors int) (*ChainGen, error) {
|
|||||||
return nil, xerrors.Errorf("failed to get metadata datastore: %w", err)
|
return nil, xerrors.Errorf("failed to get metadata datastore: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
bds, err := lr.Datastore("/blocks")
|
bds, err := lr.Datastore("/chain")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("failed to get blocks datastore: %w", err)
|
return nil, xerrors.Errorf("failed to get blocks datastore: %w", err)
|
||||||
}
|
}
|
||||||
@@ -219,6 +219,10 @@ func NewGeneratorWithSectors(numSectors int) (*ChainGen, error) {
|
|||||||
miners := []address.Address{maddr1, maddr2}
|
miners := []address.Address{maddr1, maddr2}
|
||||||
|
|
||||||
beac := beacon.NewMockBeacon(time.Second)
|
beac := beacon.NewMockBeacon(time.Second)
|
||||||
|
//beac, err := drand.NewDrandBeacon(tpl.Timestamp, build.BlockDelay)
|
||||||
|
//if err != nil {
|
||||||
|
//return nil, xerrors.Errorf("creating drand beacon: %w", err)
|
||||||
|
//}
|
||||||
|
|
||||||
gen := &ChainGen{
|
gen := &ChainGen{
|
||||||
bs: bs,
|
bs: bs,
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
|
|||||||
|
|
||||||
for i, m := range miners {
|
for i, m := range miners {
|
||||||
// Create miner through power actor
|
// Create miner through power actor
|
||||||
|
i := i
|
||||||
|
m := m
|
||||||
|
|
||||||
spt, err := ffiwrapper.SealProofTypeFromSectorSize(m.SectorSize)
|
spt, err := ffiwrapper.SealProofTypeFromSectorSize(m.SectorSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -154,6 +156,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
|
|||||||
|
|
||||||
// Commit sectors
|
// Commit sectors
|
||||||
for pi, preseal := range m.Sectors {
|
for pi, preseal := range m.Sectors {
|
||||||
|
preseal := preseal
|
||||||
// TODO: Maybe check seal (Can just be snark inputs, doesn't go into the genesis file)
|
// TODO: Maybe check seal (Can just be snark inputs, doesn't go into the genesis file)
|
||||||
|
|
||||||
// check deals, get dealWeight
|
// check deals, get dealWeight
|
||||||
|
|||||||
@@ -255,12 +255,15 @@ func TestStateTreeConsistency(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for i, a := range addrs {
|
for i, a := range addrs {
|
||||||
st.SetActor(a, &types.Actor{
|
err := st.SetActor(a, &types.Actor{
|
||||||
Code: randomCid,
|
Code: randomCid,
|
||||||
Head: randomCid,
|
Head: randomCid,
|
||||||
Balance: types.NewInt(uint64(10000 + i)),
|
Balance: types.NewInt(uint64(10000 + i)),
|
||||||
Nonce: uint64(1000 - i),
|
Nonce: uint64(1000 - i),
|
||||||
})
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("while setting actor: %+v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
root, err := st.Flush(context.TODO())
|
root, err := st.Flush(context.TODO())
|
||||||
|
|||||||
@@ -382,8 +382,8 @@ func (sm *StateManager) LoadActorState(ctx context.Context, a address.Address, o
|
|||||||
cst := cbor.NewCborStore(sm.cs.Blockstore())
|
cst := cbor.NewCborStore(sm.cs.Blockstore())
|
||||||
if err := cst.Get(ctx, act.Head, out); err != nil {
|
if err := cst.Get(ctx, act.Head, out); err != nil {
|
||||||
var r cbg.Deferred
|
var r cbg.Deferred
|
||||||
cst.Get(ctx, act.Head, &r)
|
_ = cst.Get(ctx, act.Head, &r)
|
||||||
fmt.Printf("badhead %x\n", r.Raw)
|
log.Errorw("bad actor head", "error", err, "raw", r.Raw, "address", a)
|
||||||
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -610,9 +610,9 @@ func (sm *StateManager) searchBackForMsg(ctx context.Context, from *types.TipSet
|
|||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// we either have no messages from the sender, or the latest message we found has a lower nonce than the one being searched for,
|
if act.Nonce < m.VMMessage().Nonce {
|
||||||
// either way, no reason to lookback, it ain't there
|
// nonce on chain is before message nonce we're looking for, its
|
||||||
if act.Nonce == 0 || act.Nonce < m.VMMessage().Nonce {
|
// not going to be here
|
||||||
return nil, nil, nil
|
return nil, nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -138,6 +138,24 @@ func PreCommitInfo(ctx context.Context, sm *StateManager, maddr address.Address,
|
|||||||
return *i, nil
|
return *i, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func MinerSectorInfo(ctx context.Context, sm *StateManager, maddr address.Address, sid abi.SectorNumber, ts *types.TipSet) (*miner.SectorOnChainInfo, error) {
|
||||||
|
var mas miner.State
|
||||||
|
_, err := sm.LoadActorState(ctx, maddr, &mas, ts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, xerrors.Errorf("(get sset) failed to load miner actor state: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
sectorInfo, ok, err := mas.GetSector(sm.cs.Store(ctx), sid)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if !ok {
|
||||||
|
return nil, xerrors.New("sector not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
return sectorInfo, nil
|
||||||
|
}
|
||||||
|
|
||||||
func GetMinerSectorSet(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address, filter *abi.BitField, filterOut bool) ([]*api.ChainSectorInfo, error) {
|
func GetMinerSectorSet(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address, filter *abi.BitField, filterOut bool) ([]*api.ChainSectorInfo, error) {
|
||||||
var mas miner.State
|
var mas miner.State
|
||||||
_, err := sm.LoadActorState(ctx, maddr, &mas, ts)
|
_, err := sm.LoadActorState(ctx, maddr, &mas, ts)
|
||||||
|
|||||||
@@ -895,11 +895,17 @@ func DrawRandomness(rbase []byte, pers crypto.DomainSeparationTag, round abi.Cha
|
|||||||
return nil, xerrors.Errorf("deriving randomness: %w", err)
|
return nil, xerrors.Errorf("deriving randomness: %w", err)
|
||||||
}
|
}
|
||||||
VRFDigest := blake2b.Sum256(rbase)
|
VRFDigest := blake2b.Sum256(rbase)
|
||||||
h.Write(VRFDigest[:])
|
_, err := h.Write(VRFDigest[:])
|
||||||
|
if err != nil {
|
||||||
|
return nil, xerrors.Errorf("hashing VRFDigest: %w", err)
|
||||||
|
}
|
||||||
if err := binary.Write(h, binary.BigEndian, round); err != nil {
|
if err := binary.Write(h, binary.BigEndian, round); err != nil {
|
||||||
return nil, xerrors.Errorf("deriving randomness: %w", err)
|
return nil, xerrors.Errorf("deriving randomness: %w", err)
|
||||||
}
|
}
|
||||||
h.Write(entropy)
|
_, err = h.Write(entropy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, xerrors.Errorf("hashing entropy: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
return h.Sum(nil), nil
|
return h.Sum(nil), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ func BenchmarkGetRandomness(b *testing.B) {
|
|||||||
b.Fatal(err)
|
b.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
bds, err := lr.Datastore("/blocks")
|
bds, err := lr.Datastore("/chain")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatal(err)
|
b.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -417,7 +417,7 @@ func TestSyncBadTimestamp(t *testing.T) {
|
|||||||
a1 := tu.mineOnBlock(base, 0, nil, false, true)
|
a1 := tu.mineOnBlock(base, 0, nil, false, true)
|
||||||
|
|
||||||
tu.g.Timestamper = nil
|
tu.g.Timestamper = nil
|
||||||
tu.g.ResyncBankerNonce(a1.TipSet())
|
require.NoError(t, tu.g.ResyncBankerNonce(a1.TipSet()))
|
||||||
|
|
||||||
fmt.Println("After mine bad block!")
|
fmt.Println("After mine bad block!")
|
||||||
tu.printHeads()
|
tu.printHeads()
|
||||||
@@ -479,7 +479,7 @@ func TestSyncFork(t *testing.T) {
|
|||||||
a := tu.mineOnBlock(a1, p1, []int{0}, true, false)
|
a := tu.mineOnBlock(a1, p1, []int{0}, true, false)
|
||||||
a = tu.mineOnBlock(a, p1, []int{0}, true, false)
|
a = tu.mineOnBlock(a, p1, []int{0}, true, false)
|
||||||
|
|
||||||
tu.g.ResyncBankerNonce(a1.TipSet())
|
require.NoError(t, tu.g.ResyncBankerNonce(a1.TipSet()))
|
||||||
// chain B will now be heaviest
|
// chain B will now be heaviest
|
||||||
b := tu.mineOnBlock(base, p2, []int{1}, true, false)
|
b := tu.mineOnBlock(base, p2, []int{1}, true, false)
|
||||||
b = tu.mineOnBlock(b, p2, []int{1}, true, false)
|
b = tu.mineOnBlock(b, p2, []int{1}, true, false)
|
||||||
|
|||||||
@@ -4,13 +4,14 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/crypto"
|
|
||||||
cid "github.com/ipfs/go-cid"
|
cid "github.com/ipfs/go-cid"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/crypto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func testBlockHeader(t testing.TB) *BlockHeader {
|
func testBlockHeader(t testing.TB) *BlockHeader {
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
import "time"
|
|
||||||
|
|
||||||
type ExecutionResult struct {
|
type ExecutionResult struct {
|
||||||
Msg *Message
|
Msg *Message
|
||||||
MsgRct *MessageReceipt
|
MsgRct *MessageReceipt
|
||||||
Error string
|
Error string
|
||||||
Duration time.Duration
|
|
||||||
|
|
||||||
Subcalls []*ExecutionResult
|
Subcalls []*ExecutionResult
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/gen"
|
"github.com/filecoin-project/lotus/chain/gen"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
@@ -173,14 +174,18 @@ func WriteJsonToFile(fname string, obj interface{}) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer fi.Close()
|
defer fi.Close() //nolint:errcheck
|
||||||
|
|
||||||
out, err := json.MarshalIndent(obj, "", " ")
|
out, err := json.MarshalIndent(obj, "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
fi.Write(out)
|
_, err = fi.Write(out)
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("writing json: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package vm
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-address"
|
||||||
addr "github.com/filecoin-project/go-address"
|
addr "github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/crypto"
|
"github.com/filecoin-project/specs-actors/actors/crypto"
|
||||||
@@ -143,3 +144,8 @@ func (ps pricedSyscalls) VerifyConsensusFault(h1 []byte, h2 []byte, extra []byte
|
|||||||
ps.chargeGas(ps.pl.OnVerifyConsensusFault())
|
ps.chargeGas(ps.pl.OnVerifyConsensusFault())
|
||||||
return ps.under.VerifyConsensusFault(h1, h2, extra)
|
return ps.under.VerifyConsensusFault(h1, h2, extra)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ps pricedSyscalls) BatchVerifySeals(inp map[address.Address][]abi.SealVerifyInfo) (map[address.Address][]bool, error) {
|
||||||
|
ps.chargeGas(0) // TODO: this is only called by the cron actor. Should we even charge gas?
|
||||||
|
return ps.under.BatchVerifySeals(inp)
|
||||||
|
}
|
||||||
|
|||||||
+8
-9
@@ -5,7 +5,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
@@ -184,7 +183,7 @@ func (rs *Runtime) ValidateImmediateCallerAcceptAny() {
|
|||||||
func (rs *Runtime) CurrentBalance() abi.TokenAmount {
|
func (rs *Runtime) CurrentBalance() abi.TokenAmount {
|
||||||
b, err := rs.GetBalance(rs.Message().Receiver())
|
b, err := rs.GetBalance(rs.Message().Receiver())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rs.Abortf(exitcode.ExitCode(err.RetCode()), "get current balance: %v", err)
|
rs.Abortf(err.RetCode(), "get current balance: %v", err)
|
||||||
}
|
}
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
@@ -356,19 +355,18 @@ func (rs *Runtime) Send(to address.Address, method abi.MethodNum, m vmr.CBORMars
|
|||||||
params = buf.Bytes()
|
params = buf.Bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
ret, err := rs.internalSend(rs.Message().Receiver(), to, method, types.BigInt(value), params)
|
ret, err := rs.internalSend(rs.Message().Receiver(), to, method, value, params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err.IsFatal() {
|
if err.IsFatal() {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
log.Warnf("vmctx send failed: to: %s, method: %d: ret: %d, err: %s", to, method, ret, err)
|
log.Warnf("vmctx send failed: to: %s, method: %d: ret: %d, err: %s", to, method, ret, err)
|
||||||
return nil, exitcode.ExitCode(err.RetCode())
|
return nil, err.RetCode()
|
||||||
}
|
}
|
||||||
return &dumbWrapperType{ret}, 0
|
return &dumbWrapperType{ret}, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rt *Runtime) internalSend(from, to address.Address, method abi.MethodNum, value types.BigInt, params []byte) ([]byte, aerrors.ActorError) {
|
func (rt *Runtime) internalSend(from, to address.Address, method abi.MethodNum, value types.BigInt, params []byte) ([]byte, aerrors.ActorError) {
|
||||||
start := time.Now()
|
|
||||||
ctx, span := trace.StartSpan(rt.ctx, "vmc.Send")
|
ctx, span := trace.StartSpan(rt.ctx, "vmc.Send")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
if span.IsRecordingEvents() {
|
if span.IsRecordingEvents() {
|
||||||
@@ -402,15 +400,14 @@ func (rt *Runtime) internalSend(from, to address.Address, method abi.MethodNum,
|
|||||||
}
|
}
|
||||||
|
|
||||||
mr := types.MessageReceipt{
|
mr := types.MessageReceipt{
|
||||||
ExitCode: exitcode.ExitCode(aerrors.RetCode(errSend)),
|
ExitCode: aerrors.RetCode(errSend),
|
||||||
Return: ret,
|
Return: ret,
|
||||||
GasUsed: 0,
|
GasUsed: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
er := types.ExecutionResult{
|
er := types.ExecutionResult{
|
||||||
Msg: msg,
|
Msg: msg,
|
||||||
MsgRct: &mr,
|
MsgRct: &mr,
|
||||||
Duration: time.Since(start),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if errSend != nil {
|
if errSend != nil {
|
||||||
@@ -435,6 +432,7 @@ type shimStateHandle struct {
|
|||||||
|
|
||||||
func (ssh *shimStateHandle) Create(obj vmr.CBORMarshaler) {
|
func (ssh *shimStateHandle) Create(obj vmr.CBORMarshaler) {
|
||||||
c := ssh.rs.Put(obj)
|
c := ssh.rs.Put(obj)
|
||||||
|
// TODO: handle error below
|
||||||
ssh.rs.stateCommit(EmptyObjectCid, c)
|
ssh.rs.stateCommit(EmptyObjectCid, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -464,6 +462,7 @@ func (ssh *shimStateHandle) Transaction(obj vmr.CBORer, f func() interface{}) in
|
|||||||
|
|
||||||
c := ssh.rs.Put(obj)
|
c := ssh.rs.Put(obj)
|
||||||
|
|
||||||
|
// TODO: handle error below
|
||||||
ssh.rs.stateCommit(baseState, c)
|
ssh.rs.stateCommit(baseState, c)
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|||||||
+28
-1
@@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
@@ -225,7 +226,7 @@ func (ss *syscallShim) VerifySeal(info abi.SealVerifyInfo) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ticket := []byte(info.Randomness)
|
ticket := []byte(info.Randomness)
|
||||||
proof := []byte(info.Proof)
|
proof := info.Proof
|
||||||
seed := []byte(info.InteractiveRandomness)
|
seed := []byte(info.InteractiveRandomness)
|
||||||
|
|
||||||
log.Debugf("Verif r:%x; d:%x; m:%s; t:%x; s:%x; N:%d; p:%x", info.SealedCID, info.UnsealedCID, miner, ticket, seed, info.SectorID.Number, proof)
|
log.Debugf("Verif r:%x; d:%x; m:%s; t:%x; s:%x; N:%d; p:%x", info.SealedCID, info.UnsealedCID, miner, ticket, seed, info.SectorID.Number, proof)
|
||||||
@@ -252,3 +253,29 @@ func (ss *syscallShim) VerifySignature(sig crypto.Signature, addr address.Addres
|
|||||||
|
|
||||||
return sigs.Verify(&sig, kaddr, input)
|
return sigs.Verify(&sig, kaddr, input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ss *syscallShim) BatchVerifySeals(inp map[address.Address][]abi.SealVerifyInfo) (map[address.Address][]bool, error) {
|
||||||
|
out := make(map[address.Address][]bool)
|
||||||
|
|
||||||
|
var wg sync.WaitGroup
|
||||||
|
for addr, seals := range inp {
|
||||||
|
results := make([]bool, len(seals))
|
||||||
|
out[addr] = results
|
||||||
|
|
||||||
|
for i, s := range seals {
|
||||||
|
wg.Add(1)
|
||||||
|
go func(ma address.Address, ix int, svi abi.SealVerifyInfo, res []bool) {
|
||||||
|
defer wg.Done()
|
||||||
|
if err := ss.VerifySeal(svi); err != nil {
|
||||||
|
log.Warnw("seal verify in batch failed", "miner", ma, "index", ix, "err", err)
|
||||||
|
res[ix] = false
|
||||||
|
} else {
|
||||||
|
res[ix] = true
|
||||||
|
}
|
||||||
|
}(addr, i, s, results)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wg.Wait()
|
||||||
|
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ func init() {
|
|||||||
func TestChainValidationMessageSuite(t *testing.T) {
|
func TestChainValidationMessageSuite(t *testing.T) {
|
||||||
f := factory.NewFactories()
|
f := factory.NewFactories()
|
||||||
for _, testCase := range suites.MessageTestCases() {
|
for _, testCase := range suites.MessageTestCases() {
|
||||||
|
testCase := testCase
|
||||||
if TestSuiteSkipper.Skip(testCase) {
|
if TestSuiteSkipper.Skip(testCase) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -53,6 +54,7 @@ func TestChainValidationMessageSuite(t *testing.T) {
|
|||||||
func TestChainValidationTipSetSuite(t *testing.T) {
|
func TestChainValidationTipSetSuite(t *testing.T) {
|
||||||
f := factory.NewFactories()
|
f := factory.NewFactories()
|
||||||
for _, testCase := range suites.TipSetTestCases() {
|
for _, testCase := range suites.TipSetTestCases() {
|
||||||
|
testCase := testCase
|
||||||
if TestSuiteSkipper.Skip(testCase) {
|
if TestSuiteSkipper.Skip(testCase) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
+20
-6
@@ -246,7 +246,7 @@ func (vm *VM) ApplyImplicitMessage(ctx context.Context, msg *types.Message) (*Ap
|
|||||||
ret, actorErr, rt := vm.send(ctx, msg, nil, 0)
|
ret, actorErr, rt := vm.send(ctx, msg, nil, 0)
|
||||||
return &ApplyRet{
|
return &ApplyRet{
|
||||||
MessageReceipt: types.MessageReceipt{
|
MessageReceipt: types.MessageReceipt{
|
||||||
ExitCode: exitcode.ExitCode(aerrors.RetCode(actorErr)),
|
ExitCode: aerrors.RetCode(actorErr),
|
||||||
Return: ret,
|
Return: ret,
|
||||||
GasUsed: 0,
|
GasUsed: 0,
|
||||||
},
|
},
|
||||||
@@ -415,7 +415,7 @@ func (vm *VM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet,
|
|||||||
|
|
||||||
return &ApplyRet{
|
return &ApplyRet{
|
||||||
MessageReceipt: types.MessageReceipt{
|
MessageReceipt: types.MessageReceipt{
|
||||||
ExitCode: exitcode.ExitCode(errcode),
|
ExitCode: errcode,
|
||||||
Return: ret,
|
Return: ret,
|
||||||
GasUsed: gasUsed,
|
GasUsed: gasUsed,
|
||||||
},
|
},
|
||||||
@@ -607,16 +607,30 @@ func (vm *VM) transfer(from, to address.Address, amt types.BigInt) aerrors.Actor
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fromId, err := vm.cstate.LookupID(from)
|
||||||
|
if err != nil {
|
||||||
|
return aerrors.Fatalf("transfer failed when resolving sender address: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
toId, err := vm.cstate.LookupID(to)
|
||||||
|
if err != nil {
|
||||||
|
return aerrors.Fatalf("transfer failed when resolving receiver address: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if fromId == toId {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if amt.LessThan(types.NewInt(0)) {
|
if amt.LessThan(types.NewInt(0)) {
|
||||||
return aerrors.Newf(exitcode.SysErrForbidden, "attempted to transfer negative value: %s", amt)
|
return aerrors.Newf(exitcode.SysErrForbidden, "attempted to transfer negative value: %s", amt)
|
||||||
}
|
}
|
||||||
|
|
||||||
f, err := vm.cstate.GetActor(from)
|
f, err := vm.cstate.GetActor(fromId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return aerrors.Fatalf("transfer failed when retrieving sender actor: %s", err)
|
return aerrors.Fatalf("transfer failed when retrieving sender actor: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
t, err := vm.cstate.GetActor(to)
|
t, err := vm.cstate.GetActor(toId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return aerrors.Fatalf("transfer failed when retrieving receiver actor: %s", err)
|
return aerrors.Fatalf("transfer failed when retrieving receiver actor: %s", err)
|
||||||
}
|
}
|
||||||
@@ -626,11 +640,11 @@ func (vm *VM) transfer(from, to address.Address, amt types.BigInt) aerrors.Actor
|
|||||||
}
|
}
|
||||||
depositFunds(t, amt)
|
depositFunds(t, amt)
|
||||||
|
|
||||||
if err := vm.cstate.SetActor(from, f); err != nil {
|
if err := vm.cstate.SetActor(fromId, f); err != nil {
|
||||||
return aerrors.Fatalf("transfer failed when setting receiver actor: %s", err)
|
return aerrors.Fatalf("transfer failed when setting receiver actor: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := vm.cstate.SetActor(to, t); err != nil {
|
if err := vm.cstate.SetActor(toId, t); err != nil {
|
||||||
return aerrors.Fatalf("transfer failed when setting sender actor: %s", err)
|
return aerrors.Fatalf("transfer failed when setting sender actor: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
|
|
||||||
_ "github.com/filecoin-project/lotus/lib/sigs/bls"
|
_ "github.com/filecoin-project/lotus/lib/sigs/bls" // enable bls signatures
|
||||||
_ "github.com/filecoin-project/lotus/lib/sigs/secp"
|
_ "github.com/filecoin-project/lotus/lib/sigs/secp" // enable secp signatures
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/lib/sigs"
|
"github.com/filecoin-project/lotus/lib/sigs"
|
||||||
|
|||||||
+6
-1
@@ -804,7 +804,12 @@ var chainExportCmd = &cli.Command{
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer fi.Close()
|
defer func() {
|
||||||
|
err := fi.Close()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("error closing output file: %+v", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
ts, err := LoadTipSet(ctx, cctx, api)
|
ts, err := LoadTipSet(ctx, cctx, api)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
+4
-1
@@ -206,7 +206,10 @@ var msigInspectCmd = &cli.Command{
|
|||||||
tx := pending[txid]
|
tx := pending[txid]
|
||||||
fmt.Fprintf(w, "%d\t%s\t%s\t%s\t%d\t%x\n", txid, state(tx), tx.To, types.FIL(tx.Value), tx.Method, tx.Params)
|
fmt.Fprintf(w, "%d\t%s\t%s\t%s\t%d\t%x\n", txid, state(tx), tx.To, types.FIL(tx.Value), tx.Method, tx.Params)
|
||||||
}
|
}
|
||||||
w.Flush()
|
if err := w.Flush(); err != nil {
|
||||||
|
return xerrors.Errorf("flushing output: %+v", err)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ var fetchParamCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
sectorSize := uint64(sectorSizeInt)
|
sectorSize := uint64(sectorSizeInt)
|
||||||
err = paramfetch.GetParams(build.ParametersJson(), sectorSize)
|
err = paramfetch.GetParams(build.ParametersJSON(), sectorSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("fetching proof parameters: %w", err)
|
return xerrors.Errorf("fetching proof parameters: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -370,7 +370,7 @@ var paychVoucherSubmitCmd = &cli.Command{
|
|||||||
return fmt.Errorf("message execution failed (exit code %d)", mwait.Receipt.ExitCode)
|
return fmt.Errorf("message execution failed (exit code %d)", mwait.Receipt.ExitCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("channel updated succesfully")
|
fmt.Println("channel updated successfully")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
|||||||
+2
-5
@@ -1082,15 +1082,12 @@ func printInternalExecutionsHtml(trace []*types.ExecutionResult, getCode func(ad
|
|||||||
ret = `, Return</div><div><pre class="ret">` + ret + `</pre></div>`
|
ret = `, Return</div><div><pre class="ret">` + ret + `</pre></div>`
|
||||||
}
|
}
|
||||||
|
|
||||||
slow := im.Duration > 10*time.Millisecond
|
|
||||||
veryslow := im.Duration > 50*time.Millisecond
|
|
||||||
|
|
||||||
fmt.Printf(`<div class="exec">
|
fmt.Printf(`<div class="exec">
|
||||||
<div><h4 class="call">%s:%s</h4></div>
|
<div><h4 class="call">%s:%s</h4></div>
|
||||||
<div><b>%s</b> -> <b>%s</b> (%s FIL), M%d</div>
|
<div><b>%s</b> -> <b>%s</b> (%s FIL), M%d</div>
|
||||||
%s
|
%s
|
||||||
<div><span class="slow-%t-%t">Took %s</span>, <span class="exit%d">Exit: <b>%d</b></span>%s
|
<div><span class="exit%d">Exit: <b>%d</b></span>%s
|
||||||
`, codeStr(toCode), methods[toCode][im.Msg.Method].name, im.Msg.From, im.Msg.To, types.FIL(im.Msg.Value), im.Msg.Method, params, slow, veryslow, im.Duration, im.MsgRct.ExitCode, im.MsgRct.ExitCode, ret)
|
`, codeStr(toCode), methods[toCode][im.Msg.Method].name, im.Msg.From, im.Msg.To, types.FIL(im.Msg.Value), im.Msg.Method, params, im.MsgRct.ExitCode, im.MsgRct.ExitCode, ret)
|
||||||
if im.MsgRct.ExitCode != 0 {
|
if im.MsgRct.ExitCode != 0 {
|
||||||
fmt.Printf(`<div class="error">Error: <pre>%s</pre></div>`, im.Error)
|
fmt.Printf(`<div class="error">Error: <pre>%s</pre></div>`, im.Error)
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -23,7 +23,9 @@ var versionCmd = &cli.Command{
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Println(v)
|
fmt.Println("Daemon: ", v)
|
||||||
|
|
||||||
|
fmt.Print("Local: ")
|
||||||
cli.VersionPrinter(cctx)
|
cli.VersionPrinter(cctx)
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -53,8 +53,7 @@ var runCmd = &cli.Command{
|
|||||||
defer closer()
|
defer closer()
|
||||||
ctx := lcli.ReqContext(cctx)
|
ctx := lcli.ReqContext(cctx)
|
||||||
|
|
||||||
sendSmallFundsTxs(ctx, api, addr, 5)
|
return sendSmallFundsTxs(ctx, api, addr, 5)
|
||||||
return nil
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ var importBenchCmd = &cli.Command{
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer cfi.Close()
|
defer cfi.Close() //nolint:errcheck // read only file
|
||||||
|
|
||||||
tdir, err := ioutil.TempDir("", "lotus-import-bench")
|
tdir, err := ioutil.TempDir("", "lotus-import-bench")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -80,7 +80,7 @@ var importBenchCmd = &cli.Command{
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer prof.Close()
|
defer prof.Close() //nolint:errcheck
|
||||||
|
|
||||||
if err := pprof.StartCPUProfile(prof); err != nil {
|
if err := pprof.StartCPUProfile(prof); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -146,7 +146,7 @@ var importBenchCmd = &cli.Command{
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer ibj.Close()
|
defer ibj.Close() //nolint:errcheck
|
||||||
|
|
||||||
if err := json.NewEncoder(ibj).Encode(out); err != nil {
|
if err := json.NewEncoder(ibj).Encode(out); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
+16
-12
@@ -78,7 +78,7 @@ func main() {
|
|||||||
app := &cli.App{
|
app := &cli.App{
|
||||||
Name: "lotus-bench",
|
Name: "lotus-bench",
|
||||||
Usage: "Benchmark performance of lotus on your hardware",
|
Usage: "Benchmark performance of lotus on your hardware",
|
||||||
Version: build.UserVersion,
|
Version: build.UserVersion(),
|
||||||
Commands: []*cli.Command{
|
Commands: []*cli.Command{
|
||||||
proveCmd,
|
proveCmd,
|
||||||
sealBenchCmd,
|
sealBenchCmd,
|
||||||
@@ -141,7 +141,10 @@ var sealBenchCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
if c.Bool("no-gpu") {
|
if c.Bool("no-gpu") {
|
||||||
os.Setenv("BELLMAN_NO_GPU", "1")
|
err := os.Setenv("BELLMAN_NO_GPU", "1")
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("setting no-gpu flag: %w", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
robench := c.String("benchmark-existing-sectorbuilder")
|
robench := c.String("benchmark-existing-sectorbuilder")
|
||||||
@@ -154,7 +157,10 @@ var sealBenchCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
os.MkdirAll(sdir, 0775)
|
err = os.MkdirAll(sdir, 0775) //nolint:gosec
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("creating sectorbuilder dir: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
tsdir, err := ioutil.TempDir(sdir, "bench")
|
tsdir, err := ioutil.TempDir(sdir, "bench")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -209,7 +215,7 @@ var sealBenchCmd = &cli.Command{
|
|||||||
|
|
||||||
// Only fetch parameters if actually needed
|
// Only fetch parameters if actually needed
|
||||||
if !c.Bool("skip-commit2") {
|
if !c.Bool("skip-commit2") {
|
||||||
if err := paramfetch.GetParams(build.ParametersJson(), uint64(sectorSize)); err != nil {
|
if err := paramfetch.GetParams(build.ParametersJSON(), uint64(sectorSize)); err != nil {
|
||||||
return xerrors.Errorf("getting params: %w", err)
|
return xerrors.Errorf("getting params: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -562,15 +568,10 @@ func runSeals(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, numSectors int, mid
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: RM unsealed sector first
|
err := sb.UnsealPiece(context.TODO(), abi.SectorID{Miner: mid, Number: 1}, 0, abi.UnpaddedPieceSize(sectorSize), ticket, cids.Unsealed)
|
||||||
rc, err := sb.ReadPieceFromSealedSector(context.TODO(), abi.SectorID{Miner: mid, Number: 1}, 0, abi.UnpaddedPieceSize(sectorSize), ticket, cids.Unsealed)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := rc.Close(); err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
unseal := time.Now()
|
unseal := time.Now()
|
||||||
|
|
||||||
@@ -599,7 +600,10 @@ var proveCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
if c.Bool("no-gpu") {
|
if c.Bool("no-gpu") {
|
||||||
os.Setenv("BELLMAN_NO_GPU", "1")
|
err := os.Setenv("BELLMAN_NO_GPU", "1")
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("setting no-gpu flag: %w", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !c.Args().Present() {
|
if !c.Args().Present() {
|
||||||
@@ -616,7 +620,7 @@ var proveCmd = &cli.Command{
|
|||||||
return xerrors.Errorf("unmarshalling input file: %w", err)
|
return xerrors.Errorf("unmarshalling input file: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := paramfetch.GetParams(build.ParametersJson(), c2in.SectorSize); err != nil {
|
if err := paramfetch.GetParams(build.ParametersJSON(), c2in.SectorSize); err != nil {
|
||||||
return xerrors.Errorf("getting params: %w", err)
|
return xerrors.Errorf("getting params: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ func main() {
|
|||||||
app := &cli.App{
|
app := &cli.App{
|
||||||
Name: "lotus-chainwatch",
|
Name: "lotus-chainwatch",
|
||||||
Usage: "Devnet token distribution utility",
|
Usage: "Devnet token distribution utility",
|
||||||
Version: build.UserVersion,
|
Version: build.UserVersion(),
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "repo",
|
Name: "repo",
|
||||||
@@ -86,7 +86,7 @@ var runCmd = &cli.Command{
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer st.close()
|
defer st.close() //nolint:errcheck
|
||||||
|
|
||||||
runSyncer(ctx, api, st, maxBatch)
|
runSyncer(ctx, api, st, maxBatch)
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/chain/store"
|
"github.com/filecoin-project/lotus/chain/store"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
parmap "github.com/filecoin-project/lotus/lib/parmap"
|
||||||
)
|
)
|
||||||
|
|
||||||
func runSyncer(ctx context.Context, api api.FullNode, st *storage, maxBatch int) {
|
func runSyncer(ctx context.Context, api api.FullNode, st *storage, maxBatch int) {
|
||||||
@@ -138,7 +139,7 @@ func syncHead(ctx context.Context, api api.FullNode, st *storage, ts *types.TipS
|
|||||||
log.Infof("Syncing %d blocks", len(toSync))
|
log.Infof("Syncing %d blocks", len(toSync))
|
||||||
|
|
||||||
paDone := 0
|
paDone := 0
|
||||||
par(50, maparr(toSync), func(bh *types.BlockHeader) {
|
parmap.Par(50, parmap.MapArr(toSync), func(bh *types.BlockHeader) {
|
||||||
paDone++
|
paDone++
|
||||||
if paDone%100 == 0 {
|
if paDone%100 == 0 {
|
||||||
log.Infof("pa: %d %d%%", paDone, (paDone*100)/len(toSync))
|
log.Infof("pa: %d %d%%", paDone, (paDone*100)/len(toSync))
|
||||||
@@ -152,7 +153,7 @@ func syncHead(ctx context.Context, api api.FullNode, st *storage, ts *types.TipS
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
par(50, aadrs, func(addr address.Address) {
|
parmap.Par(50, aadrs, func(addr address.Address) {
|
||||||
act, err := api.StateGetActor(ctx, addr, ts.Key())
|
act, err := api.StateGetActor(ctx, addr, ts.Key())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
@@ -198,6 +199,8 @@ func syncHead(ctx context.Context, api api.FullNode, st *storage, ts *types.TipS
|
|||||||
}
|
}
|
||||||
|
|
||||||
for a, act := range changes {
|
for a, act := range changes {
|
||||||
|
act := act
|
||||||
|
|
||||||
addr, err := address.NewFromString(a)
|
addr, err := address.NewFromString(a)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
@@ -239,7 +242,7 @@ func syncHead(ctx context.Context, api api.FullNode, st *storage, ts *types.TipS
|
|||||||
addresses[message.From] = address.Undef
|
addresses[message.From] = address.Undef
|
||||||
}
|
}
|
||||||
|
|
||||||
par(50, kmaparr(addresses), func(addr address.Address) {
|
parmap.Par(50, parmap.KMapArr(addresses), func(addr address.Address) {
|
||||||
raddr, err := api.StateLookupID(ctx, addr, types.EmptyTSK)
|
raddr, err := api.StateLookupID(ctx, addr, types.EmptyTSK)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn(err)
|
log.Warn(err)
|
||||||
@@ -268,7 +271,7 @@ func syncHead(ctx context.Context, api api.FullNode, st *storage, ts *types.TipS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
par(50, kvmaparr(miners), func(it func() (minerKey, *minerInfo)) {
|
parmap.Par(50, parmap.KVMapArr(miners), func(it func() (minerKey, *minerInfo)) {
|
||||||
k, info := it()
|
k, info := it()
|
||||||
|
|
||||||
pow, err := api.StateMinerPower(ctx, k.addr, types.EmptyTSK)
|
pow, err := api.StateMinerPower(ctx, k.addr, types.EmptyTSK)
|
||||||
@@ -386,7 +389,7 @@ func fetchMessages(ctx context.Context, api api.FullNode, toSync map[cid.Cid]*ty
|
|||||||
messages := map[cid.Cid]*types.Message{}
|
messages := map[cid.Cid]*types.Message{}
|
||||||
inclusions := map[cid.Cid][]cid.Cid{} // block -> msgs
|
inclusions := map[cid.Cid][]cid.Cid{} // block -> msgs
|
||||||
|
|
||||||
par(50, maparr(toSync), func(header *types.BlockHeader) {
|
parmap.Par(50, parmap.MapArr(toSync), func(header *types.BlockHeader) {
|
||||||
msgs, err := api.ChainGetBlockMessages(ctx, header.Cid())
|
msgs, err := api.ChainGetBlockMessages(ctx, header.Cid())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
@@ -423,7 +426,7 @@ func fetchParentReceipts(ctx context.Context, api api.FullNode, toSync map[cid.C
|
|||||||
var lk sync.Mutex
|
var lk sync.Mutex
|
||||||
out := map[mrec]*types.MessageReceipt{}
|
out := map[mrec]*types.MessageReceipt{}
|
||||||
|
|
||||||
par(50, maparr(toSync), func(header *types.BlockHeader) {
|
parmap.Par(50, parmap.MapArr(toSync), func(header *types.BlockHeader) {
|
||||||
recs, err := api.ChainGetParentReceipts(ctx, header.Cid())
|
recs, err := api.ChainGetParentReceipts(ctx, header.Cid())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ func main() {
|
|||||||
app := &cli.App{
|
app := &cli.App{
|
||||||
Name: "lotus-fountain",
|
Name: "lotus-fountain",
|
||||||
Usage: "Devnet token distribution utility",
|
Usage: "Devnet token distribution utility",
|
||||||
Version: build.UserVersion,
|
Version: build.UserVersion(),
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "repo",
|
Name: "repo",
|
||||||
@@ -157,7 +157,7 @@ func (h *handler) send(w http.ResponseWriter, r *http.Request) {
|
|||||||
to, err := address.NewFromString(r.FormValue("address"))
|
to, err := address.NewFromString(r.FormValue("address"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(400)
|
w.WriteHeader(400)
|
||||||
w.Write([]byte(err.Error()))
|
_, _ = w.Write([]byte(err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,11 +204,11 @@ func (h *handler) send(w http.ResponseWriter, r *http.Request) {
|
|||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(400)
|
w.WriteHeader(400)
|
||||||
w.Write([]byte(err.Error()))
|
_, _ = w.Write([]byte(err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Write([]byte(smsg.Cid().String()))
|
_, _ = w.Write([]byte(smsg.Cid().String()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *handler) mkminer(w http.ResponseWriter, r *http.Request) {
|
func (h *handler) mkminer(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ func main() {
|
|||||||
app := &cli.App{
|
app := &cli.App{
|
||||||
Name: "lotus-health",
|
Name: "lotus-health",
|
||||||
Usage: "Tools for monitoring lotus daemon health",
|
Usage: "Tools for monitoring lotus daemon health",
|
||||||
Version: build.UserVersion,
|
Version: build.UserVersion(),
|
||||||
Commands: local,
|
Commands: local,
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
@@ -79,7 +79,7 @@ var watchHeadCmd = &cli.Command{
|
|||||||
&cli.IntFlag{
|
&cli.IntFlag{
|
||||||
Name: "api-retries",
|
Name: "api-retries",
|
||||||
Value: 8,
|
Value: 8,
|
||||||
Usage: "number of API retry attemps",
|
Usage: "number of API retry attempts",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import (
|
|||||||
lcli "github.com/filecoin-project/lotus/cli"
|
lcli "github.com/filecoin-project/lotus/cli"
|
||||||
"github.com/filecoin-project/lotus/lib/lotuslog"
|
"github.com/filecoin-project/lotus/lib/lotuslog"
|
||||||
"github.com/filecoin-project/lotus/node/repo"
|
"github.com/filecoin-project/lotus/node/repo"
|
||||||
"github.com/filecoin-project/sector-storage"
|
sectorstorage "github.com/filecoin-project/sector-storage"
|
||||||
"github.com/filecoin-project/sector-storage/sealtasks"
|
"github.com/filecoin-project/sector-storage/sealtasks"
|
||||||
"github.com/filecoin-project/sector-storage/stores"
|
"github.com/filecoin-project/sector-storage/stores"
|
||||||
)
|
)
|
||||||
@@ -47,7 +47,7 @@ func main() {
|
|||||||
app := &cli.App{
|
app := &cli.App{
|
||||||
Name: "lotus-seal-worker",
|
Name: "lotus-seal-worker",
|
||||||
Usage: "Remote storage miner worker",
|
Usage: "Remote storage miner worker",
|
||||||
Version: build.UserVersion,
|
Version: build.UserVersion(),
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: FlagStorageRepo,
|
Name: FlagStorageRepo,
|
||||||
@@ -107,7 +107,9 @@ var runCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
Action: func(cctx *cli.Context) error {
|
Action: func(cctx *cli.Context) error {
|
||||||
if !cctx.Bool("enable-gpu-proving") {
|
if !cctx.Bool("enable-gpu-proving") {
|
||||||
os.Setenv("BELLMAN_NO_GPU", "true")
|
if err := os.Setenv("BELLMAN_NO_GPU", "true"); err != nil {
|
||||||
|
return xerrors.Errorf("could not set no-gpu env: %+v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if cctx.String("address") == "" {
|
if cctx.String("address") == "" {
|
||||||
@@ -146,7 +148,7 @@ var runCmd = &cli.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if cctx.Bool("commit") {
|
if cctx.Bool("commit") {
|
||||||
if err := paramfetch.GetParams(build.ParametersJson(), uint64(ssize)); err != nil {
|
if err := paramfetch.GetParams(build.ParametersJSON(), uint64(ssize)); err != nil {
|
||||||
return xerrors.Errorf("get params: %w", err)
|
return xerrors.Errorf("get params: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -290,7 +292,7 @@ var runCmd = &cli.Command{
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
<-ctx.Done()
|
<-ctx.Done()
|
||||||
log.Warn("Shutting down...")
|
log.Warn("Shutting down..")
|
||||||
if err := srv.Shutdown(context.TODO()); err != nil {
|
if err := srv.Shutdown(context.TODO()); err != nil {
|
||||||
log.Errorf("shutting down RPC server failed: %s", err)
|
log.Errorf("shutting down RPC server failed: %s", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ func main() {
|
|||||||
app := &cli.App{
|
app := &cli.App{
|
||||||
Name: "lotus-seed",
|
Name: "lotus-seed",
|
||||||
Usage: "Seal sectors for genesis miner",
|
Usage: "Seal sectors for genesis miner",
|
||||||
Version: build.UserVersion,
|
Version: build.UserVersion(),
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "sector-dir",
|
Name: "sector-dir",
|
||||||
@@ -145,7 +145,6 @@ var aggregateManifestsCmd = &cli.Command{
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer fi.Close()
|
|
||||||
var val map[string]genesis.Miner
|
var val map[string]genesis.Miner
|
||||||
if err := json.NewDecoder(fi).Decode(&val); err != nil {
|
if err := json.NewDecoder(fi).Decode(&val); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/minio/blake2b-simd"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -15,6 +14,7 @@ import (
|
|||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
ic "github.com/libp2p/go-libp2p-core/crypto"
|
ic "github.com/libp2p/go-libp2p-core/crypto"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
|
"github.com/minio/blake2b-simd"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
@@ -48,7 +48,7 @@ func PreSeal(maddr address.Address, pt abi.RegisteredProof, offset abi.SectorNum
|
|||||||
SealProofType: spt,
|
SealProofType: spt,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := os.MkdirAll(sbroot, 0775); err != nil {
|
if err := os.MkdirAll(sbroot, 0775); err != nil { //nolint:gosec
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ var importCarCmd = &cli.Command{
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer lr.Close()
|
defer lr.Close() //nolint:errcheck
|
||||||
|
|
||||||
cf := cctx.Args().Get(0)
|
cf := cctx.Args().Get(0)
|
||||||
f, err := os.OpenFile(cf, os.O_RDONLY, 0664)
|
f, err := os.OpenFile(cf, os.O_RDONLY, 0664)
|
||||||
@@ -42,7 +42,7 @@ var importCarCmd = &cli.Command{
|
|||||||
return xerrors.Errorf("opening the car file: %w", err)
|
return xerrors.Errorf("opening the car file: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ds, err := lr.Datastore("/blocks")
|
ds, err := lr.Datastore("/chain")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ var fetchParamCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
sectorSize := uint64(sectorSizeInt)
|
sectorSize := uint64(sectorSizeInt)
|
||||||
err = paramfetch.GetParams(build.ParametersJson(), sectorSize)
|
err = paramfetch.GetParams(build.ParametersJSON(), sectorSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("fetching proof parameters: %w", err)
|
return xerrors.Errorf("fetching proof parameters: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ import (
|
|||||||
lapi "github.com/filecoin-project/lotus/api"
|
lapi "github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/lotus/chain/actors"
|
"github.com/filecoin-project/lotus/chain/actors"
|
||||||
"github.com/filecoin-project/lotus/chain/beacon/drand"
|
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
lcli "github.com/filecoin-project/lotus/cli"
|
lcli "github.com/filecoin-project/lotus/cli"
|
||||||
"github.com/filecoin-project/lotus/genesis"
|
"github.com/filecoin-project/lotus/genesis"
|
||||||
@@ -127,7 +126,7 @@ var initCmd = &cli.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.Info("Checking proof parameters")
|
log.Info("Checking proof parameters")
|
||||||
if err := paramfetch.GetParams(build.ParametersJson(), uint64(ssize)); err != nil {
|
if err := paramfetch.GetParams(build.ParametersJSON(), uint64(ssize)); err != nil {
|
||||||
return xerrors.Errorf("fetching proof parameters: %w", err)
|
return xerrors.Errorf("fetching proof parameters: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,7 +388,7 @@ func storageMinerInit(ctx context.Context, cctx *cli.Context, api lapi.FullNode,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer lr.Close()
|
defer lr.Close() //nolint:errcheck
|
||||||
|
|
||||||
log.Info("Initializing libp2p identity")
|
log.Info("Initializing libp2p identity")
|
||||||
|
|
||||||
@@ -437,7 +436,7 @@ func storageMinerInit(ctx context.Context, cctx *cli.Context, api lapi.FullNode,
|
|||||||
|
|
||||||
smgr, err := sectorstorage.New(ctx, lr, stores.NewIndex(), &ffiwrapper.Config{
|
smgr, err := sectorstorage.New(ctx, lr, stores.NewIndex(), &ffiwrapper.Config{
|
||||||
SealProofType: spt,
|
SealProofType: spt,
|
||||||
}, sectorstorage.SealerConfig{true, true, true}, nil, sa)
|
}, sectorstorage.SealerConfig{true, true, true, true}, nil, sa)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -446,17 +445,7 @@ func storageMinerInit(ctx context.Context, cctx *cli.Context, api lapi.FullNode,
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
gen, err := api.ChainGetGenesis(ctx)
|
m := miner.NewMiner(api, epp, a)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
beacon, err := drand.NewDrandBeacon(gen.Blocks()[0].Timestamp, build.BlockDelay)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
m := miner.NewMiner(api, epp, beacon, a)
|
|
||||||
{
|
{
|
||||||
if err := m.Start(ctx); err != nil {
|
if err := m.Start(ctx); err != nil {
|
||||||
return xerrors.Errorf("failed to start up genesis miner: %w", err)
|
return xerrors.Errorf("failed to start up genesis miner: %w", err)
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ func main() {
|
|||||||
initCmd,
|
initCmd,
|
||||||
rewardsCmd,
|
rewardsCmd,
|
||||||
runCmd,
|
runCmd,
|
||||||
stopCmd,
|
|
||||||
sectorsCmd,
|
sectorsCmd,
|
||||||
storageCmd,
|
storageCmd,
|
||||||
setPriceCmd,
|
setPriceCmd,
|
||||||
@@ -58,7 +57,7 @@ func main() {
|
|||||||
app := &cli.App{
|
app := &cli.App{
|
||||||
Name: "lotus-storage-miner",
|
Name: "lotus-storage-miner",
|
||||||
Usage: "Filecoin decentralized storage network storage miner",
|
Usage: "Filecoin decentralized storage network storage miner",
|
||||||
Version: build.UserVersion,
|
Version: build.UserVersion(),
|
||||||
EnableShellCompletion: true,
|
EnableShellCompletion: true,
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
lcli "github.com/filecoin-project/lotus/cli"
|
lcli "github.com/filecoin-project/lotus/cli"
|
||||||
@@ -12,6 +10,7 @@ import (
|
|||||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
"gopkg.in/urfave/cli.v2"
|
"gopkg.in/urfave/cli.v2"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var provingCmd = &cli.Command{
|
var provingCmd = &cli.Command{
|
||||||
|
|||||||
@@ -100,12 +100,9 @@ var runCmd = &cli.Command{
|
|||||||
return xerrors.Errorf("repo at '%s' is not initialized, run 'lotus-storage-miner init' to set it up", storageRepoPath)
|
return xerrors.Errorf("repo at '%s' is not initialized, run 'lotus-storage-miner init' to set it up", storageRepoPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
shutdownChan := make(chan struct{})
|
|
||||||
|
|
||||||
var minerapi api.StorageMiner
|
var minerapi api.StorageMiner
|
||||||
stop, err := node.New(ctx,
|
stop, err := node.New(ctx,
|
||||||
node.StorageMiner(&minerapi),
|
node.StorageMiner(&minerapi),
|
||||||
node.Override(new(dtypes.ShutdownChan), shutdownChan),
|
|
||||||
node.Online(),
|
node.Online(),
|
||||||
node.Repo(r),
|
node.Repo(r),
|
||||||
|
|
||||||
@@ -159,12 +156,8 @@ var runCmd = &cli.Command{
|
|||||||
|
|
||||||
sigChan := make(chan os.Signal, 2)
|
sigChan := make(chan os.Signal, 2)
|
||||||
go func() {
|
go func() {
|
||||||
select {
|
<-sigChan
|
||||||
case <-sigChan:
|
log.Warn("Shutting down..")
|
||||||
case <-shutdownChan:
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Warn("Shutting down...")
|
|
||||||
if err := stop(context.TODO()); err != nil {
|
if err := stop(context.TODO()); err != nil {
|
||||||
log.Errorf("graceful shutting down failed: %s", err)
|
log.Errorf("graceful shutting down failed: %s", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
_ "net/http/pprof"
|
|
||||||
|
|
||||||
"gopkg.in/urfave/cli.v2"
|
|
||||||
|
|
||||||
lcli "github.com/filecoin-project/lotus/cli"
|
|
||||||
)
|
|
||||||
|
|
||||||
var stopCmd = &cli.Command{
|
|
||||||
Name: "stop",
|
|
||||||
Usage: "Stop a running lotus storage miner",
|
|
||||||
Flags: []cli.Flag{},
|
|
||||||
Action: func(cctx *cli.Context) error {
|
|
||||||
api, closer, err := lcli.GetAPI(cctx)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer closer()
|
|
||||||
|
|
||||||
err = api.Shutdown(lcli.ReqContext(cctx))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -249,7 +249,7 @@ var storageListCmd = &cli.Command{
|
|||||||
|
|
||||||
type storedSector struct {
|
type storedSector struct {
|
||||||
id stores.ID
|
id stores.ID
|
||||||
store stores.StorageInfo
|
store stores.SectorStorageInfo
|
||||||
|
|
||||||
unsealed, sealed, cache bool
|
unsealed, sealed, cache bool
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-31
@@ -29,7 +29,6 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/stmgr"
|
"github.com/filecoin-project/lotus/chain/stmgr"
|
||||||
"github.com/filecoin-project/lotus/chain/store"
|
"github.com/filecoin-project/lotus/chain/store"
|
||||||
"github.com/filecoin-project/lotus/chain/vm"
|
"github.com/filecoin-project/lotus/chain/vm"
|
||||||
lcli "github.com/filecoin-project/lotus/cli"
|
|
||||||
"github.com/filecoin-project/lotus/lib/peermgr"
|
"github.com/filecoin-project/lotus/lib/peermgr"
|
||||||
"github.com/filecoin-project/lotus/metrics"
|
"github.com/filecoin-project/lotus/metrics"
|
||||||
"github.com/filecoin-project/lotus/node"
|
"github.com/filecoin-project/lotus/node"
|
||||||
@@ -45,26 +44,6 @@ const (
|
|||||||
preTemplateFlag = "genesis-template"
|
preTemplateFlag = "genesis-template"
|
||||||
)
|
)
|
||||||
|
|
||||||
var daemonStopCmd = &cli.Command{
|
|
||||||
Name: "stop",
|
|
||||||
Usage: "Stop a running lotus daemon",
|
|
||||||
Flags: []cli.Flag{},
|
|
||||||
Action: func(cctx *cli.Context) error {
|
|
||||||
api, closer, err := lcli.GetAPI(cctx)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer closer()
|
|
||||||
|
|
||||||
err = api.Shutdown(lcli.ReqContext(cctx))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
// DaemonCmd is the `go-lotus daemon` command
|
// DaemonCmd is the `go-lotus daemon` command
|
||||||
var DaemonCmd = &cli.Command{
|
var DaemonCmd = &cli.Command{
|
||||||
Name: "daemon",
|
Name: "daemon",
|
||||||
@@ -155,7 +134,7 @@ var DaemonCmd = &cli.Command{
|
|||||||
return xerrors.Errorf("repo init error: %w", err)
|
return xerrors.Errorf("repo init error: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := paramfetch.GetParams(build.ParametersJson(), 0); err != nil {
|
if err := paramfetch.GetParams(build.ParametersJSON(), 0); err != nil {
|
||||||
return xerrors.Errorf("fetching proof parameters: %w", err)
|
return xerrors.Errorf("fetching proof parameters: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,15 +170,12 @@ var DaemonCmd = &cli.Command{
|
|||||||
genesis = node.Override(new(modules.Genesis), testing.MakeGenesis(cctx.String(makeGenFlag), cctx.String(preTemplateFlag)))
|
genesis = node.Override(new(modules.Genesis), testing.MakeGenesis(cctx.String(makeGenFlag), cctx.String(preTemplateFlag)))
|
||||||
}
|
}
|
||||||
|
|
||||||
shutdownChan := make(chan struct{})
|
|
||||||
|
|
||||||
var api api.FullNode
|
var api api.FullNode
|
||||||
|
|
||||||
stop, err := node.New(ctx,
|
stop, err := node.New(ctx,
|
||||||
node.FullAPI(&api),
|
node.FullAPI(&api),
|
||||||
|
|
||||||
node.Override(new(dtypes.Bootstrapper), isBootstrapper),
|
node.Override(new(dtypes.Bootstrapper), isBootstrapper),
|
||||||
node.Override(new(dtypes.ShutdownChan), shutdownChan),
|
|
||||||
node.Online(),
|
node.Online(),
|
||||||
node.Repo(r),
|
node.Repo(r),
|
||||||
|
|
||||||
@@ -245,10 +221,7 @@ var DaemonCmd = &cli.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: properly parse api endpoint (or make it a URL)
|
// TODO: properly parse api endpoint (or make it a URL)
|
||||||
return serveRPC(api, stop, endpoint, shutdownChan)
|
return serveRPC(api, stop, endpoint)
|
||||||
},
|
|
||||||
Subcommands: []*cli.Command{
|
|
||||||
daemonStopCmd,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,9 +269,9 @@ func ImportChain(r repo.Repo, fname string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer lr.Close()
|
defer lr.Close() //nolint:errcheck
|
||||||
|
|
||||||
ds, err := lr.Datastore("/blocks")
|
ds, err := lr.Datastore("/chain")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -52,7 +52,7 @@ func main() {
|
|||||||
app := &cli.App{
|
app := &cli.App{
|
||||||
Name: "lotus",
|
Name: "lotus",
|
||||||
Usage: "Filecoin decentralized storage network client",
|
Usage: "Filecoin decentralized storage network client",
|
||||||
Version: build.UserVersion,
|
Version: build.UserVersion(),
|
||||||
EnableShellCompletion: true,
|
EnableShellCompletion: true,
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
|
|||||||
+6
-12
@@ -28,7 +28,7 @@ import (
|
|||||||
|
|
||||||
var log = logging.Logger("main")
|
var log = logging.Logger("main")
|
||||||
|
|
||||||
func serveRPC(a api.FullNode, stop node.StopFunc, addr multiaddr.Multiaddr, shutdownCh <-chan struct{}) error {
|
func serveRPC(a api.FullNode, stop node.StopFunc, addr multiaddr.Multiaddr) error {
|
||||||
rpcServer := jsonrpc.NewServer()
|
rpcServer := jsonrpc.NewServer()
|
||||||
rpcServer.Register("Filecoin", apistruct.PermissionedFullAPI(a))
|
rpcServer.Register("Filecoin", apistruct.PermissionedFullAPI(a))
|
||||||
|
|
||||||
@@ -62,23 +62,17 @@ func serveRPC(a api.FullNode, stop node.StopFunc, addr multiaddr.Multiaddr, shut
|
|||||||
|
|
||||||
srv := &http.Server{Handler: http.DefaultServeMux}
|
srv := &http.Server{Handler: http.DefaultServeMux}
|
||||||
|
|
||||||
sigCh := make(chan os.Signal, 2)
|
sigChan := make(chan os.Signal, 2)
|
||||||
go func() {
|
go func() {
|
||||||
select {
|
<-sigChan
|
||||||
case <-sigCh:
|
|
||||||
case <-shutdownCh:
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Warn("Shutting down...")
|
|
||||||
if err := srv.Shutdown(context.TODO()); err != nil {
|
if err := srv.Shutdown(context.TODO()); err != nil {
|
||||||
log.Errorf("shutting down RPC server failed: %s", err)
|
log.Errorf("shutting down RPC server failed: %s", err)
|
||||||
}
|
}
|
||||||
if err := stop(context.TODO()); err != nil {
|
if err := stop(context.TODO()); err != nil {
|
||||||
log.Errorf("graceful shutting down failed: %s", err)
|
log.Errorf("graceful shutting down failed: %s", err)
|
||||||
}
|
}
|
||||||
log.Warn("Graceful shutdown successful")
|
|
||||||
}()
|
}()
|
||||||
signal.Notify(sigCh, syscall.SIGTERM, syscall.SIGINT)
|
signal.Notify(sigChan, syscall.SIGTERM, syscall.SIGINT)
|
||||||
|
|
||||||
return srv.Serve(manet.NetListener(lst))
|
return srv.Serve(manet.NetListener(lst))
|
||||||
}
|
}
|
||||||
@@ -91,14 +85,14 @@ func handleImport(a *impl.FullNodeAPI) func(w http.ResponseWriter, r *http.Reque
|
|||||||
}
|
}
|
||||||
if !auth.HasPerm(r.Context(), nil, apistruct.PermWrite) {
|
if !auth.HasPerm(r.Context(), nil, apistruct.PermWrite) {
|
||||||
w.WriteHeader(401)
|
w.WriteHeader(401)
|
||||||
json.NewEncoder(w).Encode(struct{ Error string }{"unauthorized: missing write permission"})
|
_ = json.NewEncoder(w).Encode(struct{ Error string }{"unauthorized: missing write permission"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c, err := a.ClientImportLocal(r.Context(), r.Body)
|
c, err := a.ClientImportLocal(r.Context(), r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(500)
|
w.WriteHeader(500)
|
||||||
json.NewEncoder(w).Encode(struct{ Error string }{err.Error()})
|
_ = json.NewEncoder(w).Encode(struct{ Error string }{err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.WriteHeader(200)
|
w.WriteHeader(200)
|
||||||
|
|||||||
@@ -1,70 +0,0 @@
|
|||||||
# Why does Filecoin mining work best on AMD?
|
|
||||||
Currently, Filecoin's Proof of Replication (PoRep) prefers to be run on AMD
|
|
||||||
processors. More accurately, it runs much much slower on Intel CPUs (it runs
|
|
||||||
competitively fast on some ARM processors, like the ones in newer Samsung
|
|
||||||
phones, but they lack the RAM to seal the larger sector sizes). The main reason
|
|
||||||
that we see this benefit on AMD processors is due to their implementation of
|
|
||||||
the SHA hardware instructions. Now, why do we use the SHA instruction?
|
|
||||||
|
|
||||||
## PoRep security assumptions
|
|
||||||
Our research team has two different models for the security of Proofs of
|
|
||||||
Replication. These are the Latency Assumption, and the Cost Assumption. These
|
|
||||||
assumptions are arguments for why an attacker cannot pull off a 'regeneration
|
|
||||||
attack'. That is, the attacker cannot seal and commit random data (generated by
|
|
||||||
a function), delete it, and then reseal it on the fly to respond to PoSt
|
|
||||||
challenges, without actually storing the data for that time period.
|
|
||||||
|
|
||||||
### Cost Assumptions
|
|
||||||
The cost assumption states that the real money cost (hardware, electricity,
|
|
||||||
etc) of generating a sector is higher than the real money cost of simply
|
|
||||||
storing it on disks. NSE is a new PoRep our research team is working on that is
|
|
||||||
based on the cost assumption, and is thus able to be very parallelizable (In
|
|
||||||
comparison to schemes based on a latency assumption, as will be explained
|
|
||||||
next). However, cost assumptions vary greatly with available and hypothetical
|
|
||||||
hardware. For example, someone making an ASIC for NSE could break the cost
|
|
||||||
assumption by lowering the cost of sealing too much. This is one of our main
|
|
||||||
hesitations around shipping NSE.
|
|
||||||
|
|
||||||
### Latency Assumptions
|
|
||||||
A Proof of Replication that is secure under a latency assumption is secure
|
|
||||||
because an attacker cannot regenerate the data in time. We use this assumption
|
|
||||||
for SDR, where we assume that an attacker cannot regenerate enough of a sector
|
|
||||||
fast enough to respond to a PoSt. The way we achieve this is through the use
|
|
||||||
of depth-robust graphs. Without going into too much detail, depth-robust
|
|
||||||
graphs guarantee a minimum number of serial operations to compute an encoding
|
|
||||||
based on the graph. Each edge in the graph represents an operation we need to
|
|
||||||
perform. We thus have a guarantee that someone has to perform some operation
|
|
||||||
N times in a row in order to compute the encoding. That means that the
|
|
||||||
computation of the encoding must take at least as long as N times the fastest
|
|
||||||
someone can do that operation.
|
|
||||||
|
|
||||||
Now, to make this secure, we need to choose an operation that can't be made
|
|
||||||
much faster. There are many potential candidates here, depending on what
|
|
||||||
hardware you want to require. We opted not to require ASICs in order to mine
|
|
||||||
Filecoin, so that limits our choices severely. We have to look at what
|
|
||||||
operations CPUs are really good at. One candidate was AES encryption, which
|
|
||||||
also has hardware instructions. However, the difference between the performance
|
|
||||||
of CPU AES instructions, and the hypothetical 'best' performance you get was
|
|
||||||
still too great. This gap is generally called 'Amax', an attacker’s maximum
|
|
||||||
advantage. The higher the Amax of an algorithm we choose, the more expensive
|
|
||||||
the overall process has to become in order to bound how fast the attacker could
|
|
||||||
do it.
|
|
||||||
As we were doing our research, we noticed that AMD shipped their new processors
|
|
||||||
with a builtin SHA function, and we looked into how fast someone could possibly
|
|
||||||
compute a SHA hash. We found that AMD’s implementation is only around 3 times
|
|
||||||
slower than anyone could reasonably do (given estimates by the hardware
|
|
||||||
engineers at [Supranational](https://www.supranational.net/) ). This is
|
|
||||||
incredibly impressive for something you can get in consumer hardware. With
|
|
||||||
this, we were able to make SDR sealing reasonably performant for people with
|
|
||||||
off-the-shelf hardware.
|
|
||||||
|
|
||||||
## Super Optimized CPUs
|
|
||||||
|
|
||||||
Given all of the above, with a latency assumption that we're basing our proofs
|
|
||||||
on right now, you need a processor that can do iterated SHA hashes really fast.
|
|
||||||
As mentioned earlier, this isn’t just AMD processors, but many ARM processors
|
|
||||||
also have support for this. Hopefully, new Intel processors also follow suit.
|
|
||||||
But for now, Filecoin works best on AMD processors.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Vendored
-154
@@ -1,154 +0,0 @@
|
|||||||
package bitvector
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"log"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
// ErrOutOfRange - the index passed is out of range for the BitVector
|
|
||||||
ErrOutOfRange = errors.New("index out of range")
|
|
||||||
)
|
|
||||||
|
|
||||||
// BitNumbering indicates the ordering of bits, either
|
|
||||||
// least-significant bit in position 0, or most-significant bit
|
|
||||||
// in position 0.
|
|
||||||
//
|
|
||||||
// It it used in 3 ways with BitVector:
|
|
||||||
// 1. Ordering of bits within the Buf []byte structure
|
|
||||||
// 2. What order to add bits when using Extend()
|
|
||||||
// 3. What order to read bits when using Take()
|
|
||||||
//
|
|
||||||
// https://en.wikipedia.org/wiki/Bit_numbering
|
|
||||||
type BitNumbering int
|
|
||||||
|
|
||||||
const (
|
|
||||||
// LSB0 - bit ordering starts with the low-order bit
|
|
||||||
LSB0 BitNumbering = iota
|
|
||||||
|
|
||||||
// MSB0 - bit ordering starts with the high-order bit
|
|
||||||
MSB0
|
|
||||||
)
|
|
||||||
|
|
||||||
// BitVector is used to manipulate ordered collections of bits
|
|
||||||
type BitVector struct {
|
|
||||||
Buf []byte
|
|
||||||
|
|
||||||
// BytePacking is the bit ordering within bytes
|
|
||||||
BytePacking BitNumbering
|
|
||||||
|
|
||||||
// Len is the logical number of bits in the vector.
|
|
||||||
// The last byte in Buf may have undefined bits if Len is not a multiple of 8
|
|
||||||
Len uint
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewBitVector constructs a new BitVector from a slice of bytes.
|
|
||||||
//
|
|
||||||
// The bytePacking parameter is required to know how to interpret the bit ordering within the bytes.
|
|
||||||
func NewBitVector(buf []byte, bytePacking BitNumbering) *BitVector {
|
|
||||||
return &BitVector{
|
|
||||||
BytePacking: bytePacking,
|
|
||||||
Buf: buf,
|
|
||||||
Len: uint(len(buf) * 8),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Push adds a single bit to the BitVector.
|
|
||||||
//
|
|
||||||
// Although it takes a byte, only the low-order bit is used, so just use 0 or 1.
|
|
||||||
func (v *BitVector) Push(val byte) {
|
|
||||||
if v.Len%8 == 0 {
|
|
||||||
v.Buf = append(v.Buf, 0)
|
|
||||||
}
|
|
||||||
lastIdx := v.Len / 8
|
|
||||||
|
|
||||||
switch v.BytePacking {
|
|
||||||
case LSB0:
|
|
||||||
v.Buf[lastIdx] |= (val & 1) << (v.Len % 8)
|
|
||||||
default:
|
|
||||||
v.Buf[lastIdx] |= (val & 1) << (7 - (v.Len % 8))
|
|
||||||
}
|
|
||||||
|
|
||||||
v.Len++
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get returns a single bit as a byte -- either 0 or 1
|
|
||||||
func (v *BitVector) Get(idx uint) (byte, error) {
|
|
||||||
if idx >= v.Len {
|
|
||||||
return 0, ErrOutOfRange
|
|
||||||
}
|
|
||||||
blockIdx := idx / 8
|
|
||||||
|
|
||||||
switch v.BytePacking {
|
|
||||||
case LSB0:
|
|
||||||
return v.Buf[blockIdx] >> (idx % 8) & 1, nil
|
|
||||||
default:
|
|
||||||
return v.Buf[blockIdx] >> (7 - idx%8) & 1, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extend adds up to 8 bits to the receiver
|
|
||||||
//
|
|
||||||
// Given a byte b == 0b11010101
|
|
||||||
// v.Extend(b, 4, LSB0) would add < 1, 0, 1, 0 >
|
|
||||||
// v.Extend(b, 4, MSB0) would add < 1, 1, 0, 1 >
|
|
||||||
//
|
|
||||||
// Panics if count is out of range
|
|
||||||
func (v *BitVector) Extend(val byte, count uint, order BitNumbering) {
|
|
||||||
if count > 8 {
|
|
||||||
log.Panicf("invalid count")
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := uint(0); i < count; i++ {
|
|
||||||
switch order {
|
|
||||||
case LSB0:
|
|
||||||
v.Push((val >> i) & 1)
|
|
||||||
default:
|
|
||||||
v.Push((val >> (7 - i)) & 1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Take reads up to 8 bits at the given index.
|
|
||||||
//
|
|
||||||
// Given a BitVector < 1, 1, 0, 1, 0, 1, 0, 1 >
|
|
||||||
// v.Take(0, 4, LSB0) would return 0b00001011
|
|
||||||
// v.Take(0, 4, MSB0) would return 0b11010000
|
|
||||||
//
|
|
||||||
// Panics if count is out of range
|
|
||||||
func (v *BitVector) Take(index uint, count uint, order BitNumbering) (out byte) {
|
|
||||||
if count > 8 {
|
|
||||||
log.Panicf("invalid count")
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := uint(0); i < count; i++ {
|
|
||||||
val, _ := v.Get(index + i)
|
|
||||||
|
|
||||||
switch order {
|
|
||||||
case LSB0:
|
|
||||||
out |= val << i
|
|
||||||
default:
|
|
||||||
out |= val << (7 - i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Iterator returns a function, which when invoked, returns the number
|
|
||||||
// of bits requested, and increments an internal cursor.
|
|
||||||
//
|
|
||||||
// When the end of the BitVector is reached, it returns zeroes indefinitely
|
|
||||||
//
|
|
||||||
// Panics if count is out of range
|
|
||||||
func (v *BitVector) Iterator(order BitNumbering) func(uint) byte {
|
|
||||||
cursor := uint(0)
|
|
||||||
return func(count uint) (out byte) {
|
|
||||||
if count > 8 {
|
|
||||||
log.Panicf("invalid count")
|
|
||||||
}
|
|
||||||
|
|
||||||
out = v.Take(cursor, count, order)
|
|
||||||
cursor += count
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-136
@@ -1,136 +0,0 @@
|
|||||||
package bitvector_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
|
|
||||||
bitvector "github.com/filecoin-project/lotus/extern/rleplus/internal"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestBitVector(t *testing.T) {
|
|
||||||
t.Run("zero value", func(t *testing.T) {
|
|
||||||
var v bitvector.BitVector
|
|
||||||
|
|
||||||
assert.Equal(t, bitvector.LSB0, v.BytePacking)
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("Push", func(t *testing.T) {
|
|
||||||
// MSB0 bit numbering
|
|
||||||
v := bitvector.BitVector{BytePacking: bitvector.MSB0}
|
|
||||||
v.Push(1)
|
|
||||||
v.Push(0)
|
|
||||||
v.Push(1)
|
|
||||||
v.Push(1)
|
|
||||||
|
|
||||||
assert.Equal(t, byte(176), v.Buf[0])
|
|
||||||
|
|
||||||
// LSB0 bit numbering
|
|
||||||
v = bitvector.BitVector{BytePacking: bitvector.LSB0}
|
|
||||||
v.Push(1)
|
|
||||||
v.Push(0)
|
|
||||||
v.Push(1)
|
|
||||||
v.Push(1)
|
|
||||||
|
|
||||||
assert.Equal(t, byte(13), v.Buf[0])
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("Get", func(t *testing.T) {
|
|
||||||
bits := []byte{1, 0, 1, 1, 0, 0, 1, 0}
|
|
||||||
|
|
||||||
for _, numbering := range []bitvector.BitNumbering{bitvector.MSB0, bitvector.LSB0} {
|
|
||||||
v := bitvector.BitVector{BytePacking: numbering}
|
|
||||||
|
|
||||||
for _, bit := range bits {
|
|
||||||
v.Push(bit)
|
|
||||||
}
|
|
||||||
|
|
||||||
for idx, expected := range bits {
|
|
||||||
actual, _ := v.Get(uint(idx))
|
|
||||||
assert.Equal(t, expected, actual)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("Extend", func(t *testing.T) {
|
|
||||||
val := byte(171) // 0b10101011
|
|
||||||
|
|
||||||
var v bitvector.BitVector
|
|
||||||
|
|
||||||
// MSB0 bit numbering
|
|
||||||
v = bitvector.BitVector{}
|
|
||||||
v.Extend(val, 4, bitvector.MSB0)
|
|
||||||
assertBitVector(t, []byte{1, 0, 1, 0}, v)
|
|
||||||
v.Extend(val, 5, bitvector.MSB0)
|
|
||||||
assertBitVector(t, []byte{1, 0, 1, 0, 1, 0, 1, 0, 1}, v)
|
|
||||||
|
|
||||||
// LSB0 bit numbering
|
|
||||||
v = bitvector.BitVector{}
|
|
||||||
v.Extend(val, 4, bitvector.LSB0)
|
|
||||||
assertBitVector(t, []byte{1, 1, 0, 1}, v)
|
|
||||||
v.Extend(val, 5, bitvector.LSB0)
|
|
||||||
assertBitVector(t, []byte{1, 1, 0, 1, 1, 1, 0, 1, 0}, v)
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("invalid counts to Take/Extend/Iterator cause panics", func(t *testing.T) {
|
|
||||||
v := bitvector.BitVector{BytePacking: bitvector.LSB0}
|
|
||||||
|
|
||||||
assert.Panics(t, func() { v.Extend(0xff, 9, bitvector.LSB0) })
|
|
||||||
|
|
||||||
assert.Panics(t, func() { v.Take(0, 9, bitvector.LSB0) })
|
|
||||||
|
|
||||||
next := v.Iterator(bitvector.LSB0)
|
|
||||||
assert.Panics(t, func() { next(9) })
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("Take", func(t *testing.T) {
|
|
||||||
var v bitvector.BitVector
|
|
||||||
|
|
||||||
bits := []byte{1, 0, 1, 0, 1, 0, 1, 1}
|
|
||||||
for _, bit := range bits {
|
|
||||||
v.Push(bit)
|
|
||||||
}
|
|
||||||
|
|
||||||
assert.Equal(t, byte(176), v.Take(4, 4, bitvector.MSB0))
|
|
||||||
assert.Equal(t, byte(13), v.Take(4, 4, bitvector.LSB0))
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("Iterator", func(t *testing.T) {
|
|
||||||
var buf []byte
|
|
||||||
|
|
||||||
// make a bitvector of 256 sample bits
|
|
||||||
for i := 0; i < 32; i++ {
|
|
||||||
buf = append(buf, 128+32)
|
|
||||||
}
|
|
||||||
|
|
||||||
v := bitvector.NewBitVector(buf, bitvector.LSB0)
|
|
||||||
|
|
||||||
next := v.Iterator(bitvector.LSB0)
|
|
||||||
|
|
||||||
// compare to Get()
|
|
||||||
for i := uint(0); i < v.Len; i++ {
|
|
||||||
expected, _ := v.Get(i)
|
|
||||||
assert.Equal(t, expected, next(1))
|
|
||||||
}
|
|
||||||
|
|
||||||
// out of range should return zero
|
|
||||||
assert.Equal(t, byte(0), next(1))
|
|
||||||
assert.Equal(t, byte(0), next(8))
|
|
||||||
|
|
||||||
// compare to Take()
|
|
||||||
next = v.Iterator(bitvector.LSB0)
|
|
||||||
assert.Equal(t, next(5), v.Take(0, 5, bitvector.LSB0))
|
|
||||||
assert.Equal(t, next(8), v.Take(5, 8, bitvector.LSB0))
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note: When using this helper assertion, expectedBits should *only* be 0s and 1s.
|
|
||||||
func assertBitVector(t *testing.T, expectedBits []byte, actual bitvector.BitVector) {
|
|
||||||
assert.Equal(t, uint(len(expectedBits)), actual.Len)
|
|
||||||
|
|
||||||
for idx, bit := range expectedBits {
|
|
||||||
actualBit, err := actual.Get(uint(idx))
|
|
||||||
assert.NoError(t, err)
|
|
||||||
assert.Equal(t, bit, actualBit)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vendored
-204
@@ -1,204 +0,0 @@
|
|||||||
package rleplus
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/binary"
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"sort"
|
|
||||||
|
|
||||||
bitvector "github.com/filecoin-project/lotus/extern/rleplus/internal"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Version is the 2 lowest bits of this constant
|
|
||||||
const Version = 0
|
|
||||||
|
|
||||||
var (
|
|
||||||
// ErrRunLengthTooLarge - data implies a run-length which isn't supported
|
|
||||||
ErrRunLengthTooLarge = fmt.Errorf("run length too large for RLE+ version %d", Version)
|
|
||||||
|
|
||||||
// ErrDecode - invalid encoding for this version
|
|
||||||
ErrDecode = fmt.Errorf("invalid encoding for RLE+ version %d", Version)
|
|
||||||
|
|
||||||
// ErrWrongVersion - wrong version of RLE+
|
|
||||||
ErrWrongVersion = errors.New("invalid RLE+ version")
|
|
||||||
)
|
|
||||||
|
|
||||||
// Encode returns the RLE+ representation of the provided integers.
|
|
||||||
// Also returned is the number of bits required by this encoding,
|
|
||||||
// which is not necessarily on a byte boundary.
|
|
||||||
//
|
|
||||||
// The RLE+ spec is here: https://github.com/filecoin-project/specs/blob/master/data-structures.md#rle-bitset-encoding
|
|
||||||
// and is described by the BNF Grammar:
|
|
||||||
//
|
|
||||||
// <encoding> ::= <header> <blocks>
|
|
||||||
// <header> ::= <version> <bit>
|
|
||||||
// <version> ::= "00"
|
|
||||||
// <blocks> ::= <block> <blocks> | ""
|
|
||||||
// <block> ::= <block_single> | <block_short> | <block_long>
|
|
||||||
// <block_single> ::= "1"
|
|
||||||
// <block_short> ::= "01" <bit> <bit> <bit> <bit>
|
|
||||||
// <block_long> ::= "00" <unsigned_varint>
|
|
||||||
// <bit> ::= "0" | "1"
|
|
||||||
//
|
|
||||||
// Filecoin specific:
|
|
||||||
// The encoding is returned as a []byte, each byte packed starting with the low-order bit (LSB0)
|
|
||||||
func Encode(ints []uint64) ([]byte, uint, error) {
|
|
||||||
v := bitvector.BitVector{BytePacking: bitvector.LSB0}
|
|
||||||
firstBit, runs := RunLengths(ints)
|
|
||||||
|
|
||||||
// Add version header
|
|
||||||
v.Extend(Version, 2, bitvector.LSB0)
|
|
||||||
|
|
||||||
v.Push(firstBit)
|
|
||||||
|
|
||||||
for _, run := range runs {
|
|
||||||
switch {
|
|
||||||
case run == 1:
|
|
||||||
v.Push(1)
|
|
||||||
case run < 16:
|
|
||||||
v.Push(0)
|
|
||||||
v.Push(1)
|
|
||||||
v.Extend(byte(run), 4, bitvector.LSB0)
|
|
||||||
case run >= 16:
|
|
||||||
v.Push(0)
|
|
||||||
v.Push(0)
|
|
||||||
// 10 bytes needed to encode MaxUint64
|
|
||||||
buf := make([]byte, 10)
|
|
||||||
numBytes := binary.PutUvarint(buf, run)
|
|
||||||
for i := 0; i < numBytes; i++ {
|
|
||||||
v.Extend(buf[i], 8, bitvector.LSB0)
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return nil, 0, ErrRunLengthTooLarge
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return v.Buf, v.Len, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode returns integers represented by the given RLE+ encoding
|
|
||||||
//
|
|
||||||
// The length of the encoding is not specified. It is inferred by
|
|
||||||
// reading zeroes from the (possibly depleted) BitVector, by virtue
|
|
||||||
// of the behavior of BitVector.Take() returning 0 when the end of
|
|
||||||
// the BitVector has been reached. This has the downside of not
|
|
||||||
// being able to detect corrupt encodings.
|
|
||||||
//
|
|
||||||
// The passed []byte should be packed in LSB0 bit numbering
|
|
||||||
func Decode(buf []byte) (ints []uint64, err error) {
|
|
||||||
if len(buf) == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
v := bitvector.NewBitVector(buf, bitvector.LSB0)
|
|
||||||
take := v.Iterator(bitvector.LSB0)
|
|
||||||
|
|
||||||
// Read version and check
|
|
||||||
// Version check
|
|
||||||
ver := take(2)
|
|
||||||
if ver != Version {
|
|
||||||
return nil, ErrWrongVersion
|
|
||||||
}
|
|
||||||
|
|
||||||
curIdx := uint64(0)
|
|
||||||
curBit := take(1)
|
|
||||||
var runLength int
|
|
||||||
done := false
|
|
||||||
|
|
||||||
for done == false {
|
|
||||||
y := take(1)
|
|
||||||
switch y {
|
|
||||||
case 1:
|
|
||||||
runLength = 1
|
|
||||||
case 0:
|
|
||||||
val := take(1)
|
|
||||||
|
|
||||||
if val == 1 {
|
|
||||||
// short block
|
|
||||||
runLength = int(take(4))
|
|
||||||
} else {
|
|
||||||
// long block
|
|
||||||
var buf []byte
|
|
||||||
for {
|
|
||||||
b := take(8)
|
|
||||||
buf = append(buf, b)
|
|
||||||
|
|
||||||
if b&0x80 == 0 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
// 10 bytes is required to store math.MaxUint64 in a uvarint
|
|
||||||
if len(buf) > 10 {
|
|
||||||
return nil, ErrDecode
|
|
||||||
}
|
|
||||||
}
|
|
||||||
x, _ := binary.Uvarint(buf)
|
|
||||||
|
|
||||||
if x == 0 {
|
|
||||||
done = true
|
|
||||||
}
|
|
||||||
runLength = int(x)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if curBit == 1 {
|
|
||||||
for j := 0; j < runLength; j++ {
|
|
||||||
ints = append(ints, curIdx+uint64(j))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
curIdx += uint64(runLength)
|
|
||||||
curBit = 1 - curBit
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// RunLengths transforms integers into its bit-set-run-length representation.
|
|
||||||
//
|
|
||||||
// A set of unsigned integers { 0, 2, 4, 5, 6 } can be thought of as
|
|
||||||
// indices into a bitset { 1, 0, 1, 0, 1, 1, 1 } where bitset[index] == 1.
|
|
||||||
//
|
|
||||||
// The bit set run lengths of this set would then be { 1, 1, 1, 1, 3 },
|
|
||||||
// representing lengths of runs alternating between 1 and 0, starting
|
|
||||||
// with a first bit of 1.
|
|
||||||
//
|
|
||||||
// Duplicated numbers are ignored.
|
|
||||||
//
|
|
||||||
// This is a helper function for Encode()
|
|
||||||
func RunLengths(ints []uint64) (firstBit byte, runs []uint64) {
|
|
||||||
if len(ints) == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sort our incoming numbers
|
|
||||||
sort.Slice(ints, func(i, j int) bool { return ints[i] < ints[j] })
|
|
||||||
|
|
||||||
prev := ints[0]
|
|
||||||
|
|
||||||
// Initialize our return value
|
|
||||||
if prev == 0 {
|
|
||||||
firstBit = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if firstBit == 0 {
|
|
||||||
// first run of zeroes
|
|
||||||
runs = append(runs, prev)
|
|
||||||
}
|
|
||||||
runs = append(runs, 1)
|
|
||||||
|
|
||||||
for _, cur := range ints[1:] {
|
|
||||||
delta := cur - prev
|
|
||||||
switch {
|
|
||||||
case delta == 1:
|
|
||||||
runs[len(runs)-1]++
|
|
||||||
case delta > 1:
|
|
||||||
// add run of zeroes if there is a gap
|
|
||||||
runs = append(runs, delta-1)
|
|
||||||
runs = append(runs, 1)
|
|
||||||
default:
|
|
||||||
// repeated number?
|
|
||||||
}
|
|
||||||
prev = cur
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
Vendored
-213
@@ -1,213 +0,0 @@
|
|||||||
package rleplus_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"math"
|
|
||||||
"sort"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/extern/rleplus"
|
|
||||||
bitvector "github.com/filecoin-project/lotus/extern/rleplus/internal"
|
|
||||||
"gotest.tools/assert"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestRleplus(t *testing.T) {
|
|
||||||
|
|
||||||
t.Run("Encode", func(t *testing.T) {
|
|
||||||
// Encode an intset
|
|
||||||
ints := []uint64{
|
|
||||||
// run of 1
|
|
||||||
0,
|
|
||||||
// gap of 1
|
|
||||||
// run of 1
|
|
||||||
2,
|
|
||||||
// gap of 1
|
|
||||||
// run of 3
|
|
||||||
4, 5, 6,
|
|
||||||
// gap of 4
|
|
||||||
// run of 17
|
|
||||||
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
|
|
||||||
}
|
|
||||||
|
|
||||||
expectedBits := []byte{
|
|
||||||
0, 0, // version
|
|
||||||
1, // first bit
|
|
||||||
1, // run of 1
|
|
||||||
1, // gap of 1
|
|
||||||
1, // run of 1
|
|
||||||
1, // gap of 1
|
|
||||||
0, 1, 1, 1, 0, 0, // run of 3
|
|
||||||
0, 1, 0, 0, 1, 0, // gap of 4
|
|
||||||
|
|
||||||
// run of 17 < 0 0 (varint) >
|
|
||||||
0, 0,
|
|
||||||
1, 0, 0, 0, 1, 0, 0, 0,
|
|
||||||
}
|
|
||||||
|
|
||||||
v := bitvector.BitVector{}
|
|
||||||
for _, bit := range expectedBits {
|
|
||||||
v.Push(bit)
|
|
||||||
}
|
|
||||||
actualBytes, _, err := rleplus.Encode(ints)
|
|
||||||
assert.NilError(t, err)
|
|
||||||
|
|
||||||
assert.Equal(t, len(v.Buf), len(actualBytes))
|
|
||||||
for idx, expected := range v.Buf {
|
|
||||||
assert.Equal(
|
|
||||||
t,
|
|
||||||
fmt.Sprintf("%08b", expected),
|
|
||||||
fmt.Sprintf("%08b", actualBytes[idx]),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("Encode allows all runs sizes possible uint64", func(t *testing.T) {
|
|
||||||
// create a run of math.MaxUint64
|
|
||||||
ints := []uint64{math.MaxUint64}
|
|
||||||
|
|
||||||
// There would be 64 bits(1) for the UvarInt, totally 9 bytes.
|
|
||||||
expected := []byte{0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x20}
|
|
||||||
encodeBytes, _, err := rleplus.Encode(ints)
|
|
||||||
assert.NilError(t, err)
|
|
||||||
for idx, v := range encodeBytes {
|
|
||||||
assert.Equal(
|
|
||||||
t,
|
|
||||||
fmt.Sprintf("%8b", v),
|
|
||||||
fmt.Sprintf("%8b", expected[idx]),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("Encode for some big numbers", func(t *testing.T) {
|
|
||||||
// create a run of math.MaxUint64
|
|
||||||
ints := make([]uint64, 1024)
|
|
||||||
|
|
||||||
// ints {2^63 .. 2^63+1023}
|
|
||||||
for i := uint64(0); i < 1024; i++ {
|
|
||||||
ints[i] = uint64(1)<<63 + i
|
|
||||||
}
|
|
||||||
|
|
||||||
expected := []byte{0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x30, 0x00, 0x40, 0x04}
|
|
||||||
encodeBytes, _, err := rleplus.Encode(ints)
|
|
||||||
assert.NilError(t, err)
|
|
||||||
for idx, v := range encodeBytes {
|
|
||||||
// fmt.Println(v, expected[idx])
|
|
||||||
assert.Equal(
|
|
||||||
t,
|
|
||||||
fmt.Sprintf("%8b", v),
|
|
||||||
fmt.Sprintf("%8b", expected[idx]),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("Decode", func(t *testing.T) {
|
|
||||||
testCases := [][]uint64{
|
|
||||||
{},
|
|
||||||
{1},
|
|
||||||
{0},
|
|
||||||
{0, 1, 2, 3},
|
|
||||||
{
|
|
||||||
// run of 1
|
|
||||||
0,
|
|
||||||
// gap of 1
|
|
||||||
// run of 1
|
|
||||||
2,
|
|
||||||
// gap of 1
|
|
||||||
// run of 3
|
|
||||||
4, 5, 6,
|
|
||||||
// gap of 4
|
|
||||||
// run of 17
|
|
||||||
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tc := range testCases {
|
|
||||||
encoded, _, err := rleplus.Encode(tc)
|
|
||||||
assert.NilError(t, err)
|
|
||||||
|
|
||||||
result, err := rleplus.Decode(encoded)
|
|
||||||
assert.NilError(t, err)
|
|
||||||
|
|
||||||
sort.Slice(tc, func(i, j int) bool { return tc[i] < tc[j] })
|
|
||||||
sort.Slice(result, func(i, j int) bool { return result[i] < result[j] })
|
|
||||||
|
|
||||||
assert.Equal(t, len(tc), len(result))
|
|
||||||
|
|
||||||
for idx, expected := range tc {
|
|
||||||
assert.Equal(t, expected, result[idx])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("Decode version check", func(t *testing.T) {
|
|
||||||
_, err := rleplus.Decode([]byte{0xff})
|
|
||||||
assert.Error(t, err, "invalid RLE+ version")
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("Decode returns an error with a bad encoding", func(t *testing.T) {
|
|
||||||
// create an encoding with a buffer with a run which is too long
|
|
||||||
_, err := rleplus.Decode([]byte{0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff})
|
|
||||||
assert.Error(t, err, "invalid encoding for RLE+ version 0")
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("outputs same as reference implementation", func(t *testing.T) {
|
|
||||||
// Encoding bitvec![LittleEndian; 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
|
|
||||||
// in the Rust reference implementation gives an encoding of [223, 145, 136, 0] (without version field)
|
|
||||||
// The bit vector is equivalent to the integer set { 0, 2, 4, 5, 6, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27 }
|
|
||||||
|
|
||||||
// This is the above reference output with a version header "00" manually added
|
|
||||||
referenceEncoding := []byte{124, 71, 34, 2}
|
|
||||||
|
|
||||||
expectedNumbers := []uint64{0, 2, 4, 5, 6, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27}
|
|
||||||
|
|
||||||
encoded, _, err := rleplus.Encode(expectedNumbers)
|
|
||||||
assert.NilError(t, err)
|
|
||||||
|
|
||||||
// Our encoded bytes are the same as the ref bytes
|
|
||||||
assert.Equal(t, len(referenceEncoding), len(encoded))
|
|
||||||
for idx, expected := range referenceEncoding {
|
|
||||||
assert.Equal(t, expected, encoded[idx])
|
|
||||||
}
|
|
||||||
|
|
||||||
decoded, err := rleplus.Decode(referenceEncoding)
|
|
||||||
assert.NilError(t, err)
|
|
||||||
|
|
||||||
// Our decoded integers are the same as expected
|
|
||||||
sort.Slice(decoded, func(i, j int) bool { return decoded[i] < decoded[j] })
|
|
||||||
assert.Equal(t, len(expectedNumbers), len(decoded))
|
|
||||||
for idx, expected := range expectedNumbers {
|
|
||||||
assert.Equal(t, expected, decoded[idx])
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("RunLengths", func(t *testing.T) {
|
|
||||||
testCases := []struct {
|
|
||||||
ints []uint64
|
|
||||||
first byte
|
|
||||||
runs []uint64
|
|
||||||
}{
|
|
||||||
// empty
|
|
||||||
{},
|
|
||||||
|
|
||||||
// leading with ones
|
|
||||||
{[]uint64{0}, 1, []uint64{1}},
|
|
||||||
{[]uint64{0, 1}, 1, []uint64{2}},
|
|
||||||
{[]uint64{0, 0xffffffff, 0xffffffff + 1}, 1, []uint64{1, 0xffffffff - 1, 2}},
|
|
||||||
|
|
||||||
// leading with zeroes
|
|
||||||
{[]uint64{1}, 0, []uint64{1, 1}},
|
|
||||||
{[]uint64{2}, 0, []uint64{2, 1}},
|
|
||||||
{[]uint64{10, 11, 13, 20}, 0, []uint64{10, 2, 1, 1, 6, 1}},
|
|
||||||
{[]uint64{10, 11, 11, 13, 20, 10, 11, 13, 20}, 0, []uint64{10, 2, 1, 1, 6, 1}},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
|
||||||
first, runs := rleplus.RunLengths(testCase.ints)
|
|
||||||
assert.Equal(t, testCase.first, first)
|
|
||||||
assert.Equal(t, len(testCase.runs), len(runs))
|
|
||||||
for idx, runLength := range testCase.runs {
|
|
||||||
assert.Equal(t, runLength, runs[idx])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
+1
-1
@@ -28,7 +28,7 @@ type PreSeal struct {
|
|||||||
type Miner struct {
|
type Miner struct {
|
||||||
Owner address.Address
|
Owner address.Address
|
||||||
Worker address.Address
|
Worker address.Address
|
||||||
PeerId peer.ID
|
PeerId peer.ID //nolint:golint
|
||||||
|
|
||||||
MarketBalance abi.TokenAmount
|
MarketBalance abi.TokenAmount
|
||||||
PowerBalance abi.TokenAmount
|
PowerBalance abi.TokenAmount
|
||||||
|
|||||||
@@ -11,41 +11,45 @@ require (
|
|||||||
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
|
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
|
||||||
github.com/coreos/go-systemd/v22 v22.0.0
|
github.com/coreos/go-systemd/v22 v22.0.0
|
||||||
github.com/docker/go-units v0.4.0
|
github.com/docker/go-units v0.4.0
|
||||||
github.com/drand/drand v0.8.2-0.20200518165838-d61135e6e2c8
|
github.com/drand/drand v0.9.2-0.20200529123141-6b138aefaef2
|
||||||
|
github.com/drand/kyber v1.0.2
|
||||||
github.com/fatih/color v1.8.0
|
github.com/fatih/color v1.8.0
|
||||||
github.com/filecoin-project/chain-validation v0.0.6-0.20200526171800-c56c1882dc99
|
github.com/filecoin-project/chain-validation v0.0.6-0.20200528212128-d4578ae4f874
|
||||||
github.com/filecoin-project/filecoin-ffi v0.26.1-0.20200508175440-05b30afeb00d
|
github.com/filecoin-project/filecoin-ffi v0.26.1-0.20200508175440-05b30afeb00d
|
||||||
github.com/filecoin-project/go-address v0.0.2-0.20200504173055-8b6f2fb2b3ef
|
github.com/filecoin-project/go-address v0.0.2-0.20200504173055-8b6f2fb2b3ef
|
||||||
github.com/filecoin-project/go-amt-ipld/v2 v2.0.1-0.20200424220931-6263827e49f2
|
github.com/filecoin-project/go-amt-ipld/v2 v2.0.1-0.20200424220931-6263827e49f2
|
||||||
github.com/filecoin-project/go-bitfield v0.0.1
|
github.com/filecoin-project/go-bitfield v0.0.2-0.20200518150651-562fdb554b6e
|
||||||
github.com/filecoin-project/go-cbor-util v0.0.0-20191219014500-08c40a1e63a2
|
github.com/filecoin-project/go-cbor-util v0.0.0-20191219014500-08c40a1e63a2
|
||||||
github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03
|
github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03
|
||||||
github.com/filecoin-project/go-data-transfer v0.3.0
|
github.com/filecoin-project/go-data-transfer v0.3.0
|
||||||
github.com/filecoin-project/go-fil-commcid v0.0.0-20200208005934-2b8bd03caca5
|
github.com/filecoin-project/go-fil-commcid v0.0.0-20200208005934-2b8bd03caca5
|
||||||
github.com/filecoin-project/go-fil-markets v0.2.7
|
github.com/filecoin-project/go-fil-markets v0.2.7
|
||||||
github.com/filecoin-project/go-jsonrpc v0.1.1-0.20200602181149-522144ab4e24
|
github.com/filecoin-project/go-jsonrpc v0.1.1-0.20200520183639-7c6ee2e066b4
|
||||||
github.com/filecoin-project/go-padreader v0.0.0-20200210211231-548257017ca6
|
github.com/filecoin-project/go-padreader v0.0.0-20200210211231-548257017ca6
|
||||||
github.com/filecoin-project/go-paramfetch v0.0.2-0.20200505180321-973f8949ea8e
|
github.com/filecoin-project/go-paramfetch v0.0.2-0.20200505180321-973f8949ea8e
|
||||||
github.com/filecoin-project/go-statestore v0.1.0
|
github.com/filecoin-project/go-statestore v0.1.0
|
||||||
github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b
|
github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b
|
||||||
github.com/filecoin-project/sector-storage v0.0.0-20200522011946-a59ca7536a95
|
github.com/filecoin-project/sector-storage v0.0.0-20200529175241-9df0cdf19326
|
||||||
github.com/filecoin-project/specs-actors v0.5.4-0.20200521014528-0df536f7e461
|
github.com/filecoin-project/specs-actors v0.5.4
|
||||||
github.com/filecoin-project/specs-storage v0.0.0-20200417134612-61b2d91a6102
|
github.com/filecoin-project/specs-storage v0.0.0-20200417134612-61b2d91a6102
|
||||||
github.com/filecoin-project/storage-fsm v0.0.0-20200522010518-83fd743db8bc
|
github.com/filecoin-project/storage-fsm v0.0.0-20200528050623-cdada6e88960
|
||||||
github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1
|
github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1
|
||||||
|
github.com/go-kit/kit v0.10.0
|
||||||
github.com/go-ole/go-ole v1.2.4 // indirect
|
github.com/go-ole/go-ole v1.2.4 // indirect
|
||||||
github.com/google/uuid v1.1.1
|
github.com/google/uuid v1.1.1
|
||||||
github.com/gorilla/mux v1.7.4
|
github.com/gorilla/mux v1.7.4
|
||||||
github.com/gorilla/websocket v1.4.2
|
github.com/gorilla/websocket v1.4.2
|
||||||
github.com/hashicorp/go-multierror v1.1.0
|
github.com/hashicorp/go-multierror v1.1.0
|
||||||
github.com/hashicorp/golang-lru v0.5.4
|
github.com/hashicorp/golang-lru v0.5.4
|
||||||
github.com/influxdata/influxdb1-client v0.0.0-20190809212627-fc22c7df067e
|
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d
|
||||||
github.com/ipfs/go-bitswap v0.2.8
|
github.com/ipfs/go-bitswap v0.2.8
|
||||||
github.com/ipfs/go-block-format v0.0.2
|
github.com/ipfs/go-block-format v0.0.2
|
||||||
github.com/ipfs/go-blockservice v0.1.3
|
github.com/ipfs/go-blockservice v0.1.3
|
||||||
github.com/ipfs/go-cid v0.0.6-0.20200501230655-7c82f3b81c00
|
github.com/ipfs/go-cid v0.0.6-0.20200501230655-7c82f3b81c00
|
||||||
github.com/ipfs/go-datastore v0.4.4
|
github.com/ipfs/go-datastore v0.4.4
|
||||||
github.com/ipfs/go-ds-badger2 v0.1.0
|
github.com/ipfs/go-ds-badger2 v0.1.0
|
||||||
|
github.com/ipfs/go-ds-leveldb v0.4.2
|
||||||
|
github.com/ipfs/go-ds-measure v0.1.0
|
||||||
github.com/ipfs/go-filestore v1.0.0
|
github.com/ipfs/go-filestore v1.0.0
|
||||||
github.com/ipfs/go-fs-lock v0.0.1
|
github.com/ipfs/go-fs-lock v0.0.1
|
||||||
github.com/ipfs/go-graphsync v0.0.6-0.20200504202014-9d5f2c26a103
|
github.com/ipfs/go-graphsync v0.0.6-0.20200504202014-9d5f2c26a103
|
||||||
@@ -61,33 +65,33 @@ require (
|
|||||||
github.com/ipfs/go-ipld-cbor v0.0.5-0.20200428170625-a0bd04d3cbdf
|
github.com/ipfs/go-ipld-cbor v0.0.5-0.20200428170625-a0bd04d3cbdf
|
||||||
github.com/ipfs/go-ipld-format v0.2.0
|
github.com/ipfs/go-ipld-format v0.2.0
|
||||||
github.com/ipfs/go-log v1.0.4
|
github.com/ipfs/go-log v1.0.4
|
||||||
github.com/ipfs/go-log/v2 v2.0.8
|
github.com/ipfs/go-log/v2 v2.1.1
|
||||||
github.com/ipfs/go-merkledag v0.3.1
|
github.com/ipfs/go-merkledag v0.3.1
|
||||||
github.com/ipfs/go-path v0.0.7
|
github.com/ipfs/go-path v0.0.7
|
||||||
github.com/ipfs/go-unixfs v0.2.4
|
github.com/ipfs/go-unixfs v0.2.4
|
||||||
github.com/ipfs/interface-go-ipfs-core v0.2.3
|
github.com/ipfs/interface-go-ipfs-core v0.2.3
|
||||||
github.com/ipld/go-car v0.1.1-0.20200430185908-8ff2e52a4c88
|
github.com/ipld/go-car v0.1.1-0.20200526133713-1c7508d55aae
|
||||||
github.com/ipld/go-ipld-prime v0.0.2-0.20200428162820-8b59dc292b8e
|
github.com/ipld/go-ipld-prime v0.0.2-0.20200428162820-8b59dc292b8e
|
||||||
github.com/kelseyhightower/envconfig v1.4.0
|
github.com/kelseyhightower/envconfig v1.4.0
|
||||||
github.com/lib/pq v1.2.0
|
github.com/lib/pq v1.2.0
|
||||||
github.com/libp2p/go-eventbus v0.2.1
|
github.com/libp2p/go-eventbus v0.1.0
|
||||||
github.com/libp2p/go-libp2p v0.9.4
|
github.com/libp2p/go-libp2p v0.9.2
|
||||||
github.com/libp2p/go-libp2p-connmgr v0.2.4
|
github.com/libp2p/go-libp2p-connmgr v0.2.3
|
||||||
github.com/libp2p/go-libp2p-core v0.5.7
|
github.com/libp2p/go-libp2p-core v0.5.6
|
||||||
github.com/libp2p/go-libp2p-discovery v0.4.0
|
github.com/libp2p/go-libp2p-discovery v0.4.0
|
||||||
github.com/libp2p/go-libp2p-kad-dht v0.8.1
|
github.com/libp2p/go-libp2p-kad-dht v0.7.6
|
||||||
github.com/libp2p/go-libp2p-mplex v0.2.3
|
github.com/libp2p/go-libp2p-mplex v0.2.3
|
||||||
github.com/libp2p/go-libp2p-peer v0.2.0
|
github.com/libp2p/go-libp2p-peer v0.2.0
|
||||||
github.com/libp2p/go-libp2p-peerstore v0.2.4
|
github.com/libp2p/go-libp2p-peerstore v0.2.4
|
||||||
github.com/libp2p/go-libp2p-pubsub v0.3.2
|
github.com/libp2p/go-libp2p-pubsub v0.3.1
|
||||||
github.com/libp2p/go-libp2p-quic-transport v0.5.0
|
github.com/libp2p/go-libp2p-quic-transport v0.1.1
|
||||||
github.com/libp2p/go-libp2p-record v0.1.2
|
github.com/libp2p/go-libp2p-record v0.1.2
|
||||||
github.com/libp2p/go-libp2p-routing-helpers v0.2.3
|
github.com/libp2p/go-libp2p-routing-helpers v0.2.1
|
||||||
github.com/libp2p/go-libp2p-secio v0.2.2
|
github.com/libp2p/go-libp2p-secio v0.2.2
|
||||||
github.com/libp2p/go-libp2p-swarm v0.2.6
|
github.com/libp2p/go-libp2p-swarm v0.2.4
|
||||||
github.com/libp2p/go-libp2p-tls v0.1.3
|
github.com/libp2p/go-libp2p-tls v0.1.3
|
||||||
github.com/libp2p/go-libp2p-yamux v0.2.8
|
github.com/libp2p/go-libp2p-yamux v0.2.7
|
||||||
github.com/libp2p/go-maddr-filter v0.1.0
|
github.com/libp2p/go-maddr-filter v0.0.5
|
||||||
github.com/mattn/go-isatty v0.0.12 // indirect
|
github.com/mattn/go-isatty v0.0.12 // indirect
|
||||||
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1
|
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1
|
||||||
github.com/mitchellh/go-homedir v1.1.0
|
github.com/mitchellh/go-homedir v1.1.0
|
||||||
@@ -99,6 +103,7 @@ require (
|
|||||||
github.com/opentracing/opentracing-go v1.1.0
|
github.com/opentracing/opentracing-go v1.1.0
|
||||||
github.com/stretchr/objx v0.2.0 // indirect
|
github.com/stretchr/objx v0.2.0 // indirect
|
||||||
github.com/stretchr/testify v1.5.1
|
github.com/stretchr/testify v1.5.1
|
||||||
|
github.com/syndtr/goleveldb v1.0.0
|
||||||
github.com/whyrusleeping/bencher v0.0.0-20190829221104-bb6607aa8bba
|
github.com/whyrusleeping/bencher v0.0.0-20190829221104-bb6607aa8bba
|
||||||
github.com/whyrusleeping/cbor-gen v0.0.0-20200504204219-64967432584d
|
github.com/whyrusleeping/cbor-gen v0.0.0-20200504204219-64967432584d
|
||||||
github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7
|
github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7
|
||||||
@@ -110,10 +115,9 @@ require (
|
|||||||
go.uber.org/zap v1.15.0
|
go.uber.org/zap v1.15.0
|
||||||
go4.org v0.0.0-20190313082347-94abd6928b1d // indirect
|
go4.org v0.0.0-20190313082347-94abd6928b1d // indirect
|
||||||
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299
|
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299
|
||||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
|
golang.org/x/time v0.0.0-20191024005414-555d28b269f0
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543
|
||||||
gopkg.in/urfave/cli.v2 v2.0.0-20180128182452-d3ae77c26ac8
|
gopkg.in/urfave/cli.v2 v2.0.0-20180128182452-d3ae77c26ac8
|
||||||
gotest.tools v2.2.0+incompatible
|
|
||||||
launchpad.net/gocheck v0.0.0-20140225173054-000000000087 // indirect
|
launchpad.net/gocheck v0.0.0-20140225173054-000000000087 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
madns "github.com/multiformats/go-multiaddr-dns"
|
madns "github.com/multiformats/go-multiaddr-dns"
|
||||||
)
|
)
|
||||||
|
|
||||||
// parseAddresses is a function that takes in a slice of string peer addresses
|
// ParseAddresses is a function that takes in a slice of string peer addresses
|
||||||
// (multiaddr + peerid) and returns a slice of properly constructed peers
|
// (multiaddr + peerid) and returns a slice of properly constructed peers
|
||||||
func ParseAddresses(ctx context.Context, addrs []string) ([]peer.AddrInfo, error) {
|
func ParseAddresses(ctx context.Context, addrs []string) ([]peer.AddrInfo, error) {
|
||||||
// resolve addresses
|
// resolve addresses
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ func (crt *incrt) Read(buf []byte) (int, error) {
|
|||||||
|
|
||||||
n, err := crt.rd.Read(buf)
|
n, err := crt.rd.Read(buf)
|
||||||
|
|
||||||
crt.rd.SetReadDeadline(time.Time{})
|
_ = crt.rd.SetReadDeadline(time.Time{})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
dur := now().Sub(start)
|
dur := now().Sub(start)
|
||||||
crt.wait -= dur
|
crt.wait -= dur
|
||||||
|
|||||||
@@ -8,14 +8,14 @@ import (
|
|||||||
|
|
||||||
func SetupLogLevels() {
|
func SetupLogLevels() {
|
||||||
if _, set := os.LookupEnv("GOLOG_LOG_LEVEL"); !set {
|
if _, set := os.LookupEnv("GOLOG_LOG_LEVEL"); !set {
|
||||||
logging.SetLogLevel("*", "INFO")
|
_ = logging.SetLogLevel("*", "INFO")
|
||||||
logging.SetLogLevel("dht", "ERROR")
|
_ = logging.SetLogLevel("dht", "ERROR")
|
||||||
logging.SetLogLevel("swarm2", "WARN")
|
_ = logging.SetLogLevel("swarm2", "WARN")
|
||||||
logging.SetLogLevel("bitswap", "WARN")
|
_ = logging.SetLogLevel("bitswap", "WARN")
|
||||||
//logging.SetLogLevel("pubsub", "WARN")
|
//_ = logging.SetLogLevel("pubsub", "WARN")
|
||||||
logging.SetLogLevel("connmgr", "WARN")
|
_ = logging.SetLogLevel("connmgr", "WARN")
|
||||||
logging.SetLogLevel("advmgr", "DEBUG")
|
_ = logging.SetLogLevel("advmgr", "DEBUG")
|
||||||
logging.SetLogLevel("stores", "DEBUG")
|
_ = logging.SetLogLevel("stores", "DEBUG")
|
||||||
logging.SetLogLevel("nat", "INFO")
|
_ = logging.SetLogLevel("nat", "INFO")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package main
|
package parmap
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
func maparr(in interface{}) interface{} {
|
func MapArr(in interface{}) interface{} {
|
||||||
rin := reflect.ValueOf(in)
|
rin := reflect.ValueOf(in)
|
||||||
rout := reflect.MakeSlice(reflect.SliceOf(rin.Type().Elem()), rin.Len(), rin.Len())
|
rout := reflect.MakeSlice(reflect.SliceOf(rin.Type().Elem()), rin.Len(), rin.Len())
|
||||||
var i int
|
var i int
|
||||||
@@ -19,7 +19,7 @@ func maparr(in interface{}) interface{} {
|
|||||||
return rout.Interface()
|
return rout.Interface()
|
||||||
}
|
}
|
||||||
|
|
||||||
func kmaparr(in interface{}) interface{} {
|
func KMapArr(in interface{}) interface{} {
|
||||||
rin := reflect.ValueOf(in)
|
rin := reflect.ValueOf(in)
|
||||||
rout := reflect.MakeSlice(reflect.SliceOf(rin.Type().Key()), rin.Len(), rin.Len())
|
rout := reflect.MakeSlice(reflect.SliceOf(rin.Type().Key()), rin.Len(), rin.Len())
|
||||||
var i int
|
var i int
|
||||||
@@ -34,7 +34,7 @@ func kmaparr(in interface{}) interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// map[k]v => []func() (k, v)
|
// map[k]v => []func() (k, v)
|
||||||
func kvmaparr(in interface{}) interface{} {
|
func KVMapArr(in interface{}) interface{} {
|
||||||
rin := reflect.ValueOf(in)
|
rin := reflect.ValueOf(in)
|
||||||
|
|
||||||
t := reflect.FuncOf([]reflect.Type{}, []reflect.Type{
|
t := reflect.FuncOf([]reflect.Type{}, []reflect.Type{
|
||||||
@@ -59,7 +59,7 @@ func kvmaparr(in interface{}) interface{} {
|
|||||||
return rout.Interface()
|
return rout.Interface()
|
||||||
}
|
}
|
||||||
|
|
||||||
func par(concurrency int, arr interface{}, f interface{}) {
|
func Par(concurrency int, arr interface{}, f interface{}) {
|
||||||
throttle := make(chan struct{}, concurrency)
|
throttle := make(chan struct{}, concurrency)
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
|
|
||||||
@@ -44,12 +44,11 @@
|
|||||||
"Constructor",
|
"Constructor",
|
||||||
"AddBalance",
|
"AddBalance",
|
||||||
"WithdrawBalance",
|
"WithdrawBalance",
|
||||||
"HandleExpiredDeals",
|
|
||||||
"PublishStorageDeals",
|
"PublishStorageDeals",
|
||||||
"VerifyDealsOnSectorProveCommit",
|
"VerifyDealsOnSectorProveCommit",
|
||||||
"OnMinerSectorsTerminate",
|
"OnMinerSectorsTerminate",
|
||||||
"ComputeDataCommitment",
|
"ComputeDataCommitment",
|
||||||
"HandleInitTimeoutDeals"
|
"CronTick"
|
||||||
],
|
],
|
||||||
"fil/1/storageminer": [
|
"fil/1/storageminer": [
|
||||||
"Send",
|
"Send",
|
||||||
@@ -68,7 +67,8 @@
|
|||||||
"CheckSectorProven",
|
"CheckSectorProven",
|
||||||
"AddLockedFund",
|
"AddLockedFund",
|
||||||
"ReportConsensusFault",
|
"ReportConsensusFault",
|
||||||
"WithdrawBalance"
|
"WithdrawBalance",
|
||||||
|
"ConfirmSectorProofsValid"
|
||||||
],
|
],
|
||||||
"fil/1/storagepower": [
|
"fil/1/storagepower": [
|
||||||
"Send",
|
"Send",
|
||||||
@@ -83,7 +83,8 @@
|
|||||||
"EnrollCronEvent",
|
"EnrollCronEvent",
|
||||||
"OnEpochTickEnd",
|
"OnEpochTickEnd",
|
||||||
"UpdatePledgeTotal",
|
"UpdatePledgeTotal",
|
||||||
"OnConsensusFault"
|
"OnConsensusFault",
|
||||||
|
"SubmitPoRepForBulkVerify"
|
||||||
],
|
],
|
||||||
"fil/1/verifiedregistry": [
|
"fil/1/verifiedregistry": [
|
||||||
"Send",
|
"Send",
|
||||||
|
|||||||
+3
-3
@@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
@@ -16,7 +17,6 @@ import (
|
|||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
genesis2 "github.com/filecoin-project/lotus/chain/gen/genesis"
|
genesis2 "github.com/filecoin-project/lotus/chain/gen/genesis"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/cmd/lotus-seed/seed"
|
"github.com/filecoin-project/lotus/cmd/lotus-seed/seed"
|
||||||
@@ -65,7 +65,7 @@ func (api *api) Spawn() (nodeInfo, error) {
|
|||||||
template.Miners = append(template.Miners, *genm)
|
template.Miners = append(template.Miners, *genm)
|
||||||
template.Accounts = append(template.Accounts, genesis.Actor{
|
template.Accounts = append(template.Accounts, genesis.Actor{
|
||||||
Type: genesis.TAccount,
|
Type: genesis.TAccount,
|
||||||
Balance: big.NewInt(100000000000000),
|
Balance: types.FromFil(5000000),
|
||||||
Meta: (&genesis.AccountMeta{Owner: genm.Owner}).ActorMeta(),
|
Meta: (&genesis.AccountMeta{Owner: genm.Owner}).ActorMeta(),
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -171,7 +171,7 @@ func (api *api) SpawnStorage(fullNodeRepo string) (nodeInfo, error) {
|
|||||||
initArgs := []string{"init", "--nosync"}
|
initArgs := []string{"init", "--nosync"}
|
||||||
if fullNodeRepo == api.running[1].meta.Repo {
|
if fullNodeRepo == api.running[1].meta.Repo {
|
||||||
presealPrefix := filepath.Join(fullNodeRepo, "preseal")
|
presealPrefix := filepath.Join(fullNodeRepo, "preseal")
|
||||||
initArgs = []string{"init", "--actor=t01000", "--genesis-miner", "--pre-sealed-sectors=" + presealPrefix, "--pre-sealed-metadata=" + filepath.Join(presealPrefix, "pre-seal-t0101.json")}
|
initArgs = []string{"init", "--actor=t01000", "--genesis-miner", "--pre-sealed-sectors=" + presealPrefix, "--pre-sealed-metadata=" + filepath.Join(presealPrefix, "pre-seal-t01000.json")}
|
||||||
}
|
}
|
||||||
|
|
||||||
id := atomic.AddInt32(&api.cmds, 1)
|
id := atomic.AddInt32(&api.cmds, 1)
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ package retrievaladapter
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"github.com/filecoin-project/sector-storage/storiface"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
|
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
|
||||||
"github.com/filecoin-project/go-fil-markets/shared"
|
"github.com/filecoin-project/go-fil-markets/shared"
|
||||||
sectorstorage "github.com/filecoin-project/sector-storage"
|
sectorstorage "github.com/filecoin-project/sector-storage"
|
||||||
"github.com/filecoin-project/sector-storage/ffiwrapper"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/paych"
|
"github.com/filecoin-project/specs-actors/actors/builtin/paych"
|
||||||
|
|
||||||
@@ -54,7 +54,14 @@ func (rpn *retrievalProviderNode) UnsealSector(ctx context.Context, sectorID uin
|
|||||||
Miner: abi.ActorID(mid),
|
Miner: abi.ActorID(mid),
|
||||||
Number: abi.SectorNumber(sectorID),
|
Number: abi.SectorNumber(sectorID),
|
||||||
}
|
}
|
||||||
return rpn.sealer.ReadPieceFromSealedSector(ctx, sid, ffiwrapper.UnpaddedByteIndex(offset), abi.UnpaddedPieceSize(length), si.TicketValue, *si.CommD)
|
|
||||||
|
r, w := io.Pipe()
|
||||||
|
go func() {
|
||||||
|
err := rpn.sealer.ReadPiece(ctx, w, sid, storiface.UnpaddedByteIndex(offset), abi.UnpaddedPieceSize(length), si.TicketValue, *si.CommD)
|
||||||
|
_ = w.CloseWithError(err)
|
||||||
|
}()
|
||||||
|
|
||||||
|
return r, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rpn *retrievalProviderNode) SavePaymentVoucher(ctx context.Context, paymentChannel address.Address, voucher *paych.SignedVoucher, proof []byte, expectedAmount abi.TokenAmount, tok shared.TipSetToken) (abi.TokenAmount, error) {
|
func (rpn *retrievalProviderNode) SavePaymentVoucher(ctx context.Context, paymentChannel address.Address, voucher *paych.SignedVoucher, proof []byte, expectedAmount abi.TokenAmount, tok shared.TipSetToken) (abi.TokenAmount, error) {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/market"
|
"github.com/filecoin-project/specs-actors/actors/builtin/market"
|
||||||
peer "github.com/libp2p/go-libp2p-peer"
|
peer "github.com/libp2p/go-libp2p-core/peer"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
||||||
|
|||||||
+3
-10
@@ -15,7 +15,6 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/lotus/chain/beacon"
|
|
||||||
"github.com/filecoin-project/lotus/chain/gen"
|
"github.com/filecoin-project/lotus/chain/gen"
|
||||||
"github.com/filecoin-project/lotus/chain/store"
|
"github.com/filecoin-project/lotus/chain/store"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
@@ -31,7 +30,7 @@ var log = logging.Logger("miner")
|
|||||||
// returns a callback reporting whether we mined a blocks in this round
|
// returns a callback reporting whether we mined a blocks in this round
|
||||||
type waitFunc func(ctx context.Context, baseTime uint64) (func(bool), error)
|
type waitFunc func(ctx context.Context, baseTime uint64) (func(bool), error)
|
||||||
|
|
||||||
func NewMiner(api api.FullNode, epp gen.WinningPoStProver, beacon beacon.RandomBeacon, addr address.Address) *Miner {
|
func NewMiner(api api.FullNode, epp gen.WinningPoStProver, addr address.Address) *Miner {
|
||||||
arc, err := lru.NewARC(10000)
|
arc, err := lru.NewARC(10000)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@@ -40,7 +39,6 @@ func NewMiner(api api.FullNode, epp gen.WinningPoStProver, beacon beacon.RandomB
|
|||||||
return &Miner{
|
return &Miner{
|
||||||
api: api,
|
api: api,
|
||||||
epp: epp,
|
epp: epp,
|
||||||
beacon: beacon,
|
|
||||||
address: addr,
|
address: addr,
|
||||||
waitFunc: func(ctx context.Context, baseTime uint64) (func(bool), error) {
|
waitFunc: func(ctx context.Context, baseTime uint64) (func(bool), error) {
|
||||||
// Wait around for half the block time in case other parents come in
|
// Wait around for half the block time in case other parents come in
|
||||||
@@ -56,8 +54,7 @@ func NewMiner(api api.FullNode, epp gen.WinningPoStProver, beacon beacon.RandomB
|
|||||||
type Miner struct {
|
type Miner struct {
|
||||||
api api.FullNode
|
api api.FullNode
|
||||||
|
|
||||||
epp gen.WinningPoStProver
|
epp gen.WinningPoStProver
|
||||||
beacon beacon.RandomBeacon
|
|
||||||
|
|
||||||
lk sync.Mutex
|
lk sync.Mutex
|
||||||
address address.Address
|
address address.Address
|
||||||
@@ -271,12 +268,8 @@ func (m *Miner) mineOne(ctx context.Context, base *MiningBase) (*types.BlockMsg,
|
|||||||
|
|
||||||
beaconPrev := mbi.PrevBeaconEntry
|
beaconPrev := mbi.PrevBeaconEntry
|
||||||
|
|
||||||
bvals, err := beacon.BeaconEntriesForBlock(ctx, m.beacon, round, beaconPrev)
|
|
||||||
if err != nil {
|
|
||||||
return nil, xerrors.Errorf("get beacon entries failed: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
tDrand := time.Now()
|
tDrand := time.Now()
|
||||||
|
bvals := mbi.BeaconEntries
|
||||||
|
|
||||||
hasPower, err := m.hasPower(ctx, m.address, base.TipSet)
|
hasPower, err := m.hasPower(ctx, m.address, base.TipSet)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
+2
-4
@@ -5,20 +5,18 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/chain/beacon"
|
|
||||||
"github.com/filecoin-project/lotus/chain/gen"
|
"github.com/filecoin-project/lotus/chain/gen"
|
||||||
lru "github.com/hashicorp/golang-lru"
|
lru "github.com/hashicorp/golang-lru"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewTestMiner(nextCh <-chan func(bool), addr address.Address) func(api.FullNode, gen.WinningPoStProver, beacon.RandomBeacon) *Miner {
|
func NewTestMiner(nextCh <-chan func(bool), addr address.Address) func(api.FullNode, gen.WinningPoStProver) *Miner {
|
||||||
return func(api api.FullNode, epp gen.WinningPoStProver, b beacon.RandomBeacon) *Miner {
|
return func(api api.FullNode, epp gen.WinningPoStProver) *Miner {
|
||||||
arc, err := lru.NewARC(10000)
|
arc, err := lru.NewARC(10000)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
m := &Miner{
|
m := &Miner{
|
||||||
beacon: b,
|
|
||||||
api: api,
|
api: api,
|
||||||
waitFunc: chanWaiter(nextCh),
|
waitFunc: chanWaiter(nextCh),
|
||||||
epp: epp,
|
epp: epp,
|
||||||
|
|||||||
@@ -150,7 +150,6 @@ func defaults() []Option {
|
|||||||
Override(new(helpers.MetricsCtx), context.Background),
|
Override(new(helpers.MetricsCtx), context.Background),
|
||||||
Override(new(record.Validator), modules.RecordValidator),
|
Override(new(record.Validator), modules.RecordValidator),
|
||||||
Override(new(dtypes.Bootstrapper), dtypes.Bootstrapper(false)),
|
Override(new(dtypes.Bootstrapper), dtypes.Bootstrapper(false)),
|
||||||
Override(new(dtypes.ShutdownChan), make(chan struct{})),
|
|
||||||
|
|
||||||
// Filecoin modules
|
// Filecoin modules
|
||||||
|
|
||||||
@@ -293,7 +292,6 @@ func Online() Option {
|
|||||||
Override(new(*sectorblocks.SectorBlocks), sectorblocks.NewSectorBlocks),
|
Override(new(*sectorblocks.SectorBlocks), sectorblocks.NewSectorBlocks),
|
||||||
Override(new(*storage.Miner), modules.StorageMiner),
|
Override(new(*storage.Miner), modules.StorageMiner),
|
||||||
Override(new(dtypes.NetworkName), modules.StorageNetworkName),
|
Override(new(dtypes.NetworkName), modules.StorageNetworkName),
|
||||||
Override(new(beacon.RandomBeacon), modules.MinerRandomBeacon),
|
|
||||||
|
|
||||||
Override(new(dtypes.StagingBlockstore), modules.StagingBlockstore),
|
Override(new(dtypes.StagingBlockstore), modules.StagingBlockstore),
|
||||||
Override(new(dtypes.StagingDAG), modules.StagingDAG),
|
Override(new(dtypes.StagingDAG), modules.StagingDAG),
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ func DefaultStorageMiner() *StorageMiner {
|
|||||||
AllowPreCommit1: true,
|
AllowPreCommit1: true,
|
||||||
AllowPreCommit2: true,
|
AllowPreCommit2: true,
|
||||||
AllowCommit: true,
|
AllowCommit: true,
|
||||||
|
AllowUnseal: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cfg.Common.API.ListenAddress = "/ip4/127.0.0.1/tcp/2345/http"
|
cfg.Common.API.ListenAddress = "/ip4/127.0.0.1/tcp/2345/http"
|
||||||
|
|||||||
@@ -2,12 +2,13 @@ package config
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/filecoin-project/sector-storage/stores"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/sector-storage/stores"
|
||||||
)
|
)
|
||||||
|
|
||||||
func StorageFromFile(path string, def *stores.StorageConfig) (*stores.StorageConfig, error) {
|
func StorageFromFile(path string, def *stores.StorageConfig) (*stores.StorageConfig, error) {
|
||||||
|
|||||||
+5
-5
@@ -64,7 +64,7 @@ func (hs *Service) HandleStream(s inet.Stream) {
|
|||||||
var hmsg HelloMessage
|
var hmsg HelloMessage
|
||||||
if err := cborutil.ReadCborRPC(s, &hmsg); err != nil {
|
if err := cborutil.ReadCborRPC(s, &hmsg); err != nil {
|
||||||
log.Infow("failed to read hello message, disconnecting", "error", err)
|
log.Infow("failed to read hello message, disconnecting", "error", err)
|
||||||
s.Conn().Close()
|
_ = s.Conn().Close()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
arrived := time.Now()
|
arrived := time.Now()
|
||||||
@@ -76,11 +76,11 @@ func (hs *Service) HandleStream(s inet.Stream) {
|
|||||||
|
|
||||||
if hmsg.GenesisHash != hs.syncer.Genesis.Cids()[0] {
|
if hmsg.GenesisHash != hs.syncer.Genesis.Cids()[0] {
|
||||||
log.Warnf("other peer has different genesis! (%s)", hmsg.GenesisHash)
|
log.Warnf("other peer has different genesis! (%s)", hmsg.GenesisHash)
|
||||||
s.Conn().Close()
|
_ = s.Conn().Close()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
defer s.Close()
|
defer s.Close() //nolint:errcheck
|
||||||
|
|
||||||
sent := time.Now()
|
sent := time.Now()
|
||||||
msg := &LatencyMessage{
|
msg := &LatencyMessage{
|
||||||
@@ -152,10 +152,10 @@ func (hs *Service) SayHello(ctx context.Context, pid peer.ID) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer s.Close()
|
defer s.Close() //nolint:errcheck
|
||||||
|
|
||||||
lmsg := &LatencyMessage{}
|
lmsg := &LatencyMessage{}
|
||||||
s.SetReadDeadline(time.Now().Add(10 * time.Second))
|
_ = s.SetReadDeadline(time.Now().Add(10 * time.Second))
|
||||||
err := cborutil.ReadCborRPC(s, lmsg)
|
err := cborutil.ReadCborRPC(s, lmsg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Infow("reading latency message", "error", err)
|
log.Infow("reading latency message", "error", err)
|
||||||
|
|||||||
@@ -432,7 +432,7 @@ func (a *API) ClientGenCar(ctx context.Context, ref api.FileRef, outputPath stri
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
defer bufferedDS.Remove(ctx, c)
|
defer bufferedDS.Remove(ctx, c) //nolint:errcheck
|
||||||
ssb := builder.NewSelectorSpecBuilder(basicnode.Style.Any)
|
ssb := builder.NewSelectorSpecBuilder(basicnode.Style.Any)
|
||||||
|
|
||||||
// entire DAG selector
|
// entire DAG selector
|
||||||
@@ -440,7 +440,6 @@ func (a *API) ClientGenCar(ctx context.Context, ref api.FileRef, outputPath stri
|
|||||||
ssb.ExploreAll(ssb.ExploreRecursiveEdge())).Node()
|
ssb.ExploreAll(ssb.ExploreRecursiveEdge())).Node()
|
||||||
|
|
||||||
f, err := os.Create(outputPath)
|
f, err := os.Create(outputPath)
|
||||||
defer f.Close()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -450,7 +449,7 @@ func (a *API) ClientGenCar(ctx context.Context, ref api.FileRef, outputPath stri
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return f.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) clientImport(ref api.FileRef, bufferedDS *ipld.BufferedDAG) (cid.Cid, error) {
|
func (a *API) clientImport(ref api.FileRef, bufferedDS *ipld.BufferedDAG) (cid.Cid, error) {
|
||||||
|
|||||||
@@ -25,10 +25,9 @@ import (
|
|||||||
type CommonAPI struct {
|
type CommonAPI struct {
|
||||||
fx.In
|
fx.In
|
||||||
|
|
||||||
APISecret *dtypes.APIAlg
|
APISecret *dtypes.APIAlg
|
||||||
Host host.Host
|
Host host.Host
|
||||||
Router lp2p.BaseIpfsRouting
|
Router lp2p.BaseIpfsRouting
|
||||||
ShutdownChan dtypes.ShutdownChan
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type jwtPayload struct {
|
type jwtPayload struct {
|
||||||
@@ -101,7 +100,7 @@ func (a *CommonAPI) ID(context.Context) (peer.ID, error) {
|
|||||||
|
|
||||||
func (a *CommonAPI) Version(context.Context) (api.Version, error) {
|
func (a *CommonAPI) Version(context.Context) (api.Version, error) {
|
||||||
return api.Version{
|
return api.Version{
|
||||||
Version: build.UserVersion,
|
Version: build.UserVersion(),
|
||||||
APIVersion: build.APIVersion,
|
APIVersion: build.APIVersion,
|
||||||
|
|
||||||
BlockDelay: build.BlockDelay,
|
BlockDelay: build.BlockDelay,
|
||||||
@@ -116,9 +115,4 @@ func (a *CommonAPI) LogSetLevel(ctx context.Context, subsystem, level string) er
|
|||||||
return logging.SetLogLevel(subsystem, level)
|
return logging.SetLogLevel(subsystem, level)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *CommonAPI) Shutdown(ctx context.Context) error {
|
|
||||||
a.ShutdownChan <- struct{}{}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ api.Common = &CommonAPI{}
|
var _ api.Common = &CommonAPI{}
|
||||||
|
|||||||
@@ -425,7 +425,7 @@ func (a *ChainAPI) ChainExport(ctx context.Context, tsk types.TipSetKey) (<-chan
|
|||||||
r, w := io.Pipe()
|
r, w := io.Pipe()
|
||||||
out := make(chan []byte)
|
out := make(chan []byte)
|
||||||
go func() {
|
go func() {
|
||||||
defer w.Close()
|
defer w.Close() //nolint:errcheck // it is a pipe
|
||||||
if err := a.Chain.Export(ctx, ts, w); err != nil {
|
if err := a.Chain.Export(ctx, ts, w); err != nil {
|
||||||
log.Errorf("chain export call failed: %s", err)
|
log.Errorf("chain export call failed: %s", err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -580,6 +580,14 @@ func (a *StateAPI) StateSectorPreCommitInfo(ctx context.Context, maddr address.A
|
|||||||
return stmgr.PreCommitInfo(ctx, a.StateManager, maddr, n, ts)
|
return stmgr.PreCommitInfo(ctx, a.StateManager, maddr, n, ts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *StateAPI) StateSectorGetInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk types.TipSetKey) (*miner.SectorOnChainInfo, error) {
|
||||||
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
||||||
|
if err != nil {
|
||||||
|
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
||||||
|
}
|
||||||
|
return stmgr.MinerSectorInfo(ctx, a.StateManager, maddr, n, ts)
|
||||||
|
}
|
||||||
|
|
||||||
func (a *StateAPI) StateListMessages(ctx context.Context, match *types.Message, tsk types.TipSetKey, toheight abi.ChainEpoch) ([]cid.Cid, error) {
|
func (a *StateAPI) StateListMessages(ctx context.Context, match *types.Message, tsk types.TipSetKey, toheight abi.ChainEpoch) ([]cid.Cid, error) {
|
||||||
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type remoteWorker struct {
|
type remoteWorker struct {
|
||||||
api.WorkerApi
|
api.WorkerAPI
|
||||||
closer jsonrpc.ClientCloser
|
closer jsonrpc.ClientCloser
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user