Compare commits
139
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
96a5e579cf | ||
|
|
5f4efedbdd | ||
|
|
9d49c6861f | ||
|
|
3b56288a5e | ||
|
|
f257f4febb | ||
|
|
df867f3349 | ||
|
|
5270c20263 | ||
|
|
7762cd0a68 | ||
|
|
e91cc9cd08 | ||
|
|
741825a04e | ||
|
|
49b27da426 | ||
|
|
bf4bbd15e5 | ||
|
|
baa69c3c81 | ||
|
|
ac644605f2 | ||
|
|
94da339622 | ||
|
|
366359803a | ||
|
|
3b13397165 | ||
|
|
163c2b2544 | ||
|
|
9e2603c1bf | ||
|
|
d27750590a | ||
|
|
33a00ab9e5 | ||
|
|
f765fe36d7 | ||
|
|
be7a95c9a5 | ||
|
|
2571480bb6 | ||
|
|
73d928751d | ||
|
|
0c19544d94 | ||
|
|
a80dce2e3b | ||
|
|
fb09d1ad2b | ||
|
|
963e4dd2fc | ||
|
|
a5d81c6cc9 | ||
|
|
b167e73acb | ||
|
|
e7af464033 | ||
|
|
28e454fd4a | ||
|
|
55a9c9ae0a | ||
|
|
b3eef76cdd | ||
|
|
3f81ff3507 | ||
|
|
2347ba6f39 | ||
|
|
b9d3c26eae | ||
|
|
cd6670205c | ||
|
|
9f4ac4f4f3 | ||
|
|
e4bed4d963 | ||
|
|
76b5c8b145 | ||
|
|
9836c45e03 | ||
|
|
51f1712564 | ||
|
|
e9eff8be5c | ||
|
|
4855045ea2 | ||
|
|
6b06ae528c | ||
|
|
813961b458 | ||
|
|
7ae9d26cd1 | ||
|
|
9e5cc7c910 | ||
|
|
60101fd97b | ||
|
|
0bc174697a | ||
|
|
7bee5b3abc | ||
|
|
656b285195 | ||
|
|
86083531c6 | ||
|
|
c01f70105f | ||
|
|
5aafa91e22 | ||
|
|
f9f0d86ddf | ||
|
|
8bbe63bd9d | ||
|
|
fa3b1552cf | ||
|
|
c625b30781 | ||
|
|
da960a9de4 | ||
|
|
ea111b058e | ||
|
|
ce33074626 | ||
|
|
5f95a92135 | ||
|
|
cd817906b2 | ||
|
|
29dbc26dbd | ||
|
|
04f0130530 | ||
|
|
57567db017 | ||
|
|
5574e4f11b | ||
|
|
4c5d84d106 | ||
|
|
7f962e19c2 | ||
|
|
186fd4da74 | ||
|
|
2fdcf5347b | ||
|
|
4a983995a8 | ||
|
|
263bdc9687 | ||
|
|
42c76aaebc | ||
|
|
9326cb5411 | ||
|
|
415b69155b | ||
|
|
3423d29815 | ||
|
|
673a972fe9 | ||
|
|
1fd20b636b | ||
|
|
d7a2556292 | ||
|
|
bbb954afc5 | ||
|
|
22851df145 | ||
|
|
96ade5f2dd | ||
|
|
5605aae269 | ||
|
|
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 |
+16
-30
@@ -1,6 +1,6 @@
|
|||||||
version: 2.1
|
version: 2.1
|
||||||
orbs:
|
orbs:
|
||||||
go: gotest/tools@0.0.9
|
go: gotest/tools@0.0.13
|
||||||
|
|
||||||
executors:
|
executors:
|
||||||
golang:
|
golang:
|
||||||
@@ -79,7 +79,6 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- install-deps
|
- install-deps
|
||||||
- prepare
|
- prepare
|
||||||
- go/mod-download
|
|
||||||
- go/mod-tidy-check
|
- go/mod-tidy-check
|
||||||
|
|
||||||
build-all:
|
build-all:
|
||||||
@@ -87,12 +86,8 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- install-deps
|
- install-deps
|
||||||
- prepare
|
- prepare
|
||||||
- go/mod-download
|
|
||||||
- run: sudo apt-get update
|
- run: sudo apt-get update
|
||||||
- run: sudo apt-get install npm
|
- run: sudo apt-get install npm
|
||||||
- restore_cache:
|
|
||||||
name: restore go mod cache
|
|
||||||
key: v1-go-deps-{{ arch }}-{{ checksum "/home/circleci/project/go.mod" }}
|
|
||||||
- run:
|
- run:
|
||||||
command: make buildall
|
command: make buildall
|
||||||
- store_artifacts:
|
- store_artifacts:
|
||||||
@@ -112,10 +107,6 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- install-deps
|
- install-deps
|
||||||
- prepare
|
- prepare
|
||||||
- go/mod-download
|
|
||||||
- restore_cache:
|
|
||||||
name: restore go mod cache
|
|
||||||
key: v1-go-deps-{{ arch }}-{{ checksum "/home/circleci/project/go.mod" }}
|
|
||||||
- run:
|
- run:
|
||||||
command: make debug
|
command: make debug
|
||||||
|
|
||||||
@@ -134,6 +125,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
|
||||||
@@ -156,10 +150,6 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- install-deps
|
- install-deps
|
||||||
- prepare
|
- prepare
|
||||||
- go/mod-download
|
|
||||||
- restore_cache:
|
|
||||||
name: restore go mod cache
|
|
||||||
key: v1-go-deps-{{ arch }}-{{ checksum "/home/circleci/project/go.mod" }}
|
|
||||||
- run:
|
- run:
|
||||||
command: make deps lotus
|
command: make deps lotus
|
||||||
no_output_timeout: 30m
|
no_output_timeout: 30m
|
||||||
@@ -171,6 +161,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 -- \
|
||||||
@@ -189,16 +180,11 @@ jobs:
|
|||||||
shell: /bin/bash -eo pipefail
|
shell: /bin/bash -eo pipefail
|
||||||
command: |
|
command: |
|
||||||
bash <(curl -s https://codecov.io/bash)
|
bash <(curl -s https://codecov.io/bash)
|
||||||
- save_cache:
|
|
||||||
name: save go mod cache
|
|
||||||
key: v1-go-deps-{{ arch }}-{{ checksum "/home/circleci/project/go.mod" }}
|
|
||||||
paths:
|
|
||||||
- "~/go/pkg"
|
|
||||||
- "~/go/src/github.com"
|
|
||||||
- "~/go/src/golang.org"
|
|
||||||
|
|
||||||
test-short:
|
test-short:
|
||||||
<<: *test
|
<<: *test
|
||||||
|
test-window-post:
|
||||||
|
<<: *test
|
||||||
|
|
||||||
build-macos:
|
build-macos:
|
||||||
description: build darwin lotus binary
|
description: build darwin lotus binary
|
||||||
@@ -228,10 +214,9 @@ jobs:
|
|||||||
curl --location https://github.com/stedolan/jq/releases/download/jq-1.6/jq-osx-amd64 --output /usr/local/bin/jq
|
curl --location https://github.com/stedolan/jq/releases/download/jq-1.6/jq-osx-amd64 --output /usr/local/bin/jq
|
||||||
chmod +x /usr/local/bin/jq
|
chmod +x /usr/local/bin/jq
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
name: restore go mod and cargo cache
|
name: restore cargo cache
|
||||||
key: v3-go-deps-{{ arch }}-{{ checksum "~/go/src/github.com/filecoin-project/lotus/go.sum" }}
|
key: v3-go-deps-{{ arch }}-{{ checksum "~/go/src/github.com/filecoin-project/lotus/go.sum" }}
|
||||||
- install-deps
|
- install-deps
|
||||||
- go/mod-download
|
|
||||||
- run:
|
- run:
|
||||||
command: make build
|
command: make build
|
||||||
no_output_timeout: 30m
|
no_output_timeout: 30m
|
||||||
@@ -258,7 +243,6 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- install-deps
|
- install-deps
|
||||||
- prepare
|
- prepare
|
||||||
- go/mod-download
|
|
||||||
- run:
|
- run:
|
||||||
command: "! go fmt ./... 2>&1 | read"
|
command: "! go fmt ./... 2>&1 | read"
|
||||||
|
|
||||||
@@ -271,7 +255,7 @@ jobs:
|
|||||||
default: golang
|
default: golang
|
||||||
golangci-lint-version:
|
golangci-lint-version:
|
||||||
type: string
|
type: string
|
||||||
default: 1.23.8
|
default: 1.27.0
|
||||||
concurrency:
|
concurrency:
|
||||||
type: string
|
type: string
|
||||||
default: '2'
|
default: '2'
|
||||||
@@ -287,7 +271,6 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- install-deps
|
- install-deps
|
||||||
- prepare
|
- prepare
|
||||||
- go/mod-download
|
|
||||||
- run:
|
- run:
|
||||||
command: make deps
|
command: make deps
|
||||||
no_output_timeout: 30m
|
no_output_timeout: 30m
|
||||||
@@ -297,7 +280,7 @@ jobs:
|
|||||||
- run:
|
- run:
|
||||||
name: Lint
|
name: Lint
|
||||||
command: |
|
command: |
|
||||||
$HOME/.local/bin/golangci-lint run -v \
|
$HOME/.local/bin/golangci-lint run -v --timeout 2m \
|
||||||
--concurrency << parameters.concurrency >> << parameters.args >>
|
--concurrency << parameters.concurrency >> << parameters.args >>
|
||||||
lint-changes:
|
lint-changes:
|
||||||
<<: *lint
|
<<: *lint
|
||||||
@@ -331,11 +314,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:
|
||||||
|
|||||||
+15
-1
@@ -22,13 +22,27 @@ 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: api/apistruct/struct.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
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ type Common interface {
|
|||||||
NetAddrsListen(context.Context) (peer.AddrInfo, error)
|
NetAddrsListen(context.Context) (peer.AddrInfo, error)
|
||||||
NetDisconnect(context.Context, peer.ID) error
|
NetDisconnect(context.Context, peer.ID) error
|
||||||
NetFindPeer(context.Context, peer.ID) (peer.AddrInfo, error)
|
NetFindPeer(context.Context, peer.ID) (peer.AddrInfo, error)
|
||||||
|
NetPubsubScores(context.Context) ([]PubsubScore, error)
|
||||||
|
|
||||||
// ID returns peerID of libp2p node backing this API
|
// ID returns peerID of libp2p node backing this API
|
||||||
ID(context.Context) (peer.ID, error)
|
ID(context.Context) (peer.ID, error)
|
||||||
|
|||||||
+3
-1
@@ -101,6 +101,7 @@ type FullNode interface {
|
|||||||
WalletSetDefault(context.Context, address.Address) error
|
WalletSetDefault(context.Context, address.Address) error
|
||||||
WalletExport(context.Context, address.Address) (*types.KeyInfo, error)
|
WalletExport(context.Context, address.Address) (*types.KeyInfo, error)
|
||||||
WalletImport(context.Context, *types.KeyInfo) (address.Address, error)
|
WalletImport(context.Context, *types.KeyInfo) (address.Address, error)
|
||||||
|
WalletDelete(context.Context, address.Address) error
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
|
|
||||||
@@ -154,8 +155,9 @@ 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(ctx context.Context, cid cid.Cid, confidence uint64) (*MsgLookup, error)
|
||||||
StateSearchMsg(context.Context, cid.Cid) (*MsgLookup, error)
|
StateSearchMsg(context.Context, cid.Cid) (*MsgLookup, error)
|
||||||
StateListMiners(context.Context, types.TipSetKey) ([]address.Address, error)
|
StateListMiners(context.Context, types.TipSetKey) ([]address.Address, error)
|
||||||
StateListActors(context.Context, types.TipSetKey) ([]address.Address, error)
|
StateListActors(context.Context, types.TipSetKey) ([]address.Address, 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
|
||||||
|
|||||||
+11
-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,13 @@ 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
|
|
||||||
|
MoveStorage(ctx context.Context, sector abi.SectorID) 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, stores.PathType, 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
|
||||||
|
|||||||
+58
-22
@@ -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"
|
||||||
@@ -41,6 +42,7 @@ type CommonStruct struct {
|
|||||||
NetAddrsListen func(context.Context) (peer.AddrInfo, error) `perm:"read"`
|
NetAddrsListen func(context.Context) (peer.AddrInfo, error) `perm:"read"`
|
||||||
NetDisconnect func(context.Context, peer.ID) error `perm:"write"`
|
NetDisconnect func(context.Context, peer.ID) error `perm:"write"`
|
||||||
NetFindPeer func(context.Context, peer.ID) (peer.AddrInfo, error) `perm:"read"`
|
NetFindPeer func(context.Context, peer.ID) (peer.AddrInfo, error) `perm:"read"`
|
||||||
|
NetPubsubScores func(context.Context) ([]api.PubsubScore, error) `perm:"read"`
|
||||||
|
|
||||||
ID func(context.Context) (peer.ID, error) `perm:"read"`
|
ID func(context.Context) (peer.ID, error) `perm:"read"`
|
||||||
Version func(context.Context) (api.Version, error) `perm:"read"`
|
Version func(context.Context) (api.Version, error) `perm:"read"`
|
||||||
@@ -104,6 +106,7 @@ type FullNodeStruct struct {
|
|||||||
WalletSetDefault func(context.Context, address.Address) error `perm:"admin"`
|
WalletSetDefault func(context.Context, address.Address) error `perm:"admin"`
|
||||||
WalletExport func(context.Context, address.Address) (*types.KeyInfo, error) `perm:"admin"`
|
WalletExport func(context.Context, address.Address) (*types.KeyInfo, error) `perm:"admin"`
|
||||||
WalletImport func(context.Context, *types.KeyInfo) (address.Address, error) `perm:"admin"`
|
WalletImport func(context.Context, *types.KeyInfo) (address.Address, error) `perm:"admin"`
|
||||||
|
WalletDelete func(context.Context, address.Address) error `perm:"write"`
|
||||||
|
|
||||||
ClientImport func(ctx context.Context, ref api.FileRef) (cid.Cid, error) `perm:"admin"`
|
ClientImport func(ctx context.Context, ref api.FileRef) (cid.Cid, error) `perm:"admin"`
|
||||||
ClientListImports func(ctx context.Context) ([]api.Import, error) `perm:"write"`
|
ClientListImports func(ctx context.Context) ([]api.Import, error) `perm:"write"`
|
||||||
@@ -130,12 +133,13 @@ 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"`
|
||||||
StateReadState func(context.Context, *types.Actor, types.TipSetKey) (*api.ActorState, error) `perm:"read"`
|
StateReadState func(context.Context, *types.Actor, types.TipSetKey) (*api.ActorState, error) `perm:"read"`
|
||||||
StatePledgeCollateral func(context.Context, types.TipSetKey) (types.BigInt, error) `perm:"read"`
|
StatePledgeCollateral func(context.Context, types.TipSetKey) (types.BigInt, error) `perm:"read"`
|
||||||
StateWaitMsg func(context.Context, cid.Cid) (*api.MsgLookup, error) `perm:"read"`
|
StateWaitMsg func(ctx context.Context, cid cid.Cid, confidence uint64) (*api.MsgLookup, error) `perm:"read"`
|
||||||
StateSearchMsg func(context.Context, cid.Cid) (*api.MsgLookup, error) `perm:"read"`
|
StateSearchMsg func(context.Context, cid.Cid) (*api.MsgLookup, error) `perm:"read"`
|
||||||
StateListMiners func(context.Context, types.TipSetKey) ([]address.Address, error) `perm:"read"`
|
StateListMiners func(context.Context, types.TipSetKey) ([]address.Address, error) `perm:"read"`
|
||||||
StateListActors func(context.Context, types.TipSetKey) ([]address.Address, error) `perm:"read"`
|
StateListActors func(context.Context, types.TipSetKey) ([]address.Address, error) `perm:"read"`
|
||||||
@@ -203,16 +207,17 @@ 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"`
|
||||||
|
StorageLock func(ctx context.Context, sector abi.SectorID, read stores.SectorFileType, write stores.SectorFileType) 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"`
|
||||||
@@ -236,8 +241,12 @@ type WorkerStruct struct {
|
|||||||
SealCommit1 func(ctx context.Context, sector abi.SectorID, ticket abi.SealRandomness, seed abi.InteractiveSealRandomness, pieces []abi.PieceInfo, cids storage.SectorCids) (storage.Commit1Out, error) `perm:"admin"`
|
SealCommit1 func(ctx context.Context, sector abi.SectorID, ticket abi.SealRandomness, seed abi.InteractiveSealRandomness, pieces []abi.PieceInfo, cids storage.SectorCids) (storage.Commit1Out, error) `perm:"admin"`
|
||||||
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"`
|
||||||
|
MoveStorage func(ctx context.Context, sector 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, stores.PathType, stores.AcquireMode) error `perm:"admin"`
|
||||||
|
|
||||||
Closing func(context.Context) (<-chan struct{}, error) `perm:"admin"`
|
Closing func(context.Context) (<-chan struct{}, error) `perm:"admin"`
|
||||||
}
|
}
|
||||||
@@ -253,6 +262,9 @@ func (c *CommonStruct) AuthNew(ctx context.Context, perms []auth.Permission) ([]
|
|||||||
return c.Internal.AuthNew(ctx, perms)
|
return c.Internal.AuthNew(ctx, perms)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *CommonStruct) NetPubsubScores(ctx context.Context) ([]api.PubsubScore, error) {
|
||||||
|
return c.Internal.NetPubsubScores(ctx)
|
||||||
|
}
|
||||||
func (c *CommonStruct) NetConnectedness(ctx context.Context, pid peer.ID) (network.Connectedness, error) {
|
func (c *CommonStruct) NetConnectedness(ctx context.Context, pid peer.ID) (network.Connectedness, error) {
|
||||||
return c.Internal.NetConnectedness(ctx, pid)
|
return c.Internal.NetConnectedness(ctx, pid)
|
||||||
}
|
}
|
||||||
@@ -427,6 +439,10 @@ func (c *FullNodeStruct) WalletImport(ctx context.Context, ki *types.KeyInfo) (a
|
|||||||
return c.Internal.WalletImport(ctx, ki)
|
return c.Internal.WalletImport(ctx, ki)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *FullNodeStruct) WalletDelete(ctx context.Context, addr address.Address) error {
|
||||||
|
return c.Internal.WalletDelete(ctx, addr)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) MpoolGetNonce(ctx context.Context, addr address.Address) (uint64, error) {
|
func (c *FullNodeStruct) MpoolGetNonce(ctx context.Context, addr address.Address) (uint64, error) {
|
||||||
return c.Internal.MpoolGetNonce(ctx, addr)
|
return c.Internal.MpoolGetNonce(ctx, addr)
|
||||||
}
|
}
|
||||||
@@ -567,6 +583,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)
|
||||||
}
|
}
|
||||||
@@ -587,8 +607,8 @@ func (c *FullNodeStruct) StatePledgeCollateral(ctx context.Context, tsk types.Ti
|
|||||||
return c.Internal.StatePledgeCollateral(ctx, tsk)
|
return c.Internal.StatePledgeCollateral(ctx, tsk)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) StateWaitMsg(ctx context.Context, msgc cid.Cid) (*api.MsgLookup, error) {
|
func (c *FullNodeStruct) StateWaitMsg(ctx context.Context, msgc cid.Cid, confidence uint64) (*api.MsgLookup, error) {
|
||||||
return c.Internal.StateWaitMsg(ctx, msgc)
|
return c.Internal.StateWaitMsg(ctx, msgc, confidence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) StateSearchMsg(ctx context.Context, msgc cid.Cid) (*api.MsgLookup, error) {
|
func (c *FullNodeStruct) StateSearchMsg(ctx context.Context, msgc cid.Cid) (*api.MsgLookup, error) {
|
||||||
@@ -763,15 +783,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,14 +811,18 @@ 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 {
|
||||||
return c.Internal.StorageReportHealth(ctx, id, report)
|
return c.Internal.StorageReportHealth(ctx, id, report)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *StorageMinerStruct) StorageLock(ctx context.Context, sector abi.SectorID, read stores.SectorFileType, write stores.SectorFileType) error {
|
||||||
|
return c.Internal.StorageLock(ctx, sector, read, write)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *StorageMinerStruct) MarketImportDealData(ctx context.Context, propcid cid.Cid, path string) error {
|
func (c *StorageMinerStruct) MarketImportDealData(ctx context.Context, propcid cid.Cid, path string) error {
|
||||||
return c.Internal.MarketImportDealData(ctx, propcid, path)
|
return c.Internal.MarketImportDealData(ctx, propcid, path)
|
||||||
}
|
}
|
||||||
@@ -865,8 +889,20 @@ 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) MoveStorage(ctx context.Context, sector abi.SectorID) error {
|
||||||
return w.Internal.Fetch(ctx, id, fileType, b)
|
return w.Internal.MoveStorage(ctx, sector)
|
||||||
|
}
|
||||||
|
|
||||||
|
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.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, ptype stores.PathType, am stores.AcquireMode) error {
|
||||||
|
return w.Internal.Fetch(ctx, id, fileType, ptype, am)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WorkerStruct) Closing(ctx context.Context) (<-chan struct{}, error) {
|
func (w *WorkerStruct) Closing(ctx context.Context) (<-chan struct{}, error) {
|
||||||
@@ -876,4 +912,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{}{
|
||||||
|
|||||||
@@ -193,8 +193,7 @@ func (v *Visitor) Visit(node ast.Node) ast.Visitor {
|
|||||||
|
|
||||||
const noComment = "There are not yet any comments for this method."
|
const noComment = "There are not yet any comments for this method."
|
||||||
|
|
||||||
func parseApiASTInfo() (map[string]string, map[string]string) {
|
func parseApiASTInfo() (map[string]string, map[string]string) { //nolint:golint
|
||||||
|
|
||||||
fset := token.NewFileSet()
|
fset := token.NewFileSet()
|
||||||
pkgs, err := parser.ParseDir(fset, "./api", nil, parser.AllErrors|parser.ParseComments)
|
pkgs, err := parser.ParseDir(fset, "./api", nil, parser.AllErrors|parser.ParseComments)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -320,6 +319,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)
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -35,7 +35,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDealFlow(t *testing.T, b APIBuilder, blocktime time.Duration, carExport bool) {
|
func TestDealFlow(t *testing.T, b APIBuilder, blocktime time.Duration, carExport bool) {
|
||||||
os.Setenv("BELLMAN_NO_GPU", "1")
|
_ = os.Setenv("BELLMAN_NO_GPU", "1")
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
n, sn := b(t, 1, oneMiner)
|
n, sn := b(t, 1, oneMiner)
|
||||||
@@ -72,7 +72,7 @@ func TestDealFlow(t *testing.T, b APIBuilder, blocktime time.Duration, carExport
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDoubleDealFlow(t *testing.T, b APIBuilder, blocktime time.Duration) {
|
func TestDoubleDealFlow(t *testing.T, b APIBuilder, blocktime time.Duration) {
|
||||||
os.Setenv("BELLMAN_NO_GPU", "1")
|
_ = os.Setenv("BELLMAN_NO_GPU", "1")
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
n, sn := b(t, 1, oneMiner)
|
n, sn := b(t, 1, oneMiner)
|
||||||
@@ -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 {
|
||||||
|
|||||||
+1
-1
@@ -82,7 +82,7 @@ func (ts *testSuite) testMiningReal(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDealMining(t *testing.T, b APIBuilder, blocktime time.Duration, carExport bool) {
|
func TestDealMining(t *testing.T, b APIBuilder, blocktime time.Duration, carExport bool) {
|
||||||
os.Setenv("BELLMAN_NO_GPU", "1")
|
_ = os.Setenv("BELLMAN_NO_GPU", "1")
|
||||||
|
|
||||||
// test making a deal with a fresh miner, and see if it starts to mine
|
// test making a deal with a fresh miner, and see if it starts to mine
|
||||||
|
|
||||||
|
|||||||
+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
|
||||||
|
}
|
||||||
@@ -3,10 +3,12 @@ package api
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 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) {
|
||||||
@@ -32,3 +34,8 @@ type ObjStat struct {
|
|||||||
Size uint64
|
Size uint64
|
||||||
Links uint64
|
Links uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PubsubScore struct {
|
||||||
|
ID peer.ID
|
||||||
|
Score float64
|
||||||
|
}
|
||||||
|
|||||||
@@ -34,3 +34,12 @@ func BuiltinBootstrap() ([]peer.AddrInfo, error) {
|
|||||||
})
|
})
|
||||||
return out, err
|
return out, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DrandBootstrap() ([]peer.AddrInfo, error) {
|
||||||
|
addrs := []string{
|
||||||
|
"/dnsaddr/pl-eu.testnet.drand.sh/",
|
||||||
|
"/dnsaddr/pl-us.testnet.drand.sh/",
|
||||||
|
"/dnsaddr/pl-sin.testnet.drand.sh/",
|
||||||
|
}
|
||||||
|
return addrutil.ParseAddresses(context.TODO(), addrs)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,12 +1,6 @@
|
|||||||
/dns4/bootstrap-0-sin.fil-test.net/tcp/1347/p2p/12D3KooWKNF7vNFEhnvB45E9mw2B5z6t419W3ziZPLdUDVnLLKGs
|
/dns4/t01000.miner.interopnet.kittyhawk.wtf/tcp/1347/p2p/12D3KooWLVgeFhXA7ztuSS1uvk4NVzZwRZLxg8PBy1mJuHfc8J6E
|
||||||
/ip4/86.109.15.57/tcp/1347/p2p/12D3KooWKNF7vNFEhnvB45E9mw2B5z6t419W3ziZPLdUDVnLLKGs
|
/ip4/34.217.110.132/tcp/1347/p2p/12D3KooWLVgeFhXA7ztuSS1uvk4NVzZwRZLxg8PBy1mJuHfc8J6E
|
||||||
/dns4/bootstrap-0-dfw.fil-test.net/tcp/1347/p2p/12D3KooWECJTm7RUPyGfNbRwm6y2fK4wA7EB8rDJtWsq5AKi7iDr
|
/dns4/peer0.interopnet.kittyhawk.wtf/tcp/1347/p2p/12D3KooWBkXWpT1hLHXz7VzR8ZHCJ42P6c9Nb9532ATSguBpLTKJ
|
||||||
/ip4/139.178.84.45/tcp/1347/p2p/12D3KooWECJTm7RUPyGfNbRwm6y2fK4wA7EB8rDJtWsq5AKi7iDr
|
/ip4/54.187.182.170/tcp/1347/p2p/12D3KooWBkXWpT1hLHXz7VzR8ZHCJ42P6c9Nb9532ATSguBpLTKJ
|
||||||
/dns4/bootstrap-0-fra.fil-test.net/tcp/1347/p2p/12D3KooWC7MD6m7iNCuDsYtNr7xVtazihyVUizBbhmhEiyMAm9ym
|
/dns4/peer1.interopnet.kittyhawk.wtf/tcp/1347/p2p/12D3KooWJk5hQHNdCsidtX4jhKQMBXKJdo2kjhrNHUZBPmCZKwKt
|
||||||
/ip4/136.144.49.17/tcp/1347/p2p/12D3KooWC7MD6m7iNCuDsYtNr7xVtazihyVUizBbhmhEiyMAm9ym
|
/ip4/52.24.84.39/tcp/1347/p2p/12D3KooWJk5hQHNdCsidtX4jhKQMBXKJdo2kjhrNHUZBPmCZKwKt
|
||||||
/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
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ var BlocksPerEpoch = uint64(builtin.ExpectedLeadersPerEpoch)
|
|||||||
|
|
||||||
// Epochs
|
// Epochs
|
||||||
const Finality = miner.ChainFinalityish
|
const Finality = miner.ChainFinalityish
|
||||||
|
const MessageConfidence = 5
|
||||||
|
|
||||||
// constants for Weight calculation
|
// constants for Weight calculation
|
||||||
// The ratio of weight contributed by short-term vs long-term factors in a given round
|
// The ratio of weight contributed by short-term vs long-term factors in a given round
|
||||||
@@ -118,11 +119,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,deadcode
|
||||||
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)
|
||||||
@@ -561,26 +561,30 @@ func (bpt *bsPeerTracker) logSuccess(p peer.ID, dur time.Duration) {
|
|||||||
bpt.lk.Lock()
|
bpt.lk.Lock()
|
||||||
defer bpt.lk.Unlock()
|
defer bpt.lk.Unlock()
|
||||||
|
|
||||||
if pi, ok := bpt.peers[p]; !ok {
|
var pi *peerStats
|
||||||
|
var ok bool
|
||||||
|
if pi, ok = bpt.peers[p]; !ok {
|
||||||
log.Warnw("log success called on peer not in tracker", "peerid", p.String())
|
log.Warnw("log success called on peer not in tracker", "peerid", p.String())
|
||||||
return
|
return
|
||||||
} else {
|
|
||||||
pi.successes++
|
|
||||||
|
|
||||||
logTime(pi, dur)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pi.successes++
|
||||||
|
logTime(pi, dur)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bpt *bsPeerTracker) logFailure(p peer.ID, dur time.Duration) {
|
func (bpt *bsPeerTracker) logFailure(p peer.ID, dur time.Duration) {
|
||||||
bpt.lk.Lock()
|
bpt.lk.Lock()
|
||||||
defer bpt.lk.Unlock()
|
defer bpt.lk.Unlock()
|
||||||
if pi, ok := bpt.peers[p]; !ok {
|
|
||||||
|
var pi *peerStats
|
||||||
|
var ok bool
|
||||||
|
if pi, ok = bpt.peers[p]; !ok {
|
||||||
log.Warn("log failure called on peer not in tracker", "peerid", p.String())
|
log.Warn("log failure called on peer not in tracker", "peerid", p.String())
|
||||||
return
|
return
|
||||||
} else {
|
|
||||||
pi.failures++
|
|
||||||
logTime(pi, dur)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pi.failures++
|
||||||
|
logTime(pi, dur)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bpt *bsPeerTracker) removePeer(p peer.ID) {
|
func (bpt *bsPeerTracker) removePeer(p peer.ID) {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import (
|
|||||||
|
|
||||||
var log = logging.Logger("events")
|
var log = logging.Logger("events")
|
||||||
|
|
||||||
// `curH`-`ts.Height` = `confidence`
|
// HeightHandler `curH`-`ts.Height` = `confidence`
|
||||||
type HeightHandler func(ctx context.Context, ts *types.TipSet, curH abi.ChainEpoch) error
|
type HeightHandler func(ctx context.Context, ts *types.TipSet, curH abi.ChainEpoch) error
|
||||||
type RevertHandler func(ctx context.Context, ts *types.TipSet) error
|
type RevertHandler func(ctx context.Context, ts *types.TipSet) error
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ type heightHandler struct {
|
|||||||
revert RevertHandler
|
revert RevertHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
type eventApi interface {
|
type eventAPI interface {
|
||||||
ChainNotify(context.Context) (<-chan []*api.HeadChange, error)
|
ChainNotify(context.Context) (<-chan []*api.HeadChange, error)
|
||||||
ChainGetBlockMessages(context.Context, cid.Cid) (*api.BlockMessages, error)
|
ChainGetBlockMessages(context.Context, cid.Cid) (*api.BlockMessages, error)
|
||||||
ChainGetTipSetByHeight(context.Context, abi.ChainEpoch, types.TipSetKey) (*types.TipSet, error)
|
ChainGetTipSetByHeight(context.Context, abi.ChainEpoch, types.TipSetKey) (*types.TipSet, error)
|
||||||
@@ -42,7 +42,7 @@ type eventApi interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Events struct {
|
type Events struct {
|
||||||
api eventApi
|
api eventAPI
|
||||||
|
|
||||||
tsc *tipSetCache
|
tsc *tipSetCache
|
||||||
lk sync.Mutex
|
lk sync.Mutex
|
||||||
@@ -54,7 +54,7 @@ type Events struct {
|
|||||||
calledEvents
|
calledEvents
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewEvents(ctx context.Context, api eventApi) *Events {
|
func NewEvents(ctx context.Context, api eventAPI) *Events {
|
||||||
gcConfidence := 2 * build.ForkLengthThreshold
|
gcConfidence := 2 * build.ForkLengthThreshold
|
||||||
|
|
||||||
tsc := newTSCache(gcConfidence, api.ChainGetTipSetByHeight)
|
tsc := newTSCache(gcConfidence, api.ChainGetTipSetByHeight)
|
||||||
@@ -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{},
|
||||||
@@ -82,9 +82,9 @@ func NewEvents(ctx context.Context, api eventApi) *Events {
|
|||||||
|
|
||||||
confQueue: map[triggerH]map[msgH][]*queuedEvent{},
|
confQueue: map[triggerH]map[msgH][]*queuedEvent{},
|
||||||
revertQueue: map[msgH][]triggerH{},
|
revertQueue: map[msgH][]triggerH{},
|
||||||
triggers: map[triggerId]*callHandler{},
|
triggers: map[triggerID]*callHandler{},
|
||||||
matchers: map[triggerId][]MatchFunc{},
|
matchers: map[triggerID][]MatchFunc{},
|
||||||
timeouts: map[abi.ChainEpoch]map[triggerId]int{},
|
timeouts: map[abi.ChainEpoch]map[triggerID]int{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import (
|
|||||||
|
|
||||||
const NoTimeout = math.MaxInt64
|
const NoTimeout = math.MaxInt64
|
||||||
|
|
||||||
type triggerId = uint64
|
type triggerID = uint64
|
||||||
|
|
||||||
// msgH is the block height at which a message was present / event has happened
|
// msgH is the block height at which a message was present / event has happened
|
||||||
type msgH = abi.ChainEpoch
|
type msgH = abi.ChainEpoch
|
||||||
@@ -23,6 +23,7 @@ type msgH = abi.ChainEpoch
|
|||||||
// message (msgH+confidence)
|
// message (msgH+confidence)
|
||||||
type triggerH = abi.ChainEpoch
|
type triggerH = abi.ChainEpoch
|
||||||
|
|
||||||
|
// CalledHandler arguments:
|
||||||
// `ts` is the tipset, in which the `msg` is included.
|
// `ts` is the tipset, in which the `msg` is included.
|
||||||
// `curH`-`ts.Height` = `confidence`
|
// `curH`-`ts.Height` = `confidence`
|
||||||
type CalledHandler func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH abi.ChainEpoch) (more bool, err error)
|
type CalledHandler func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH abi.ChainEpoch) (more bool, err error)
|
||||||
@@ -48,7 +49,7 @@ type callHandler struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type queuedEvent struct {
|
type queuedEvent struct {
|
||||||
trigger triggerId
|
trigger triggerID
|
||||||
|
|
||||||
h abi.ChainEpoch
|
h abi.ChainEpoch
|
||||||
msg *types.Message
|
msg *types.Message
|
||||||
@@ -57,7 +58,7 @@ type queuedEvent struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type calledEvents struct {
|
type calledEvents struct {
|
||||||
cs eventApi
|
cs eventAPI
|
||||||
tsc *tipSetCache
|
tsc *tipSetCache
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
gcConfidence uint64
|
gcConfidence uint64
|
||||||
@@ -66,10 +67,10 @@ type calledEvents struct {
|
|||||||
|
|
||||||
lk sync.Mutex
|
lk sync.Mutex
|
||||||
|
|
||||||
ctr triggerId
|
ctr triggerID
|
||||||
|
|
||||||
triggers map[triggerId]*callHandler
|
triggers map[triggerID]*callHandler
|
||||||
matchers map[triggerId][]MatchFunc
|
matchers map[triggerID][]MatchFunc
|
||||||
|
|
||||||
// maps block heights to events
|
// maps block heights to events
|
||||||
// [triggerH][msgH][event]
|
// [triggerH][msgH][event]
|
||||||
@@ -78,8 +79,8 @@ type calledEvents struct {
|
|||||||
// [msgH][triggerH]
|
// [msgH][triggerH]
|
||||||
revertQueue map[msgH][]triggerH
|
revertQueue map[msgH][]triggerH
|
||||||
|
|
||||||
// [timeoutH+confidence][triggerId]{calls}
|
// [timeoutH+confidence][triggerID]{calls}
|
||||||
timeouts map[abi.ChainEpoch]map[triggerId]int
|
timeouts map[abi.ChainEpoch]map[triggerID]int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *calledEvents) headChangeCalled(rev, app []*types.TipSet) error {
|
func (e *calledEvents) headChangeCalled(rev, app []*types.TipSet) error {
|
||||||
@@ -157,8 +158,8 @@ func (e *calledEvents) checkNewCalls(ts *types.TipSet) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *calledEvents) queueForConfidence(triggerId uint64, msg *types.Message, ts *types.TipSet) {
|
func (e *calledEvents) queueForConfidence(trigID uint64, msg *types.Message, ts *types.TipSet) {
|
||||||
trigger := e.triggers[triggerId]
|
trigger := e.triggers[trigID]
|
||||||
|
|
||||||
appliedH := ts.Height()
|
appliedH := ts.Height()
|
||||||
|
|
||||||
@@ -171,7 +172,7 @@ func (e *calledEvents) queueForConfidence(triggerId uint64, msg *types.Message,
|
|||||||
}
|
}
|
||||||
|
|
||||||
byOrigH[appliedH] = append(byOrigH[appliedH], &queuedEvent{
|
byOrigH[appliedH] = append(byOrigH[appliedH], &queuedEvent{
|
||||||
trigger: triggerId,
|
trigger: trigID,
|
||||||
h: appliedH,
|
h: appliedH,
|
||||||
msg: msg,
|
msg: msg,
|
||||||
})
|
})
|
||||||
@@ -231,11 +232,11 @@ func (e *calledEvents) applyTimeouts(ts *types.TipSet) {
|
|||||||
return // nothing to do
|
return // nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
for triggerId, calls := range triggers {
|
for triggerID, calls := range triggers {
|
||||||
if calls > 0 {
|
if calls > 0 {
|
||||||
continue // don't timeout if the method was called
|
continue // don't timeout if the method was called
|
||||||
}
|
}
|
||||||
trigger := e.triggers[triggerId]
|
trigger := e.triggers[triggerID]
|
||||||
if trigger.disabled {
|
if trigger.disabled {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,12 +15,12 @@ type heightEvents struct {
|
|||||||
tsc *tipSetCache
|
tsc *tipSetCache
|
||||||
gcConfidence abi.ChainEpoch
|
gcConfidence abi.ChainEpoch
|
||||||
|
|
||||||
ctr triggerId
|
ctr triggerID
|
||||||
|
|
||||||
heightTriggers map[triggerId]*heightHandler
|
heightTriggers map[triggerID]*heightHandler
|
||||||
|
|
||||||
htTriggerHeights map[triggerH][]triggerId
|
htTriggerHeights map[triggerH][]triggerID
|
||||||
htHeights map[msgH][]triggerId
|
htHeights map[msgH][]triggerID
|
||||||
|
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -211,15 +211,14 @@ func (fcs *fakeCS) advance(rev, app int, msgs map[int]cid.Cid, nulls ...int) { /
|
|||||||
fcs.sub(revs, apps)
|
fcs.sub(revs, apps)
|
||||||
|
|
||||||
fcs.sync.Lock()
|
fcs.sync.Lock()
|
||||||
fcs.sync.Unlock()
|
fcs.sync.Unlock() //nolint:staticcheck
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fcs *fakeCS) notifDone() {
|
func (fcs *fakeCS) notifDone() {
|
||||||
fcs.sync.Unlock()
|
fcs.sync.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ eventApi = &fakeCS{}
|
var _ eventAPI = &fakeCS{}
|
||||||
|
|
||||||
func TestAt(t *testing.T) {
|
func TestAt(t *testing.T) {
|
||||||
fcs := &fakeCS{
|
fcs := &fakeCS{
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ func (e *calledEvents) CheckMsg(ctx context.Context, smsg types.ChainMsg, hnd Ca
|
|||||||
func (e *calledEvents) MatchMsg(inmsg *types.Message) MatchFunc {
|
func (e *calledEvents) MatchMsg(inmsg *types.Message) MatchFunc {
|
||||||
return func(msg *types.Message) (bool, error) {
|
return func(msg *types.Message) (bool, error) {
|
||||||
if msg.From == inmsg.From && msg.Nonce == inmsg.Nonce && !inmsg.Equals(msg) {
|
if msg.From == inmsg.From && msg.Nonce == inmsg.Nonce && !inmsg.Equals(msg) {
|
||||||
return false, xerrors.Errorf("matching msg %s from %s, nonce %d: got duplicate origin/nonce msg %s", inmsg.Cid(), inmsg.From, inmsg.Nonce, msg.Nonce)
|
return false, xerrors.Errorf("matching msg %s from %s, nonce %d: got duplicate origin/nonce msg %d", inmsg.Cid(), inmsg.From, inmsg.Nonce, msg.Nonce)
|
||||||
}
|
}
|
||||||
|
|
||||||
return inmsg.Equals(msg), nil
|
return inmsg.Equals(msg), nil
|
||||||
|
|||||||
+6
-9
@@ -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,
|
||||||
@@ -427,7 +431,7 @@ func (cg *ChainGen) makeBlock(parents *types.TipSet, m address.Address, vrfticke
|
|||||||
return fblk, err
|
return fblk, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function is awkward. It's used to deal with messages made when
|
// ResyncBankerNonce is used for dealing with messages made when
|
||||||
// simulating forks
|
// simulating forks
|
||||||
func (cg *ChainGen) ResyncBankerNonce(ts *types.TipSet) error {
|
func (cg *ChainGen) ResyncBankerNonce(ts *types.TipSet) error {
|
||||||
act, err := cg.sm.GetActor(cg.banker, ts)
|
act, err := cg.sm.GetActor(cg.banker, ts)
|
||||||
@@ -534,13 +538,6 @@ func (wpp *wppProvider) ComputeProof(context.Context, []abi.SectorInfo, abi.PoSt
|
|||||||
}}, nil
|
}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProofInput struct {
|
|
||||||
sectors []abi.SectorInfo
|
|
||||||
hvrf []byte
|
|
||||||
challengedSectors []uint64
|
|
||||||
vrfout []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
func IsRoundWinner(ctx context.Context, ts *types.TipSet, round abi.ChainEpoch,
|
func IsRoundWinner(ctx context.Context, ts *types.TipSet, round abi.ChainEpoch,
|
||||||
miner address.Address, brand types.BeaconEntry, mbi *api.MiningBaseInfo, a MiningCheckAPI) (*types.ElectionProof, error) {
|
miner address.Address, brand types.BeaconEntry, mbi *api.MiningBaseInfo, a MiningCheckAPI) (*types.ElectionProof, error) {
|
||||||
|
|
||||||
|
|||||||
@@ -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 {
|
||||||
@@ -69,7 +71,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
|
|||||||
constructorParams := &power.CreateMinerParams{
|
constructorParams := &power.CreateMinerParams{
|
||||||
Owner: m.Worker,
|
Owner: m.Worker,
|
||||||
Worker: m.Worker,
|
Worker: m.Worker,
|
||||||
Peer: m.PeerId,
|
Peer: []byte(m.PeerId),
|
||||||
SealProofType: spt,
|
SealProofType: spt,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import (
|
|||||||
"github.com/ipfs/go-datastore"
|
"github.com/ipfs/go-datastore"
|
||||||
)
|
)
|
||||||
|
|
||||||
type testMpoolApi struct {
|
type testMpoolAPI struct {
|
||||||
cb func(rev, app []*types.TipSet) error
|
cb func(rev, app []*types.TipSet) error
|
||||||
|
|
||||||
bmsgs map[cid.Cid][]*types.SignedMessage
|
bmsgs map[cid.Cid][]*types.SignedMessage
|
||||||
@@ -25,68 +25,68 @@ type testMpoolApi struct {
|
|||||||
tipsets []*types.TipSet
|
tipsets []*types.TipSet
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTestMpoolApi() *testMpoolApi {
|
func newTestMpoolAPI() *testMpoolAPI {
|
||||||
return &testMpoolApi{
|
return &testMpoolAPI{
|
||||||
bmsgs: make(map[cid.Cid][]*types.SignedMessage),
|
bmsgs: make(map[cid.Cid][]*types.SignedMessage),
|
||||||
statenonce: make(map[address.Address]uint64),
|
statenonce: make(map[address.Address]uint64),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tma *testMpoolApi) applyBlock(t *testing.T, b *types.BlockHeader) {
|
func (tma *testMpoolAPI) applyBlock(t *testing.T, b *types.BlockHeader) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
if err := tma.cb(nil, []*types.TipSet{mock.TipSet(b)}); err != nil {
|
if err := tma.cb(nil, []*types.TipSet{mock.TipSet(b)}); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tma *testMpoolApi) revertBlock(t *testing.T, b *types.BlockHeader) {
|
func (tma *testMpoolAPI) revertBlock(t *testing.T, b *types.BlockHeader) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
if err := tma.cb([]*types.TipSet{mock.TipSet(b)}, nil); err != nil {
|
if err := tma.cb([]*types.TipSet{mock.TipSet(b)}, nil); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tma *testMpoolApi) setStateNonce(addr address.Address, v uint64) {
|
func (tma *testMpoolAPI) setStateNonce(addr address.Address, v uint64) {
|
||||||
tma.statenonce[addr] = v
|
tma.statenonce[addr] = v
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tma *testMpoolApi) setBlockMessages(h *types.BlockHeader, msgs ...*types.SignedMessage) {
|
func (tma *testMpoolAPI) setBlockMessages(h *types.BlockHeader, msgs ...*types.SignedMessage) {
|
||||||
tma.bmsgs[h.Cid()] = msgs
|
tma.bmsgs[h.Cid()] = msgs
|
||||||
tma.tipsets = append(tma.tipsets, mock.TipSet(h))
|
tma.tipsets = append(tma.tipsets, mock.TipSet(h))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tma *testMpoolApi) SubscribeHeadChanges(cb func(rev, app []*types.TipSet) error) *types.TipSet {
|
func (tma *testMpoolAPI) SubscribeHeadChanges(cb func(rev, app []*types.TipSet) error) *types.TipSet {
|
||||||
tma.cb = cb
|
tma.cb = cb
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tma *testMpoolApi) PutMessage(m types.ChainMsg) (cid.Cid, error) {
|
func (tma *testMpoolAPI) PutMessage(m types.ChainMsg) (cid.Cid, error) {
|
||||||
return cid.Undef, nil
|
return cid.Undef, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tma *testMpoolApi) PubSubPublish(string, []byte) error {
|
func (tma *testMpoolAPI) PubSubPublish(string, []byte) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tma *testMpoolApi) StateGetActor(addr address.Address, ts *types.TipSet) (*types.Actor, error) {
|
func (tma *testMpoolAPI) StateGetActor(addr address.Address, ts *types.TipSet) (*types.Actor, error) {
|
||||||
return &types.Actor{
|
return &types.Actor{
|
||||||
Nonce: tma.statenonce[addr],
|
Nonce: tma.statenonce[addr],
|
||||||
Balance: types.NewInt(90000000),
|
Balance: types.NewInt(90000000),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tma *testMpoolApi) StateAccountKey(ctx context.Context, addr address.Address, ts *types.TipSet) (address.Address, error) {
|
func (tma *testMpoolAPI) StateAccountKey(ctx context.Context, addr address.Address, ts *types.TipSet) (address.Address, error) {
|
||||||
if addr.Protocol() != address.BLS && addr.Protocol() != address.SECP256K1 {
|
if addr.Protocol() != address.BLS && addr.Protocol() != address.SECP256K1 {
|
||||||
return address.Undef, fmt.Errorf("given address was not a key addr")
|
return address.Undef, fmt.Errorf("given address was not a key addr")
|
||||||
}
|
}
|
||||||
return addr, nil
|
return addr, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tma *testMpoolApi) MessagesForBlock(h *types.BlockHeader) ([]*types.Message, []*types.SignedMessage, error) {
|
func (tma *testMpoolAPI) MessagesForBlock(h *types.BlockHeader) ([]*types.Message, []*types.SignedMessage, error) {
|
||||||
return nil, tma.bmsgs[h.Cid()], nil
|
return nil, tma.bmsgs[h.Cid()], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tma *testMpoolApi) MessagesForTipset(ts *types.TipSet) ([]types.ChainMsg, error) {
|
func (tma *testMpoolAPI) MessagesForTipset(ts *types.TipSet) ([]types.ChainMsg, error) {
|
||||||
if len(ts.Blocks()) != 1 {
|
if len(ts.Blocks()) != 1 {
|
||||||
panic("cant deal with multiblock tipsets in this test")
|
panic("cant deal with multiblock tipsets in this test")
|
||||||
}
|
}
|
||||||
@@ -108,7 +108,7 @@ func (tma *testMpoolApi) MessagesForTipset(ts *types.TipSet) ([]types.ChainMsg,
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tma *testMpoolApi) LoadTipSet(tsk types.TipSetKey) (*types.TipSet, error) {
|
func (tma *testMpoolAPI) LoadTipSet(tsk types.TipSetKey) (*types.TipSet, error) {
|
||||||
for _, ts := range tma.tipsets {
|
for _, ts := range tma.tipsets {
|
||||||
if types.CidArrsEqual(tsk.Cids(), ts.Cids()) {
|
if types.CidArrsEqual(tsk.Cids(), ts.Cids()) {
|
||||||
return ts, nil
|
return ts, nil
|
||||||
@@ -138,7 +138,7 @@ func mustAdd(t *testing.T, mp *MessagePool, msg *types.SignedMessage) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMessagePool(t *testing.T) {
|
func TestMessagePool(t *testing.T) {
|
||||||
tma := newTestMpoolApi()
|
tma := newTestMpoolAPI()
|
||||||
|
|
||||||
w, err := wallet.NewWallet(wallet.NewMemKeyStore())
|
w, err := wallet.NewWallet(wallet.NewMemKeyStore())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -179,7 +179,7 @@ func TestMessagePool(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRevertMessages(t *testing.T) {
|
func TestRevertMessages(t *testing.T) {
|
||||||
tma := newTestMpoolApi()
|
tma := newTestMpoolAPI()
|
||||||
|
|
||||||
w, err := wallet.NewWallet(wallet.NewMemKeyStore())
|
w, err := wallet.NewWallet(wallet.NewMemKeyStore())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import (
|
|||||||
|
|
||||||
var log = logging.Logger("statetree")
|
var log = logging.Logger("statetree")
|
||||||
|
|
||||||
// Stores actors state by their ID.
|
// StateTree stores actors state by their ID.
|
||||||
type StateTree struct {
|
type StateTree struct {
|
||||||
root *hamt.Node
|
root *hamt.Node
|
||||||
Store cbor.IpldStore
|
Store cbor.IpldStore
|
||||||
@@ -149,7 +149,7 @@ func (st *StateTree) SetActor(addr address.Address, act *types.Actor) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// `LookupID` gets the ID address of this actor's `addr` stored in the `InitActor`.
|
// LookupID gets the ID address of this actor's `addr` stored in the `InitActor`.
|
||||||
func (st *StateTree) LookupID(addr address.Address) (address.Address, error) {
|
func (st *StateTree) LookupID(addr address.Address) (address.Address, error) {
|
||||||
if addr.Protocol() == address.ID {
|
if addr.Protocol() == address.ID {
|
||||||
return addr, nil
|
return addr, nil
|
||||||
|
|||||||
@@ -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())
|
||||||
|
|||||||
+41
-10
@@ -326,7 +326,7 @@ func (sm *StateManager) computeTipSetState(ctx context.Context, blks []*types.Bl
|
|||||||
blkmsgs = append(blkmsgs, bm)
|
blkmsgs = append(blkmsgs, bm)
|
||||||
}
|
}
|
||||||
|
|
||||||
return sm.ApplyBlocks(ctx, pstate, blkmsgs, abi.ChainEpoch(blks[0].Height), r, cb)
|
return sm.ApplyBlocks(ctx, pstate, blkmsgs, blks[0].Height, r, cb)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *StateManager) parentState(ts *types.TipSet) cid.Cid {
|
func (sm *StateManager) parentState(ts *types.TipSet) cid.Cid {
|
||||||
@@ -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
|
||||||
}
|
}
|
||||||
@@ -405,8 +405,8 @@ func (sm *StateManager) LoadActorStateRaw(ctx context.Context, a address.Address
|
|||||||
return act, nil
|
return act, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Similar to `vm.ResolveToKeyAddr` but does not allow `Actor` type of addresses. Uses the `TipSet` `ts`
|
// ResolveToKeyAddress is similar to `vm.ResolveToKeyAddr` but does not allow `Actor` type of addresses.
|
||||||
// to generate the VM state.
|
// Uses the `TipSet` `ts` to generate the VM state.
|
||||||
func (sm *StateManager) ResolveToKeyAddress(ctx context.Context, addr address.Address, ts *types.TipSet) (address.Address, error) {
|
func (sm *StateManager) ResolveToKeyAddress(ctx context.Context, addr address.Address, ts *types.TipSet) (address.Address, error) {
|
||||||
switch addr.Protocol() {
|
switch addr.Protocol() {
|
||||||
case address.BLS, address.SECP256K1:
|
case address.BLS, address.SECP256K1:
|
||||||
@@ -480,7 +480,10 @@ func (sm *StateManager) GetReceipt(ctx context.Context, msg cid.Cid, ts *types.T
|
|||||||
return r, nil
|
return r, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *StateManager) WaitForMessage(ctx context.Context, mcid cid.Cid) (*types.TipSet, *types.MessageReceipt, error) {
|
// WaitForMessage blocks until a message appears on chain. It looks backwards in the chain to see if this has already
|
||||||
|
// happened. It guarantees that the message has been on chain for at least confidence epochs without being reverted
|
||||||
|
// before returning.
|
||||||
|
func (sm *StateManager) WaitForMessage(ctx context.Context, mcid cid.Cid, confidence uint64) (*types.TipSet, *types.MessageReceipt, error) {
|
||||||
ctx, cancel := context.WithCancel(ctx)
|
ctx, cancel := context.WithCancel(ctx)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
@@ -528,6 +531,11 @@ func (sm *StateManager) WaitForMessage(ctx context.Context, mcid cid.Cid) (*type
|
|||||||
close(backSearchWait)
|
close(backSearchWait)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
var candidateTs *types.TipSet
|
||||||
|
var candidateRcp *types.MessageReceipt
|
||||||
|
heightOfHead := head[0].Val.Height()
|
||||||
|
reverts := map[types.TipSetKey]bool{}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case notif, ok := <-tsub:
|
case notif, ok := <-tsub:
|
||||||
@@ -537,21 +545,44 @@ func (sm *StateManager) WaitForMessage(ctx context.Context, mcid cid.Cid) (*type
|
|||||||
for _, val := range notif {
|
for _, val := range notif {
|
||||||
switch val.Type {
|
switch val.Type {
|
||||||
case store.HCRevert:
|
case store.HCRevert:
|
||||||
continue
|
if val.Val.Equals(candidateTs) {
|
||||||
|
candidateTs = nil
|
||||||
|
candidateRcp = nil
|
||||||
|
}
|
||||||
|
if backSearchWait != nil {
|
||||||
|
reverts[val.Val.Key()] = true
|
||||||
|
}
|
||||||
case store.HCApply:
|
case store.HCApply:
|
||||||
|
if candidateTs != nil && val.Val.Height() >= candidateTs.Height()+abi.ChainEpoch(confidence) {
|
||||||
|
return candidateTs, candidateRcp, nil
|
||||||
|
}
|
||||||
r, err := sm.tipsetExecutedMessage(val.Val, mcid, msg.VMMessage())
|
r, err := sm.tipsetExecutedMessage(val.Val, mcid, msg.VMMessage())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
if r != nil {
|
if r != nil {
|
||||||
return val.Val, r, nil
|
if confidence == 0 {
|
||||||
|
return val.Val, r, err
|
||||||
|
}
|
||||||
|
candidateTs = val.Val
|
||||||
|
candidateRcp = r
|
||||||
}
|
}
|
||||||
|
heightOfHead = val.Val.Height()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case <-backSearchWait:
|
case <-backSearchWait:
|
||||||
if backTs != nil {
|
// check if we found the message in the chain and that is hasn't been reverted since we started searching
|
||||||
return backTs, backRcp, nil
|
if backTs != nil && !reverts[backTs.Key()] {
|
||||||
|
// if head is at or past confidence interval, return immediately
|
||||||
|
if heightOfHead >= backTs.Height()+abi.ChainEpoch(confidence) {
|
||||||
|
return backTs, backRcp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// wait for confidence interval
|
||||||
|
candidateTs = backTs
|
||||||
|
candidateRcp = backRcp
|
||||||
}
|
}
|
||||||
|
reverts = nil
|
||||||
backSearchWait = nil
|
backSearchWait = nil
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return nil, nil, ctx.Err()
|
return nil, nil, ctx.Err()
|
||||||
|
|||||||
+21
-3
@@ -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)
|
||||||
@@ -268,7 +286,7 @@ func GetMinerRecoveries(ctx context.Context, sm *StateManager, ts *types.TipSet,
|
|||||||
return mas.Recoveries, nil
|
return mas.Recoveries, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetStorageDeal(ctx context.Context, sm *StateManager, dealId abi.DealID, ts *types.TipSet) (*api.MarketDeal, error) {
|
func GetStorageDeal(ctx context.Context, sm *StateManager, dealID abi.DealID, ts *types.TipSet) (*api.MarketDeal, error) {
|
||||||
var state market.State
|
var state market.State
|
||||||
if _, err := sm.LoadActorState(ctx, builtin.StorageMarketActorAddr, &state, ts); err != nil {
|
if _, err := sm.LoadActorState(ctx, builtin.StorageMarketActorAddr, &state, ts); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -280,7 +298,7 @@ func GetStorageDeal(ctx context.Context, sm *StateManager, dealId abi.DealID, ts
|
|||||||
}
|
}
|
||||||
|
|
||||||
var dp market.DealProposal
|
var dp market.DealProposal
|
||||||
if err := da.Get(ctx, uint64(dealId), &dp); err != nil {
|
if err := da.Get(ctx, uint64(dealID), &dp); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,7 +307,7 @@ func GetStorageDeal(ctx context.Context, sm *StateManager, dealId abi.DealID, ts
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
st, found, err := sa.Get(dealId)
|
st, found, err := sa.Get(dealID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,157 @@
|
|||||||
|
package store
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
|
lru "github.com/hashicorp/golang-lru"
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ChainIndex struct {
|
||||||
|
skipCache *lru.ARCCache
|
||||||
|
|
||||||
|
loadTipSet loadTipSetFunc
|
||||||
|
|
||||||
|
skipLength abi.ChainEpoch
|
||||||
|
}
|
||||||
|
type loadTipSetFunc func(types.TipSetKey) (*types.TipSet, error)
|
||||||
|
|
||||||
|
func NewChainIndex(lts loadTipSetFunc) *ChainIndex {
|
||||||
|
sc, _ := lru.NewARC(8192)
|
||||||
|
return &ChainIndex{
|
||||||
|
skipCache: sc,
|
||||||
|
loadTipSet: lts,
|
||||||
|
skipLength: 20,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type lbEntry struct {
|
||||||
|
ts *types.TipSet
|
||||||
|
parentHeight abi.ChainEpoch
|
||||||
|
targetHeight abi.ChainEpoch
|
||||||
|
target types.TipSetKey
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ci *ChainIndex) GetTipsetByHeight(ctx context.Context, from *types.TipSet, to abi.ChainEpoch) (*types.TipSet, error) {
|
||||||
|
if from.Height()-to <= ci.skipLength {
|
||||||
|
return ci.walkBack(from, to)
|
||||||
|
}
|
||||||
|
|
||||||
|
rounded, err := ci.roundDown(from)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
cur := rounded.Key()
|
||||||
|
for {
|
||||||
|
cval, ok := ci.skipCache.Get(cur)
|
||||||
|
if !ok {
|
||||||
|
fc, err := ci.fillCache(cur)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cval = fc
|
||||||
|
}
|
||||||
|
|
||||||
|
lbe := cval.(*lbEntry)
|
||||||
|
if lbe.ts.Height() == to || lbe.parentHeight < to {
|
||||||
|
return lbe.ts, nil
|
||||||
|
} else if to > lbe.targetHeight {
|
||||||
|
return ci.walkBack(lbe.ts, to)
|
||||||
|
}
|
||||||
|
|
||||||
|
cur = lbe.target
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ci *ChainIndex) GetTipsetByHeightWithoutCache(from *types.TipSet, to abi.ChainEpoch) (*types.TipSet, error) {
|
||||||
|
return ci.walkBack(from, to)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ci *ChainIndex) fillCache(tsk types.TipSetKey) (*lbEntry, error) {
|
||||||
|
ts, err := ci.loadTipSet(tsk)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if ts.Height() == 0 {
|
||||||
|
return &lbEntry{
|
||||||
|
ts: ts,
|
||||||
|
parentHeight: 0,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// will either be equal to ts.Height, or at least > ts.Parent.Height()
|
||||||
|
rheight := ci.roundHeight(ts.Height())
|
||||||
|
|
||||||
|
parent, err := ci.loadTipSet(ts.Parents())
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if parent.Height() > rheight {
|
||||||
|
return nil, xerrors.Errorf("cache is inconsistent")
|
||||||
|
}
|
||||||
|
|
||||||
|
rheight -= ci.skipLength
|
||||||
|
|
||||||
|
skipTarget, err := ci.walkBack(parent, rheight)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
lbe := &lbEntry{
|
||||||
|
ts: ts,
|
||||||
|
parentHeight: parent.Height(),
|
||||||
|
targetHeight: skipTarget.Height(),
|
||||||
|
target: skipTarget.Key(),
|
||||||
|
}
|
||||||
|
ci.skipCache.Add(tsk, lbe)
|
||||||
|
|
||||||
|
return lbe, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ci *ChainIndex) roundHeight(h abi.ChainEpoch) abi.ChainEpoch {
|
||||||
|
return abi.ChainEpoch(h/ci.skipLength) * ci.skipLength
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ci *ChainIndex) roundDown(ts *types.TipSet) (*types.TipSet, error) {
|
||||||
|
target := ci.roundHeight(ts.Height())
|
||||||
|
|
||||||
|
rounded, err := ci.walkBack(ts, target)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return rounded, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ci *ChainIndex) walkBack(from *types.TipSet, to abi.ChainEpoch) (*types.TipSet, error) {
|
||||||
|
if to > from.Height() {
|
||||||
|
return nil, xerrors.Errorf("looking for tipset with height greater than start point")
|
||||||
|
}
|
||||||
|
|
||||||
|
if to == from.Height() {
|
||||||
|
return from, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
ts := from
|
||||||
|
|
||||||
|
for {
|
||||||
|
pts, err := ci.loadTipSet(ts.Parents())
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if to > pts.Height() {
|
||||||
|
return ts, nil
|
||||||
|
}
|
||||||
|
if to == pts.Height() {
|
||||||
|
return pts, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
ts = pts
|
||||||
|
}
|
||||||
|
}
|
||||||
+55
-39
@@ -62,6 +62,8 @@ type ChainStore struct {
|
|||||||
tstLk sync.Mutex
|
tstLk sync.Mutex
|
||||||
tipsets map[abi.ChainEpoch][]cid.Cid
|
tipsets map[abi.ChainEpoch][]cid.Cid
|
||||||
|
|
||||||
|
cindex *ChainIndex
|
||||||
|
|
||||||
reorgCh chan<- reorg
|
reorgCh chan<- reorg
|
||||||
headChangeNotifs []func(rev, app []*types.TipSet) error
|
headChangeNotifs []func(rev, app []*types.TipSet) error
|
||||||
|
|
||||||
@@ -84,6 +86,10 @@ func NewChainStore(bs bstore.Blockstore, ds dstore.Batching, vmcalls runtime.Sys
|
|||||||
vmcalls: vmcalls,
|
vmcalls: vmcalls,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ci := NewChainIndex(cs.LoadTipSet)
|
||||||
|
|
||||||
|
cs.cindex = ci
|
||||||
|
|
||||||
cs.reorgCh = cs.reorgWorker(context.TODO())
|
cs.reorgCh = cs.reorgWorker(context.TODO())
|
||||||
|
|
||||||
hcnf := func(rev, app []*types.TipSet) error {
|
hcnf := func(rev, app []*types.TipSet) error {
|
||||||
@@ -387,7 +393,7 @@ func (cs *ChainStore) LoadTipSet(tsk types.TipSetKey) (*types.TipSet, error) {
|
|||||||
return ts, nil
|
return ts, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns true if 'a' is an ancestor of 'b'
|
// IsAncestorOf returns true if 'a' is an ancestor of 'b'
|
||||||
func (cs *ChainStore) IsAncestorOf(a, b *types.TipSet) (bool, error) {
|
func (cs *ChainStore) IsAncestorOf(a, b *types.TipSet) (bool, error) {
|
||||||
if b.Height() <= a.Height() {
|
if b.Height() <= a.Height() {
|
||||||
return false, nil
|
return false, nil
|
||||||
@@ -895,39 +901,50 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cs *ChainStore) GetRandomness(ctx context.Context, blks []cid.Cid, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) (out []byte, err error) {
|
func (cs *ChainStore) GetRandomness(ctx context.Context, blks []cid.Cid, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error) {
|
||||||
_, span := trace.StartSpan(ctx, "store.GetRandomness")
|
_, span := trace.StartSpan(ctx, "store.GetRandomness")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
span.AddAttributes(trace.Int64Attribute("round", int64(round)))
|
span.AddAttributes(trace.Int64Attribute("round", int64(round)))
|
||||||
|
|
||||||
//defer func() {
|
ts, err := cs.LoadTipSet(types.NewTipSetKey(blks...))
|
||||||
//log.Infof("getRand %v %d %d %x -> %x", blks, pers, round, entropy, out)
|
if err != nil {
|
||||||
//}()
|
return nil, err
|
||||||
for {
|
|
||||||
nts, err := cs.LoadTipSet(types.NewTipSetKey(blks...))
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
mtb := nts.MinTicketBlock()
|
|
||||||
|
|
||||||
// if at (or just past -- for null epochs) appropriate epoch
|
|
||||||
// or at genesis (works for negative epochs)
|
|
||||||
if nts.Height() <= round || mtb.Height == 0 {
|
|
||||||
return DrawRandomness(nts.MinTicketBlock().Ticket.VRFProof, pers, round, entropy)
|
|
||||||
}
|
|
||||||
|
|
||||||
blks = mtb.Parents
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if round > ts.Height() {
|
||||||
|
return nil, xerrors.Errorf("cannot draw randomness from the future")
|
||||||
|
}
|
||||||
|
|
||||||
|
searchHeight := round
|
||||||
|
if searchHeight < 0 {
|
||||||
|
searchHeight = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
randTs, err := cs.GetTipsetByHeight(ctx, searchHeight, ts, true)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
mtb := randTs.MinTicketBlock()
|
||||||
|
|
||||||
|
// if at (or just past -- for null epochs) appropriate epoch
|
||||||
|
// or at genesis (works for negative epochs)
|
||||||
|
return DrawRandomness(mtb.Ticket.VRFProof, pers, round, entropy)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTipsetByHeight returns the tipset on the chain behind 'ts' at the given
|
// GetTipsetByHeight returns the tipset on the chain behind 'ts' at the given
|
||||||
@@ -940,7 +957,7 @@ func (cs *ChainStore) GetTipsetByHeight(ctx context.Context, h abi.ChainEpoch, t
|
|||||||
}
|
}
|
||||||
|
|
||||||
if h > ts.Height() {
|
if h > ts.Height() {
|
||||||
return nil, xerrors.Errorf("looking for tipset with height less than start point")
|
return nil, xerrors.Errorf("looking for tipset with height greater than start point")
|
||||||
}
|
}
|
||||||
|
|
||||||
if h == ts.Height() {
|
if h == ts.Height() {
|
||||||
@@ -951,24 +968,24 @@ func (cs *ChainStore) GetTipsetByHeight(ctx context.Context, h abi.ChainEpoch, t
|
|||||||
log.Warnf("expensive call to GetTipsetByHeight, seeking %d levels", ts.Height()-h)
|
log.Warnf("expensive call to GetTipsetByHeight, seeking %d levels", ts.Height()-h)
|
||||||
}
|
}
|
||||||
|
|
||||||
for {
|
lbts, err := cs.cindex.GetTipsetByHeight(ctx, ts, h)
|
||||||
pts, err := cs.LoadTipSet(ts.Parents())
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if lbts.Height() < h {
|
||||||
|
log.Warnf("chain index returned the wrong tipset at height %d, using slow retrieval", h)
|
||||||
|
lbts, err = cs.cindex.GetTipsetByHeightWithoutCache(ts, h)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if h > pts.Height() {
|
|
||||||
if prev {
|
|
||||||
return pts, nil
|
|
||||||
}
|
|
||||||
return ts, nil
|
|
||||||
}
|
|
||||||
if h == pts.Height() {
|
|
||||||
return pts, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
ts = pts
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if lbts.Height() == h || !prev {
|
||||||
|
return lbts, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return cs.LoadTipSet(lbts.Parents())
|
||||||
}
|
}
|
||||||
|
|
||||||
func recurseLinks(bs blockstore.Blockstore, root cid.Cid, in []cid.Cid) ([]cid.Cid, error) {
|
func recurseLinks(bs blockstore.Blockstore, root cid.Cid, in []cid.Cid) ([]cid.Cid, error) {
|
||||||
@@ -1148,7 +1165,6 @@ func (cr *chainRand) GetRandomness(ctx context.Context, pers crypto.DomainSepara
|
|||||||
func (cs *ChainStore) GetTipSetFromKey(tsk types.TipSetKey) (*types.TipSet, error) {
|
func (cs *ChainStore) GetTipSetFromKey(tsk types.TipSetKey) (*types.TipSet, error) {
|
||||||
if tsk.IsEmpty() {
|
if tsk.IsEmpty() {
|
||||||
return cs.GetHeaviestTipSet(), nil
|
return cs.GetHeaviestTipSet(), nil
|
||||||
} else {
|
|
||||||
return cs.LoadTipSet(tsk)
|
|
||||||
}
|
}
|
||||||
|
return cs.LoadTipSet(tsk)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,8 +57,7 @@ func HandleIncomingBlocks(ctx context.Context, bsub *pubsub.Subscription, s *cha
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:golint
|
src := msg.GetFrom()
|
||||||
src := peer.ID(msg.GetFrom())
|
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
log.Infof("New block over pubsub: %s", blk.Cid())
|
log.Infof("New block over pubsub: %s", blk.Cid())
|
||||||
@@ -207,7 +206,7 @@ func (bv *BlockValidator) Validate(ctx context.Context, pid peer.ID, msg *pubsub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = sigs.CheckBlockSignature(blk.Header, ctx, key)
|
err = sigs.CheckBlockSignature(ctx, blk.Header, key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("block signature verification failed: %s", err)
|
log.Errorf("block signature verification failed: %s", err)
|
||||||
recordFailure("signature_verification_failed")
|
recordFailure("signature_verification_failed")
|
||||||
|
|||||||
+2
-2
@@ -526,7 +526,7 @@ func blockSanityChecks(h *types.BlockHeader) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Should match up with 'Semantical Validation' in validation.md in the spec
|
// ValidateBlock should match up with 'Semantical Validation' in validation.md in the spec
|
||||||
func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) error {
|
func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) error {
|
||||||
ctx, span := trace.StartSpan(ctx, "validateBlock")
|
ctx, span := trace.StartSpan(ctx, "validateBlock")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
@@ -665,7 +665,7 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) err
|
|||||||
})
|
})
|
||||||
|
|
||||||
blockSigCheck := async.Err(func() error {
|
blockSigCheck := async.Err(func() error {
|
||||||
if err := sigs.CheckBlockSignature(h, ctx, waddr); err != nil {
|
if err := sigs.CheckBlockSignature(ctx, h, waddr); err != nil {
|
||||||
return xerrors.Errorf("check block signature failed: %w", err)
|
return xerrors.Errorf("check block signature failed: %w", err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
+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)
|
||||||
|
|||||||
@@ -74,8 +74,8 @@ type BlockHeader struct {
|
|||||||
validated bool // true if the signature has been validated
|
validated bool // true if the signature has been validated
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BlockHeader) ToStorageBlock() (block.Block, error) {
|
func (blk *BlockHeader) ToStorageBlock() (block.Block, error) {
|
||||||
data, err := b.Serialize()
|
data, err := blk.Serialize()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -89,8 +89,8 @@ func (b *BlockHeader) ToStorageBlock() (block.Block, error) {
|
|||||||
return block.NewBlockWithCid(data, c)
|
return block.NewBlockWithCid(data, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BlockHeader) Cid() cid.Cid {
|
func (blk *BlockHeader) Cid() cid.Cid {
|
||||||
sb, err := b.ToStorageBlock()
|
sb, err := blk.ToStorageBlock()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err) // Not sure i'm entirely comfortable with this one, needs to be checked
|
panic(err) // Not sure i'm entirely comfortable with this one, needs to be checked
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
+6
-10
@@ -41,20 +41,16 @@ type Message struct {
|
|||||||
Params []byte
|
Params []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Message) BlockMiner() address.Address {
|
func (m *Message) Caller() address.Address {
|
||||||
panic("implement me")
|
return m.From
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Message) Caller() address.Address {
|
func (m *Message) Receiver() address.Address {
|
||||||
return t.From
|
return m.To
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Message) Receiver() address.Address {
|
func (m *Message) ValueReceived() abi.TokenAmount {
|
||||||
return t.To
|
return m.Value
|
||||||
}
|
|
||||||
|
|
||||||
func (t *Message) ValueReceived() abi.TokenAmount {
|
|
||||||
return t.Value
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func DecodeMessage(b []byte) (*Message, error) {
|
func DecodeMessage(b []byte) (*Message, error) {
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ import (
|
|||||||
"github.com/multiformats/go-multihash"
|
"github.com/multiformats/go-multihash"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (m *SignedMessage) ToStorageBlock() (block.Block, error) {
|
func (sm *SignedMessage) ToStorageBlock() (block.Block, error) {
|
||||||
if m.Signature.Type == crypto.SigTypeBLS {
|
if sm.Signature.Type == crypto.SigTypeBLS {
|
||||||
return m.Message.ToStorageBlock()
|
return sm.Message.ToStorageBlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := m.Serialize()
|
data, err := sm.Serialize()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -28,12 +28,12 @@ func (m *SignedMessage) ToStorageBlock() (block.Block, error) {
|
|||||||
return block.NewBlockWithCid(data, c)
|
return block.NewBlockWithCid(data, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *SignedMessage) Cid() cid.Cid {
|
func (sm *SignedMessage) Cid() cid.Cid {
|
||||||
if m.Signature.Type == crypto.SigTypeBLS {
|
if sm.Signature.Type == crypto.SigTypeBLS {
|
||||||
return m.Message.Cid()
|
return sm.Message.Cid()
|
||||||
}
|
}
|
||||||
|
|
||||||
sb, err := m.ToStorageBlock()
|
sb, err := sm.ToStorageBlock()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ type TipSet struct {
|
|||||||
height abi.ChainEpoch
|
height abi.ChainEpoch
|
||||||
}
|
}
|
||||||
|
|
||||||
// why didnt i just export the fields? Because the struct has methods with the
|
|
||||||
// same names already
|
|
||||||
type ExpTipSet struct {
|
type ExpTipSet struct {
|
||||||
Cids []cid.Cid
|
Cids []cid.Cid
|
||||||
Blocks []*BlockHeader
|
Blocks []*BlockHeader
|
||||||
@@ -32,6 +30,8 @@ type ExpTipSet struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ts *TipSet) MarshalJSON() ([]byte, error) {
|
func (ts *TipSet) MarshalJSON() ([]byte, error) {
|
||||||
|
// why didnt i just export the fields? Because the struct has methods with the
|
||||||
|
// same names already
|
||||||
return json.Marshal(ExpTipSet{
|
return json.Marshal(ExpTipSet{
|
||||||
Cids: ts.cids,
|
Cids: ts.cids,
|
||||||
Blocks: ts.blks,
|
Blocks: ts.blks,
|
||||||
|
|||||||
@@ -61,9 +61,9 @@ func TestTipSetKey(t *testing.T) {
|
|||||||
|
|
||||||
t.Run("JSON", func(t *testing.T) {
|
t.Run("JSON", func(t *testing.T) {
|
||||||
k0 := NewTipSetKey()
|
k0 := NewTipSetKey()
|
||||||
verifyJson(t, "[]", k0)
|
verifyJSON(t, "[]", k0)
|
||||||
k3 := NewTipSetKey(c1, c2, c3)
|
k3 := NewTipSetKey(c1, c2, c3)
|
||||||
verifyJson(t, `[`+
|
verifyJSON(t, `[`+
|
||||||
`{"/":"bafy2bzacecesrkxghscnq7vatble2hqdvwat6ed23vdu4vvo3uuggsoaya7ki"},`+
|
`{"/":"bafy2bzacecesrkxghscnq7vatble2hqdvwat6ed23vdu4vvo3uuggsoaya7ki"},`+
|
||||||
`{"/":"bafy2bzacebxfyh2fzoxrt6kcgc5dkaodpcstgwxxdizrww225vrhsizsfcg4g"},`+
|
`{"/":"bafy2bzacebxfyh2fzoxrt6kcgc5dkaodpcstgwxxdizrww225vrhsizsfcg4g"},`+
|
||||||
`{"/":"bafy2bzacedwviarjtjraqakob5pslltmuo5n3xev3nt5zylezofkbbv5jclyu"}`+
|
`{"/":"bafy2bzacedwviarjtjraqakob5pslltmuo5n3xev3nt5zylezofkbbv5jclyu"}`+
|
||||||
@@ -71,7 +71,7 @@ func TestTipSetKey(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func verifyJson(t *testing.T, expected string, k TipSetKey) {
|
func verifyJSON(t *testing.T, expected string, k TipSetKey) {
|
||||||
bytes, err := json.Marshal(k)
|
bytes, err := json.Marshal(k)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, expected, string(bytes))
|
assert.Equal(t, expected, string(bytes))
|
||||||
|
|||||||
@@ -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)
|
||||||
|
}
|
||||||
|
|||||||
+6
-8
@@ -32,7 +32,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/actors/aerrors"
|
"github.com/filecoin-project/lotus/chain/actors/aerrors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type invoker struct {
|
type Invoker struct {
|
||||||
builtInCode map[cid.Cid]nativeCode
|
builtInCode map[cid.Cid]nativeCode
|
||||||
builtInState map[cid.Cid]reflect.Type
|
builtInState map[cid.Cid]reflect.Type
|
||||||
}
|
}
|
||||||
@@ -40,8 +40,8 @@ type invoker struct {
|
|||||||
type invokeFunc func(rt runtime.Runtime, params []byte) ([]byte, aerrors.ActorError)
|
type invokeFunc func(rt runtime.Runtime, params []byte) ([]byte, aerrors.ActorError)
|
||||||
type nativeCode []invokeFunc
|
type nativeCode []invokeFunc
|
||||||
|
|
||||||
func NewInvoker() *invoker {
|
func NewInvoker() *Invoker {
|
||||||
inv := &invoker{
|
inv := &Invoker{
|
||||||
builtInCode: make(map[cid.Cid]nativeCode),
|
builtInCode: make(map[cid.Cid]nativeCode),
|
||||||
builtInState: make(map[cid.Cid]reflect.Type),
|
builtInState: make(map[cid.Cid]reflect.Type),
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,7 @@ func NewInvoker() *invoker {
|
|||||||
return inv
|
return inv
|
||||||
}
|
}
|
||||||
|
|
||||||
func (inv *invoker) Invoke(codeCid cid.Cid, rt runtime.Runtime, method abi.MethodNum, params []byte) ([]byte, aerrors.ActorError) {
|
func (inv *Invoker) Invoke(codeCid cid.Cid, rt runtime.Runtime, method abi.MethodNum, params []byte) ([]byte, aerrors.ActorError) {
|
||||||
|
|
||||||
code, ok := inv.builtInCode[codeCid]
|
code, ok := inv.builtInCode[codeCid]
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -76,7 +76,7 @@ func (inv *invoker) Invoke(codeCid cid.Cid, rt runtime.Runtime, method abi.Metho
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (inv *invoker) Register(c cid.Cid, instance Invokee, state interface{}) {
|
func (inv *Invoker) Register(c cid.Cid, instance Invokee, state interface{}) {
|
||||||
code, err := inv.transform(instance)
|
code, err := inv.transform(instance)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(xerrors.Errorf("%s: %w", string(c.Hash()), err))
|
panic(xerrors.Errorf("%s: %w", string(c.Hash()), err))
|
||||||
@@ -89,9 +89,7 @@ type Invokee interface {
|
|||||||
Exports() []interface{}
|
Exports() []interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
var tAError = reflect.TypeOf((*aerrors.ActorError)(nil)).Elem()
|
func (*Invoker) transform(instance Invokee) (nativeCode, error) {
|
||||||
|
|
||||||
func (*invoker) transform(instance Invokee) (nativeCode, error) {
|
|
||||||
itype := reflect.TypeOf(instance)
|
itype := reflect.TypeOf(instance)
|
||||||
exports := instance.Exports()
|
exports := instance.Exports()
|
||||||
for i, m := range exports {
|
for i, m := range exports {
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ func (basicContract) InvokeSomething10(rt runtime.Runtime, params *basicParams)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestInvokerBasic(t *testing.T) {
|
func TestInvokerBasic(t *testing.T) {
|
||||||
inv := invoker{}
|
inv := Invoker{}
|
||||||
code, err := inv.transform(basicContract{})
|
code, err := inv.transform(basicContract{})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -2,6 +2,7 @@ package vm
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/actors"
|
"github.com/filecoin-project/lotus/chain/actors"
|
||||||
"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"
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
@@ -27,7 +28,7 @@ func init() {
|
|||||||
|
|
||||||
var EmptyObjectCid cid.Cid
|
var EmptyObjectCid cid.Cid
|
||||||
|
|
||||||
// Creates account actors from only BLS/SECP256K1 addresses.
|
// TryCreateAccountActor creates account actors from only BLS/SECP256K1 addresses.
|
||||||
func TryCreateAccountActor(rt *Runtime, addr address.Address) (*types.Actor, aerrors.ActorError) {
|
func TryCreateAccountActor(rt *Runtime, addr address.Address) (*types.Actor, aerrors.ActorError) {
|
||||||
addrID, err := rt.state.RegisterNewAddress(addr)
|
addrID, err := rt.state.RegisterNewAddress(addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
+54
-52
@@ -107,8 +107,8 @@ type notFoundErr interface {
|
|||||||
IsNotFound() bool
|
IsNotFound() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *Runtime) Get(c cid.Cid, o vmr.CBORUnmarshaler) bool {
|
func (rt *Runtime) Get(c cid.Cid, o vmr.CBORUnmarshaler) bool {
|
||||||
if err := rs.cst.Get(context.TODO(), c, o); err != nil {
|
if err := rt.cst.Get(context.TODO(), c, o); err != nil {
|
||||||
var nfe notFoundErr
|
var nfe notFoundErr
|
||||||
if xerrors.As(err, &nfe) && nfe.IsNotFound() {
|
if xerrors.As(err, &nfe) && nfe.IsNotFound() {
|
||||||
if xerrors.As(err, new(cbor.SerializationError)) {
|
if xerrors.As(err, new(cbor.SerializationError)) {
|
||||||
@@ -122,8 +122,8 @@ func (rs *Runtime) Get(c cid.Cid, o vmr.CBORUnmarshaler) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *Runtime) Put(x vmr.CBORMarshaler) cid.Cid {
|
func (rt *Runtime) Put(x vmr.CBORMarshaler) cid.Cid {
|
||||||
c, err := rs.cst.Put(context.TODO(), x)
|
c, err := rt.cst.Put(context.TODO(), x)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if xerrors.As(err, new(cbor.SerializationError)) {
|
if xerrors.As(err, new(cbor.SerializationError)) {
|
||||||
panic(aerrors.Newf(exitcode.ErrSerialization, "failed to marshal cbor object %s", err))
|
panic(aerrors.Newf(exitcode.ErrSerialization, "failed to marshal cbor object %s", err))
|
||||||
@@ -135,7 +135,7 @@ func (rs *Runtime) Put(x vmr.CBORMarshaler) cid.Cid {
|
|||||||
|
|
||||||
var _ vmr.Runtime = (*Runtime)(nil)
|
var _ vmr.Runtime = (*Runtime)(nil)
|
||||||
|
|
||||||
func (rs *Runtime) shimCall(f func() interface{}) (rval []byte, aerr aerrors.ActorError) {
|
func (rt *Runtime) shimCall(f func() interface{}) (rval []byte, aerr aerrors.ActorError) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
if ar, ok := r.(aerrors.ActorError); ok {
|
if ar, ok := r.(aerrors.ActorError); ok {
|
||||||
@@ -150,8 +150,8 @@ func (rs *Runtime) shimCall(f func() interface{}) (rval []byte, aerr aerrors.Act
|
|||||||
|
|
||||||
ret := f()
|
ret := f()
|
||||||
|
|
||||||
if !rs.callerValidated {
|
if !rt.callerValidated {
|
||||||
rs.Abortf(exitcode.SysErrorIllegalActor, "Caller MUST be validated during method execution")
|
rt.Abortf(exitcode.SysErrorIllegalActor, "Caller MUST be validated during method execution")
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ret := ret.(type) {
|
switch ret := ret.(type) {
|
||||||
@@ -172,25 +172,25 @@ func (rs *Runtime) shimCall(f func() interface{}) (rval []byte, aerr aerrors.Act
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *Runtime) Message() vmr.Message {
|
func (rt *Runtime) Message() vmr.Message {
|
||||||
return rs.vmsg
|
return rt.vmsg
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *Runtime) ValidateImmediateCallerAcceptAny() {
|
func (rt *Runtime) ValidateImmediateCallerAcceptAny() {
|
||||||
rs.abortIfAlreadyValidated()
|
rt.abortIfAlreadyValidated()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *Runtime) CurrentBalance() abi.TokenAmount {
|
func (rt *Runtime) CurrentBalance() abi.TokenAmount {
|
||||||
b, err := rs.GetBalance(rs.Message().Receiver())
|
b, err := rt.GetBalance(rt.Message().Receiver())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rs.Abortf(exitcode.ExitCode(err.RetCode()), "get current balance: %v", err)
|
rt.Abortf(err.RetCode(), "get current balance: %v", err)
|
||||||
}
|
}
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *Runtime) GetActorCodeCID(addr address.Address) (ret cid.Cid, ok bool) {
|
func (rt *Runtime) GetActorCodeCID(addr address.Address) (ret cid.Cid, ok bool) {
|
||||||
act, err := rs.state.GetActor(addr)
|
act, err := rt.state.GetActor(addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if xerrors.Is(err, types.ErrActorNotFound) {
|
if xerrors.Is(err, types.ErrActorNotFound) {
|
||||||
return cid.Undef, false
|
return cid.Undef, false
|
||||||
@@ -210,8 +210,8 @@ func (rt *Runtime) GetRandomness(personalization crypto.DomainSeparationTag, ran
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *Runtime) Store() vmr.Store {
|
func (rt *Runtime) Store() vmr.Store {
|
||||||
return rs
|
return rt
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rt *Runtime) NewActorAddress() address.Address {
|
func (rt *Runtime) NewActorAddress() address.Address {
|
||||||
@@ -236,12 +236,12 @@ func (rt *Runtime) NewActorAddress() address.Address {
|
|||||||
return addr
|
return addr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rt *Runtime) CreateActor(codeId cid.Cid, address address.Address) {
|
func (rt *Runtime) CreateActor(codeID cid.Cid, address address.Address) {
|
||||||
if !builtin.IsBuiltinActor(codeId) {
|
if !builtin.IsBuiltinActor(codeID) {
|
||||||
rt.Abortf(exitcode.SysErrorIllegalArgument, "Can only create built-in actors.")
|
rt.Abortf(exitcode.SysErrorIllegalArgument, "Can only create built-in actors.")
|
||||||
}
|
}
|
||||||
|
|
||||||
if builtin.IsSingletonActor(codeId) {
|
if builtin.IsSingletonActor(codeID) {
|
||||||
rt.Abortf(exitcode.SysErrorIllegalArgument, "Can only have one instance of singleton actors.")
|
rt.Abortf(exitcode.SysErrorIllegalArgument, "Can only have one instance of singleton actors.")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,7 +253,7 @@ func (rt *Runtime) CreateActor(codeId cid.Cid, address address.Address) {
|
|||||||
rt.ChargeGas(rt.Pricelist().OnCreateActor())
|
rt.ChargeGas(rt.Pricelist().OnCreateActor())
|
||||||
|
|
||||||
err = rt.state.SetActor(address, &types.Actor{
|
err = rt.state.SetActor(address, &types.Actor{
|
||||||
Code: codeId,
|
Code: codeID,
|
||||||
Head: EmptyObjectCid,
|
Head: EmptyObjectCid,
|
||||||
Nonce: 0,
|
Nonce: 0,
|
||||||
Balance: big.Zero(),
|
Balance: big.Zero(),
|
||||||
@@ -283,12 +283,12 @@ func (rt *Runtime) DeleteActor(addr address.Address) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *Runtime) Syscalls() vmr.Syscalls {
|
func (rt *Runtime) Syscalls() vmr.Syscalls {
|
||||||
// TODO: Make sure this is wrapped in something that charges gas for each of the calls
|
// TODO: Make sure this is wrapped in something that charges gas for each of the calls
|
||||||
return rs.sys
|
return rt.sys
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *Runtime) StartSpan(name string) vmr.TraceSpan {
|
func (rt *Runtime) StartSpan(name string) vmr.TraceSpan {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,12 +308,12 @@ func (rt *Runtime) Context() context.Context {
|
|||||||
return rt.ctx
|
return rt.ctx
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *Runtime) Abortf(code exitcode.ExitCode, msg string, args ...interface{}) {
|
func (rt *Runtime) Abortf(code exitcode.ExitCode, msg string, args ...interface{}) {
|
||||||
log.Error("Abortf: ", fmt.Sprintf(msg, args...))
|
log.Error("Abortf: ", fmt.Sprintf(msg, args...))
|
||||||
panic(aerrors.NewfSkip(2, code, msg, args...))
|
panic(aerrors.NewfSkip(2, code, msg, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *Runtime) AbortStateMsg(msg string) {
|
func (rt *Runtime) AbortStateMsg(msg string) {
|
||||||
panic(aerrors.NewfSkip(3, 101, msg))
|
panic(aerrors.NewfSkip(3, 101, msg))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,8 +331,8 @@ func (rt *Runtime) ValidateImmediateCallerType(ts ...cid.Cid) {
|
|||||||
rt.Abortf(exitcode.SysErrForbidden, "caller cid type %q was not one of %v", callerCid, ts)
|
rt.Abortf(exitcode.SysErrForbidden, "caller cid type %q was not one of %v", callerCid, ts)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *Runtime) CurrEpoch() abi.ChainEpoch {
|
func (rt *Runtime) CurrEpoch() abi.ChainEpoch {
|
||||||
return rs.height
|
return rt.height
|
||||||
}
|
}
|
||||||
|
|
||||||
type dumbWrapperType struct {
|
type dumbWrapperType struct {
|
||||||
@@ -343,26 +343,26 @@ func (dwt *dumbWrapperType) Into(um vmr.CBORUnmarshaler) error {
|
|||||||
return um.UnmarshalCBOR(bytes.NewReader(dwt.val))
|
return um.UnmarshalCBOR(bytes.NewReader(dwt.val))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *Runtime) Send(to address.Address, method abi.MethodNum, m vmr.CBORMarshaler, value abi.TokenAmount) (vmr.SendReturn, exitcode.ExitCode) {
|
func (rt *Runtime) Send(to address.Address, method abi.MethodNum, m vmr.CBORMarshaler, value abi.TokenAmount) (vmr.SendReturn, exitcode.ExitCode) {
|
||||||
if !rs.allowInternal {
|
if !rt.allowInternal {
|
||||||
rs.Abortf(exitcode.SysErrorIllegalActor, "runtime.Send() is currently disallowed")
|
rt.Abortf(exitcode.SysErrorIllegalActor, "runtime.Send() is currently disallowed")
|
||||||
}
|
}
|
||||||
var params []byte
|
var params []byte
|
||||||
if m != nil {
|
if m != nil {
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
if err := m.MarshalCBOR(buf); err != nil {
|
if err := m.MarshalCBOR(buf); err != nil {
|
||||||
rs.Abortf(exitcode.SysErrInvalidParameters, "failed to marshal input parameters: %s", err)
|
rt.Abortf(exitcode.SysErrInvalidParameters, "failed to marshal input parameters: %s", err)
|
||||||
}
|
}
|
||||||
params = buf.Bytes()
|
params = buf.Bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
ret, err := rs.internalSend(rs.Message().Receiver(), to, method, types.BigInt(value), params)
|
ret, err := rt.internalSend(rt.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
|
||||||
}
|
}
|
||||||
@@ -402,7 +402,7 @@ 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,
|
||||||
}
|
}
|
||||||
@@ -425,46 +425,48 @@ func (rt *Runtime) internalSend(from, to address.Address, method abi.MethodNum,
|
|||||||
return ret, errSend
|
return ret, errSend
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *Runtime) State() vmr.StateHandle {
|
func (rt *Runtime) State() vmr.StateHandle {
|
||||||
return &shimStateHandle{rs: rs}
|
return &shimStateHandle{rt: rt}
|
||||||
}
|
}
|
||||||
|
|
||||||
type shimStateHandle struct {
|
type shimStateHandle struct {
|
||||||
rs *Runtime
|
rt *Runtime
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ssh *shimStateHandle) Create(obj vmr.CBORMarshaler) {
|
func (ssh *shimStateHandle) Create(obj vmr.CBORMarshaler) {
|
||||||
c := ssh.rs.Put(obj)
|
c := ssh.rt.Put(obj)
|
||||||
ssh.rs.stateCommit(EmptyObjectCid, c)
|
// TODO: handle error below
|
||||||
|
ssh.rt.stateCommit(EmptyObjectCid, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ssh *shimStateHandle) Readonly(obj vmr.CBORUnmarshaler) {
|
func (ssh *shimStateHandle) Readonly(obj vmr.CBORUnmarshaler) {
|
||||||
act, err := ssh.rs.state.GetActor(ssh.rs.Message().Receiver())
|
act, err := ssh.rt.state.GetActor(ssh.rt.Message().Receiver())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ssh.rs.Abortf(exitcode.SysErrorIllegalArgument, "failed to get actor for Readonly state: %s", err)
|
ssh.rt.Abortf(exitcode.SysErrorIllegalArgument, "failed to get actor for Readonly state: %s", err)
|
||||||
}
|
}
|
||||||
ssh.rs.Get(act.Head, obj)
|
ssh.rt.Get(act.Head, obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ssh *shimStateHandle) Transaction(obj vmr.CBORer, f func() interface{}) interface{} {
|
func (ssh *shimStateHandle) Transaction(obj vmr.CBORer, f func() interface{}) interface{} {
|
||||||
if obj == nil {
|
if obj == nil {
|
||||||
ssh.rs.Abortf(exitcode.SysErrorIllegalActor, "Must not pass nil to Transaction()")
|
ssh.rt.Abortf(exitcode.SysErrorIllegalActor, "Must not pass nil to Transaction()")
|
||||||
}
|
}
|
||||||
|
|
||||||
act, err := ssh.rs.state.GetActor(ssh.rs.Message().Receiver())
|
act, err := ssh.rt.state.GetActor(ssh.rt.Message().Receiver())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ssh.rs.Abortf(exitcode.SysErrorIllegalActor, "failed to get actor for Transaction: %s", err)
|
ssh.rt.Abortf(exitcode.SysErrorIllegalActor, "failed to get actor for Transaction: %s", err)
|
||||||
}
|
}
|
||||||
baseState := act.Head
|
baseState := act.Head
|
||||||
ssh.rs.Get(baseState, obj)
|
ssh.rt.Get(baseState, obj)
|
||||||
|
|
||||||
ssh.rs.allowInternal = false
|
ssh.rt.allowInternal = false
|
||||||
out := f()
|
out := f()
|
||||||
ssh.rs.allowInternal = true
|
ssh.rt.allowInternal = true
|
||||||
|
|
||||||
c := ssh.rs.Put(obj)
|
c := ssh.rt.Put(obj)
|
||||||
|
|
||||||
ssh.rs.stateCommit(baseState, c)
|
// TODO: handle error below
|
||||||
|
ssh.rt.stateCommit(baseState, c)
|
||||||
|
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|||||||
+36
-16
@@ -4,6 +4,8 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
goruntime "runtime"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
@@ -183,7 +185,7 @@ func (ss *syscallShim) VerifyBlockSig(blk *types.BlockHeader) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := sigs.CheckBlockSignature(blk, ss.ctx, waddr); err != nil {
|
if err := sigs.CheckBlockSignature(ss.ctx, blk, waddr); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,20 +203,6 @@ func (ss *syscallShim) VerifyPoSt(proof abi.WindowPoStVerifyInfo) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func cidToCommD(c cid.Cid) [32]byte {
|
|
||||||
b := c.Bytes()
|
|
||||||
var out [32]byte
|
|
||||||
copy(out[:], b[len(b)-32:])
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
|
|
||||||
func cidToCommR(c cid.Cid) [32]byte {
|
|
||||||
b := c.Bytes()
|
|
||||||
var out [32]byte
|
|
||||||
copy(out[:], b[len(b)-32:])
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ss *syscallShim) VerifySeal(info abi.SealVerifyInfo) error {
|
func (ss *syscallShim) VerifySeal(info abi.SealVerifyInfo) error {
|
||||||
//_, span := trace.StartSpan(ctx, "ValidatePoRep")
|
//_, span := trace.StartSpan(ctx, "ValidatePoRep")
|
||||||
//defer span.End()
|
//defer span.End()
|
||||||
@@ -225,7 +213,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 +240,35 @@ 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)
|
||||||
|
|
||||||
|
sema := make(chan struct{}, goruntime.NumCPU())
|
||||||
|
|
||||||
|
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()
|
||||||
|
sema <- struct{}{}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
<-sema
|
||||||
|
}(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
|
||||||
}
|
}
|
||||||
|
|||||||
+23
-9
@@ -131,7 +131,7 @@ type VM struct {
|
|||||||
cst *cbor.BasicIpldStore
|
cst *cbor.BasicIpldStore
|
||||||
buf *bufbstore.BufferedBS
|
buf *bufbstore.BufferedBS
|
||||||
blockHeight abi.ChainEpoch
|
blockHeight abi.ChainEpoch
|
||||||
inv *invoker
|
inv *Invoker
|
||||||
rand Rand
|
rand Rand
|
||||||
|
|
||||||
Syscalls runtime.Syscalls
|
Syscalls runtime.Syscalls
|
||||||
@@ -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,
|
||||||
},
|
},
|
||||||
@@ -454,7 +454,7 @@ func (vm *VM) Flush(ctx context.Context) (cid.Cid, error) {
|
|||||||
return root, nil
|
return root, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// vm.MutateState(idAddr, func(cst cbor.IpldStore, st *ActorStateType) error {...})
|
// MutateState usage: MutateState(ctx, idAddr, func(cst cbor.IpldStore, st *ActorStateType) error {...})
|
||||||
func (vm *VM) MutateState(ctx context.Context, addr address.Address, fn interface{}) error {
|
func (vm *VM) MutateState(ctx context.Context, addr address.Address, fn interface{}) error {
|
||||||
act, err := vm.cstate.GetActor(addr)
|
act, err := vm.cstate.GetActor(addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -591,7 +591,7 @@ func (vm *VM) Invoke(act *types.Actor, rt *Runtime, method abi.MethodNum, params
|
|||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (vm *VM) SetInvoker(i *invoker) {
|
func (vm *VM) SetInvoker(i *Invoker) {
|
||||||
vm.inv = i
|
vm.inv = i
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+24
-6
@@ -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"
|
||||||
@@ -22,10 +22,11 @@ import (
|
|||||||
var log = logging.Logger("wallet")
|
var log = logging.Logger("wallet")
|
||||||
|
|
||||||
const (
|
const (
|
||||||
KNamePrefix = "wallet-"
|
KNamePrefix = "wallet-"
|
||||||
KDefault = "default"
|
KTrashPrefix = "trash-"
|
||||||
KTBLS = "bls"
|
KDefault = "default"
|
||||||
KTSecp256k1 = "secp256k1"
|
KTBLS = "bls"
|
||||||
|
KTSecp256k1 = "secp256k1"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Wallet struct {
|
type Wallet struct {
|
||||||
@@ -230,6 +231,23 @@ func (w *Wallet) HasKey(addr address.Address) (bool, error) {
|
|||||||
return k != nil, nil
|
return k != nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *Wallet) DeleteKey(addr address.Address) error {
|
||||||
|
k, err := w.findKey(addr)
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("failed to delete key %s : %w", addr, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := w.keystore.Put(KTrashPrefix+k.Address.String(), k.KeyInfo); err != nil {
|
||||||
|
return xerrors.Errorf("failed to mark key %s as trashed: %w", addr, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := w.keystore.Delete(KNamePrefix + k.Address.String()); err != nil {
|
||||||
|
return xerrors.Errorf("failed to delete key %s: %w", addr, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
type Key struct {
|
type Key struct {
|
||||||
types.KeyInfo
|
types.KeyInfo
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -3,8 +3,8 @@ package cli
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
"gopkg.in/urfave/cli.v2"
|
|
||||||
|
|
||||||
"github.com/filecoin-project/go-jsonrpc/auth"
|
"github.com/filecoin-project/go-jsonrpc/auth"
|
||||||
|
|
||||||
|
|||||||
+9
-3
@@ -23,9 +23,9 @@ import (
|
|||||||
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
||||||
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||||
cid "github.com/ipfs/go-cid"
|
cid "github.com/ipfs/go-cid"
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
cbg "github.com/whyrusleeping/cbor-gen"
|
cbg "github.com/whyrusleeping/cbor-gen"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
"gopkg.in/urfave/cli.v2"
|
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/chain/actors"
|
"github.com/filecoin-project/lotus/chain/actors"
|
||||||
@@ -442,7 +442,8 @@ var chainGetCmd = &cli.Command{
|
|||||||
- /ipfs/[cid]/@Hi:123 - get varint elem 123 from hamt
|
- /ipfs/[cid]/@Hi:123 - get varint elem 123 from hamt
|
||||||
- /ipfs/[cid]/@Hu:123 - get uvarint elem 123 from hamt
|
- /ipfs/[cid]/@Hu:123 - get uvarint elem 123 from hamt
|
||||||
- /ipfs/[cid]/@Ha:t01 - get element under Addr(t01).Bytes
|
- /ipfs/[cid]/@Ha:t01 - get element under Addr(t01).Bytes
|
||||||
- /ipfs/[cid]/@A:10 - get 10th amt element
|
- /ipfs/[cid]/@A:10 - get 10th amt element
|
||||||
|
- .../@Ha:t01/@state - get pretty map-based actor state
|
||||||
|
|
||||||
List of --as-type types:
|
List of --as-type types:
|
||||||
- raw
|
- raw
|
||||||
@@ -804,7 +805,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 {
|
||||||
|
|||||||
+68
-8
@@ -8,9 +8,11 @@ import (
|
|||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
|
"github.com/ipfs/go-cidutil/cidenc"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
|
"github.com/multiformats/go-multibase"
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
"gopkg.in/urfave/cli.v2"
|
|
||||||
|
|
||||||
"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"
|
||||||
@@ -21,6 +23,32 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var CidBaseFlag = cli.StringFlag{
|
||||||
|
Name: "cid-base",
|
||||||
|
Hidden: true,
|
||||||
|
Value: "base32",
|
||||||
|
Usage: "Multibase encoding used for version 1 CIDs in output.",
|
||||||
|
DefaultText: "base32",
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCidEncoder returns an encoder using the `cid-base` flag if provided, or
|
||||||
|
// the default (Base32) encoder if not.
|
||||||
|
func GetCidEncoder(cctx *cli.Context) (cidenc.Encoder, error) {
|
||||||
|
val := cctx.String("cid-base")
|
||||||
|
|
||||||
|
e := cidenc.Encoder{Base: multibase.MustNewEncoder(multibase.Base32)}
|
||||||
|
|
||||||
|
if val != "" {
|
||||||
|
var err error
|
||||||
|
e.Base, err = multibase.EncoderByName(val)
|
||||||
|
if err != nil {
|
||||||
|
return e, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return e, nil
|
||||||
|
}
|
||||||
|
|
||||||
var clientCmd = &cli.Command{
|
var clientCmd = &cli.Command{
|
||||||
Name: "client",
|
Name: "client",
|
||||||
Usage: "Make deals, store data, retrieve data",
|
Usage: "Make deals, store data, retrieve data",
|
||||||
@@ -46,6 +74,7 @@ var clientImportCmd = &cli.Command{
|
|||||||
Name: "car",
|
Name: "car",
|
||||||
Usage: "import from a car file instead of a regular file",
|
Usage: "import from a car file instead of a regular file",
|
||||||
},
|
},
|
||||||
|
&CidBaseFlag,
|
||||||
},
|
},
|
||||||
Action: func(cctx *cli.Context) error {
|
Action: func(cctx *cli.Context) error {
|
||||||
api, closer, err := GetFullNodeAPI(cctx)
|
api, closer, err := GetFullNodeAPI(cctx)
|
||||||
@@ -67,7 +96,14 @@ var clientImportCmd = &cli.Command{
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Println(c.String())
|
|
||||||
|
encoder, err := GetCidEncoder(cctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(encoder.Encode(c))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -76,6 +112,9 @@ var clientCommPCmd = &cli.Command{
|
|||||||
Name: "commP",
|
Name: "commP",
|
||||||
Usage: "calculate the piece-cid (commP) of a CAR file",
|
Usage: "calculate the piece-cid (commP) of a CAR file",
|
||||||
ArgsUsage: "[inputFile minerAddress]",
|
ArgsUsage: "[inputFile minerAddress]",
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
&CidBaseFlag,
|
||||||
|
},
|
||||||
Action: func(cctx *cli.Context) error {
|
Action: func(cctx *cli.Context) error {
|
||||||
api, closer, err := GetFullNodeAPI(cctx)
|
api, closer, err := GetFullNodeAPI(cctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -94,11 +133,16 @@ var clientCommPCmd = &cli.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret, err := api.ClientCalcCommP(ctx, cctx.Args().Get(0), miner)
|
ret, err := api.ClientCalcCommP(ctx, cctx.Args().Get(0), miner)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Println("CID: ", ret.Root)
|
|
||||||
|
encoder, err := GetCidEncoder(cctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("CID: ", encoder.Encode(ret.Root))
|
||||||
fmt.Println("Piece size: ", ret.Size)
|
fmt.Println("Piece size: ", ret.Size)
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
@@ -137,6 +181,9 @@ var clientCarGenCmd = &cli.Command{
|
|||||||
var clientLocalCmd = &cli.Command{
|
var clientLocalCmd = &cli.Command{
|
||||||
Name: "local",
|
Name: "local",
|
||||||
Usage: "List locally imported data",
|
Usage: "List locally imported data",
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
&CidBaseFlag,
|
||||||
|
},
|
||||||
Action: func(cctx *cli.Context) error {
|
Action: func(cctx *cli.Context) error {
|
||||||
api, closer, err := GetFullNodeAPI(cctx)
|
api, closer, err := GetFullNodeAPI(cctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -149,8 +196,14 @@ var clientLocalCmd = &cli.Command{
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
encoder, err := GetCidEncoder(cctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
for _, v := range list {
|
for _, v := range list {
|
||||||
fmt.Printf("%s %s %d %s\n", v.Key, v.FilePath, v.Size, v.Status)
|
fmt.Printf("%s %s %d %s\n", encoder.Encode(v.Key), v.FilePath, v.Size, v.Status)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
@@ -178,6 +231,7 @@ var clientDealCmd = &cli.Command{
|
|||||||
Usage: "specify the epoch that the deal should start at",
|
Usage: "specify the epoch that the deal should start at",
|
||||||
Value: -1,
|
Value: -1,
|
||||||
},
|
},
|
||||||
|
&CidBaseFlag,
|
||||||
},
|
},
|
||||||
Action: func(cctx *cli.Context) error {
|
Action: func(cctx *cli.Context) error {
|
||||||
api, closer, err := GetFullNodeAPI(cctx)
|
api, closer, err := GetFullNodeAPI(cctx)
|
||||||
@@ -263,7 +317,13 @@ var clientDealCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(proposal)
|
encoder, err := GetCidEncoder(cctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(encoder.Encode(*proposal))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -446,11 +506,11 @@ var clientQueryAskCmd = &cli.Command{
|
|||||||
return xerrors.Errorf("failed to get peerID for miner: %w", err)
|
return xerrors.Errorf("failed to get peerID for miner: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if mi.PeerId == peer.ID("SETME") {
|
if peer.ID(mi.PeerId) == peer.ID("SETME") {
|
||||||
return fmt.Errorf("the miner hasn't initialized yet")
|
return fmt.Errorf("the miner hasn't initialized yet")
|
||||||
}
|
}
|
||||||
|
|
||||||
pid = mi.PeerId
|
pid = peer.ID(mi.PeerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
ask, err := api.ClientQueryAsk(ctx, pid, maddr)
|
ask, err := api.ClientQueryAsk(ctx, pid, maddr)
|
||||||
|
|||||||
+1
-1
@@ -13,8 +13,8 @@ import (
|
|||||||
"github.com/mitchellh/go-homedir"
|
"github.com/mitchellh/go-homedir"
|
||||||
"github.com/multiformats/go-multiaddr"
|
"github.com/multiformats/go-multiaddr"
|
||||||
manet "github.com/multiformats/go-multiaddr-net"
|
manet "github.com/multiformats/go-multiaddr-net"
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
"gopkg.in/urfave/cli.v2"
|
|
||||||
|
|
||||||
"github.com/filecoin-project/go-jsonrpc"
|
"github.com/filecoin-project/go-jsonrpc"
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -3,8 +3,8 @@ package cli
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
"gopkg.in/urfave/cli.v2"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var logCmd = &cli.Command{
|
var logCmd = &cli.Command{
|
||||||
|
|||||||
+1
-1
@@ -5,8 +5,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
"gopkg.in/urfave/cli.v2"
|
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
|
|
||||||
|
|||||||
+9
-5
@@ -17,12 +17,13 @@ import (
|
|||||||
cid "github.com/ipfs/go-cid"
|
cid "github.com/ipfs/go-cid"
|
||||||
"github.com/ipfs/go-hamt-ipld"
|
"github.com/ipfs/go-hamt-ipld"
|
||||||
cbor "github.com/ipfs/go-ipld-cbor"
|
cbor "github.com/ipfs/go-ipld-cbor"
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
cbg "github.com/whyrusleeping/cbor-gen"
|
cbg "github.com/whyrusleeping/cbor-gen"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
"gopkg.in/urfave/cli.v2"
|
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/api/apibstore"
|
"github.com/filecoin-project/lotus/api/apibstore"
|
||||||
|
"github.com/filecoin-project/lotus/build"
|
||||||
types "github.com/filecoin-project/lotus/chain/types"
|
types "github.com/filecoin-project/lotus/chain/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -117,7 +118,7 @@ var msigCreateCmd = &cli.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// wait for it to get mined into a block
|
// wait for it to get mined into a block
|
||||||
wait, err := api.StateWaitMsg(ctx, msgCid)
|
wait, err := api.StateWaitMsg(ctx, msgCid, build.MessageConfidence)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -206,7 +207,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
|
||||||
@@ -333,7 +337,7 @@ var msigProposeCmd = &cli.Command{
|
|||||||
|
|
||||||
fmt.Println("send proposal in message: ", msgCid)
|
fmt.Println("send proposal in message: ", msgCid)
|
||||||
|
|
||||||
wait, err := api.StateWaitMsg(ctx, msgCid)
|
wait, err := api.StateWaitMsg(ctx, msgCid, build.MessageConfidence)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -449,7 +453,7 @@ var msigApproveCmd = &cli.Command{
|
|||||||
|
|
||||||
fmt.Println("sent approval in message: ", msgCid)
|
fmt.Println("sent approval in message: ", msgCid)
|
||||||
|
|
||||||
wait, err := api.StateWaitMsg(ctx, msgCid)
|
wait, err := api.StateWaitMsg(ctx, msgCid, build.MessageConfidence)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
+26
-2
@@ -7,7 +7,7 @@ import (
|
|||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
|
|
||||||
"gopkg.in/urfave/cli.v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/lib/addrutil"
|
"github.com/filecoin-project/lotus/lib/addrutil"
|
||||||
)
|
)
|
||||||
@@ -21,6 +21,7 @@ var netCmd = &cli.Command{
|
|||||||
netListen,
|
netListen,
|
||||||
netId,
|
netId,
|
||||||
netFindPeer,
|
netFindPeer,
|
||||||
|
netScores,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +45,30 @@ var netPeers = &cli.Command{
|
|||||||
})
|
})
|
||||||
|
|
||||||
for _, peer := range peers {
|
for _, peer := range peers {
|
||||||
fmt.Println(peer)
|
fmt.Printf("%s, %s\n", peer.ID, peer.Addrs)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
var netScores = &cli.Command{
|
||||||
|
Name: "scores",
|
||||||
|
Usage: "Print peers' pubsub scores",
|
||||||
|
Action: func(cctx *cli.Context) error {
|
||||||
|
api, closer, err := GetAPI(cctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer closer()
|
||||||
|
ctx := ReqContext(cctx)
|
||||||
|
scores, err := api.NetPubsubScores(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, peer := range scores {
|
||||||
|
fmt.Printf("%s, %f\n", peer.ID, peer.Score)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
+3
-2
@@ -3,8 +3,8 @@ package cli
|
|||||||
import (
|
import (
|
||||||
"github.com/docker/go-units"
|
"github.com/docker/go-units"
|
||||||
paramfetch "github.com/filecoin-project/go-paramfetch"
|
paramfetch "github.com/filecoin-project/go-paramfetch"
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
"gopkg.in/urfave/cli.v2"
|
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
)
|
)
|
||||||
@@ -24,7 +24,8 @@ var fetchParamCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
sectorSize := uint64(sectorSizeInt)
|
sectorSize := uint64(sectorSizeInt)
|
||||||
err = paramfetch.GetParams(build.ParametersJson(), sectorSize)
|
|
||||||
|
err = paramfetch.GetParams(ReqContext(cctx), 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)
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-3
@@ -4,10 +4,11 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/filecoin-project/lotus/build"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/paych"
|
"github.com/filecoin-project/specs-actors/actors/builtin/paych"
|
||||||
"gopkg.in/urfave/cli.v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
|
||||||
types "github.com/filecoin-project/lotus/chain/types"
|
types "github.com/filecoin-project/lotus/chain/types"
|
||||||
)
|
)
|
||||||
@@ -361,7 +362,7 @@ var paychVoucherSubmitCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
mwait, err := api.StateWaitMsg(ctx, mcid)
|
mwait, err := api.StateWaitMsg(ctx, mcid, build.MessageConfidence)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -370,7 +371,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
|
||||||
},
|
},
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"gopkg.in/urfave/cli.v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var sendCmd = &cli.Command{
|
var sendCmd = &cli.Command{
|
||||||
|
|||||||
+13
-10
@@ -15,9 +15,9 @@ import (
|
|||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
"github.com/multiformats/go-multihash"
|
"github.com/multiformats/go-multihash"
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
cbg "github.com/whyrusleeping/cbor-gen"
|
cbg "github.com/whyrusleeping/cbor-gen"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
"gopkg.in/urfave/cli.v2"
|
|
||||||
|
|
||||||
"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"
|
||||||
@@ -35,6 +35,7 @@ import (
|
|||||||
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/miner"
|
"github.com/filecoin-project/lotus/miner"
|
||||||
)
|
)
|
||||||
@@ -392,7 +393,7 @@ var stateReplaySetCmd = &cli.Command{
|
|||||||
|
|
||||||
ts, err = types.NewTipSet(headers)
|
ts, err = types.NewTipSet(headers)
|
||||||
} else {
|
} else {
|
||||||
r, err := api.StateWaitMsg(ctx, mcid)
|
r, err := api.StateWaitMsg(ctx, mcid, build.MessageConfidence)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("finding message in chain: %w", err)
|
return xerrors.Errorf("finding message in chain: %w", err)
|
||||||
}
|
}
|
||||||
@@ -1041,7 +1042,7 @@ func computeStateHtml(ts *types.TipSet, o *api.ComputeStateOutput, getCode func(
|
|||||||
|
|
||||||
if len(ir.InternalExecutions) > 0 {
|
if len(ir.InternalExecutions) > 0 {
|
||||||
fmt.Println("<div>Internal executions:</div>")
|
fmt.Println("<div>Internal executions:</div>")
|
||||||
if err := printInternalExecutionsHtml(ir.InternalExecutions, getCode); err != nil {
|
if err := printInternalExecutionsHtml(cid.String(), ir.InternalExecutions, getCode); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1053,8 +1054,10 @@ func computeStateHtml(ts *types.TipSet, o *api.ComputeStateOutput, getCode func(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func printInternalExecutionsHtml(trace []*types.ExecutionResult, getCode func(addr address.Address) (cid.Cid, error)) error {
|
func printInternalExecutionsHtml(hashName string, trace []*types.ExecutionResult, getCode func(addr address.Address) (cid.Cid, error)) error {
|
||||||
for _, im := range trace {
|
for i, im := range trace {
|
||||||
|
hashName := fmt.Sprintf("%s-r%d", hashName, i)
|
||||||
|
|
||||||
toCode, err := getCode(im.Msg.To)
|
toCode, err := getCode(im.Msg.To)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("getting code for %s: %w", toCode, err)
|
return xerrors.Errorf("getting code for %s: %w", toCode, err)
|
||||||
@@ -1085,18 +1088,18 @@ func printInternalExecutionsHtml(trace []*types.ExecutionResult, getCode func(ad
|
|||||||
slow := im.Duration > 10*time.Millisecond
|
slow := im.Duration > 10*time.Millisecond
|
||||||
veryslow := im.Duration > 50*time.Millisecond
|
veryslow := im.Duration > 50*time.Millisecond
|
||||||
|
|
||||||
fmt.Printf(`<div class="exec">
|
fmt.Printf(`<div class="exec" id="%s">
|
||||||
<div><h4 class="call">%s:%s</h4></div>
|
<div><a href="#%s"><h4 class="call">%s:%s</h4></a></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="slow-%t-%t">Took %s</span>, <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)
|
`, hashName, hashName, 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)
|
||||||
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)
|
||||||
}
|
}
|
||||||
if len(im.Subcalls) > 0 {
|
if len(im.Subcalls) > 0 {
|
||||||
fmt.Println("<div>Subcalls:</div>")
|
fmt.Println("<div>Subcalls:</div>")
|
||||||
if err := printInternalExecutionsHtml(im.Subcalls, getCode); err != nil {
|
if err := printInternalExecutionsHtml(hashName, im.Subcalls, getCode); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1156,7 +1159,7 @@ var stateWaitMsgCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
mw, err := api.StateWaitMsg(ctx, msg)
|
mw, err := api.StateWaitMsg(ctx, msg, build.MessageConfidence)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
cid "github.com/ipfs/go-cid"
|
cid "github.com/ipfs/go-cid"
|
||||||
"gopkg.in/urfave/cli.v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
|
|||||||
+4
-2
@@ -3,7 +3,7 @@ package cli
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"gopkg.in/urfave/cli.v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var versionCmd = &cli.Command{
|
var versionCmd = &cli.Command{
|
||||||
@@ -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
|
||||||
},
|
},
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gopkg.in/urfave/cli.v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var waitApiCmd = &cli.Command{
|
var waitApiCmd = &cli.Command{
|
||||||
|
|||||||
+27
-1
@@ -15,7 +15,7 @@ import (
|
|||||||
"github.com/filecoin-project/specs-actors/actors/crypto"
|
"github.com/filecoin-project/specs-actors/actors/crypto"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"gopkg.in/urfave/cli.v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var walletCmd = &cli.Command{
|
var walletCmd = &cli.Command{
|
||||||
@@ -31,6 +31,7 @@ var walletCmd = &cli.Command{
|
|||||||
walletSetDefault,
|
walletSetDefault,
|
||||||
walletSign,
|
walletSign,
|
||||||
walletVerify,
|
walletVerify,
|
||||||
|
walletDelete,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,3 +376,28 @@ var walletVerify = &cli.Command{
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var walletDelete = &cli.Command{
|
||||||
|
Name: "delete",
|
||||||
|
Usage: "Delete an account from the wallet",
|
||||||
|
ArgsUsage: "<address> ",
|
||||||
|
Action: func(cctx *cli.Context) error {
|
||||||
|
api, closer, err := GetFullNodeAPI(cctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer closer()
|
||||||
|
ctx := ReqContext(cctx)
|
||||||
|
|
||||||
|
if !cctx.Args().Present() || cctx.NArg() != 1 {
|
||||||
|
return fmt.Errorf("must specify address to delete")
|
||||||
|
}
|
||||||
|
|
||||||
|
addr, err := address.NewFromString(cctx.Args().First())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return api.WalletDelete(ctx, addr)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import (
|
|||||||
"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"
|
||||||
|
|
||||||
"gopkg.in/urfave/cli.v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -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
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import (
|
|||||||
"github.com/ipfs/go-datastore"
|
"github.com/ipfs/go-datastore"
|
||||||
badger "github.com/ipfs/go-ds-badger2"
|
badger "github.com/ipfs/go-ds-badger2"
|
||||||
blockstore "github.com/ipfs/go-ipfs-blockstore"
|
blockstore "github.com/ipfs/go-ipfs-blockstore"
|
||||||
"gopkg.in/urfave/cli.v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TipSetExec struct {
|
type TipSetExec struct {
|
||||||
@@ -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
|
||||||
|
|||||||
+18
-13
@@ -15,11 +15,12 @@ import (
|
|||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
"github.com/minio/blake2b-simd"
|
"github.com/minio/blake2b-simd"
|
||||||
"github.com/mitchellh/go-homedir"
|
"github.com/mitchellh/go-homedir"
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
"gopkg.in/urfave/cli.v2"
|
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
paramfetch "github.com/filecoin-project/go-paramfetch"
|
paramfetch "github.com/filecoin-project/go-paramfetch"
|
||||||
|
lcli "github.com/filecoin-project/lotus/cli"
|
||||||
"github.com/filecoin-project/sector-storage/ffiwrapper"
|
"github.com/filecoin-project/sector-storage/ffiwrapper"
|
||||||
"github.com/filecoin-project/sector-storage/ffiwrapper/basicfs"
|
"github.com/filecoin-project/sector-storage/ffiwrapper/basicfs"
|
||||||
"github.com/filecoin-project/sector-storage/stores"
|
"github.com/filecoin-project/sector-storage/stores"
|
||||||
@@ -78,7 +79,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 +142,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 +158,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 +216,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(lcli.ReqContext(c), build.ParametersJSON(), uint64(sectorSize)); err != nil {
|
||||||
return xerrors.Errorf("getting params: %w", err)
|
return xerrors.Errorf("getting params: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -562,15 +569,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 +601,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 +621,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(lcli.ReqContext(c), build.ParametersJSON(), c2in.SectorSize); err != nil {
|
||||||
return xerrors.Errorf("getting params: %w", err)
|
return xerrors.Errorf("getting params: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ func subBlocks(ctx context.Context, api aapi.FullNode, st *storage) {
|
|||||||
bh.Cid(): bh,
|
bh.Cid(): bh,
|
||||||
}, false)
|
}, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//log.Errorf("%+v", err)
|
log.Errorf("%+v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
"gopkg.in/urfave/cli.v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var dotCmd = &cli.Command{
|
var dotCmd = &cli.Command{
|
||||||
@@ -20,7 +20,13 @@ var dotCmd = &cli.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
minH, err := strconv.ParseInt(cctx.Args().Get(0), 10, 32)
|
minH, err := strconv.ParseInt(cctx.Args().Get(0), 10, 32)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
tosee, err := strconv.ParseInt(cctx.Args().Get(1), 10, 32)
|
tosee, err := strconv.ParseInt(cctx.Args().Get(1), 10, 32)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
maxH := minH + tosee
|
maxH := minH + tosee
|
||||||
|
|
||||||
res, err := st.db.Query(`select block, parent, b.miner, b.height, p.height from block_parents
|
res, err := st.db.Query(`select block, parent, b.miner, b.height, p.height from block_parents
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
"gopkg.in/urfave/cli.v2"
|
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
lcli "github.com/filecoin-project/lotus/cli"
|
lcli "github.com/filecoin-project/lotus/cli"
|
||||||
@@ -17,7 +17,7 @@ import (
|
|||||||
var log = logging.Logger("chainwatch")
|
var log = logging.Logger("chainwatch")
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
logging.SetLogLevel("*", "INFO")
|
_ = logging.SetLogLevel("*", "INFO")
|
||||||
|
|
||||||
log.Info("Starting chainwatch")
|
log.Info("Starting chainwatch")
|
||||||
|
|
||||||
@@ -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,21 +139,21 @@ 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))
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(bh.Parents) == 0 { // genesis case
|
if len(bh.Parents) == 0 { // genesis case
|
||||||
ts, err := types.NewTipSet([]*types.BlockHeader{bh})
|
ts, _ := types.NewTipSet([]*types.BlockHeader{bh})
|
||||||
aadrs, err := api.StateListActors(ctx, ts.Key())
|
aadrs, err := api.StateListActors(ctx, ts.Key())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
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)
|
||||||
|
|||||||
+11
-11
@@ -14,8 +14,8 @@ import (
|
|||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
"gopkg.in/urfave/cli.v2"
|
|
||||||
|
|
||||||
"github.com/filecoin-project/sector-storage/ffiwrapper"
|
"github.com/filecoin-project/sector-storage/ffiwrapper"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
@@ -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,25 +204,25 @@ 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) {
|
||||||
owner, err := address.NewFromString(r.FormValue("address"))
|
owner, 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
|
||||||
}
|
}
|
||||||
|
|
||||||
if owner.Protocol() != address.BLS {
|
if owner.Protocol() != address.BLS {
|
||||||
w.WriteHeader(400)
|
w.WriteHeader(400)
|
||||||
w.Write([]byte("Miner address must use BLS. A BLS address starts with the prefix 't3'."))
|
_, _ = w.Write([]byte("Miner address must use BLS. A BLS address starts with the prefix 't3'."))
|
||||||
w.Write([]byte("Please create a BLS address by running \"lotus wallet new bls\" while connected to a Lotus node."))
|
_, _ = w.Write([]byte("Please create a BLS address by running \"lotus wallet new bls\" while connected to a Lotus node."))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,7 +294,7 @@ func (h *handler) mkminer(w http.ResponseWriter, r *http.Request) {
|
|||||||
Owner: owner,
|
Owner: owner,
|
||||||
Worker: owner,
|
Worker: owner,
|
||||||
SealProofType: spt,
|
SealProofType: spt,
|
||||||
Peer: h.defaultMinerPeer,
|
Peer: abi.PeerID(h.defaultMinerPeer),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(400)
|
w.WriteHeader(400)
|
||||||
@@ -334,7 +334,7 @@ func (h *handler) msgwait(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
mw, err := h.api.StateWaitMsg(r.Context(), c)
|
mw, err := h.api.StateWaitMsg(r.Context(), c, build.MessageConfidence)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(400)
|
w.WriteHeader(400)
|
||||||
w.Write([]byte(err.Error()))
|
w.Write([]byte(err.Error()))
|
||||||
@@ -357,7 +357,7 @@ func (h *handler) msgwaitaddr(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
mw, err := h.api.StateWaitMsg(r.Context(), c)
|
mw, err := h.api.StateWaitMsg(r.Context(), c, build.MessageConfidence)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(400)
|
w.WriteHeader(400)
|
||||||
w.Write([]byte(err.Error()))
|
w.Write([]byte(err.Error()))
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
|
|
||||||
cid "github.com/ipfs/go-cid"
|
cid "github.com/ipfs/go-cid"
|
||||||
logging "github.com/ipfs/go-log"
|
logging "github.com/ipfs/go-log"
|
||||||
"gopkg.in/urfave/cli.v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-jsonrpc"
|
"github.com/filecoin-project/go-jsonrpc"
|
||||||
|
|
||||||
@@ -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 {
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ import (
|
|||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
"gopkg.in/urfave/cli.v2"
|
|
||||||
|
|
||||||
"github.com/filecoin-project/go-jsonrpc"
|
"github.com/filecoin-project/go-jsonrpc"
|
||||||
"github.com/filecoin-project/go-jsonrpc/auth"
|
"github.com/filecoin-project/go-jsonrpc/auth"
|
||||||
@@ -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,14 +148,14 @@ 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(ctx, build.ParametersJSON(), uint64(ssize)); err != nil {
|
||||||
return xerrors.Errorf("get params: %w", err)
|
return xerrors.Errorf("get params: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var taskTypes []sealtasks.TaskType
|
var taskTypes []sealtasks.TaskType
|
||||||
|
|
||||||
taskTypes = append(taskTypes, sealtasks.TTFetch)
|
taskTypes = append(taskTypes, sealtasks.TTFetch, sealtasks.TTCommit1, sealtasks.TTFinalize)
|
||||||
|
|
||||||
if cctx.Bool("precommit1") {
|
if cctx.Bool("precommit1") {
|
||||||
taskTypes = append(taskTypes, sealtasks.TTPreCommit1)
|
taskTypes = append(taskTypes, sealtasks.TTPreCommit1)
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import (
|
|||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/mitchellh/go-homedir"
|
"github.com/mitchellh/go-homedir"
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
"gopkg.in/urfave/cli.v2"
|
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
|
|
||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
"github.com/mitchellh/go-homedir"
|
"github.com/mitchellh/go-homedir"
|
||||||
"gopkg.in/urfave/cli.v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
|
||||||
"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"
|
||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"gopkg.in/urfave/cli.v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var base16Cmd = &cli.Command{
|
var base16Cmd = &cli.Command{
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"gopkg.in/urfave/cli.v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
|
||||||
"github.com/multiformats/go-base32"
|
"github.com/multiformats/go-base32"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"gopkg.in/urfave/cli.v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var bigIntParseCmd = &cli.Command{
|
var bigIntParseCmd = &cli.Command{
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
"gopkg.in/urfave/cli.v2"
|
|
||||||
|
|
||||||
"github.com/filecoin-project/go-bitfield"
|
"github.com/filecoin-project/go-bitfield"
|
||||||
rlepluslazy "github.com/filecoin-project/go-bitfield/rle"
|
rlepluslazy "github.com/filecoin-project/go-bitfield/rle"
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
commcid "github.com/filecoin-project/go-fil-commcid"
|
commcid "github.com/filecoin-project/go-fil-commcid"
|
||||||
"gopkg.in/urfave/cli.v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var commpToCidCmd = &cli.Command{
|
var commpToCidCmd = &cli.Command{
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import (
|
|||||||
|
|
||||||
blockstore "github.com/ipfs/go-ipfs-blockstore"
|
blockstore "github.com/ipfs/go-ipfs-blockstore"
|
||||||
"github.com/ipld/go-car"
|
"github.com/ipld/go-car"
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
"gopkg.in/urfave/cli.v2"
|
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/node/repo"
|
"github.com/filecoin-project/lotus/node/repo"
|
||||||
)
|
)
|
||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"gopkg.in/urfave/cli.v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
|
||||||
_ "github.com/filecoin-project/lotus/lib/sigs/bls"
|
_ "github.com/filecoin-project/lotus/lib/sigs/bls"
|
||||||
_ "github.com/filecoin-project/lotus/lib/sigs/secp"
|
_ "github.com/filecoin-project/lotus/lib/sigs/secp"
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user