diff --git a/api/api_full.go b/api/api_full.go index 50a562839..13add2130 100644 --- a/api/api_full.go +++ b/api/api_full.go @@ -4,8 +4,6 @@ import ( "context" "time" - "github.com/filecoin-project/lotus/chain/vm" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-fil-markets/storagemarket" "github.com/filecoin-project/specs-actors/actors/abi" @@ -18,10 +16,10 @@ import ( "github.com/ipfs/go-cid" "github.com/ipfs/go-filestore" "github.com/libp2p/go-libp2p-core/peer" - xerrors "golang.org/x/xerrors" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/types" + "github.com/filecoin-project/lotus/chain/vm" ) // FullNode API is a low-level interface to the Filecoin network full node @@ -374,18 +372,3 @@ type ComputeStateOutput struct { Root cid.Cid Trace []*InvocResult } - -func ProofTypeFromSectorSize(ssize abi.SectorSize) (abi.RegisteredProof, abi.RegisteredProof, error) { - switch ssize { - case 2 << 10: - return abi.RegisteredProof_StackedDRG2KiBPoSt, abi.RegisteredProof_StackedDRG2KiBSeal, nil - case 8 << 20: - return abi.RegisteredProof_StackedDRG8MiBPoSt, abi.RegisteredProof_StackedDRG8MiBSeal, nil - case 512 << 20: - return abi.RegisteredProof_StackedDRG512MiBPoSt, abi.RegisteredProof_StackedDRG512MiBSeal, nil - case 32 << 30: - return abi.RegisteredProof_StackedDRG32GiBPoSt, abi.RegisteredProof_StackedDRG32GiBSeal, nil - default: - return 0, 0, xerrors.Errorf("unsupported sector size for miner: %v", ssize) - } -} diff --git a/api/api_storage.go b/api/api_storage.go index 4712ed98c..d4cccb156 100644 --- a/api/api_storage.go +++ b/api/api_storage.go @@ -11,6 +11,7 @@ import ( "github.com/filecoin-project/specs-actors/actors/abi" "github.com/filecoin-project/lotus/chain/types" + "github.com/filecoin-project/lotus/storage/sectorstorage" "github.com/filecoin-project/lotus/storage/sectorstorage/stores" ) @@ -114,7 +115,7 @@ type StorageMiner interface { // WorkerConnect tells the node to connect to workers RPC WorkerConnect(context.Context, string) error - WorkerStats(context.Context) (map[uint64]WorkerStats, error) + WorkerStats(context.Context) (map[uint64]sectorstorage.WorkerStats, error) stores.SectorIndex diff --git a/api/api_worker.go b/api/api_worker.go index 113952adb..b0a4400f4 100644 --- a/api/api_worker.go +++ b/api/api_worker.go @@ -6,6 +6,7 @@ import ( "github.com/filecoin-project/specs-storage/storage" "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/storage/sectorstorage" "github.com/filecoin-project/lotus/storage/sectorstorage/sealtasks" "github.com/filecoin-project/lotus/storage/sectorstorage/stores" ) @@ -16,31 +17,7 @@ type WorkerApi interface { TaskTypes(context.Context) (map[sealtasks.TaskType]struct{}, error) // TaskType -> Weight Paths(context.Context) ([]stores.StoragePath, error) - Info(context.Context) (WorkerInfo, error) + Info(context.Context) (sectorstorage.WorkerInfo, error) storage.Sealer } - -type WorkerResources struct { - MemPhysical uint64 - MemSwap uint64 - - MemReserved uint64 // Used by system / other processes - - GPUs []string -} - -type WorkerInfo struct { - Hostname string - - Resources WorkerResources -} - -type WorkerStats struct { - Info WorkerInfo - - MemUsedMin uint64 - MemUsedMax uint64 - GpuUsed bool - CpuUse int -} diff --git a/api/apistruct/struct.go b/api/apistruct/struct.go index 6a9903bd9..ccb80ba2b 100644 --- a/api/apistruct/struct.go +++ b/api/apistruct/struct.go @@ -21,6 +21,7 @@ import ( "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/types" + "github.com/filecoin-project/lotus/storage/sectorstorage" "github.com/filecoin-project/lotus/storage/sectorstorage/sealtasks" "github.com/filecoin-project/lotus/storage/sectorstorage/stores" ) @@ -181,8 +182,8 @@ type StorageMinerStruct struct { SectorsRefs func(context.Context) (map[string][]api.SealedRef, error) `perm:"read"` SectorsUpdate func(context.Context, abi.SectorNumber, api.SectorState) error `perm:"write"` - WorkerConnect func(context.Context, string) error `perm:"admin"` // TODO: worker perm - WorkerStats func(context.Context) (map[uint64]api.WorkerStats, error) `perm:"admin"` + WorkerConnect func(context.Context, string) error `perm:"admin"` // TODO: worker perm + WorkerStats func(context.Context) (map[uint64]sectorstorage.WorkerStats, error) `perm:"admin"` StorageList func(context.Context) (map[stores.ID][]stores.Decl, error) `perm:"admin"` StorageLocal func(context.Context) (map[stores.ID]string, error) `perm:"admin"` @@ -209,7 +210,7 @@ type WorkerStruct struct { TaskTypes func(context.Context) (map[sealtasks.TaskType]struct{}, error) `perm:"admin"` Paths func(context.Context) ([]stores.StoragePath, error) `perm:"admin"` - Info func(context.Context) (api.WorkerInfo, error) `perm:"admin"` + Info func(context.Context) (sectorstorage.WorkerInfo, error) `perm:"admin"` SealPreCommit1 func(ctx context.Context, sector abi.SectorID, ticket abi.SealRandomness, pieces []abi.PieceInfo) (storage.PreCommit1Out, error) `perm:"admin"` SealPreCommit2 func(context.Context, abi.SectorID, storage.PreCommit1Out) (cids storage.SectorCids, err error) `perm:"admin"` @@ -666,7 +667,7 @@ func (c *StorageMinerStruct) WorkerConnect(ctx context.Context, url string) erro return c.Internal.WorkerConnect(ctx, url) } -func (c *StorageMinerStruct) WorkerStats(ctx context.Context) (map[uint64]api.WorkerStats, error) { +func (c *StorageMinerStruct) WorkerStats(ctx context.Context) (map[uint64]sectorstorage.WorkerStats, error) { return c.Internal.WorkerStats(ctx) } @@ -746,7 +747,7 @@ func (w *WorkerStruct) Paths(ctx context.Context) ([]stores.StoragePath, error) return w.Internal.Paths(ctx) } -func (w *WorkerStruct) Info(ctx context.Context) (api.WorkerInfo, error) { +func (w *WorkerStruct) Info(ctx context.Context) (sectorstorage.WorkerInfo, error) { return w.Internal.Info(ctx) } diff --git a/chain/sync.go b/chain/sync.go index 070751b29..f924a6ebb 100644 --- a/chain/sync.go +++ b/chain/sync.go @@ -732,7 +732,7 @@ func (syncer *Syncer) VerifyElectionPoStProof(ctx context.Context, h *types.Bloc return xerrors.Errorf("[TESTING] election post was invalid") } - rt, _, err := api.ProofTypeFromSectorSize(ssize) + rt, _, err := ffiwrapper.ProofTypeFromSectorSize(ssize) if err != nil { return err } diff --git a/cmd/lotus-bench/main.go b/cmd/lotus-bench/main.go index 89a8831f1..247850cec 100644 --- a/cmd/lotus-bench/main.go +++ b/cmd/lotus-bench/main.go @@ -162,7 +162,7 @@ func main() { } sectorSize := abi.SectorSize(sectorSizeInt) - ppt, spt, err := lapi.ProofTypeFromSectorSize(sectorSize) + ppt, spt, err := ffiwrapper.ProofTypeFromSectorSize(sectorSize) if err != nil { return err } @@ -536,7 +536,7 @@ var proveCmd = &cli.Command{ return err } - ppt, spt, err := lapi.ProofTypeFromSectorSize(abi.SectorSize(c2in.SectorSize)) + ppt, spt, err := ffiwrapper.ProofTypeFromSectorSize(abi.SectorSize(c2in.SectorSize)) if err != nil { return err } diff --git a/cmd/lotus-seal-worker/main.go b/cmd/lotus-seal-worker/main.go index f1e68687a..3c7276434 100644 --- a/cmd/lotus-seal-worker/main.go +++ b/cmd/lotus-seal-worker/main.go @@ -3,6 +3,7 @@ package main import ( "context" "encoding/json" + "github.com/filecoin-project/lotus/storage/sectorstorage/ffiwrapper" "io/ioutil" "net" "net/http" @@ -24,7 +25,6 @@ import ( "github.com/filecoin-project/lotus/lib/auth" "github.com/filecoin-project/lotus/lib/jsonrpc" "github.com/filecoin-project/lotus/lib/lotuslog" - "github.com/filecoin-project/lotus/node/config" "github.com/filecoin-project/lotus/node/repo" "github.com/filecoin-project/lotus/storage/sectorstorage" "github.com/filecoin-project/lotus/storage/sectorstorage/sealtasks" @@ -189,7 +189,7 @@ var runCmd = &cli.Command{ return err } - var localPaths []config.LocalPath + var localPaths []stores.LocalPath if !cctx.Bool("no-local-storage") { b, err := json.MarshalIndent(&stores.LocalStorageMeta{ @@ -206,12 +206,12 @@ var runCmd = &cli.Command{ return xerrors.Errorf("persisting storage metadata (%s): %w", filepath.Join(lr.Path(), "sectorstore.json"), err) } - localPaths = append(localPaths, config.LocalPath{ + localPaths = append(localPaths, stores.LocalPath{ Path: lr.Path(), }) } - if err := lr.SetStorage(func(sc *config.StorageConfig) { + if err := lr.SetStorage(func(sc *stores.StorageConfig) { sc.StoragePaths = append(sc.StoragePaths, localPaths...) }); err != nil { return xerrors.Errorf("set storage config: %w", err) @@ -242,7 +242,7 @@ var runCmd = &cli.Command{ } // Setup remote sector store - _, spt, err := api.ProofTypeFromSectorSize(ssize) + _, spt, err := ffiwrapper.ProofTypeFromSectorSize(ssize) if err != nil { return xerrors.Errorf("getting proof type: %w", err) } diff --git a/cmd/lotus-seed/main.go b/cmd/lotus-seed/main.go index 245f8d487..538465401 100644 --- a/cmd/lotus-seed/main.go +++ b/cmd/lotus-seed/main.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "github.com/docker/go-units" + "github.com/filecoin-project/lotus/storage/sectorstorage/ffiwrapper" "io/ioutil" "os" @@ -16,7 +17,6 @@ import ( "github.com/filecoin-project/specs-actors/actors/abi" "github.com/filecoin-project/specs-actors/actors/abi/big" - lapi "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/cmd/lotus-seed/seed" @@ -120,7 +120,7 @@ var preSealCmd = &cli.Command{ } sectorSize := abi.SectorSize(sectorSizeInt) - rp, _, err := lapi.ProofTypeFromSectorSize(sectorSize) + rp, _, err := ffiwrapper.ProofTypeFromSectorSize(sectorSize) if err != nil { return err } diff --git a/cmd/lotus-storage-miner/init.go b/cmd/lotus-storage-miner/init.go index dc88bf2a5..9f728016a 100644 --- a/cmd/lotus-storage-miner/init.go +++ b/cmd/lotus-storage-miner/init.go @@ -7,6 +7,7 @@ import ( "encoding/binary" "encoding/json" "fmt" + "github.com/filecoin-project/lotus/node/modules" "io/ioutil" "os" "path/filepath" @@ -37,7 +38,6 @@ import ( lcli "github.com/filecoin-project/lotus/cli" "github.com/filecoin-project/lotus/genesis" "github.com/filecoin-project/lotus/miner" - "github.com/filecoin-project/lotus/node/config" "github.com/filecoin-project/lotus/node/modules/dtypes" "github.com/filecoin-project/lotus/node/repo" "github.com/filecoin-project/lotus/storage" @@ -171,7 +171,7 @@ var initCmd = &cli.Command{ return err } - var localPaths []config.LocalPath + var localPaths []stores.LocalPath if pssb := cctx.StringSlice("pre-sealed-sectors"); len(pssb) != 0 { log.Infof("Setting up storage config with presealed sectors: %v", pssb) @@ -181,7 +181,7 @@ var initCmd = &cli.Command{ if err != nil { return err } - localPaths = append(localPaths, config.LocalPath{ + localPaths = append(localPaths, stores.LocalPath{ Path: psp, }) } @@ -202,12 +202,12 @@ var initCmd = &cli.Command{ return xerrors.Errorf("persisting storage metadata (%s): %w", filepath.Join(lr.Path(), "sectorstore.json"), err) } - localPaths = append(localPaths, config.LocalPath{ + localPaths = append(localPaths, stores.LocalPath{ Path: lr.Path(), }) } - if err := lr.SetStorage(func(sc *config.StorageConfig) { + if err := lr.SetStorage(func(sc *stores.StorageConfig) { sc.StoragePaths = append(sc.StoragePaths, localPaths...) }); err != nil { return xerrors.Errorf("set storage config: %w", err) @@ -394,7 +394,7 @@ func storageMinerInit(ctx context.Context, cctx *cli.Context, api lapi.FullNode, return err } - ppt, spt, err := lapi.ProofTypeFromSectorSize(ssize) + ppt, spt, err := ffiwrapper.ProofTypeFromSectorSize(ssize) if err != nil { return err } @@ -404,10 +404,15 @@ func storageMinerInit(ctx context.Context, cctx *cli.Context, api lapi.FullNode, return xerrors.Errorf("getting id address: %w", err) } + sa, err := modules.StorageAuth(ctx, api) + if err != nil { + return err + } + smgr, err := sectorstorage.New(ctx, lr, stores.NewIndex(), &ffiwrapper.Config{ SealProofType: spt, PoStProofType: ppt, - }, config.Storage{true, true, true}, nil, api) + }, sectorstorage.SealerConfig{true, true, true}, nil, sa) if err != nil { return err } diff --git a/cmd/lotus-storage-miner/workers.go b/cmd/lotus-storage-miner/workers.go index 71a6431ab..9ba8ca79c 100644 --- a/cmd/lotus-storage-miner/workers.go +++ b/cmd/lotus-storage-miner/workers.go @@ -2,8 +2,8 @@ package main import ( "fmt" - "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/chain/types" + "github.com/filecoin-project/lotus/storage/sectorstorage" "gopkg.in/urfave/cli.v2" "sort" @@ -37,7 +37,7 @@ var workersListCmd = &cli.Command{ type sortableStat struct { id uint64 - api.WorkerStats + sectorstorage.WorkerStats } st := make([]sortableStat, 0, len(stats)) diff --git a/node/builder.go b/node/builder.go index 9a8ac88b4..87869df66 100644 --- a/node/builder.go +++ b/node/builder.go @@ -263,6 +263,7 @@ func Online() Option { // Storage miner ApplyIf(func(s *Settings) bool { return s.nodeType == repo.StorageMiner }, Override(new(api.Common), From(new(common.CommonAPI))), + Override(new(sectorstorage.StorageAuth), modules.StorageAuth), Override(new(*stores.Index), stores.NewIndex), Override(new(stores.SectorIndex), From(new(*stores.Index))), @@ -384,7 +385,7 @@ func ConfigStorageMiner(c interface{}) Option { return Options( ConfigCommon(&cfg.Common), - Override(new(config.Storage), cfg.Storage), + Override(new(sectorstorage.SealerConfig), cfg.Storage), ) } diff --git a/node/config/def.go b/node/config/def.go index 70fddf64a..9a85ed43e 100644 --- a/node/config/def.go +++ b/node/config/def.go @@ -2,6 +2,7 @@ package config import ( "encoding" + "github.com/filecoin-project/lotus/storage/sectorstorage" "time" ) @@ -23,7 +24,7 @@ type FullNode struct { type StorageMiner struct { Common - Storage Storage + Storage sectorstorage.SealerConfig } // API contains configs for API endpoint @@ -51,14 +52,6 @@ type Metrics struct { PubsubTracing bool } -// // Storage Miner -type Storage struct { - // Local worker config - AllowPreCommit1 bool - AllowPreCommit2 bool - AllowCommit bool -} - func defCommon() Common { return Common{ API: API{ @@ -90,7 +83,7 @@ func DefaultStorageMiner() *StorageMiner { cfg := &StorageMiner{ Common: defCommon(), - Storage: Storage{ + Storage: sectorstorage.SealerConfig{ AllowPreCommit1: true, AllowPreCommit2: true, AllowCommit: true, diff --git a/node/config/storage.go b/node/config/storage.go index 834447c3a..04240fb42 100644 --- a/node/config/storage.go +++ b/node/config/storage.go @@ -2,6 +2,7 @@ package config import ( "encoding/json" + "github.com/filecoin-project/lotus/storage/sectorstorage/stores" "io" "io/ioutil" "os" @@ -9,16 +10,7 @@ import ( "golang.org/x/xerrors" ) -type LocalPath struct { - Path string -} - -// .lotusstorage/storage.json -type StorageConfig struct { - StoragePaths []LocalPath -} - -func StorageFromFile(path string, def *StorageConfig) (*StorageConfig, error) { +func StorageFromFile(path string, def *stores.StorageConfig) (*stores.StorageConfig, error) { file, err := os.Open(path) switch { case os.IsNotExist(err): @@ -34,8 +26,8 @@ func StorageFromFile(path string, def *StorageConfig) (*StorageConfig, error) { return StorageFromReader(file) } -func StorageFromReader(reader io.Reader) (*StorageConfig, error) { - var cfg StorageConfig +func StorageFromReader(reader io.Reader) (*stores.StorageConfig, error) { + var cfg stores.StorageConfig err := json.NewDecoder(reader).Decode(&cfg) if err != nil { return nil, err @@ -44,7 +36,7 @@ func StorageFromReader(reader io.Reader) (*StorageConfig, error) { return &cfg, nil } -func WriteStorageFile(path string, config StorageConfig) error { +func WriteStorageFile(path string, config stores.StorageConfig) error { b, err := json.MarshalIndent(config, "", " ") if err != nil { return xerrors.Errorf("marshaling storage config: %w", err) diff --git a/node/impl/client/client.go b/node/impl/client/client.go index 66d9ae8ed..c27c65b73 100644 --- a/node/impl/client/client.go +++ b/node/impl/client/client.go @@ -3,6 +3,7 @@ package client import ( "context" "errors" + "github.com/filecoin-project/lotus/storage/sectorstorage/ffiwrapper" "io" "os" @@ -83,7 +84,7 @@ func (a *API) ClientStartDeal(ctx context.Context, params *api.StartDealParams) return nil, xerrors.Errorf("failed checking miners sector size: %w", err) } - rt, _, err := api.ProofTypeFromSectorSize(ssize) + rt, _, err := ffiwrapper.ProofTypeFromSectorSize(ssize) if err != nil { return nil, xerrors.Errorf("bad sector size: %w", err) } diff --git a/storage/sectorstorage/worker_remote.go b/node/impl/remoteworker.go similarity index 59% rename from storage/sectorstorage/worker_remote.go rename to node/impl/remoteworker.go index ffd96f188..3e65defe1 100644 --- a/storage/sectorstorage/worker_remote.go +++ b/node/impl/remoteworker.go @@ -1,32 +1,34 @@ -package sectorstorage +package impl import ( "context" "net/http" + "golang.org/x/xerrors" + "github.com/filecoin-project/specs-actors/actors/abi" storage2 "github.com/filecoin-project/specs-storage/storage" - "golang.org/x/xerrors" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api/client" "github.com/filecoin-project/lotus/lib/jsonrpc" + "github.com/filecoin-project/lotus/storage/sectorstorage" ) -type remote struct { +type remoteWorker struct { api.WorkerApi closer jsonrpc.ClientCloser } -func (r *remote) NewSector(ctx context.Context, sector abi.SectorID) error { +func (r *remoteWorker) NewSector(ctx context.Context, sector abi.SectorID) error { return xerrors.New("unsupported") } -func (r *remote) AddPiece(ctx context.Context, sector abi.SectorID, pieceSizes []abi.UnpaddedPieceSize, newPieceSize abi.UnpaddedPieceSize, pieceData storage2.Data) (abi.PieceInfo, error) { +func (r *remoteWorker) AddPiece(ctx context.Context, sector abi.SectorID, pieceSizes []abi.UnpaddedPieceSize, newPieceSize abi.UnpaddedPieceSize, pieceData storage2.Data) (abi.PieceInfo, error) { return abi.PieceInfo{}, xerrors.New("unsupported") } -func ConnectRemote(ctx context.Context, fa api.Common, url string) (*remote, error) { +func connectRemoteWorker(ctx context.Context, fa api.Common, url string) (*remoteWorker, error) { token, err := fa.AuthNew(ctx, []api.Permission{"admin"}) if err != nil { return nil, xerrors.Errorf("creating auth token for remote connection: %w", err) @@ -40,12 +42,12 @@ func ConnectRemote(ctx context.Context, fa api.Common, url string) (*remote, err return nil, xerrors.Errorf("creating jsonrpc client: %w", err) } - return &remote{wapi, closer}, nil + return &remoteWorker{wapi, closer}, nil } -func (r *remote) Close() error { +func (r *remoteWorker) Close() error { r.closer() return nil } -var _ Worker = &remote{} +var _ sectorstorage.Worker = &remoteWorker{} diff --git a/node/impl/storminer.go b/node/impl/storminer.go index fd95ec3ef..592c74cc9 100644 --- a/node/impl/storminer.go +++ b/node/impl/storminer.go @@ -50,7 +50,7 @@ func (sm *StorageMinerAPI) ServeRemote(w http.ResponseWriter, r *http.Request) { sm.StorageMgr.ServeHTTP(w, r) } -func (sm *StorageMinerAPI) WorkerStats(context.Context) (map[uint64]api.WorkerStats, error) { +func (sm *StorageMinerAPI) WorkerStats(context.Context) (map[uint64]sectorstorage.WorkerStats, error) { return sm.StorageMgr.WorkerStats(), nil } @@ -149,7 +149,7 @@ func (sm *StorageMinerAPI) SectorsUpdate(ctx context.Context, id abi.SectorNumbe } func (sm *StorageMinerAPI) WorkerConnect(ctx context.Context, url string) error { - w, err := sectorstorage.ConnectRemote(ctx, sm, url) + w, err := connectRemoteWorker(ctx, sm, url) if err != nil { return xerrors.Errorf("connecting remote storage failed: %w", err) } diff --git a/node/modules/storageminer.go b/node/modules/storageminer.go index 8779eb1e4..3291a5dde 100644 --- a/node/modules/storageminer.go +++ b/node/modules/storageminer.go @@ -2,6 +2,7 @@ package modules import ( "context" + "net/http" "reflect" "github.com/ipfs/go-bitswap" @@ -43,7 +44,6 @@ import ( "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/markets/retrievaladapter" "github.com/filecoin-project/lotus/miner" - "github.com/filecoin-project/lotus/node/config" "github.com/filecoin-project/lotus/node/modules/dtypes" "github.com/filecoin-project/lotus/node/modules/helpers" "github.com/filecoin-project/lotus/node/repo" @@ -92,7 +92,7 @@ func ProofsConfig(maddr dtypes.MinerAddress, fnapi lapi.FullNode) (*ffiwrapper.C return nil, err } - ppt, spt, err := lapi.ProofTypeFromSectorSize(ssize) + ppt, spt, err := ffiwrapper.ProofTypeFromSectorSize(ssize) if err != nil { return nil, xerrors.Errorf("bad sector size: %w", err) } @@ -132,7 +132,7 @@ func StorageMiner(mctx helpers.MetricsCtx, lc fx.Lifecycle, api lapi.FullNode, h return nil, err } - ppt, _, err := lapi.ProofTypeFromSectorSize(sealer.SectorSize()) + ppt, _, err := ffiwrapper.ProofTypeFromSectorSize(sealer.SectorSize()) if err != nil { return nil, xerrors.Errorf("bad sector size: %w", err) } @@ -320,7 +320,7 @@ func StorageProvider(ctx helpers.MetricsCtx, fapi lapi.FullNode, h host.Host, ds return nil, err } - rt, _, err := lapi.ProofTypeFromSectorSize(ssize) + rt, _, err := ffiwrapper.ProofTypeFromSectorSize(ssize) if err != nil { return nil, err } @@ -339,10 +339,10 @@ func RetrievalProvider(h host.Host, miner *storage.Miner, sealer sectorstorage.S return retrievalimpl.NewProvider(address, adapter, network, pieceStore, ibs, ds) } -func SectorStorage(mctx helpers.MetricsCtx, lc fx.Lifecycle, ls stores.LocalStorage, si stores.SectorIndex, cfg *ffiwrapper.Config, sc config.Storage, urls sectorstorage.URLs, ca lapi.Common) (*sectorstorage.Manager, error) { +func SectorStorage(mctx helpers.MetricsCtx, lc fx.Lifecycle, ls stores.LocalStorage, si stores.SectorIndex, cfg *ffiwrapper.Config, sc sectorstorage.SealerConfig, urls sectorstorage.URLs, sa sectorstorage.StorageAuth) (*sectorstorage.Manager, error) { ctx := helpers.LifecycleCtx(mctx, lc) - sst, err := sectorstorage.New(ctx, ls, si, cfg, sc, urls, ca) + sst, err := sectorstorage.New(ctx, ls, si, cfg, sc, urls, sa) if err != nil { return nil, err } @@ -359,3 +359,14 @@ func SectorStorage(mctx helpers.MetricsCtx, lc fx.Lifecycle, ls stores.LocalStor return sst, nil } + +func StorageAuth(ctx helpers.MetricsCtx, ca lapi.Common) (sectorstorage.StorageAuth, error) { + token, err := ca.AuthNew(ctx, []lapi.Permission{"admin"}) + if err != nil { + return nil, xerrors.Errorf("creating storage auth header: %w", err) + } + + headers := http.Header{} + headers.Add("Authorization", "Bearer "+string(token)) + return sectorstorage.StorageAuth(headers), nil +} diff --git a/node/node_test.go b/node/node_test.go index 0c6cea60c..9205418cd 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -5,6 +5,7 @@ import ( "context" "crypto/rand" "github.com/filecoin-project/lotus/lib/lotuslog" + "github.com/filecoin-project/lotus/storage/mockstorage" "github.com/filecoin-project/lotus/storage/sectorstorage/ffiwrapper" "io/ioutil" "net/http/httptest" @@ -310,7 +311,7 @@ func mockSbBuilder(t *testing.T, nFull int, storage []int) ([]test.TestNode, []t if err != nil { t.Fatal(err) } - genm, k, err := mock.PreSeal(2048, maddr, nPreseal) + genm, k, err := mockstorage.PreSeal(2048, maddr, nPreseal) if err != nil { t.Fatal(err) } diff --git a/node/repo/fsrepo.go b/node/repo/fsrepo.go index b5798c754..60691640b 100644 --- a/node/repo/fsrepo.go +++ b/node/repo/fsrepo.go @@ -3,6 +3,7 @@ package repo import ( "encoding/json" "fmt" + "github.com/filecoin-project/lotus/storage/sectorstorage/stores" "io" "io/ioutil" "os" @@ -282,26 +283,26 @@ func (fsr *fsLockedRepo) Config() (interface{}, error) { return config.FromFile(fsr.join(fsConfig), defConfForType(fsr.repoType)) } -func (fsr *fsLockedRepo) GetStorage() (config.StorageConfig, error) { +func (fsr *fsLockedRepo) GetStorage() (stores.StorageConfig, error) { fsr.storageLk.Lock() defer fsr.storageLk.Unlock() return fsr.getStorage(nil) } -func (fsr *fsLockedRepo) getStorage(def *config.StorageConfig) (config.StorageConfig, error) { +func (fsr *fsLockedRepo) getStorage(def *stores.StorageConfig) (stores.StorageConfig, error) { c, err := config.StorageFromFile(fsr.join(fsStorageConfig), def) if err != nil { - return config.StorageConfig{}, err + return stores.StorageConfig{}, err } return *c, nil } -func (fsr *fsLockedRepo) SetStorage(c func(*config.StorageConfig)) error { +func (fsr *fsLockedRepo) SetStorage(c func(*stores.StorageConfig)) error { fsr.storageLk.Lock() defer fsr.storageLk.Unlock() - sc, err := fsr.getStorage(&config.StorageConfig{}) + sc, err := fsr.getStorage(&stores.StorageConfig{}) if err != nil { return xerrors.Errorf("get storage: %w", err) } diff --git a/node/repo/interface.go b/node/repo/interface.go index 135e58f86..f70fe4c0d 100644 --- a/node/repo/interface.go +++ b/node/repo/interface.go @@ -2,12 +2,12 @@ package repo import ( "errors" + "github.com/filecoin-project/lotus/storage/sectorstorage/stores" "github.com/ipfs/go-datastore" "github.com/multiformats/go-multiaddr" "github.com/filecoin-project/lotus/chain/types" - "github.com/filecoin-project/lotus/node/config" ) var ( @@ -38,8 +38,8 @@ type LockedRepo interface { // Returns config in this repo Config() (interface{}, error) - GetStorage() (config.StorageConfig, error) - SetStorage(func(*config.StorageConfig)) error + GetStorage() (stores.StorageConfig, error) + SetStorage(func(*stores.StorageConfig)) error // SetAPIEndpoint sets the endpoint of the current API // so it can be read by API clients diff --git a/node/repo/memrepo.go b/node/repo/memrepo.go index 805eab157..b51ce127a 100644 --- a/node/repo/memrepo.go +++ b/node/repo/memrepo.go @@ -41,12 +41,12 @@ type lockedMemRepo struct { tempDir string token *byte - sc *config.StorageConfig + sc *stores.StorageConfig } -func (lmem *lockedMemRepo) GetStorage() (config.StorageConfig, error) { +func (lmem *lockedMemRepo) GetStorage() (stores.StorageConfig, error) { if lmem.sc == nil { - lmem.sc = &config.StorageConfig{StoragePaths: []config.LocalPath{ + lmem.sc = &stores.StorageConfig{StoragePaths: []stores.LocalPath{ {Path: lmem.Path()}, }} } @@ -54,7 +54,7 @@ func (lmem *lockedMemRepo) GetStorage() (config.StorageConfig, error) { return *lmem.sc, nil } -func (lmem *lockedMemRepo) SetStorage(c func(*config.StorageConfig)) error { +func (lmem *lockedMemRepo) SetStorage(c func(*stores.StorageConfig)) error { _, _ = lmem.GetStorage() c(lmem.sc) @@ -75,8 +75,8 @@ func (lmem *lockedMemRepo) Path() string { } if lmem.t == StorageMiner { - if err := config.WriteStorageFile(filepath.Join(t, fsStorageConfig), config.StorageConfig{ - StoragePaths: []config.LocalPath{ + if err := config.WriteStorageFile(filepath.Join(t, fsStorageConfig), stores.StorageConfig{ + StoragePaths: []stores.LocalPath{ {Path: t}, }}); err != nil { panic(err) @@ -220,7 +220,7 @@ func (lmem *lockedMemRepo) Config() (interface{}, error) { return lmem.mem.configF(lmem.t), nil } -func (lmem *lockedMemRepo) Storage() (config.StorageConfig, error) { +func (lmem *lockedMemRepo) Storage() (stores.StorageConfig, error) { panic("implement me") } diff --git a/storage/sectorstorage/mock/preseal.go b/storage/mockstorage/preseal.go similarity index 88% rename from storage/sectorstorage/mock/preseal.go rename to storage/mockstorage/preseal.go index 20a4377cd..6521cb723 100644 --- a/storage/sectorstorage/mock/preseal.go +++ b/storage/mockstorage/preseal.go @@ -1,18 +1,19 @@ -package mock +package mockstorage import ( "github.com/filecoin-project/go-address" commcid "github.com/filecoin-project/go-fil-commcid" - "github.com/filecoin-project/lotus/storage/sectorstorage/zerocomm" + "github.com/filecoin-project/lotus/storage/sectorstorage/mock" "github.com/filecoin-project/specs-actors/actors/abi" "github.com/filecoin-project/specs-actors/actors/abi/big" "github.com/filecoin-project/specs-actors/actors/builtin/market" "github.com/filecoin-project/specs-actors/actors/crypto" - "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/wallet" "github.com/filecoin-project/lotus/genesis" + "github.com/filecoin-project/lotus/storage/sectorstorage/ffiwrapper" + "github.com/filecoin-project/lotus/storage/sectorstorage/zerocomm" ) func PreSeal(ssize abi.SectorSize, maddr address.Address, sectors int) (*genesis.Miner, *types.KeyInfo, error) { @@ -30,7 +31,7 @@ func PreSeal(ssize abi.SectorSize, maddr address.Address, sectors int) (*genesis Sectors: make([]*genesis.PreSeal, sectors), } - _, st, err := api.ProofTypeFromSectorSize(ssize) + _, st, err := ffiwrapper.ProofTypeFromSectorSize(ssize) if err != nil { return nil, nil, err } @@ -41,7 +42,7 @@ func PreSeal(ssize abi.SectorSize, maddr address.Address, sectors int) (*genesis preseal.ProofType = st preseal.CommD = zerocomm.ZeroPieceCommitment(abi.PaddedPieceSize(ssize).Unpadded()) d, _ := commcid.CIDToPieceCommitmentV1(preseal.CommD) - r := commDR(d) + r := mock.CommDR(d) preseal.CommR = commcid.ReplicaCommitmentV1ToCID(r[:]) preseal.SectorID = abi.SectorNumber(i + 1) preseal.Deal = market.DealProposal{ diff --git a/storage/sealing/garbage.go b/storage/sealing/garbage.go index 4903abf25..1f989fc1f 100644 --- a/storage/sealing/garbage.go +++ b/storage/sealing/garbage.go @@ -2,13 +2,13 @@ package sealing import ( "context" + "github.com/filecoin-project/lotus/storage/sectorstorage/ffiwrapper" "io" "golang.org/x/xerrors" "github.com/filecoin-project/specs-actors/actors/abi" - "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/lib/nullreader" ) @@ -49,7 +49,7 @@ func (m *Sealing) PledgeSector() error { size := abi.PaddedPieceSize(m.sealer.SectorSize()).Unpadded() - _, rt, err := api.ProofTypeFromSectorSize(m.sealer.SectorSize()) + _, rt, err := ffiwrapper.ProofTypeFromSectorSize(m.sealer.SectorSize()) if err != nil { log.Error(err) return diff --git a/storage/sealing/sealing.go b/storage/sealing/sealing.go index 6b78dd909..5f085216c 100644 --- a/storage/sealing/sealing.go +++ b/storage/sealing/sealing.go @@ -2,6 +2,7 @@ package sealing import ( "context" + "github.com/filecoin-project/lotus/storage/sectorstorage/ffiwrapper" "io" "github.com/filecoin-project/go-address" @@ -132,7 +133,7 @@ func (m *Sealing) SealPiece(ctx context.Context, size abi.UnpaddedPieceSize, r i return xerrors.Errorf("adding piece to sector: %w", err) } - _, rt, err := api.ProofTypeFromSectorSize(m.sealer.SectorSize()) + _, rt, err := ffiwrapper.ProofTypeFromSectorSize(m.sealer.SectorSize()) if err != nil { return xerrors.Errorf("bad sector size: %w", err) } diff --git a/storage/sectorstorage/ffiwrapper/config.go b/storage/sectorstorage/ffiwrapper/config.go index a2d79c410..9b1fc5f9a 100644 --- a/storage/sectorstorage/ffiwrapper/config.go +++ b/storage/sectorstorage/ffiwrapper/config.go @@ -55,3 +55,18 @@ func SectorSizeForRegisteredProof(p abi.RegisteredProof) (abi.SectorSize, error) return 0, fmt.Errorf("unsupported registered proof %d", p) } } + +func ProofTypeFromSectorSize(ssize abi.SectorSize) (abi.RegisteredProof, abi.RegisteredProof, error) { + switch ssize { + case 2 << 10: + return abi.RegisteredProof_StackedDRG2KiBPoSt, abi.RegisteredProof_StackedDRG2KiBSeal, nil + case 8 << 20: + return abi.RegisteredProof_StackedDRG8MiBPoSt, abi.RegisteredProof_StackedDRG8MiBSeal, nil + case 512 << 20: + return abi.RegisteredProof_StackedDRG512MiBPoSt, abi.RegisteredProof_StackedDRG512MiBSeal, nil + case 32 << 30: + return abi.RegisteredProof_StackedDRG32GiBPoSt, abi.RegisteredProof_StackedDRG32GiBSeal, nil + default: + return 0, 0, xerrors.Errorf("unsupported sector size for miner: %v", ssize) + } +} diff --git a/storage/sectorstorage/ffiwrapper/verifier_cgo.go b/storage/sectorstorage/ffiwrapper/verifier_cgo.go index 402e85fab..2de6137da 100644 --- a/storage/sectorstorage/ffiwrapper/verifier_cgo.go +++ b/storage/sectorstorage/ffiwrapper/verifier_cgo.go @@ -9,9 +9,10 @@ import ( "go.opencensus.io/trace" ffi "github.com/filecoin-project/filecoin-ffi" - "github.com/filecoin-project/lotus/storage/sectorstorage/stores" "github.com/filecoin-project/specs-actors/actors/abi" "github.com/filecoin-project/specs-storage/storage" + + "github.com/filecoin-project/lotus/storage/sectorstorage/stores" ) func (sb *Sealer) ComputeElectionPoSt(ctx context.Context, miner abi.ActorID, sectorInfo []abi.SectorInfo, challengeSeed abi.PoStRandomness, winners []abi.PoStCandidate) ([]abi.PoStProof, error) { diff --git a/storage/sectorstorage/worker_local.go b/storage/sectorstorage/localworker.go similarity index 94% rename from storage/sectorstorage/worker_local.go rename to storage/sectorstorage/localworker.go index 24d1e14df..e71a619f3 100644 --- a/storage/sectorstorage/worker_local.go +++ b/storage/sectorstorage/localworker.go @@ -12,7 +12,6 @@ import ( "github.com/filecoin-project/specs-actors/actors/abi" storage2 "github.com/filecoin-project/specs-storage/storage" - "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/storage/sectorstorage/ffiwrapper" "github.com/filecoin-project/lotus/storage/sectorstorage/sealtasks" "github.com/filecoin-project/lotus/storage/sectorstorage/stores" @@ -174,7 +173,7 @@ func (l *LocalWorker) Paths(ctx context.Context) ([]stores.StoragePath, error) { return l.localStore.Local(ctx) } -func (l *LocalWorker) Info(context.Context) (api.WorkerInfo, error) { +func (l *LocalWorker) Info(context.Context) (WorkerInfo, error) { hostname, err := os.Hostname() // TODO: allow overriding from config if err != nil { panic(err) @@ -187,17 +186,17 @@ func (l *LocalWorker) Info(context.Context) (api.WorkerInfo, error) { h, err := sysinfo.Host() if err != nil { - return api.WorkerInfo{}, xerrors.Errorf("getting host info: %w", err) + return WorkerInfo{}, xerrors.Errorf("getting host info: %w", err) } mem, err := h.Memory() if err != nil { - return api.WorkerInfo{}, xerrors.Errorf("getting memory info: %w", err) + return WorkerInfo{}, xerrors.Errorf("getting memory info: %w", err) } - return api.WorkerInfo{ + return WorkerInfo{ Hostname: hostname, - Resources: api.WorkerResources{ + Resources: WorkerResources{ MemPhysical: mem.Total, MemSwap: mem.VirtualTotal, MemReserved: mem.VirtualUsed + mem.Total - mem.Available, // TODO: sub this process diff --git a/storage/sectorstorage/manager.go b/storage/sectorstorage/manager.go index 97d645484..6f9d5877e 100644 --- a/storage/sectorstorage/manager.go +++ b/storage/sectorstorage/manager.go @@ -16,8 +16,6 @@ import ( "github.com/filecoin-project/specs-actors/actors/abi" "github.com/filecoin-project/specs-storage/storage" - "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/lotus/node/config" "github.com/filecoin-project/lotus/storage/sectorstorage/ffiwrapper" "github.com/filecoin-project/lotus/storage/sectorstorage/sealtasks" "github.com/filecoin-project/lotus/storage/sectorstorage/stores" @@ -37,11 +35,26 @@ type Worker interface { // Returns paths accessible to the worker Paths(context.Context) ([]stores.StoragePath, error) - Info(context.Context) (api.WorkerInfo, error) + Info(context.Context) (WorkerInfo, error) Close() error } +type WorkerInfo struct { + Hostname string + + Resources WorkerResources +} + +type WorkerResources struct { + MemPhysical uint64 + MemSwap uint64 + + MemReserved uint64 // Used by system / other processes + + GPUs []string +} + type SectorManager interface { SectorSize() abi.SectorSize @@ -76,7 +89,16 @@ type Manager struct { schedQueue *list.List // List[*workerRequest] } -func New(ctx context.Context, ls stores.LocalStorage, si stores.SectorIndex, cfg *ffiwrapper.Config, sc config.Storage, urls URLs, ca api.Common) (*Manager, error) { +type SealerConfig struct { + // Local worker config + AllowPreCommit1 bool + AllowPreCommit2 bool + AllowCommit bool +} + +type StorageAuth http.Header + +func New(ctx context.Context, ls stores.LocalStorage, si stores.SectorIndex, cfg *ffiwrapper.Config, sc SealerConfig, urls URLs, sa StorageAuth) (*Manager, error) { lstor, err := stores.NewLocal(ctx, ls, si, urls) if err != nil { return nil, err @@ -87,10 +109,7 @@ func New(ctx context.Context, ls stores.LocalStorage, si stores.SectorIndex, cfg return nil, xerrors.Errorf("creating prover instance: %w", err) } - token, err := ca.AuthNew(ctx, []api.Permission{"admin"}) - headers := http.Header{} - headers.Add("Authorization", "Bearer "+string(token)) - stor := stores.NewRemote(lstor, si, headers) + stor := stores.NewRemote(lstor, si, http.Header(sa)) m := &Manager{ scfg: cfg, @@ -150,8 +169,8 @@ func (m *Manager) AddLocalStorage(ctx context.Context, path string) error { return xerrors.Errorf("opening local path: %w", err) } - if err := m.ls.SetStorage(func(sc *config.StorageConfig) { - sc.StoragePaths = append(sc.StoragePaths, config.LocalPath{Path: path}) + if err := m.ls.SetStorage(func(sc *stores.StorageConfig) { + sc.StoragePaths = append(sc.StoragePaths, stores.LocalPath{Path: path}) }); err != nil { return xerrors.Errorf("get storage config: %w", err) } diff --git a/storage/sectorstorage/mock/mock.go b/storage/sectorstorage/mock/mock.go index 0591958c1..dc4ca54ef 100644 --- a/storage/sectorstorage/mock/mock.go +++ b/storage/sectorstorage/mock/mock.go @@ -17,7 +17,6 @@ import ( logging "github.com/ipfs/go-log" "golang.org/x/xerrors" - "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/storage/sectorstorage" "github.com/filecoin-project/lotus/storage/sectorstorage/ffiwrapper" ) @@ -37,7 +36,7 @@ type SectorMgr struct { type mockVerif struct{} func NewMockSectorMgr(threads int, ssize abi.SectorSize) *SectorMgr { - rt, _, err := api.ProofTypeFromSectorSize(ssize) + rt, _, err := ffiwrapper.ProofTypeFromSectorSize(ssize) if err != nil { panic(err) } diff --git a/storage/sectorstorage/mock/util.go b/storage/sectorstorage/mock/util.go index e37cf3552..2d2ebbfe2 100644 --- a/storage/sectorstorage/mock/util.go +++ b/storage/sectorstorage/mock/util.go @@ -1,20 +1,6 @@ package mock -import ( - "crypto/rand" - "io" - "io/ioutil" -) - -func randB(n uint64) []byte { - b, err := ioutil.ReadAll(io.LimitReader(rand.Reader, int64(n))) - if err != nil { - panic(err) - } - return b -} - -func commDR(in []byte) (out [32]byte) { +func CommDR(in []byte) (out [32]byte) { for i, b := range in { out[i] = ^b } diff --git a/storage/sectorstorage/resources.go b/storage/sectorstorage/resources.go index 4aafb5962..ab2e5170d 100644 --- a/storage/sectorstorage/resources.go +++ b/storage/sectorstorage/resources.go @@ -1,9 +1,10 @@ package sectorstorage import ( + "github.com/filecoin-project/specs-actors/actors/abi" + "github.com/filecoin-project/lotus/storage/sectorstorage/sealtasks" "github.com/filecoin-project/lotus/storage/sectorstorage/stores" - "github.com/filecoin-project/specs-actors/actors/abi" ) var FSOverheadSeal = map[stores.SectorFileType]int{ // 10x overheads diff --git a/storage/sectorstorage/roprov.go b/storage/sectorstorage/roprov.go index dfab863ff..694bcd2b2 100644 --- a/storage/sectorstorage/roprov.go +++ b/storage/sectorstorage/roprov.go @@ -3,10 +3,11 @@ package sectorstorage import ( "context" - "github.com/filecoin-project/lotus/storage/sectorstorage/stores" + "golang.org/x/xerrors" "github.com/filecoin-project/specs-actors/actors/abi" - "golang.org/x/xerrors" + + "github.com/filecoin-project/lotus/storage/sectorstorage/stores" ) type readonlyProvider struct { diff --git a/storage/sectorstorage/sched.go b/storage/sectorstorage/sched.go index d8e3d35a0..79f9c8971 100644 --- a/storage/sectorstorage/sched.go +++ b/storage/sectorstorage/sched.go @@ -1,11 +1,11 @@ package sectorstorage import ( - "github.com/filecoin-project/lotus/storage/sectorstorage/sealtasks" - "github.com/filecoin-project/specs-actors/actors/abi" "golang.org/x/xerrors" - "github.com/filecoin-project/lotus/api" + "github.com/filecoin-project/specs-actors/actors/abi" + + "github.com/filecoin-project/lotus/storage/sectorstorage/sealtasks" ) const mib = 1 << 20 @@ -39,7 +39,7 @@ func (r *workerRequest) respond(resp workerResponse) { type workerHandle struct { w Worker - info api.WorkerInfo + info WorkerInfo memUsedMin uint64 memUsedMax uint64 diff --git a/storage/sectorstorage/stats.go b/storage/sectorstorage/stats.go index 2cae1decb..70a5f341a 100644 --- a/storage/sectorstorage/stats.go +++ b/storage/sectorstorage/stats.go @@ -1,15 +1,22 @@ package sectorstorage -import "github.com/filecoin-project/lotus/api" +type WorkerStats struct { + Info WorkerInfo -func (m *Manager) WorkerStats() map[uint64]api.WorkerStats { + MemUsedMin uint64 + MemUsedMax uint64 + GpuUsed bool + CpuUse int +} + +func (m *Manager) WorkerStats() map[uint64]WorkerStats { m.workersLk.Lock() defer m.workersLk.Unlock() - out := map[uint64]api.WorkerStats{} + out := map[uint64]WorkerStats{} for id, handle := range m.workers { - out[uint64(id)] = api.WorkerStats{ + out[uint64(id)] = WorkerStats{ Info: handle.info, MemUsedMin: handle.memUsedMin, MemUsedMax: handle.memUsedMax, diff --git a/storage/sectorstorage/stores/http_handler.go b/storage/sectorstorage/stores/http_handler.go index 21903494b..14fbe04c8 100644 --- a/storage/sectorstorage/stores/http_handler.go +++ b/storage/sectorstorage/stores/http_handler.go @@ -10,7 +10,7 @@ import ( logging "github.com/ipfs/go-log/v2" "golang.org/x/xerrors" - "github.com/filecoin-project/lotus/lib/tarutil" + "github.com/filecoin-project/lotus/storage/sectorstorage/tarutil" ) var log = logging.Logger("stores") diff --git a/storage/sectorstorage/stores/local.go b/storage/sectorstorage/stores/local.go index a971b61b3..281475b1c 100644 --- a/storage/sectorstorage/stores/local.go +++ b/storage/sectorstorage/stores/local.go @@ -9,10 +9,9 @@ import ( "path/filepath" "sync" - "github.com/filecoin-project/specs-actors/actors/abi" "golang.org/x/xerrors" - "github.com/filecoin-project/lotus/node/config" + "github.com/filecoin-project/specs-actors/actors/abi" ) type StoragePath struct { @@ -34,9 +33,18 @@ type LocalStorageMeta struct { CanStore bool } +// .lotusstorage/storage.json +type StorageConfig struct { + StoragePaths []LocalPath +} + +type LocalPath struct { + Path string +} + type LocalStorage interface { - GetStorage() (config.StorageConfig, error) - SetStorage(func(*config.StorageConfig)) error + GetStorage() (StorageConfig, error) + SetStorage(func(*StorageConfig)) error } const MetaFile = "sectorstore.json" diff --git a/storage/sectorstorage/stores/remote.go b/storage/sectorstorage/stores/remote.go index 14550174f..349b73722 100644 --- a/storage/sectorstorage/stores/remote.go +++ b/storage/sectorstorage/stores/remote.go @@ -19,7 +19,7 @@ import ( "github.com/filecoin-project/specs-actors/actors/abi" - "github.com/filecoin-project/lotus/lib/tarutil" + "github.com/filecoin-project/lotus/storage/sectorstorage/tarutil" ) type Remote struct { diff --git a/lib/tarutil/systar.go b/storage/sectorstorage/tarutil/systar.go similarity index 100% rename from lib/tarutil/systar.go rename to storage/sectorstorage/tarutil/systar.go