workers: WorkerType mehdod on SealTask
This commit is contained in:
parent
56b97e1386
commit
a53dc5a7c7
@ -352,7 +352,11 @@ func handleMiningInfo(ctx context.Context, cctx *cli.Context, fullapi v0api.Full
|
|||||||
return xerrors.Errorf("getting worker stats: %w", err)
|
return xerrors.Errorf("getting worker stats: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var nseal, nwdpost, nwinpost int
|
workersByType := map[string]int{
|
||||||
|
sealtasks.WorkerSealing: 0,
|
||||||
|
sealtasks.WorkerWindowPoSt: 0,
|
||||||
|
sealtasks.WorkerWinningPoSt: 0,
|
||||||
|
}
|
||||||
|
|
||||||
wloop:
|
wloop:
|
||||||
for _, st := range ws {
|
for _, st := range ws {
|
||||||
@ -361,19 +365,18 @@ func handleMiningInfo(ctx context.Context, cctx *cli.Context, fullapi v0api.Full
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, task := range st.Tasks {
|
for _, task := range st.Tasks {
|
||||||
if task == sealtasks.TTGenerateWindowPoSt {
|
if task.WorkerType() != sealtasks.WorkerSealing {
|
||||||
nwdpost++
|
workersByType[task.WorkerType()]++
|
||||||
continue wloop
|
|
||||||
}
|
|
||||||
if task == sealtasks.TTGenerateWinningPoSt {
|
|
||||||
nwinpost++
|
|
||||||
continue wloop
|
continue wloop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nseal++
|
workersByType[sealtasks.WorkerSealing]++
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Workers: Seal(%d) WdPoSt(%d) WinPoSt(%d)\n", nseal, nwdpost, nwinpost)
|
fmt.Printf("Workers: Seal(%d) WdPoSt(%d) WinPoSt(%d)\n",
|
||||||
|
workersByType[sealtasks.WorkerSealing],
|
||||||
|
workersByType[sealtasks.WorkerWindowPoSt],
|
||||||
|
workersByType[sealtasks.WorkerWinningPoSt])
|
||||||
}
|
}
|
||||||
|
|
||||||
if cctx.IsSet("blocks") {
|
if cctx.IsSet("blocks") {
|
||||||
|
@ -274,51 +274,54 @@ var runCmd = &cli.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var taskTypes []sealtasks.TaskType
|
var taskTypes []sealtasks.TaskType
|
||||||
|
var workerType string
|
||||||
|
|
||||||
exclusiveSet := false
|
|
||||||
if cctx.Bool("windowpost") {
|
if cctx.Bool("windowpost") {
|
||||||
exclusiveSet = true
|
workerType = sealtasks.WorkerWindowPoSt
|
||||||
taskTypes = append(taskTypes, sealtasks.TTGenerateWindowPoSt)
|
taskTypes = append(taskTypes, sealtasks.TTGenerateWindowPoSt)
|
||||||
}
|
}
|
||||||
if cctx.Bool("winningpost") {
|
if cctx.Bool("winningpost") {
|
||||||
exclusiveSet = true
|
workerType = sealtasks.WorkerWinningPoSt
|
||||||
taskTypes = append(taskTypes, sealtasks.TTGenerateWinningPoSt)
|
taskTypes = append(taskTypes, sealtasks.TTGenerateWinningPoSt)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !exclusiveSet {
|
if workerType == "" {
|
||||||
|
workerType = sealtasks.WorkerSealing
|
||||||
taskTypes = append(taskTypes, sealtasks.TTFetch, sealtasks.TTCommit1, sealtasks.TTProveReplicaUpdate1, sealtasks.TTFinalize, sealtasks.TTFinalizeReplicaUpdate)
|
taskTypes = append(taskTypes, sealtasks.TTFetch, sealtasks.TTCommit1, sealtasks.TTProveReplicaUpdate1, sealtasks.TTFinalize, sealtasks.TTFinalizeReplicaUpdate)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!exclusiveSet || cctx.IsSet("addpiece")) && cctx.Bool("addpiece") {
|
if (workerType != sealtasks.WorkerSealing || cctx.IsSet("addpiece")) && cctx.Bool("addpiece") {
|
||||||
taskTypes = append(taskTypes, sealtasks.TTAddPiece)
|
taskTypes = append(taskTypes, sealtasks.TTAddPiece)
|
||||||
}
|
}
|
||||||
if (!exclusiveSet || cctx.IsSet("precommit1")) && cctx.Bool("precommit1") {
|
if (workerType != sealtasks.WorkerSealing || cctx.IsSet("precommit1")) && cctx.Bool("precommit1") {
|
||||||
taskTypes = append(taskTypes, sealtasks.TTPreCommit1)
|
taskTypes = append(taskTypes, sealtasks.TTPreCommit1)
|
||||||
}
|
}
|
||||||
if (!exclusiveSet || cctx.IsSet("unseal")) && cctx.Bool("unseal") {
|
if (workerType != sealtasks.WorkerSealing || cctx.IsSet("unseal")) && cctx.Bool("unseal") {
|
||||||
taskTypes = append(taskTypes, sealtasks.TTUnseal)
|
taskTypes = append(taskTypes, sealtasks.TTUnseal)
|
||||||
}
|
}
|
||||||
if (!exclusiveSet || cctx.IsSet("precommit2")) && cctx.Bool("precommit2") {
|
if (workerType != sealtasks.WorkerSealing || cctx.IsSet("precommit2")) && cctx.Bool("precommit2") {
|
||||||
taskTypes = append(taskTypes, sealtasks.TTPreCommit2)
|
taskTypes = append(taskTypes, sealtasks.TTPreCommit2)
|
||||||
}
|
}
|
||||||
if (!exclusiveSet || cctx.IsSet("commit")) && cctx.Bool("commit") {
|
if (workerType != sealtasks.WorkerSealing || cctx.IsSet("commit")) && cctx.Bool("commit") {
|
||||||
taskTypes = append(taskTypes, sealtasks.TTCommit2)
|
taskTypes = append(taskTypes, sealtasks.TTCommit2)
|
||||||
}
|
}
|
||||||
if (!exclusiveSet || cctx.IsSet("replica-update")) && cctx.Bool("replica-update") {
|
if (workerType != sealtasks.WorkerSealing || cctx.IsSet("replica-update")) && cctx.Bool("replica-update") {
|
||||||
taskTypes = append(taskTypes, sealtasks.TTReplicaUpdate)
|
taskTypes = append(taskTypes, sealtasks.TTReplicaUpdate)
|
||||||
}
|
}
|
||||||
if (!exclusiveSet || cctx.IsSet("prove-replica-update2")) && cctx.Bool("prove-replica-update2") {
|
if (workerType != sealtasks.WorkerSealing || cctx.IsSet("prove-replica-update2")) && cctx.Bool("prove-replica-update2") {
|
||||||
taskTypes = append(taskTypes, sealtasks.TTProveReplicaUpdate2)
|
taskTypes = append(taskTypes, sealtasks.TTProveReplicaUpdate2)
|
||||||
}
|
}
|
||||||
if (!exclusiveSet || cctx.IsSet("regen-sector-key")) && cctx.Bool("regen-sector-key") {
|
if (workerType != sealtasks.WorkerSealing || cctx.IsSet("regen-sector-key")) && cctx.Bool("regen-sector-key") {
|
||||||
taskTypes = append(taskTypes, sealtasks.TTRegenSectorKey)
|
taskTypes = append(taskTypes, sealtasks.TTRegenSectorKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(taskTypes) == 0 {
|
if len(taskTypes) == 0 {
|
||||||
return xerrors.Errorf("no task types specified")
|
return xerrors.Errorf("no task types specified")
|
||||||
}
|
}
|
||||||
if exclusiveSet && len(taskTypes) != 1 {
|
for _, taskType := range taskTypes {
|
||||||
return xerrors.Errorf("PoSt workers only support a single task type; have %v", taskTypes)
|
if taskType.WorkerType() != workerType {
|
||||||
|
return xerrors.Errorf("expected all task types to be for %s worker, but task %s is for %s worker", workerType, taskType, taskType.WorkerType())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open repo
|
// Open repo
|
||||||
|
17
extern/sector-storage/sealtasks/task.go
vendored
17
extern/sector-storage/sealtasks/task.go
vendored
@ -66,6 +66,23 @@ var shortNames = map[TaskType]string{
|
|||||||
TTGenerateWinningPoSt: "WNP",
|
TTGenerateWinningPoSt: "WNP",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
WorkerSealing = "Sealing"
|
||||||
|
WorkerWinningPoSt = "WinPost"
|
||||||
|
WorkerWindowPoSt = "WdPoSt"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (a TaskType) WorkerType() string {
|
||||||
|
switch a {
|
||||||
|
case TTGenerateWindowPoSt:
|
||||||
|
return WorkerWinningPoSt
|
||||||
|
case WorkerWinningPoSt:
|
||||||
|
return WorkerWindowPoSt
|
||||||
|
default:
|
||||||
|
return WorkerSealing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (a TaskType) MuchLess(b TaskType) (bool, bool) {
|
func (a TaskType) MuchLess(b TaskType) (bool, bool) {
|
||||||
oa, ob := order[a], order[b]
|
oa, ob := order[a], order[b]
|
||||||
oneNegative := oa^ob < 0
|
oneNegative := oa^ob < 0
|
||||||
|
Loading…
Reference in New Issue
Block a user