From 5de17e903cc3f68dbbf672cd40f920206fc6f613 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 24 Mar 2020 20:38:00 +0100 Subject: [PATCH] storageminer: Config for local worker task types --- cmd/lotus-storage-miner/init.go | 2 +- node/builder.go | 6 +++++- node/config/def.go | 10 +++++++++- node/modules/storageminer.go | 5 +++-- storage/sectorstorage/manager.go | 14 +++++++++----- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/cmd/lotus-storage-miner/init.go b/cmd/lotus-storage-miner/init.go index 8bf135479..aa23f56ca 100644 --- a/cmd/lotus-storage-miner/init.go +++ b/cmd/lotus-storage-miner/init.go @@ -407,7 +407,7 @@ func storageMinerInit(ctx context.Context, cctx *cli.Context, api lapi.FullNode, smgr, err := sectorstorage.New(ctx, lr, stores.NewIndex(), §orbuilder.Config{ SealProofType: spt, PoStProofType: ppt, - }, nil, api) + }, config.Storage{true, true, true}, nil, api) if err != nil { return err } diff --git a/node/builder.go b/node/builder.go index 730b1b9ef..baac693a1 100644 --- a/node/builder.go +++ b/node/builder.go @@ -382,7 +382,11 @@ func ConfigStorageMiner(c interface{}) Option { return Error(xerrors.Errorf("invalid config from repo, got: %T", c)) } - return Options(ConfigCommon(&cfg.Common)) + return Options( + ConfigCommon(&cfg.Common), + + Override(new(config.Storage), cfg.Storage), + ) } func Repo(r repo.Repo) Option { diff --git a/node/config/def.go b/node/config/def.go index 69355aadd..edb00aa5e 100644 --- a/node/config/def.go +++ b/node/config/def.go @@ -53,6 +53,10 @@ type Metrics struct { // // Storage Miner type Storage struct { + // Local worker config + AllowPreCommit1 bool + AllowPreCommit2 bool + AllowCommit bool } func defCommon() Common { @@ -86,7 +90,11 @@ func DefaultStorageMiner() *StorageMiner { cfg := &StorageMiner{ Common: defCommon(), - Storage: Storage{}, + Storage: Storage{ + AllowPreCommit1: true, + AllowPreCommit2: true, + AllowCommit: true, + }, } cfg.Common.API.ListenAddress = "/ip4/127.0.0.1/tcp/2345/http" return cfg diff --git a/node/modules/storageminer.go b/node/modules/storageminer.go index 16713e745..010201de1 100644 --- a/node/modules/storageminer.go +++ b/node/modules/storageminer.go @@ -44,6 +44,7 @@ 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" @@ -338,8 +339,8 @@ 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 *sectorbuilder.Config, urls sectorstorage.URLs, ca lapi.Common) (*sectorstorage.Manager, error) { +func SectorStorage(mctx helpers.MetricsCtx, lc fx.Lifecycle, ls stores.LocalStorage, si stores.SectorIndex, cfg *sectorbuilder.Config, sc config.Storage, urls sectorstorage.URLs, ca lapi.Common) (*sectorstorage.Manager, error) { ctx := helpers.LifecycleCtx(mctx, lc) - return sectorstorage.New(ctx, ls, si, cfg, urls, ca) + return sectorstorage.New(ctx, ls, si, cfg, sc, urls, ca) } diff --git a/storage/sectorstorage/manager.go b/storage/sectorstorage/manager.go index d198c88ec..843d841cb 100644 --- a/storage/sectorstorage/manager.go +++ b/storage/sectorstorage/manager.go @@ -74,7 +74,7 @@ type Manager struct { schedQueue *list.List // List[*workerRequest] } -func New(ctx context.Context, ls stores.LocalStorage, si stores.SectorIndex, cfg *sectorbuilder.Config, urls URLs, ca api.Common) (*Manager, error) { +func New(ctx context.Context, ls stores.LocalStorage, si stores.SectorIndex, cfg *sectorbuilder.Config, sc config.Storage, urls URLs, ca api.Common) (*Manager, error) { lstor, err := stores.NewLocal(ctx, ls, si, urls) if err != nil { return nil, err @@ -114,12 +114,16 @@ func New(ctx context.Context, ls stores.LocalStorage, si stores.SectorIndex, cfg go m.runSched() + localTasks := []sealtasks.TaskType{ + sealtasks.TTAddPiece, sealtasks.TTCommit1, sealtasks.TTFinalize, + } + if sc.AllowPreCommit1 { localTasks = append(localTasks, sealtasks.TTPreCommit1)} + if sc.AllowPreCommit2 { localTasks = append(localTasks, sealtasks.TTPreCommit2)} + if sc.AllowCommit { localTasks = append(localTasks, sealtasks.TTCommit2)} + err = m.AddWorker(ctx, NewLocalWorker(WorkerConfig{ SealProof: cfg.SealProofType, - TaskTypes: []sealtasks.TaskType{ - sealtasks.TTAddPiece, sealtasks.TTCommit1, sealtasks.TTFinalize, - sealtasks.TTPreCommit1, sealtasks.TTPreCommit2, sealtasks.TTCommit2, // TODO: Config - }, + TaskTypes: localTasks, }, stor, lstor, si)) if err != nil { return nil, xerrors.Errorf("adding local worker: %w", err)