Compare commits

..
Author SHA1 Message Date
Travis Person 06670f4cae New interop network info 2020-06-02 00:29:49 +00:00
137 changed files with 542 additions and 1549 deletions
+27 -4
View File
@@ -1,6 +1,6 @@
version: 2.1 version: 2.1
orbs: orbs:
go: gotest/tools@0.0.13 go: gotest/tools@0.0.9
executors: executors:
golang: golang:
@@ -79,6 +79,7 @@ jobs:
steps: steps:
- install-deps - install-deps
- prepare - prepare
- go/mod-download
- go/mod-tidy-check - go/mod-tidy-check
build-all: build-all:
@@ -86,8 +87,12 @@ 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:
@@ -107,6 +112,10 @@ 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
@@ -150,6 +159,10 @@ 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
@@ -180,6 +193,13 @@ 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
@@ -214,9 +234,10 @@ 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 cargo cache name: restore go mod and 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
@@ -243,6 +264,7 @@ 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"
@@ -255,7 +277,7 @@ jobs:
default: golang default: golang
golangci-lint-version: golangci-lint-version:
type: string type: string
default: 1.27.0 default: 1.23.8
concurrency: concurrency:
type: string type: string
default: '2' default: '2'
@@ -271,6 +293,7 @@ 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
@@ -280,7 +303,7 @@ jobs:
- run: - run:
name: Lint name: Lint
command: | command: |
$HOME/.local/bin/golangci-lint run -v --timeout 2m \ $HOME/.local/bin/golangci-lint run -v \
--concurrency << parameters.concurrency >> << parameters.args >> --concurrency << parameters.concurrency >> << parameters.args >>
lint-changes: lint-changes:
<<: *lint <<: *lint
-4
View File
@@ -37,10 +37,6 @@ issues:
- path: build/params_.*\.go - path: build/params_.*\.go
linters: linters:
- golint - golint
- path: api/apistruct/struct.go
linters:
- golint
- path: .*_test.go - path: .*_test.go
linters: linters:
-4
View File
@@ -25,7 +25,6 @@ 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)
@@ -35,9 +34,6 @@ type Common interface {
LogList(context.Context) ([]string, error) LogList(context.Context) ([]string, error)
LogSetLevel(context.Context, string, string) error LogSetLevel(context.Context, string, string) error
// trigger graceful shutdown
Shutdown(context.Context) error
} }
// Version provides various build-time information // Version provides various build-time information
+1 -2
View File
@@ -101,7 +101,6 @@ 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
@@ -157,7 +156,7 @@ type FullNode interface {
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) 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(ctx context.Context, cid cid.Cid, confidence uint64) (*MsgLookup, error) StateWaitMsg(context.Context, cid.Cid) (*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 -3
View File
@@ -25,12 +25,10 @@ type WorkerAPI interface {
storage.Sealer storage.Sealer
MoveStorage(ctx context.Context, sector abi.SectorID) error
UnsealPiece(context.Context, abi.SectorID, storiface.UnpaddedByteIndex, abi.UnpaddedPieceSize, abi.SealRandomness, cid.Cid) 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 ReadPiece(context.Context, io.Writer, abi.SectorID, storiface.UnpaddedByteIndex, abi.UnpaddedPieceSize) error
Fetch(context.Context, abi.SectorID, stores.SectorFileType, stores.PathType, stores.AcquireMode) error Fetch(context.Context, abi.SectorID, stores.SectorFileType, bool, stores.AcquireMode) error
Closing(context.Context) (<-chan struct{}, error) Closing(context.Context) (<-chan struct{}, error)
} }
+6 -31
View File
@@ -42,15 +42,12 @@ 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"`
LogList func(context.Context) ([]string, error) `perm:"write"` LogList func(context.Context) ([]string, error) `perm:"write"`
LogSetLevel func(context.Context, string, string) error `perm:"write"` LogSetLevel func(context.Context, string, string) error `perm:"write"`
Shutdown func(context.Context) error `perm:"admin"`
} }
} }
@@ -106,7 +103,6 @@ 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"`
@@ -139,7 +135,7 @@ type FullNodeStruct struct {
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(ctx context.Context, cid cid.Cid, confidence uint64) (*api.MsgLookup, error) `perm:"read"` StateWaitMsg func(context.Context, cid.Cid) (*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"`
@@ -217,7 +213,6 @@ type StorageMinerStruct struct {
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 stores.PathType) ([]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"`
@@ -241,12 +236,11 @@ 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"`
UnsealPiece func(context.Context, abi.SectorID, storiface.UnpaddedByteIndex, abi.UnpaddedPieceSize, abi.SealRandomness, cid.Cid) 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"` 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"` Fetch func(context.Context, abi.SectorID, stores.SectorFileType, bool, stores.AcquireMode) error `perm:"admin"`
Closing func(context.Context) (<-chan struct{}, error) `perm:"admin"` Closing func(context.Context) (<-chan struct{}, error) `perm:"admin"`
} }
@@ -262,9 +256,6 @@ 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)
} }
@@ -307,10 +298,6 @@ func (c *CommonStruct) LogSetLevel(ctx context.Context, group, level string) err
return c.Internal.LogSetLevel(ctx, group, level) return c.Internal.LogSetLevel(ctx, group, level)
} }
func (c *CommonStruct) Shutdown(ctx context.Context) error {
return c.Internal.Shutdown(ctx)
}
// FullNodeStruct // FullNodeStruct
func (c *FullNodeStruct) ClientListImports(ctx context.Context) ([]api.Import, error) { func (c *FullNodeStruct) ClientListImports(ctx context.Context) ([]api.Import, error) {
@@ -439,10 +426,6 @@ 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)
} }
@@ -607,8 +590,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, confidence uint64) (*api.MsgLookup, error) { func (c *FullNodeStruct) StateWaitMsg(ctx context.Context, msgc cid.Cid) (*api.MsgLookup, error) {
return c.Internal.StateWaitMsg(ctx, msgc, confidence) return c.Internal.StateWaitMsg(ctx, msgc)
} }
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) {
@@ -819,10 +802,6 @@ func (c *StorageMinerStruct) StorageReportHealth(ctx context.Context, id stores.
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)
} }
@@ -889,10 +868,6 @@ 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) MoveStorage(ctx context.Context, sector abi.SectorID) error {
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 { 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) return w.Internal.UnsealPiece(ctx, id, index, size, randomness, c)
} }
@@ -901,8 +876,8 @@ func (w *WorkerStruct) ReadPiece(ctx context.Context, writer io.Writer, id abi.S
return w.Internal.ReadPiece(ctx, writer, id, index, size) 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 { func (w *WorkerStruct) Fetch(ctx context.Context, id abi.SectorID, fileType stores.SectorFileType, b bool, am stores.AcquireMode) error {
return w.Internal.Fetch(ctx, id, fileType, ptype, am) return w.Internal.Fetch(ctx, id, fileType, b, am)
} }
func (w *WorkerStruct) Closing(ctx context.Context) (<-chan struct{}, error) { func (w *WorkerStruct) Closing(ctx context.Context) (<-chan struct{}, error) {
+2 -1
View File
@@ -193,7 +193,8 @@ 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) { //nolint:golint func parseApiASTInfo() (map[string]string, map[string]string) {
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 {
+2 -2
View File
@@ -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)
+1 -1
View File
@@ -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
View File
@@ -3,7 +3,6 @@ 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"
) )
@@ -34,8 +33,3 @@ type ObjStat struct {
Size uint64 Size uint64
Links uint64 Links uint64
} }
type PubsubScore struct {
ID peer.ID
Score float64
}
-9
View File
@@ -34,12 +34,3 @@ 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)
}
+6 -6
View File
@@ -1,6 +1,6 @@
/dns4/t01000.miner.interopnet.kittyhawk.wtf/tcp/1347/p2p/12D3KooWLVgeFhXA7ztuSS1uvk4NVzZwRZLxg8PBy1mJuHfc8J6E /dns4/t01000.miner.interopnet.kittyhawk.wtf/tcp/1347/p2p/12D3KooWNMVRk3KkMANV67A4zPxB83FtvLouwsYGitEofY1ympJs
/ip4/34.217.110.132/tcp/1347/p2p/12D3KooWLVgeFhXA7ztuSS1uvk4NVzZwRZLxg8PBy1mJuHfc8J6E /ip4/34.217.110.132/tcp/1347/p2p/12D3KooWNMVRk3KkMANV67A4zPxB83FtvLouwsYGitEofY1ympJs
/dns4/peer0.interopnet.kittyhawk.wtf/tcp/1347/p2p/12D3KooWBkXWpT1hLHXz7VzR8ZHCJ42P6c9Nb9532ATSguBpLTKJ /dns4/peer0.interopnet.kittyhawk.wtf/tcp/1347/p2p/12D3KooWM1ufVLkBAyyf8Jn5DMdmW5gA7upSvCUatoneHp6yUEtd
/ip4/54.187.182.170/tcp/1347/p2p/12D3KooWBkXWpT1hLHXz7VzR8ZHCJ42P6c9Nb9532ATSguBpLTKJ /ip4/54.187.182.170/tcp/1347/p2p/12D3KooWM1ufVLkBAyyf8Jn5DMdmW5gA7upSvCUatoneHp6yUEtd
/dns4/peer1.interopnet.kittyhawk.wtf/tcp/1347/p2p/12D3KooWJk5hQHNdCsidtX4jhKQMBXKJdo2kjhrNHUZBPmCZKwKt /dns4/peer1.interopnet.kittyhawk.wtf/tcp/1347/p2p/12D3KooWLxMPSbs7XEPhyUiSo6RpTTRAkRiD1bp6uKYxyZx4QSZR
/ip4/52.24.84.39/tcp/1347/p2p/12D3KooWJk5hQHNdCsidtX4jhKQMBXKJdo2kjhrNHUZBPmCZKwKt /ip4/52.24.84.39/tcp/1347/p2p/12D3KooWLxMPSbs7XEPhyUiSo6RpTTRAkRiD1bp6uKYxyZx4QSZR
Binary file not shown.
-1
View File
@@ -59,7 +59,6 @@ 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
+1 -1
View File
@@ -55,7 +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 //nolint:varcheck
const ( const (
majorMask = 0xff0000 majorMask = 0xff0000
minorMask = 0xffff00 minorMask = 0xffff00
+9 -13
View File
@@ -561,30 +561,26 @@ func (bpt *bsPeerTracker) logSuccess(p peer.ID, dur time.Duration) {
bpt.lk.Lock() bpt.lk.Lock()
defer bpt.lk.Unlock() defer bpt.lk.Unlock()
var pi *peerStats if pi, ok := bpt.peers[p]; !ok {
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++
pi.successes++ logTime(pi, dur)
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) {
+7 -7
View File
@@ -19,7 +19,7 @@ import (
var log = logging.Logger("events") var log = logging.Logger("events")
// HeightHandler `curH`-`ts.Height` = `confidence` // `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)
@@ -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{},
}, },
} }
+13 -14
View File
@@ -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,7 +23,6 @@ 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)
@@ -49,7 +48,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
@@ -58,7 +57,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
@@ -67,10 +66,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]
@@ -79,8 +78,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 {
@@ -158,8 +157,8 @@ func (e *calledEvents) checkNewCalls(ts *types.TipSet) {
}) })
} }
func (e *calledEvents) queueForConfidence(trigID uint64, msg *types.Message, ts *types.TipSet) { func (e *calledEvents) queueForConfidence(triggerId uint64, msg *types.Message, ts *types.TipSet) {
trigger := e.triggers[trigID] trigger := e.triggers[triggerId]
appliedH := ts.Height() appliedH := ts.Height()
@@ -172,7 +171,7 @@ func (e *calledEvents) queueForConfidence(trigID uint64, msg *types.Message, ts
} }
byOrigH[appliedH] = append(byOrigH[appliedH], &queuedEvent{ byOrigH[appliedH] = append(byOrigH[appliedH], &queuedEvent{
trigger: trigID, trigger: triggerId,
h: appliedH, h: appliedH,
msg: msg, msg: msg,
}) })
@@ -232,11 +231,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
} }
+4 -4
View File
@@ -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
} }
+3 -2
View File
@@ -211,14 +211,15 @@ 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() //nolint:staticcheck fcs.sync.Unlock()
} }
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{
+1 -1
View File
@@ -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 %d", inmsg.Cid(), inmsg.From, inmsg.Nonce, msg.Nonce) 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 inmsg.Equals(msg), nil return inmsg.Equals(msg), nil
+8 -1
View File
@@ -431,7 +431,7 @@ func (cg *ChainGen) makeBlock(parents *types.TipSet, m address.Address, vrfticke
return fblk, err return fblk, err
} }
// ResyncBankerNonce is used for dealing with messages made when // This function is awkward. It's used to deal 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)
@@ -538,6 +538,13 @@ 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) {
+1 -1
View File
@@ -71,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: []byte(m.PeerId), Peer: m.PeerId,
SealProofType: spt, SealProofType: spt,
} }
+17 -17
View File
@@ -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 {
+2 -2
View File
@@ -21,7 +21,7 @@ import (
var log = logging.Logger("statetree") var log = logging.Logger("statetree")
// StateTree stores actors state by their ID. // 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
+11 -42
View File
@@ -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, blks[0].Height, r, cb) return sm.ApplyBlocks(ctx, pstate, blkmsgs, abi.ChainEpoch(blks[0].Height), r, cb)
} }
func (sm *StateManager) parentState(ts *types.TipSet) cid.Cid { func (sm *StateManager) parentState(ts *types.TipSet) cid.Cid {
@@ -405,8 +405,8 @@ func (sm *StateManager) LoadActorStateRaw(ctx context.Context, a address.Address
return act, nil return act, nil
} }
// ResolveToKeyAddress is similar to `vm.ResolveToKeyAddr` but does not allow `Actor` type of addresses. // Similar to `vm.ResolveToKeyAddr` but does not allow `Actor` type of addresses. Uses the `TipSet` `ts`
// Uses the `TipSet` `ts` to generate the VM state. // 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,10 +480,7 @@ func (sm *StateManager) GetReceipt(ctx context.Context, msg cid.Cid, ts *types.T
return r, nil return r, nil
} }
// WaitForMessage blocks until a message appears on chain. It looks backwards in the chain to see if this has already func (sm *StateManager) WaitForMessage(ctx context.Context, mcid cid.Cid) (*types.TipSet, *types.MessageReceipt, error) {
// 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()
@@ -531,11 +528,6 @@ func (sm *StateManager) WaitForMessage(ctx context.Context, mcid cid.Cid, confid
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:
@@ -545,44 +537,21 @@ func (sm *StateManager) WaitForMessage(ctx context.Context, mcid cid.Cid, confid
for _, val := range notif { for _, val := range notif {
switch val.Type { switch val.Type {
case store.HCRevert: case store.HCRevert:
if val.Val.Equals(candidateTs) { continue
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 {
if confidence == 0 { return val.Val, r, nil
return val.Val, r, err
}
candidateTs = val.Val
candidateRcp = r
} }
heightOfHead = val.Val.Height()
} }
} }
case <-backSearchWait: case <-backSearchWait:
// check if we found the message in the chain and that is hasn't been reverted since we started searching if backTs != nil {
if backTs != nil && !reverts[backTs.Key()] { return backTs, backRcp, nil
// 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()
@@ -641,9 +610,9 @@ func (sm *StateManager) searchBackForMsg(ctx context.Context, from *types.TipSet
return nil, nil, err return nil, nil, err
} }
// we either have no messages from the sender, or the latest message we found has a lower nonce than the one being searched for, if act.Nonce < m.VMMessage().Nonce {
// either way, no reason to lookback, it ain't there // nonce on chain is before message nonce we're looking for, its
if act.Nonce == 0 || act.Nonce < m.VMMessage().Nonce { // not going to be here
return nil, nil, nil return nil, nil, nil
} }
+3 -3
View File
@@ -286,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
@@ -298,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
} }
@@ -307,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
} }
-161
View File
@@ -1,161 +0,0 @@
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
}
rheight -= ci.skipLength
var skipTarget *types.TipSet
if parent.Height() < rheight {
skipTarget = parent
} else {
skipTarget, err = ci.walkBack(parent, rheight)
if err != nil {
return nil, xerrors.Errorf("fillCache walkback: %w", err)
}
}
lbe := &lbEntry{
ts: ts,
parentHeight: parent.Height(),
targetHeight: skipTarget.Height(),
target: skipTarget.Key(),
}
ci.skipCache.Add(tsk, lbe)
return lbe, nil
}
// floors to nearest skipLength multiple
func (ci *ChainIndex) roundHeight(h abi.ChainEpoch) abi.ChainEpoch {
return (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() {
// in case pts is lower than the epoch we're looking for (null blocks)
// return a tipset above that height
return ts, nil
}
if to == pts.Height() {
return pts, nil
}
ts = pts
}
}
-80
View File
@@ -1,80 +0,0 @@
package store_test
import (
"bytes"
"context"
"testing"
"github.com/filecoin-project/lotus/chain/gen"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types/mock"
"github.com/filecoin-project/specs-actors/actors/abi"
datastore "github.com/ipfs/go-datastore"
syncds "github.com/ipfs/go-datastore/sync"
blockstore "github.com/ipfs/go-ipfs-blockstore"
"github.com/stretchr/testify/assert"
)
func TestIndexSeeks(t *testing.T) {
cg, err := gen.NewGenerator()
if err != nil {
t.Fatal(err)
}
gencar, err := cg.GenesisCar()
if err != nil {
t.Fatal(err)
}
gen := cg.Genesis()
ctx := context.TODO()
nbs := blockstore.NewBlockstore(syncds.MutexWrap(datastore.NewMapDatastore()))
cs := store.NewChainStore(nbs, syncds.MutexWrap(datastore.NewMapDatastore()), nil)
_, err = cs.Import(bytes.NewReader(gencar))
if err != nil {
t.Fatal(err)
}
cur := mock.TipSet(gen)
if err := cs.PutTipSet(ctx, mock.TipSet(gen)); err != nil {
t.Fatal(err)
}
cs.SetGenesis(gen)
// Put 113 blocks from genesis
for i := 0; i < 113; i++ {
nextts := mock.TipSet(mock.MkBlock(cur, 1, 1))
if err := cs.PutTipSet(ctx, nextts); err != nil {
t.Fatal(err)
}
cur = nextts
}
// Put 50 null epochs + 1 block
skip := mock.MkBlock(cur, 1, 1)
skip.Height += 50
skipts := mock.TipSet(skip)
if err := cs.PutTipSet(ctx, skipts); err != nil {
t.Fatal(err)
}
ts, err := cs.GetTipsetByHeight(ctx, skip.Height-10, skipts, false)
if err != nil {
t.Fatal(err)
}
assert.Equal(t, abi.ChainEpoch(164), ts.Height())
for i := 0; i <= 113; i++ {
ts3, err := cs.GetTipsetByHeight(ctx, abi.ChainEpoch(i), skipts, false)
if err != nil {
t.Fatal(err)
}
assert.Equal(t, abi.ChainEpoch(i), ts3.Height())
}
}
+36 -46
View File
@@ -62,8 +62,6 @@ 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
@@ -86,10 +84,6 @@ 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 {
@@ -393,7 +387,7 @@ func (cs *ChainStore) LoadTipSet(tsk types.TipSetKey) (*types.TipSet, error) {
return ts, nil return ts, nil
} }
// IsAncestorOf returns true if 'a' is an ancestor of 'b' // 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
@@ -916,35 +910,30 @@ func DrawRandomness(rbase []byte, pers crypto.DomainSeparationTag, round abi.Cha
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) ([]byte, error) { func (cs *ChainStore) GetRandomness(ctx context.Context, blks []cid.Cid, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) (out []byte, err 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)))
ts, err := cs.LoadTipSet(types.NewTipSetKey(blks...)) //defer func() {
if err != nil { //log.Infof("getRand %v %d %d %x -> %x", blks, pers, round, entropy, out)
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
@@ -957,7 +946,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 greater than start point") return nil, xerrors.Errorf("looking for tipset with height less than start point")
} }
if h == ts.Height() { if h == ts.Height() {
@@ -968,24 +957,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)
} }
lbts, err := cs.cindex.GetTipsetByHeight(ctx, ts, h) for {
if err != nil { pts, err := cs.LoadTipSet(ts.Parents())
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 lbts.Height() == h || !prev { if h > pts.Height() {
return lbts, nil if prev {
} return pts, nil
}
return ts, nil
}
if h == pts.Height() {
return pts, nil
}
return cs.LoadTipSet(lbts.Parents()) ts = pts
}
} }
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) {
@@ -1165,6 +1154,7 @@ 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)
} }
+3 -2
View File
@@ -57,7 +57,8 @@ func HandleIncomingBlocks(ctx context.Context, bsub *pubsub.Subscription, s *cha
return return
} }
src := msg.GetFrom() //nolint:golint
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())
@@ -206,7 +207,7 @@ func (bv *BlockValidator) Validate(ctx context.Context, pid peer.ID, msg *pubsub
} }
} }
err = sigs.CheckBlockSignature(ctx, blk.Header, key) err = sigs.CheckBlockSignature(blk.Header, ctx, 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
View File
@@ -526,7 +526,7 @@ func blockSanityChecks(h *types.BlockHeader) error {
return nil return nil
} }
// ValidateBlock should match up with 'Semantical Validation' in validation.md in the spec // 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(ctx, h, waddr); err != nil { if err := sigs.CheckBlockSignature(h, ctx, 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
+4 -4
View File
@@ -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 (blk *BlockHeader) ToStorageBlock() (block.Block, error) { func (b *BlockHeader) ToStorageBlock() (block.Block, error) {
data, err := blk.Serialize() data, err := b.Serialize()
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -89,8 +89,8 @@ func (blk *BlockHeader) ToStorageBlock() (block.Block, error) {
return block.NewBlockWithCid(data, c) return block.NewBlockWithCid(data, c)
} }
func (blk *BlockHeader) Cid() cid.Cid { func (b *BlockHeader) Cid() cid.Cid {
sb, err := blk.ToStorageBlock() sb, err := b.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
} }
+3 -6
View File
@@ -1,12 +1,9 @@
package types package types
import "time"
type ExecutionResult struct { type ExecutionResult struct {
Msg *Message Msg *Message
MsgRct *MessageReceipt MsgRct *MessageReceipt
Error string Error string
Duration time.Duration
Subcalls []*ExecutionResult Subcalls []*ExecutionResult
} }
+10 -6
View File
@@ -41,16 +41,20 @@ type Message struct {
Params []byte Params []byte
} }
func (m *Message) Caller() address.Address { func (t *Message) BlockMiner() address.Address {
return m.From panic("implement me")
} }
func (m *Message) Receiver() address.Address { func (t *Message) Caller() address.Address {
return m.To return t.From
} }
func (m *Message) ValueReceived() abi.TokenAmount { func (t *Message) Receiver() address.Address {
return m.Value return t.To
}
func (t *Message) ValueReceived() abi.TokenAmount {
return t.Value
} }
func DecodeMessage(b []byte) (*Message, error) { func DecodeMessage(b []byte) (*Message, error) {
+1 -6
View File
@@ -49,11 +49,6 @@ func MkBlock(parents *types.TipSet, weightInc uint64, ticketNonce uint64) *types
panic(err) panic(err)
} }
pstateRoot := c
if parents != nil {
pstateRoot = parents.Blocks()[0].ParentStateRoot
}
var pcids []cid.Cid var pcids []cid.Cid
var height abi.ChainEpoch var height abi.ChainEpoch
weight := types.NewInt(weightInc) weight := types.NewInt(weightInc)
@@ -77,7 +72,7 @@ func MkBlock(parents *types.TipSet, weightInc uint64, ticketNonce uint64) *types
ParentWeight: weight, ParentWeight: weight,
Messages: c, Messages: c,
Height: height, Height: height,
ParentStateRoot: pstateRoot, ParentStateRoot: c,
BlockSig: &crypto.Signature{Type: crypto.SigTypeBLS, Data: []byte("boo! im a signature")}, BlockSig: &crypto.Signature{Type: crypto.SigTypeBLS, Data: []byte("boo! im a signature")},
} }
} }
+8 -8
View File
@@ -9,12 +9,12 @@ import (
"github.com/multiformats/go-multihash" "github.com/multiformats/go-multihash"
) )
func (sm *SignedMessage) ToStorageBlock() (block.Block, error) { func (m *SignedMessage) ToStorageBlock() (block.Block, error) {
if sm.Signature.Type == crypto.SigTypeBLS { if m.Signature.Type == crypto.SigTypeBLS {
return sm.Message.ToStorageBlock() return m.Message.ToStorageBlock()
} }
data, err := sm.Serialize() data, err := m.Serialize()
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -28,12 +28,12 @@ func (sm *SignedMessage) ToStorageBlock() (block.Block, error) {
return block.NewBlockWithCid(data, c) return block.NewBlockWithCid(data, c)
} }
func (sm *SignedMessage) Cid() cid.Cid { func (m *SignedMessage) Cid() cid.Cid {
if sm.Signature.Type == crypto.SigTypeBLS { if m.Signature.Type == crypto.SigTypeBLS {
return sm.Message.Cid() return m.Message.Cid()
} }
sb, err := sm.ToStorageBlock() sb, err := m.ToStorageBlock()
if err != nil { if err != nil {
panic(err) panic(err)
} }
+2 -2
View File
@@ -23,6 +23,8 @@ 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
@@ -30,8 +32,6 @@ 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,
+3 -3
View File
@@ -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))
+8 -6
View File
@@ -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,7 +89,9 @@ type Invokee interface {
Exports() []interface{} Exports() []interface{}
} }
func (*Invoker) transform(instance Invokee) (nativeCode, error) { var tAError = reflect.TypeOf((*aerrors.ActorError)(nil)).Elem()
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 {
+1 -1
View File
@@ -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)
+1 -2
View File
@@ -2,7 +2,6 @@ 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"
@@ -28,7 +27,7 @@ func init() {
var EmptyObjectCid cid.Cid var EmptyObjectCid cid.Cid
// TryCreateAccountActor creates account actors from only BLS/SECP256K1 addresses. // 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 {
+52 -55
View File
@@ -5,7 +5,6 @@ import (
"context" "context"
"encoding/binary" "encoding/binary"
"fmt" "fmt"
"time"
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
"github.com/filecoin-project/specs-actors/actors/abi" "github.com/filecoin-project/specs-actors/actors/abi"
@@ -107,8 +106,8 @@ type notFoundErr interface {
IsNotFound() bool IsNotFound() bool
} }
func (rt *Runtime) Get(c cid.Cid, o vmr.CBORUnmarshaler) bool { func (rs *Runtime) Get(c cid.Cid, o vmr.CBORUnmarshaler) bool {
if err := rt.cst.Get(context.TODO(), c, o); err != nil { if err := rs.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 +121,8 @@ func (rt *Runtime) Get(c cid.Cid, o vmr.CBORUnmarshaler) bool {
return true return true
} }
func (rt *Runtime) Put(x vmr.CBORMarshaler) cid.Cid { func (rs *Runtime) Put(x vmr.CBORMarshaler) cid.Cid {
c, err := rt.cst.Put(context.TODO(), x) c, err := rs.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 +134,7 @@ func (rt *Runtime) Put(x vmr.CBORMarshaler) cid.Cid {
var _ vmr.Runtime = (*Runtime)(nil) var _ vmr.Runtime = (*Runtime)(nil)
func (rt *Runtime) shimCall(f func() interface{}) (rval []byte, aerr aerrors.ActorError) { func (rs *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 +149,8 @@ func (rt *Runtime) shimCall(f func() interface{}) (rval []byte, aerr aerrors.Act
ret := f() ret := f()
if !rt.callerValidated { if !rs.callerValidated {
rt.Abortf(exitcode.SysErrorIllegalActor, "Caller MUST be validated during method execution") rs.Abortf(exitcode.SysErrorIllegalActor, "Caller MUST be validated during method execution")
} }
switch ret := ret.(type) { switch ret := ret.(type) {
@@ -172,25 +171,25 @@ func (rt *Runtime) shimCall(f func() interface{}) (rval []byte, aerr aerrors.Act
} }
} }
func (rt *Runtime) Message() vmr.Message { func (rs *Runtime) Message() vmr.Message {
return rt.vmsg return rs.vmsg
} }
func (rt *Runtime) ValidateImmediateCallerAcceptAny() { func (rs *Runtime) ValidateImmediateCallerAcceptAny() {
rt.abortIfAlreadyValidated() rs.abortIfAlreadyValidated()
return return
} }
func (rt *Runtime) CurrentBalance() abi.TokenAmount { func (rs *Runtime) CurrentBalance() abi.TokenAmount {
b, err := rt.GetBalance(rt.Message().Receiver()) b, err := rs.GetBalance(rs.Message().Receiver())
if err != nil { if err != nil {
rt.Abortf(err.RetCode(), "get current balance: %v", err) rs.Abortf(err.RetCode(), "get current balance: %v", err)
} }
return b return b
} }
func (rt *Runtime) GetActorCodeCID(addr address.Address) (ret cid.Cid, ok bool) { func (rs *Runtime) GetActorCodeCID(addr address.Address) (ret cid.Cid, ok bool) {
act, err := rt.state.GetActor(addr) act, err := rs.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 +209,8 @@ func (rt *Runtime) GetRandomness(personalization crypto.DomainSeparationTag, ran
return res return res
} }
func (rt *Runtime) Store() vmr.Store { func (rs *Runtime) Store() vmr.Store {
return rt return rs
} }
func (rt *Runtime) NewActorAddress() address.Address { func (rt *Runtime) NewActorAddress() address.Address {
@@ -236,12 +235,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 +252,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 +282,12 @@ func (rt *Runtime) DeleteActor(addr address.Address) {
} }
} }
func (rt *Runtime) Syscalls() vmr.Syscalls { func (rs *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 rt.sys return rs.sys
} }
func (rt *Runtime) StartSpan(name string) vmr.TraceSpan { func (rs *Runtime) StartSpan(name string) vmr.TraceSpan {
panic("implement me") panic("implement me")
} }
@@ -308,12 +307,12 @@ func (rt *Runtime) Context() context.Context {
return rt.ctx return rt.ctx
} }
func (rt *Runtime) Abortf(code exitcode.ExitCode, msg string, args ...interface{}) { func (rs *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 (rt *Runtime) AbortStateMsg(msg string) { func (rs *Runtime) AbortStateMsg(msg string) {
panic(aerrors.NewfSkip(3, 101, msg)) panic(aerrors.NewfSkip(3, 101, msg))
} }
@@ -331,8 +330,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 (rt *Runtime) CurrEpoch() abi.ChainEpoch { func (rs *Runtime) CurrEpoch() abi.ChainEpoch {
return rt.height return rs.height
} }
type dumbWrapperType struct { type dumbWrapperType struct {
@@ -343,20 +342,20 @@ func (dwt *dumbWrapperType) Into(um vmr.CBORUnmarshaler) error {
return um.UnmarshalCBOR(bytes.NewReader(dwt.val)) return um.UnmarshalCBOR(bytes.NewReader(dwt.val))
} }
func (rt *Runtime) Send(to address.Address, method abi.MethodNum, m vmr.CBORMarshaler, value abi.TokenAmount) (vmr.SendReturn, exitcode.ExitCode) { func (rs *Runtime) Send(to address.Address, method abi.MethodNum, m vmr.CBORMarshaler, value abi.TokenAmount) (vmr.SendReturn, exitcode.ExitCode) {
if !rt.allowInternal { if !rs.allowInternal {
rt.Abortf(exitcode.SysErrorIllegalActor, "runtime.Send() is currently disallowed") rs.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 {
rt.Abortf(exitcode.SysErrInvalidParameters, "failed to marshal input parameters: %s", err) rs.Abortf(exitcode.SysErrInvalidParameters, "failed to marshal input parameters: %s", err)
} }
params = buf.Bytes() params = buf.Bytes()
} }
ret, err := rt.internalSend(rt.Message().Receiver(), to, method, value, params) ret, err := rs.internalSend(rs.Message().Receiver(), to, method, value, params)
if err != nil { if err != nil {
if err.IsFatal() { if err.IsFatal() {
panic(err) panic(err)
@@ -368,7 +367,6 @@ func (rt *Runtime) Send(to address.Address, method abi.MethodNum, m vmr.CBORMars
} }
func (rt *Runtime) internalSend(from, to address.Address, method abi.MethodNum, value types.BigInt, params []byte) ([]byte, aerrors.ActorError) { func (rt *Runtime) internalSend(from, to address.Address, method abi.MethodNum, value types.BigInt, params []byte) ([]byte, aerrors.ActorError) {
start := time.Now()
ctx, span := trace.StartSpan(rt.ctx, "vmc.Send") ctx, span := trace.StartSpan(rt.ctx, "vmc.Send")
defer span.End() defer span.End()
if span.IsRecordingEvents() { if span.IsRecordingEvents() {
@@ -408,9 +406,8 @@ func (rt *Runtime) internalSend(from, to address.Address, method abi.MethodNum,
} }
er := types.ExecutionResult{ er := types.ExecutionResult{
Msg: msg, Msg: msg,
MsgRct: &mr, MsgRct: &mr,
Duration: time.Since(start),
} }
if errSend != nil { if errSend != nil {
@@ -425,48 +422,48 @@ func (rt *Runtime) internalSend(from, to address.Address, method abi.MethodNum,
return ret, errSend return ret, errSend
} }
func (rt *Runtime) State() vmr.StateHandle { func (rs *Runtime) State() vmr.StateHandle {
return &shimStateHandle{rt: rt} return &shimStateHandle{rs: rs}
} }
type shimStateHandle struct { type shimStateHandle struct {
rt *Runtime rs *Runtime
} }
func (ssh *shimStateHandle) Create(obj vmr.CBORMarshaler) { func (ssh *shimStateHandle) Create(obj vmr.CBORMarshaler) {
c := ssh.rt.Put(obj) c := ssh.rs.Put(obj)
// TODO: handle error below // TODO: handle error below
ssh.rt.stateCommit(EmptyObjectCid, c) ssh.rs.stateCommit(EmptyObjectCid, c)
} }
func (ssh *shimStateHandle) Readonly(obj vmr.CBORUnmarshaler) { func (ssh *shimStateHandle) Readonly(obj vmr.CBORUnmarshaler) {
act, err := ssh.rt.state.GetActor(ssh.rt.Message().Receiver()) act, err := ssh.rs.state.GetActor(ssh.rs.Message().Receiver())
if err != nil { if err != nil {
ssh.rt.Abortf(exitcode.SysErrorIllegalArgument, "failed to get actor for Readonly state: %s", err) ssh.rs.Abortf(exitcode.SysErrorIllegalArgument, "failed to get actor for Readonly state: %s", err)
} }
ssh.rt.Get(act.Head, obj) ssh.rs.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.rt.Abortf(exitcode.SysErrorIllegalActor, "Must not pass nil to Transaction()") ssh.rs.Abortf(exitcode.SysErrorIllegalActor, "Must not pass nil to Transaction()")
} }
act, err := ssh.rt.state.GetActor(ssh.rt.Message().Receiver()) act, err := ssh.rs.state.GetActor(ssh.rs.Message().Receiver())
if err != nil { if err != nil {
ssh.rt.Abortf(exitcode.SysErrorIllegalActor, "failed to get actor for Transaction: %s", err) ssh.rs.Abortf(exitcode.SysErrorIllegalActor, "failed to get actor for Transaction: %s", err)
} }
baseState := act.Head baseState := act.Head
ssh.rt.Get(baseState, obj) ssh.rs.Get(baseState, obj)
ssh.rt.allowInternal = false ssh.rs.allowInternal = false
out := f() out := f()
ssh.rt.allowInternal = true ssh.rs.allowInternal = true
c := ssh.rt.Put(obj) c := ssh.rs.Put(obj)
// TODO: handle error below // TODO: handle error below
ssh.rt.stateCommit(baseState, c) ssh.rs.stateCommit(baseState, c)
return out return out
} }
+15 -8
View File
@@ -4,7 +4,6 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
goruntime "runtime"
"sync" "sync"
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
@@ -185,7 +184,7 @@ func (ss *syscallShim) VerifyBlockSig(blk *types.BlockHeader) error {
return err return err
} }
if err := sigs.CheckBlockSignature(ss.ctx, blk, waddr); err != nil { if err := sigs.CheckBlockSignature(blk, ss.ctx, waddr); err != nil {
return err return err
} }
@@ -203,6 +202,20 @@ 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()
@@ -244,8 +257,6 @@ func (ss *syscallShim) VerifySignature(sig crypto.Signature, addr address.Addres
func (ss *syscallShim) BatchVerifySeals(inp map[address.Address][]abi.SealVerifyInfo) (map[address.Address][]bool, error) { func (ss *syscallShim) BatchVerifySeals(inp map[address.Address][]abi.SealVerifyInfo) (map[address.Address][]bool, error) {
out := make(map[address.Address][]bool) out := make(map[address.Address][]bool)
sema := make(chan struct{}, goruntime.NumCPU())
var wg sync.WaitGroup var wg sync.WaitGroup
for addr, seals := range inp { for addr, seals := range inp {
results := make([]bool, len(seals)) results := make([]bool, len(seals))
@@ -255,16 +266,12 @@ func (ss *syscallShim) BatchVerifySeals(inp map[address.Address][]abi.SealVerify
wg.Add(1) wg.Add(1)
go func(ma address.Address, ix int, svi abi.SealVerifyInfo, res []bool) { go func(ma address.Address, ix int, svi abi.SealVerifyInfo, res []bool) {
defer wg.Done() defer wg.Done()
sema <- struct{}{}
if err := ss.VerifySeal(svi); err != nil { if err := ss.VerifySeal(svi); err != nil {
log.Warnw("seal verify in batch failed", "miner", ma, "index", ix, "err", err) log.Warnw("seal verify in batch failed", "miner", ma, "index", ix, "err", err)
res[ix] = false res[ix] = false
} else { } else {
res[ix] = true res[ix] = true
} }
<-sema
}(addr, i, s, results) }(addr, i, s, results)
} }
} }
+10 -10
View File
@@ -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
@@ -454,7 +454,7 @@ func (vm *VM) Flush(ctx context.Context) (cid.Cid, error) {
return root, nil return root, nil
} }
// MutateState usage: MutateState(ctx, idAddr, func(cst cbor.IpldStore, st *ActorStateType) error {...}) // vm.MutateState(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,17 +607,17 @@ func (vm *VM) transfer(from, to address.Address, amt types.BigInt) aerrors.Actor
return nil return nil
} }
fromID, err := vm.cstate.LookupID(from) fromId, err := vm.cstate.LookupID(from)
if err != nil { if err != nil {
return aerrors.Fatalf("transfer failed when resolving sender address: %s", err) return aerrors.Fatalf("transfer failed when resolving sender address: %s", err)
} }
toID, err := vm.cstate.LookupID(to) toId, err := vm.cstate.LookupID(to)
if err != nil { if err != nil {
return aerrors.Fatalf("transfer failed when resolving receiver address: %s", err) return aerrors.Fatalf("transfer failed when resolving receiver address: %s", err)
} }
if fromID == toID { if fromId == toId {
return nil return nil
} }
@@ -625,12 +625,12 @@ func (vm *VM) transfer(from, to address.Address, amt types.BigInt) aerrors.Actor
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(fromID) 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(toID) 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)
} }
@@ -640,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(fromID, 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(toID, 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)
} }
+4 -22
View File
@@ -22,11 +22,10 @@ import (
var log = logging.Logger("wallet") var log = logging.Logger("wallet")
const ( const (
KNamePrefix = "wallet-" KNamePrefix = "wallet-"
KTrashPrefix = "trash-" KDefault = "default"
KDefault = "default" KTBLS = "bls"
KTBLS = "bls" KTSecp256k1 = "secp256k1"
KTSecp256k1 = "secp256k1"
) )
type Wallet struct { type Wallet struct {
@@ -231,23 +230,6 @@ 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
View File
@@ -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"
+2 -3
View File
@@ -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,8 +442,7 @@ 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
+8 -68
View File
@@ -8,11 +8,9 @@ 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"
@@ -23,32 +21,6 @@ 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",
@@ -74,7 +46,6 @@ 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)
@@ -96,14 +67,7 @@ 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
}, },
} }
@@ -112,9 +76,6 @@ 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 {
@@ -133,16 +94,11 @@ 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
}, },
@@ -181,9 +137,6 @@ 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 {
@@ -196,14 +149,8 @@ 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", encoder.Encode(v.Key), v.FilePath, v.Size, v.Status) fmt.Printf("%s %s %d %s\n", v.Key, v.FilePath, v.Size, v.Status)
} }
return nil return nil
}, },
@@ -231,7 +178,6 @@ 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)
@@ -317,13 +263,7 @@ var clientDealCmd = &cli.Command{
return err return err
} }
encoder, err := GetCidEncoder(cctx) fmt.Println(proposal)
if err != nil {
return err
}
fmt.Println(encoder.Encode(*proposal))
return nil return nil
}, },
} }
@@ -506,11 +446,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 peer.ID(mi.PeerId) == peer.ID("SETME") { if mi.PeerId == peer.ID("SETME") {
return fmt.Errorf("the miner hasn't initialized yet") return fmt.Errorf("the miner hasn't initialized yet")
} }
pid = peer.ID(mi.PeerId) pid = mi.PeerId
} }
ask, err := api.ClientQueryAsk(ctx, pid, maddr) ask, err := api.ClientQueryAsk(ctx, pid, maddr)
+1 -1
View File
@@ -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
View File
@@ -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
View File
@@ -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"
+4 -5
View File
@@ -17,13 +17,12 @@ 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"
) )
@@ -118,7 +117,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, build.MessageConfidence) wait, err := api.StateWaitMsg(ctx, msgCid)
if err != nil { if err != nil {
return err return err
} }
@@ -337,7 +336,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, build.MessageConfidence) wait, err := api.StateWaitMsg(ctx, msgCid)
if err != nil { if err != nil {
return err return err
} }
@@ -453,7 +452,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, build.MessageConfidence) wait, err := api.StateWaitMsg(ctx, msgCid)
if err != nil { if err != nil {
return err return err
} }
+2 -26
View File
@@ -7,7 +7,7 @@ import (
"github.com/libp2p/go-libp2p-core/peer" "github.com/libp2p/go-libp2p-core/peer"
"github.com/urfave/cli/v2" "gopkg.in/urfave/cli.v2"
"github.com/filecoin-project/lotus/lib/addrutil" "github.com/filecoin-project/lotus/lib/addrutil"
) )
@@ -21,7 +21,6 @@ var netCmd = &cli.Command{
netListen, netListen,
netId, netId,
netFindPeer, netFindPeer,
netScores,
}, },
} }
@@ -45,30 +44,7 @@ var netPeers = &cli.Command{
}) })
for _, peer := range peers { for _, peer := range peers {
fmt.Printf("%s, %s\n", peer.ID, peer.Addrs) fmt.Println(peer)
}
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
+2 -3
View File
@@ -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,8 +24,7 @@ var fetchParamCmd = &cli.Command{
return err return err
} }
sectorSize := uint64(sectorSizeInt) sectorSize := uint64(sectorSizeInt)
err = paramfetch.GetParams(build.ParametersJSON(), sectorSize)
err = paramfetch.GetParams(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)
} }
+2 -3
View File
@@ -4,11 +4,10 @@ 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"
"github.com/urfave/cli/v2" "gopkg.in/urfave/cli.v2"
types "github.com/filecoin-project/lotus/chain/types" types "github.com/filecoin-project/lotus/chain/types"
) )
@@ -362,7 +361,7 @@ var paychVoucherSubmitCmd = &cli.Command{
return err return err
} }
mwait, err := api.StateWaitMsg(ctx, mcid, build.MessageConfidence) mwait, err := api.StateWaitMsg(ctx, mcid)
if err != nil { if err != nil {
return err return err
} }
+1 -1
View File
@@ -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"
"github.com/urfave/cli/v2" "gopkg.in/urfave/cli.v2"
) )
var sendCmd = &cli.Command{ var sendCmd = &cli.Command{
+11 -17
View File
@@ -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,7 +35,6 @@ 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"
) )
@@ -393,7 +392,7 @@ var stateReplaySetCmd = &cli.Command{
ts, err = types.NewTipSet(headers) ts, err = types.NewTipSet(headers)
} else { } else {
r, err := api.StateWaitMsg(ctx, mcid, build.MessageConfidence) r, err := api.StateWaitMsg(ctx, mcid)
if err != nil { if err != nil {
return xerrors.Errorf("finding message in chain: %w", err) return xerrors.Errorf("finding message in chain: %w", err)
} }
@@ -1042,7 +1041,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(cid.String(), ir.InternalExecutions, getCode); err != nil { if err := printInternalExecutionsHtml(ir.InternalExecutions, getCode); err != nil {
return err return err
} }
} }
@@ -1054,10 +1053,8 @@ func computeStateHtml(ts *types.TipSet, o *api.ComputeStateOutput, getCode func(
return nil return nil
} }
func printInternalExecutionsHtml(hashName string, trace []*types.ExecutionResult, getCode func(addr address.Address) (cid.Cid, error)) error { func printInternalExecutionsHtml(trace []*types.ExecutionResult, getCode func(addr address.Address) (cid.Cid, error)) error {
for i, im := range trace { for _, 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,21 +1082,18 @@ func printInternalExecutionsHtml(hashName string, trace []*types.ExecutionResult
ret = `, Return</div><div><pre class="ret">` + ret + `</pre></div>` ret = `, Return</div><div><pre class="ret">` + ret + `</pre></div>`
} }
slow := im.Duration > 10*time.Millisecond fmt.Printf(`<div class="exec">
veryslow := im.Duration > 50*time.Millisecond <div><h4 class="call">%s:%s</h4></div>
fmt.Printf(`<div class="exec" id="%s">
<div><a href="#%s"><h4 class="call">%s:%s</h4></a></div>
<div><b>%s</b> -&gt; <b>%s</b> (%s FIL), M%d</div> <div><b>%s</b> -&gt; <b>%s</b> (%s FIL), M%d</div>
%s %s
<div><span class="slow-%t-%t">Took %s</span>, <span class="exit%d">Exit: <b>%d</b></span>%s <div><span class="exit%d">Exit: <b>%d</b></span>%s
`, 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) `, codeStr(toCode), methods[toCode][im.Msg.Method].name, im.Msg.From, im.Msg.To, types.FIL(im.Msg.Value), im.Msg.Method, params, im.MsgRct.ExitCode, im.MsgRct.ExitCode, ret)
if im.MsgRct.ExitCode != 0 { if im.MsgRct.ExitCode != 0 {
fmt.Printf(`<div class="error">Error: <pre>%s</pre></div>`, im.Error) fmt.Printf(`<div class="error">Error: <pre>%s</pre></div>`, im.Error)
} }
if len(im.Subcalls) > 0 { if len(im.Subcalls) > 0 {
fmt.Println("<div>Subcalls:</div>") fmt.Println("<div>Subcalls:</div>")
if err := printInternalExecutionsHtml(hashName, im.Subcalls, getCode); err != nil { if err := printInternalExecutionsHtml(im.Subcalls, getCode); err != nil {
return err return err
} }
} }
@@ -1159,7 +1153,7 @@ var stateWaitMsgCmd = &cli.Command{
return err return err
} }
mw, err := api.StateWaitMsg(ctx, msg, build.MessageConfidence) mw, err := api.StateWaitMsg(ctx, msg)
if err != nil { if err != nil {
return err return err
} }
+1 -1
View File
@@ -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"
"github.com/urfave/cli/v2" "gopkg.in/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"
+1 -1
View File
@@ -3,7 +3,7 @@ package cli
import ( import (
"fmt" "fmt"
"github.com/urfave/cli/v2" "gopkg.in/urfave/cli.v2"
) )
var versionCmd = &cli.Command{ var versionCmd = &cli.Command{
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"time" "time"
"github.com/urfave/cli/v2" "gopkg.in/urfave/cli.v2"
) )
var waitApiCmd = &cli.Command{ var waitApiCmd = &cli.Command{
+1 -27
View File
@@ -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"
"github.com/urfave/cli/v2" "gopkg.in/urfave/cli.v2"
) )
var walletCmd = &cli.Command{ var walletCmd = &cli.Command{
@@ -31,7 +31,6 @@ var walletCmd = &cli.Command{
walletSetDefault, walletSetDefault,
walletSign, walletSign,
walletVerify, walletVerify,
walletDelete,
}, },
} }
@@ -376,28 +375,3 @@ 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)
},
}
+1 -1
View File
@@ -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"
"github.com/urfave/cli/v2" "gopkg.in/urfave/cli.v2"
) )
func main() { func main() {
+1 -1
View File
@@ -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"
"github.com/urfave/cli/v2" "gopkg.in/urfave/cli.v2"
) )
type TipSetExec struct { type TipSetExec struct {
+3 -4
View File
@@ -15,12 +15,11 @@ 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"
@@ -216,7 +215,7 @@ var sealBenchCmd = &cli.Command{
// Only fetch parameters if actually needed // Only fetch parameters if actually needed
if !c.Bool("skip-commit2") { if !c.Bool("skip-commit2") {
if err := paramfetch.GetParams(lcli.ReqContext(c), build.ParametersJSON(), uint64(sectorSize)); err != nil { if err := paramfetch.GetParams(build.ParametersJSON(), uint64(sectorSize)); err != nil {
return xerrors.Errorf("getting params: %w", err) return xerrors.Errorf("getting params: %w", err)
} }
} }
@@ -621,7 +620,7 @@ var proveCmd = &cli.Command{
return xerrors.Errorf("unmarshalling input file: %w", err) return xerrors.Errorf("unmarshalling input file: %w", err)
} }
if err := paramfetch.GetParams(lcli.ReqContext(c), build.ParametersJSON(), c2in.SectorSize); err != nil { if err := paramfetch.GetParams(build.ParametersJSON(), c2in.SectorSize); err != nil {
return xerrors.Errorf("getting params: %w", err) return xerrors.Errorf("getting params: %w", err)
} }
+1 -1
View File
@@ -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)
} }
} }
} }
+1 -7
View File
@@ -6,7 +6,7 @@ import (
"strconv" "strconv"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
"github.com/urfave/cli/v2" "gopkg.in/urfave/cli.v2"
) )
var dotCmd = &cli.Command{ var dotCmd = &cli.Command{
@@ -20,13 +20,7 @@ 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
+2 -2
View File
@@ -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")
+1 -1
View File
@@ -146,7 +146,7 @@ func syncHead(ctx context.Context, api api.FullNode, st *storage, ts *types.TipS
} }
if len(bh.Parents) == 0 { // genesis case if len(bh.Parents) == 0 { // genesis case
ts, _ := types.NewTipSet([]*types.BlockHeader{bh}) ts, err := 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)
+7 -7
View File
@@ -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"
@@ -215,14 +215,14 @@ 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: abi.PeerID(h.defaultMinerPeer), Peer: 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, build.MessageConfidence) mw, err := h.api.StateWaitMsg(r.Context(), c)
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, build.MessageConfidence) mw, err := h.api.StateWaitMsg(r.Context(), c)
if err != nil { if err != nil {
w.WriteHeader(400) w.WriteHeader(400)
w.Write([]byte(err.Error())) w.Write([]byte(err.Error()))
+1 -1
View File
@@ -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"
"github.com/urfave/cli/v2" "gopkg.in/urfave/cli.v2"
"github.com/filecoin-project/go-jsonrpc" "github.com/filecoin-project/go-jsonrpc"
+4 -4
View File
@@ -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"
@@ -148,14 +148,14 @@ var runCmd = &cli.Command{
} }
if cctx.Bool("commit") { if cctx.Bool("commit") {
if err := paramfetch.GetParams(ctx, build.ParametersJSON(), uint64(ssize)); err != nil { if err := paramfetch.GetParams(build.ParametersJSON(), uint64(ssize)); err != nil {
return xerrors.Errorf("get params: %w", err) return xerrors.Errorf("get params: %w", err)
} }
} }
var taskTypes []sealtasks.TaskType var taskTypes []sealtasks.TaskType
taskTypes = append(taskTypes, sealtasks.TTFetch, sealtasks.TTCommit1, sealtasks.TTFinalize) taskTypes = append(taskTypes, sealtasks.TTFetch)
if cctx.Bool("precommit1") { if cctx.Bool("precommit1") {
taskTypes = append(taskTypes, sealtasks.TTPreCommit1) taskTypes = append(taskTypes, sealtasks.TTPreCommit1)
@@ -292,7 +292,7 @@ var runCmd = &cli.Command{
go func() { go func() {
<-ctx.Done() <-ctx.Done()
log.Warn("Shutting down...") log.Warn("Shutting down..")
if err := srv.Shutdown(context.TODO()); err != nil { if err := srv.Shutdown(context.TODO()); err != nil {
log.Errorf("shutting down RPC server failed: %s", err) log.Errorf("shutting down RPC server failed: %s", err)
} }
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -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"
"github.com/urfave/cli/v2" "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"
+1 -1
View File
@@ -8,7 +8,7 @@ import (
"os" "os"
"strings" "strings"
"github.com/urfave/cli/v2" "gopkg.in/urfave/cli.v2"
) )
var base16Cmd = &cli.Command{ var base16Cmd = &cli.Command{
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"os" "os"
"strings" "strings"
"github.com/urfave/cli/v2" "gopkg.in/urfave/cli.v2"
"github.com/multiformats/go-base32" "github.com/multiformats/go-base32"
) )
+1 -1
View File
@@ -6,7 +6,7 @@ import (
"fmt" "fmt"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
"github.com/urfave/cli/v2" "gopkg.in/urfave/cli.v2"
) )
var bigIntParseCmd = &cli.Command{ var bigIntParseCmd = &cli.Command{
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"fmt" "fmt"
commcid "github.com/filecoin-project/go-fil-commcid" commcid "github.com/filecoin-project/go-fil-commcid"
"github.com/urfave/cli/v2" "gopkg.in/urfave/cli.v2"
) )
var commpToCidCmd = &cli.Command{ var commpToCidCmd = &cli.Command{
+1 -1
View File
@@ -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"
) )
+1 -1
View File
@@ -9,7 +9,7 @@ import (
"strings" "strings"
"text/template" "text/template"
"github.com/urfave/cli/v2" "gopkg.in/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"
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"os" "os"
logging "github.com/ipfs/go-log/v2" logging "github.com/ipfs/go-log/v2"
"github.com/urfave/cli/v2" "gopkg.in/urfave/cli.v2"
"github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/build"
) )
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"math" "math"
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
"github.com/urfave/cli/v2" "gopkg.in/urfave/cli.v2"
"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"
+2 -3
View File
@@ -3,9 +3,8 @@ package main
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"
lcli "github.com/filecoin-project/lotus/cli"
"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"
) )
@@ -25,7 +24,7 @@ var fetchParamCmd = &cli.Command{
return err return err
} }
sectorSize := uint64(sectorSizeInt) sectorSize := uint64(sectorSizeInt)
err = paramfetch.GetParams(lcli.ReqContext(cctx), build.ParametersJSON(), sectorSize) err = paramfetch.GetParams(build.ParametersJSON(), sectorSize)
if err != nil { if err != nil {
return xerrors.Errorf("fetching proof parameters: %w", err) return xerrors.Errorf("fetching proof parameters: %w", err)
} }
+1 -1
View File
@@ -6,7 +6,7 @@ import (
"os" "os"
"strings" "strings"
"github.com/urfave/cli/v2" "gopkg.in/urfave/cli.v2"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/node/modules/lp2p" "github.com/filecoin-project/lotus/node/modules/lp2p"
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"github.com/urfave/cli/v2" "gopkg.in/urfave/cli.v2"
ffi "github.com/filecoin-project/filecoin-ffi" ffi "github.com/filecoin-project/filecoin-ffi"
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
+1 -1
View File
@@ -3,7 +3,7 @@ package main
import ( import (
"fmt" "fmt"
"github.com/urfave/cli/v2" "gopkg.in/urfave/cli.v2"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
+3 -4
View File
@@ -3,10 +3,9 @@ package main
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
"github.com/urfave/cli/v2" "gopkg.in/urfave/cli.v2"
"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"
@@ -86,7 +85,7 @@ var verifRegAddVerifierCmd = &cli.Command{
fmt.Printf("message sent, now waiting on cid: %s\n", smsg.Cid()) fmt.Printf("message sent, now waiting on cid: %s\n", smsg.Cid())
mwait, err := api.StateWaitMsg(ctx, smsg.Cid(), build.MessageConfidence) mwait, err := api.StateWaitMsg(ctx, smsg.Cid())
if err != nil { if err != nil {
return err return err
} }
@@ -162,7 +161,7 @@ var verifRegVerifyClientCmd = &cli.Command{
fmt.Printf("message sent, now waiting on cid: %s\n", smsg.Cid()) fmt.Printf("message sent, now waiting on cid: %s\n", smsg.Cid())
mwait, err := api.StateWaitMsg(ctx, smsg.Cid(), build.MessageConfidence) mwait, err := api.StateWaitMsg(ctx, smsg.Cid())
if err != nil { if err != nil {
return err return err
} }
+2 -19
View File
@@ -5,17 +5,15 @@ import (
"context" "context"
"fmt" "fmt"
"sort" "sort"
"time"
"github.com/fatih/color" "github.com/fatih/color"
"github.com/urfave/cli/v2"
"golang.org/x/xerrors" "golang.org/x/xerrors"
"gopkg.in/urfave/cli.v2"
"github.com/filecoin-project/specs-actors/actors/builtin/miner" "github.com/filecoin-project/specs-actors/actors/builtin/miner"
sealing "github.com/filecoin-project/storage-fsm" sealing "github.com/filecoin-project/storage-fsm"
"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"
lcli "github.com/filecoin-project/lotus/cli" lcli "github.com/filecoin-project/lotus/cli"
) )
@@ -119,18 +117,6 @@ var infoCmd = &cli.Command{
faultyPercentage) faultyPercentage)
} }
expWinChance := float64(types.BigMul(qpercI, types.NewInt(build.BlocksPerEpoch)).Int64()) / 1000000
if expWinChance > 0 {
if expWinChance > 1 {
expWinChance = 1
}
winRate := time.Duration(float64(time.Second*build.BlockDelay) / expWinChance)
winPerDay := float64(time.Hour*24) / float64(winRate)
fmt.Print("Expected block win rate: ")
color.Blue("%.4f/day (every %s)", winPerDay, winRate.Truncate(time.Second))
}
fmt.Println() fmt.Println()
fmt.Printf("Miner Balance: %s\n", color.YellowString("%s", types.FIL(mact.Balance))) fmt.Printf("Miner Balance: %s\n", color.YellowString("%s", types.FIL(mact.Balance)))
@@ -182,20 +168,17 @@ var stateList = []stateMeta{
{col: color.FgYellow, state: sealing.PreCommit1}, {col: color.FgYellow, state: sealing.PreCommit1},
{col: color.FgYellow, state: sealing.PreCommit2}, {col: color.FgYellow, state: sealing.PreCommit2},
{col: color.FgYellow, state: sealing.PreCommitting}, {col: color.FgYellow, state: sealing.PreCommitting},
{col: color.FgYellow, state: sealing.PreCommitWait},
{col: color.FgYellow, state: sealing.WaitSeed}, {col: color.FgYellow, state: sealing.WaitSeed},
{col: color.FgYellow, state: sealing.Committing}, {col: color.FgYellow, state: sealing.Committing},
{col: color.FgYellow, state: sealing.CommitWait}, {col: color.FgYellow, state: sealing.CommitWait},
{col: color.FgYellow, state: sealing.FinalizeSector}, {col: color.FgYellow, state: sealing.FinalizeSector},
{col: color.FgRed, state: sealing.FailedUnrecoverable}, {col: color.FgRed, state: sealing.FailedUnrecoverable},
{col: color.FgRed, state: sealing.SealPreCommit1Failed}, {col: color.FgRed, state: sealing.SealFailed},
{col: color.FgRed, state: sealing.SealPreCommit2Failed},
{col: color.FgRed, state: sealing.PreCommitFailed}, {col: color.FgRed, state: sealing.PreCommitFailed},
{col: color.FgRed, state: sealing.ComputeProofFailed}, {col: color.FgRed, state: sealing.ComputeProofFailed},
{col: color.FgRed, state: sealing.CommitFailed}, {col: color.FgRed, state: sealing.CommitFailed},
{col: color.FgRed, state: sealing.PackingFailed}, {col: color.FgRed, state: sealing.PackingFailed},
{col: color.FgRed, state: sealing.FinalizeFailed},
{col: color.FgRed, state: sealing.Faulty}, {col: color.FgRed, state: sealing.Faulty},
{col: color.FgRed, state: sealing.FaultReported}, {col: color.FgRed, state: sealing.FaultReported},
{col: color.FgRed, state: sealing.FaultedFinal}, {col: color.FgRed, state: sealing.FaultedFinal},
+7 -9
View File
@@ -18,8 +18,8 @@ import (
"github.com/libp2p/go-libp2p-core/crypto" "github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/peer" "github.com/libp2p/go-libp2p-core/peer"
"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"
cborutil "github.com/filecoin-project/go-cbor-util" cborutil "github.com/filecoin-project/go-cbor-util"
@@ -125,11 +125,8 @@ var initCmd = &cli.Command{
log.Info("will attempt to symlink to imported sectors") log.Info("will attempt to symlink to imported sectors")
} }
ctx := lcli.ReqContext(cctx)
log.Info("Checking proof parameters") log.Info("Checking proof parameters")
if err := paramfetch.GetParams(build.ParametersJSON(), uint64(ssize)); err != nil {
if err := paramfetch.GetParams(ctx, build.ParametersJSON(), uint64(ssize)); err != nil {
return xerrors.Errorf("fetching proof parameters: %w", err) return xerrors.Errorf("fetching proof parameters: %w", err)
} }
@@ -140,6 +137,7 @@ var initCmd = &cli.Command{
return err return err
} }
defer closer() defer closer()
ctx := lcli.ReqContext(cctx)
log.Info("Checking full node sync status") log.Info("Checking full node sync status")
@@ -547,7 +545,7 @@ func configureStorageMiner(ctx context.Context, api lapi.FullNode, addr address.
return xerrors.Errorf("getWorkerAddr returned bad address: %w", err) return xerrors.Errorf("getWorkerAddr returned bad address: %w", err)
} }
enc, err := actors.SerializeParams(&miner2.ChangePeerIDParams{NewID: abi.PeerID(peerid)}) enc, err := actors.SerializeParams(&miner2.ChangePeerIDParams{NewID: peerid})
if err != nil { if err != nil {
return err return err
} }
@@ -568,7 +566,7 @@ func configureStorageMiner(ctx context.Context, api lapi.FullNode, addr address.
} }
log.Info("Waiting for message: ", smsg.Cid()) log.Info("Waiting for message: ", smsg.Cid())
ret, err := api.StateWaitMsg(ctx, smsg.Cid(), build.MessageConfidence) ret, err := api.StateWaitMsg(ctx, smsg.Cid())
if err != nil { if err != nil {
return err return err
} }
@@ -624,7 +622,7 @@ func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID,
Owner: owner, Owner: owner,
Worker: worker, Worker: worker,
SealProofType: spt, SealProofType: spt,
Peer: abi.PeerID(peerid), Peer: peerid,
}) })
if err != nil { if err != nil {
return address.Undef, err return address.Undef, err
@@ -650,7 +648,7 @@ func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID,
log.Infof("Pushed StorageMarket.CreateStorageMiner, %s to Mpool", signed.Cid()) log.Infof("Pushed StorageMarket.CreateStorageMiner, %s to Mpool", signed.Cid())
log.Infof("Waiting for confirmation") log.Infof("Waiting for confirmation")
mw, err := api.StateWaitMsg(ctx, signed.Cid(), build.MessageConfidence) mw, err := api.StateWaitMsg(ctx, signed.Cid())
if err != nil { if err != nil {
return address.Undef, err return address.Undef, err
} }
+5 -6
View File
@@ -4,8 +4,8 @@ import (
"os" "os"
logging "github.com/ipfs/go-log/v2" logging "github.com/ipfs/go-log/v2"
"github.com/urfave/cli/v2"
"go.opencensus.io/trace" "go.opencensus.io/trace"
"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"
@@ -27,7 +27,6 @@ func main() {
initCmd, initCmd,
rewardsCmd, rewardsCmd,
runCmd, runCmd,
stopCmd,
sectorsCmd, sectorsCmd,
storageCmd, storageCmd,
setPriceCmd, setPriceCmd,
@@ -56,10 +55,10 @@ func main() {
} }
app := &cli.App{ app := &cli.App{
Name: "lotus-storage-miner", Name: "lotus-storage-miner",
Usage: "Filecoin decentralized storage network storage miner", Usage: "Filecoin decentralized storage network storage miner",
Version: build.UserVersion(), Version: build.UserVersion(),
EnableBashCompletion: true, EnableShellCompletion: true,
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
Name: "repo", Name: "repo",
+1 -1
View File
@@ -7,7 +7,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"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
"github.com/urfave/cli/v2" "gopkg.in/urfave/cli.v2"
) )
var setPriceCmd = &cli.Command{ var setPriceCmd = &cli.Command{
+12 -50
View File
@@ -3,21 +3,14 @@ package main
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"os"
"text/tabwriter"
"time"
"github.com/urfave/cli/v2"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-bitfield"
rlepluslazy "github.com/filecoin-project/go-bitfield/rle"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
lcli "github.com/filecoin-project/lotus/cli" lcli "github.com/filecoin-project/lotus/cli"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
"golang.org/x/xerrors"
"gopkg.in/urfave/cli.v2"
"time"
) )
var provingCmd = &cli.Command{ var provingCmd = &cli.Command{
@@ -197,59 +190,28 @@ var provingDeadlinesCmd = &cli.Command{
} }
} }
tw := tabwriter.NewWriter(os.Stdout, 2, 4, 2, ' ', 0)
_, _ = fmt.Fprintln(tw, "deadline\tsectors\tpartitions\tproven")
for i, field := range deadlines.Due { for i, field := range deadlines.Due {
c, err := field.Count() c, err := field.Count()
if err != nil { if err != nil {
return err return err
} }
firstPartition, sectorCount, err := miner.PartitionsForDeadline(deadlines, mas.Info.WindowPoStPartitionSectors, uint64(i)) var info string
proven, err := mas.PostSubmissions.IsSet(uint64(i))
if err != nil { if err != nil {
return err return err
} }
partitionCount := (sectorCount + mas.Info.WindowPoStPartitionSectors - 1) / mas.Info.WindowPoStPartitionSectors if proven {
info += ", proven"
var provenPartitions uint64
{
var maskRuns []rlepluslazy.Run
if firstPartition > 0 {
maskRuns = append(maskRuns, rlepluslazy.Run{
Val: false,
Len: firstPartition,
})
}
maskRuns = append(maskRuns, rlepluslazy.Run{
Val: true,
Len: partitionCount,
})
ppbm, err := bitfield.NewFromIter(&rlepluslazy.RunSliceIterator{Runs: maskRuns})
if err != nil {
return err
}
pp, err := bitfield.IntersectBitField(ppbm, mas.PostSubmissions)
if err != nil {
return err
}
provenPartitions, err = pp.Count()
if err != nil {
return err
}
} }
var cur string
if di.Index == uint64(i) { if di.Index == uint64(i) {
cur += "\t(current)" info += " (current)"
} }
_, _ = fmt.Fprintf(tw, "%d\t%d\t%d\t%d%s\n", i, c, partitionCount, provenPartitions, cur) fmt.Printf("%d: %d sectors%s\n", i, c, info)
} }
return tw.Flush() return nil
}, },
} }
+1 -1
View File
@@ -3,7 +3,7 @@ package main
import ( import (
"fmt" "fmt"
"github.com/urfave/cli/v2" "gopkg.in/urfave/cli.v2"
"github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
+3 -10
View File
@@ -11,8 +11,8 @@ import (
mux "github.com/gorilla/mux" mux "github.com/gorilla/mux"
"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"
"github.com/filecoin-project/go-jsonrpc/auth" "github.com/filecoin-project/go-jsonrpc/auth"
@@ -100,12 +100,9 @@ var runCmd = &cli.Command{
return xerrors.Errorf("repo at '%s' is not initialized, run 'lotus-storage-miner init' to set it up", storageRepoPath) return xerrors.Errorf("repo at '%s' is not initialized, run 'lotus-storage-miner init' to set it up", storageRepoPath)
} }
shutdownChan := make(chan struct{})
var minerapi api.StorageMiner var minerapi api.StorageMiner
stop, err := node.New(ctx, stop, err := node.New(ctx,
node.StorageMiner(&minerapi), node.StorageMiner(&minerapi),
node.Override(new(dtypes.ShutdownChan), shutdownChan),
node.Online(), node.Online(),
node.Repo(r), node.Repo(r),
@@ -159,12 +156,8 @@ var runCmd = &cli.Command{
sigChan := make(chan os.Signal, 2) sigChan := make(chan os.Signal, 2)
go func() { go func() {
select { <-sigChan
case <-sigChan: log.Warn("Shutting down..")
case <-shutdownChan:
}
log.Warn("Shutting down...")
if err := stop(context.TODO()); err != nil { if err := stop(context.TODO()); err != nil {
log.Errorf("graceful shutting down failed: %s", err) log.Errorf("graceful shutting down failed: %s", err)
} }
+1 -1
View File
@@ -8,8 +8,8 @@ import (
"text/tabwriter" "text/tabwriter"
"time" "time"
"github.com/urfave/cli/v2"
"golang.org/x/xerrors" "golang.org/x/xerrors"
"gopkg.in/urfave/cli.v2"
"github.com/filecoin-project/specs-actors/actors/abi" "github.com/filecoin-project/specs-actors/actors/abi"
-29
View File
@@ -1,29 +0,0 @@
package main
import (
_ "net/http/pprof"
"github.com/urfave/cli/v2"
lcli "github.com/filecoin-project/lotus/cli"
)
var stopCmd = &cli.Command{
Name: "stop",
Usage: "Stop a running lotus storage miner",
Flags: []cli.Flag{},
Action: func(cctx *cli.Context) error {
api, closer, err := lcli.GetAPI(cctx)
if err != nil {
return err
}
defer closer()
err = api.Shutdown(lcli.ReqContext(cctx))
if err != nil {
return err
}
return nil
},
}
+1 -1
View File
@@ -14,8 +14,8 @@ import (
"github.com/fatih/color" "github.com/fatih/color"
"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" "github.com/filecoin-project/specs-actors/actors/abi"
+1 -1
View File
@@ -6,7 +6,7 @@ import (
"strings" "strings"
"github.com/fatih/color" "github.com/fatih/color"
"github.com/urfave/cli/v2" "gopkg.in/urfave/cli.v2"
"github.com/filecoin-project/sector-storage/storiface" "github.com/filecoin-project/sector-storage/storiface"
+3 -35
View File
@@ -18,18 +18,17 @@ import (
blockstore "github.com/ipfs/go-ipfs-blockstore" blockstore "github.com/ipfs/go-ipfs-blockstore"
"github.com/mitchellh/go-homedir" "github.com/mitchellh/go-homedir"
"github.com/multiformats/go-multiaddr" "github.com/multiformats/go-multiaddr"
"github.com/urfave/cli/v2"
"go.opencensus.io/stats" "go.opencensus.io/stats"
"go.opencensus.io/stats/view" "go.opencensus.io/stats/view"
"go.opencensus.io/tag" "go.opencensus.io/tag"
"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/build" "github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/stmgr" "github.com/filecoin-project/lotus/chain/stmgr"
"github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/vm" "github.com/filecoin-project/lotus/chain/vm"
lcli "github.com/filecoin-project/lotus/cli"
"github.com/filecoin-project/lotus/lib/peermgr" "github.com/filecoin-project/lotus/lib/peermgr"
"github.com/filecoin-project/lotus/metrics" "github.com/filecoin-project/lotus/metrics"
"github.com/filecoin-project/lotus/node" "github.com/filecoin-project/lotus/node"
@@ -45,26 +44,6 @@ const (
preTemplateFlag = "genesis-template" preTemplateFlag = "genesis-template"
) )
var daemonStopCmd = &cli.Command{
Name: "stop",
Usage: "Stop a running lotus daemon",
Flags: []cli.Flag{},
Action: func(cctx *cli.Context) error {
api, closer, err := lcli.GetAPI(cctx)
if err != nil {
return err
}
defer closer()
err = api.Shutdown(lcli.ReqContext(cctx))
if err != nil {
return err
}
return nil
},
}
// DaemonCmd is the `go-lotus daemon` command // DaemonCmd is the `go-lotus daemon` command
var DaemonCmd = &cli.Command{ var DaemonCmd = &cli.Command{
Name: "daemon", Name: "daemon",
@@ -155,7 +134,7 @@ var DaemonCmd = &cli.Command{
return xerrors.Errorf("repo init error: %w", err) return xerrors.Errorf("repo init error: %w", err)
} }
if err := paramfetch.GetParams(lcli.ReqContext(cctx), build.ParametersJSON(), 0); err != nil { if err := paramfetch.GetParams(build.ParametersJSON(), 0); err != nil {
return xerrors.Errorf("fetching proof parameters: %w", err) return xerrors.Errorf("fetching proof parameters: %w", err)
} }
@@ -171,11 +150,6 @@ var DaemonCmd = &cli.Command{
chainfile := cctx.String("import-chain") chainfile := cctx.String("import-chain")
if chainfile != "" { if chainfile != "" {
chainfile, err := homedir.Expand(chainfile)
if err != nil {
return err
}
if err := ImportChain(r, chainfile); err != nil { if err := ImportChain(r, chainfile); err != nil {
return err return err
} }
@@ -196,15 +170,12 @@ var DaemonCmd = &cli.Command{
genesis = node.Override(new(modules.Genesis), testing.MakeGenesis(cctx.String(makeGenFlag), cctx.String(preTemplateFlag))) genesis = node.Override(new(modules.Genesis), testing.MakeGenesis(cctx.String(makeGenFlag), cctx.String(preTemplateFlag)))
} }
shutdownChan := make(chan struct{})
var api api.FullNode var api api.FullNode
stop, err := node.New(ctx, stop, err := node.New(ctx,
node.FullAPI(&api), node.FullAPI(&api),
node.Override(new(dtypes.Bootstrapper), isBootstrapper), node.Override(new(dtypes.Bootstrapper), isBootstrapper),
node.Override(new(dtypes.ShutdownChan), shutdownChan),
node.Online(), node.Online(),
node.Repo(r), node.Repo(r),
@@ -250,10 +221,7 @@ var DaemonCmd = &cli.Command{
} }
// TODO: properly parse api endpoint (or make it a URL) // TODO: properly parse api endpoint (or make it a URL)
return serveRPC(api, stop, endpoint, shutdownChan) return serveRPC(api, stop, endpoint)
},
Subcommands: []*cli.Command{
daemonStopCmd,
}, },
} }

Some files were not shown because too many files have changed in this diff Show More