From f9e381cb2a063f12c17cc328608cb8b6b9ffe3c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 23 Feb 2024 11:53:49 +0100 Subject: [PATCH] lotus-provider: Fetch params on startup when needed --- cmd/lotus-provider/deps/deps.go | 15 +++++++++++++++ cmd/lotus-provider/tasks/tasks.go | 16 ++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/cmd/lotus-provider/deps/deps.go b/cmd/lotus-provider/deps/deps.go index 31e3058c1..9ac775a7a 100644 --- a/cmd/lotus-provider/deps/deps.go +++ b/cmd/lotus-provider/deps/deps.go @@ -23,6 +23,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-jsonrpc/auth" + "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-statestore" "github.com/filecoin-project/lotus/api" @@ -32,6 +33,7 @@ import ( "github.com/filecoin-project/lotus/journal/fsjournal" "github.com/filecoin-project/lotus/lib/harmony/harmonydb" "github.com/filecoin-project/lotus/node/config" + "github.com/filecoin-project/lotus/node/modules" "github.com/filecoin-project/lotus/node/modules/dtypes" "github.com/filecoin-project/lotus/node/repo" "github.com/filecoin-project/lotus/provider" @@ -98,6 +100,7 @@ type Deps struct { LW *sealer.LocalWorker As *multictladdr.MultiAddressSelector Maddrs map[dtypes.MinerAddress]bool + ProofTypes map[abi.RegisteredSealProof]bool Stor *paths.Remote Si *paths.DBIndex LocalStore *paths.Local @@ -253,6 +256,18 @@ Get it with: jq .PrivateKey ~/.lotus-miner/keystore/MF2XI2BNNJ3XILLQOJUXMYLUMU`, } } } + if deps.ProofTypes == nil { + deps.ProofTypes = map[abi.RegisteredSealProof]bool{} + } + if len(deps.ProofTypes) == 0 { + for maddr := range deps.Maddrs { + spt, err := modules.SealProofType(maddr, deps.Full) + if err != nil { + return err + } + deps.ProofTypes[spt] = true + } + } return nil } diff --git a/cmd/lotus-provider/tasks/tasks.go b/cmd/lotus-provider/tasks/tasks.go index 00cb6480f..6ecd680d0 100644 --- a/cmd/lotus-provider/tasks/tasks.go +++ b/cmd/lotus-provider/tasks/tasks.go @@ -6,9 +6,11 @@ import ( logging "github.com/ipfs/go-log/v2" "github.com/samber/lo" + "golang.org/x/xerrors" "github.com/filecoin-project/lotus/cmd/lotus-provider/deps" "github.com/filecoin-project/lotus/lib/harmony/harmonytask" + "github.com/filecoin-project/lotus/node/modules" "github.com/filecoin-project/lotus/provider" "github.com/filecoin-project/lotus/provider/chainsched" "github.com/filecoin-project/lotus/provider/lpffi" @@ -37,6 +39,8 @@ func StartTasks(ctx context.Context, dependencies *deps.Deps) (*harmonytask.Task chainSched := chainsched.New(full) + var needProofParams bool + /////////////////////////////////////////////////////////////////////// ///// Task Selection /////////////////////////////////////////////////////////////////////// @@ -50,11 +54,13 @@ func StartTasks(ctx context.Context, dependencies *deps.Deps) (*harmonytask.Task return nil, err } activeTasks = append(activeTasks, wdPostTask, wdPoStSubmitTask, derlareRecoverTask) + needProofParams = true } if cfg.Subsystems.EnableWinningPost { winPoStTask := lpwinning.NewWinPostTask(cfg.Subsystems.WinningPostMaxTasks, db, lw, verif, full, maddrs) activeTasks = append(activeTasks, winPoStTask) + needProofParams = true } } @@ -93,6 +99,7 @@ func StartTasks(ctx context.Context, dependencies *deps.Deps) (*harmonytask.Task if cfg.Subsystems.EnablePoRepProof { porepTask := lpseal.NewPoRepTask(db, full, sp, slr, cfg.Subsystems.PoRepProofMaxTasks) activeTasks = append(activeTasks, porepTask) + needProofParams = true } if cfg.Subsystems.EnableMoveStorage { moveStorageTask := lpseal.NewMoveStorageTask(sp, slr, db, cfg.Subsystems.MoveStorageMaxTasks) @@ -103,6 +110,15 @@ func StartTasks(ctx context.Context, dependencies *deps.Deps) (*harmonytask.Task activeTasks = append(activeTasks, commitTask) } } + + if needProofParams { + for spt := range dependencies.ProofTypes { + if err := modules.GetParams(true)(spt); err != nil { + return nil, xerrors.Errorf("getting params: %w", err) + } + } + } + log.Infow("This lotus_provider instance handles", "miner_addresses", maddrs, "tasks", lo.Map(activeTasks, func(t harmonytask.TaskInterface, _ int) string { return t.TypeDetails().Name }))