Skip to content

Commit

Permalink
lotus-provider: Fetch params on startup when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Feb 23, 2024
1 parent b691adc commit 07cec20
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cmd/lotus-provider/deps/deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"encoding/base64"
"errors"
"fmt"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/lotus/node/modules"
"net"
"net/http"
"os"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down
16 changes: 16 additions & 0 deletions cmd/lotus-provider/tasks/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package tasks

import (
"context"
"github.com/filecoin-project/lotus/node/modules"
"golang.org/x/xerrors"

logging "github.com/ipfs/go-log/v2"
"github.com/samber/lo"
Expand Down Expand Up @@ -37,6 +39,8 @@ func StartTasks(ctx context.Context, dependencies *deps.Deps) (*harmonytask.Task

chainSched := chainsched.New(full)

var needProofParams bool

///////////////////////////////////////////////////////////////////////
///// Task Selection
///////////////////////////////////////////////////////////////////////
Expand All @@ -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
}
}

Expand Down Expand Up @@ -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)
Expand All @@ -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 }))
Expand Down

0 comments on commit 07cec20

Please sign in to comment.