lotus-provider: Fetch params on startup when needed

This commit is contained in:
Łukasz Magiera 2024-02-23 11:53:49 +01:00
parent b691adc487
commit f9e381cb2a
2 changed files with 31 additions and 0 deletions

View File

@ -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
}

View File

@ -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 }))