2020-04-17 22:02:04 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2020-06-04 23:38:38 +00:00
|
|
|
"os"
|
2020-09-23 16:53:03 +00:00
|
|
|
"strconv"
|
2020-06-04 23:38:38 +00:00
|
|
|
"text/tabwriter"
|
2020-06-02 19:53:24 +00:00
|
|
|
|
2020-07-14 12:31:15 +00:00
|
|
|
"github.com/fatih/color"
|
2020-06-04 23:38:38 +00:00
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
"golang.org/x/xerrors"
|
|
|
|
|
2020-11-26 07:02:43 +00:00
|
|
|
"github.com/filecoin-project/go-address"
|
|
|
|
"github.com/filecoin-project/go-state-types/abi"
|
2020-09-12 03:07:52 +00:00
|
|
|
"github.com/filecoin-project/lotus/api/apibstore"
|
|
|
|
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
|
|
|
"github.com/filecoin-project/lotus/chain/store"
|
2020-04-17 22:02:04 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
|
|
|
lcli "github.com/filecoin-project/lotus/cli"
|
2020-11-26 07:02:43 +00:00
|
|
|
"github.com/filecoin-project/specs-storage/storage"
|
2020-04-17 22:02:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var provingCmd = &cli.Command{
|
2020-06-15 09:43:42 +00:00
|
|
|
Name: "proving",
|
|
|
|
Usage: "View proving information",
|
2020-04-17 22:02:04 +00:00
|
|
|
Subcommands: []*cli.Command{
|
|
|
|
provingInfoCmd,
|
|
|
|
provingDeadlinesCmd,
|
2020-09-23 16:53:03 +00:00
|
|
|
provingDeadlineInfoCmd,
|
2020-06-22 08:00:29 +00:00
|
|
|
provingFaultsCmd,
|
2020-11-26 07:02:43 +00:00
|
|
|
provingCheckProvableCmd,
|
2020-06-22 08:00:29 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
var provingFaultsCmd = &cli.Command{
|
|
|
|
Name: "faults",
|
|
|
|
Usage: "View the currently known proving faulty sectors information",
|
|
|
|
Action: func(cctx *cli.Context) error {
|
2020-07-14 12:31:15 +00:00
|
|
|
color.NoColor = !cctx.Bool("color")
|
|
|
|
|
2020-06-22 08:00:29 +00:00
|
|
|
nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer closer()
|
|
|
|
|
|
|
|
api, acloser, err := lcli.GetFullNodeAPI(cctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer acloser()
|
|
|
|
|
|
|
|
ctx := lcli.ReqContext(cctx)
|
|
|
|
|
2020-09-12 03:07:52 +00:00
|
|
|
stor := store.ActorStore(ctx, apibstore.NewAPIBlockstore(api))
|
|
|
|
|
2020-07-03 17:45:21 +00:00
|
|
|
maddr, err := getActorAddress(ctx, nodeApi, cctx.String("actor"))
|
2020-06-22 08:00:29 +00:00
|
|
|
if err != nil {
|
2020-07-03 17:35:20 +00:00
|
|
|
return err
|
2020-06-22 08:00:29 +00:00
|
|
|
}
|
|
|
|
|
2020-09-12 03:07:52 +00:00
|
|
|
mact, err := api.StateGetActor(ctx, maddr, types.EmptyTSK)
|
2020-06-24 02:14:20 +00:00
|
|
|
if err != nil {
|
2020-09-12 03:07:52 +00:00
|
|
|
return err
|
2020-06-24 02:14:20 +00:00
|
|
|
}
|
2020-09-12 03:07:52 +00:00
|
|
|
|
|
|
|
mas, err := miner.Load(stor, mact)
|
2020-06-24 02:14:20 +00:00
|
|
|
if err != nil {
|
2020-09-12 03:07:52 +00:00
|
|
|
return err
|
2020-06-24 02:14:20 +00:00
|
|
|
}
|
2020-09-12 03:07:52 +00:00
|
|
|
|
|
|
|
fmt.Printf("Miner: %s\n", color.BlueString("%s", maddr))
|
|
|
|
|
2020-06-24 02:14:20 +00:00
|
|
|
tw := tabwriter.NewWriter(os.Stdout, 2, 4, 2, ' ', 0)
|
2020-07-14 20:14:37 +00:00
|
|
|
_, _ = fmt.Fprintln(tw, "deadline\tpartition\tsectors")
|
2020-09-12 03:07:52 +00:00
|
|
|
err = mas.ForEachDeadline(func(dlIdx uint64, dl miner.Deadline) error {
|
2020-09-17 15:30:15 +00:00
|
|
|
return dl.ForEachPartition(func(partIdx uint64, part miner.Partition) error {
|
2020-09-17 08:17:14 +00:00
|
|
|
faults, err := part.FaultySectors()
|
2020-07-14 20:14:37 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-09-17 15:30:15 +00:00
|
|
|
return faults.ForEach(func(num uint64) error {
|
2020-07-14 20:14:37 +00:00
|
|
|
_, _ = fmt.Fprintf(tw, "%d\t%d\t%d\n", dlIdx, partIdx, num)
|
2020-09-12 03:07:52 +00:00
|
|
|
return nil
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2020-06-22 08:00:29 +00:00
|
|
|
}
|
2020-06-24 02:14:20 +00:00
|
|
|
return tw.Flush()
|
2020-04-17 22:02:04 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
var provingInfoCmd = &cli.Command{
|
2020-06-15 09:43:42 +00:00
|
|
|
Name: "info",
|
|
|
|
Usage: "View current state information",
|
2020-04-17 22:02:04 +00:00
|
|
|
Action: func(cctx *cli.Context) error {
|
2020-07-14 12:31:15 +00:00
|
|
|
color.NoColor = !cctx.Bool("color")
|
|
|
|
|
2020-04-17 22:02:04 +00:00
|
|
|
nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer closer()
|
|
|
|
|
|
|
|
api, acloser, err := lcli.GetFullNodeAPI(cctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer acloser()
|
|
|
|
|
|
|
|
ctx := lcli.ReqContext(cctx)
|
|
|
|
|
2020-07-03 17:45:21 +00:00
|
|
|
maddr, err := getActorAddress(ctx, nodeApi, cctx.String("actor"))
|
2020-04-17 22:02:04 +00:00
|
|
|
if err != nil {
|
2020-07-03 17:35:20 +00:00
|
|
|
return err
|
2020-04-17 22:02:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
head, err := api.ChainHead(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("getting chain head: %w", err)
|
|
|
|
}
|
|
|
|
|
2020-09-12 03:07:52 +00:00
|
|
|
mact, err := api.StateGetActor(ctx, maddr, head.Key())
|
2020-04-17 22:02:04 +00:00
|
|
|
if err != nil {
|
2020-09-12 03:07:52 +00:00
|
|
|
return err
|
2020-04-17 22:02:04 +00:00
|
|
|
}
|
|
|
|
|
2020-09-12 03:07:52 +00:00
|
|
|
stor := store.ActorStore(ctx, apibstore.NewAPIBlockstore(api))
|
|
|
|
|
|
|
|
mas, err := miner.Load(stor, mact)
|
2020-04-17 22:02:04 +00:00
|
|
|
if err != nil {
|
2020-09-12 03:07:52 +00:00
|
|
|
return err
|
2020-04-17 22:02:04 +00:00
|
|
|
}
|
|
|
|
|
2020-09-12 03:07:52 +00:00
|
|
|
cd, err := api.StateMinerProvingDeadline(ctx, maddr, head.Key())
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("getting miner info: %w", err)
|
2020-04-24 17:12:30 +00:00
|
|
|
}
|
|
|
|
|
2020-09-12 03:07:52 +00:00
|
|
|
fmt.Printf("Miner: %s\n", color.BlueString("%s", maddr))
|
2020-04-24 17:12:30 +00:00
|
|
|
|
2020-07-14 20:14:37 +00:00
|
|
|
proving := uint64(0)
|
|
|
|
faults := uint64(0)
|
|
|
|
recovering := uint64(0)
|
2020-09-12 03:07:52 +00:00
|
|
|
curDeadlineSectors := uint64(0)
|
2020-04-24 17:12:30 +00:00
|
|
|
|
2020-09-12 03:07:52 +00:00
|
|
|
if err := mas.ForEachDeadline(func(dlIdx uint64, dl miner.Deadline) error {
|
|
|
|
return dl.ForEachPartition(func(partIdx uint64, part miner.Partition) error {
|
|
|
|
if bf, err := part.LiveSectors(); err != nil {
|
|
|
|
return err
|
|
|
|
} else if count, err := bf.Count(); err != nil {
|
|
|
|
return err
|
|
|
|
} else {
|
|
|
|
proving += count
|
|
|
|
if dlIdx == cd.Index {
|
|
|
|
curDeadlineSectors += count
|
|
|
|
}
|
2020-07-14 20:14:37 +00:00
|
|
|
}
|
|
|
|
|
2020-09-17 08:17:14 +00:00
|
|
|
if bf, err := part.FaultySectors(); err != nil {
|
2020-09-12 03:07:52 +00:00
|
|
|
return err
|
|
|
|
} else if count, err := bf.Count(); err != nil {
|
|
|
|
return err
|
|
|
|
} else {
|
|
|
|
faults += count
|
2020-07-14 20:14:37 +00:00
|
|
|
}
|
|
|
|
|
2020-09-17 08:17:14 +00:00
|
|
|
if bf, err := part.RecoveringSectors(); err != nil {
|
2020-09-12 03:07:52 +00:00
|
|
|
return err
|
|
|
|
} else if count, err := bf.Count(); err != nil {
|
|
|
|
return err
|
|
|
|
} else {
|
|
|
|
recovering += count
|
2020-07-14 20:14:37 +00:00
|
|
|
}
|
2020-09-17 15:30:15 +00:00
|
|
|
|
|
|
|
return nil
|
2020-09-12 03:07:52 +00:00
|
|
|
})
|
|
|
|
}); err != nil {
|
|
|
|
return xerrors.Errorf("walking miner deadlines and partitions: %w", err)
|
2020-04-24 17:12:30 +00:00
|
|
|
}
|
|
|
|
|
2020-05-13 16:53:07 +00:00
|
|
|
var faultPerc float64
|
2020-07-14 20:14:37 +00:00
|
|
|
if proving > 0 {
|
|
|
|
faultPerc = float64(faults*10000/proving) / 100
|
2020-05-13 16:53:07 +00:00
|
|
|
}
|
|
|
|
|
2020-04-20 17:34:08 +00:00
|
|
|
fmt.Printf("Current Epoch: %d\n", cd.CurrentEpoch)
|
|
|
|
|
2020-09-12 03:07:52 +00:00
|
|
|
fmt.Printf("Proving Period Boundary: %d\n", cd.PeriodStart%cd.WPoStProvingPeriod)
|
2020-09-14 23:36:36 +00:00
|
|
|
fmt.Printf("Proving Period Start: %s\n", lcli.EpochTime(cd.CurrentEpoch, cd.PeriodStart))
|
2020-09-18 17:29:06 +00:00
|
|
|
fmt.Printf("Next Period Start: %s\n\n", lcli.EpochTime(cd.CurrentEpoch, cd.PeriodStart+cd.WPoStProvingPeriod))
|
2020-04-20 17:34:08 +00:00
|
|
|
|
2020-05-13 16:53:07 +00:00
|
|
|
fmt.Printf("Faults: %d (%.2f%%)\n", faults, faultPerc)
|
2020-07-14 20:14:37 +00:00
|
|
|
fmt.Printf("Recovering: %d\n", recovering)
|
2020-04-24 17:12:30 +00:00
|
|
|
|
2020-04-20 17:34:08 +00:00
|
|
|
fmt.Printf("Deadline Index: %d\n", cd.Index)
|
2020-09-12 03:07:52 +00:00
|
|
|
fmt.Printf("Deadline Sectors: %d\n", curDeadlineSectors)
|
2020-09-14 23:36:36 +00:00
|
|
|
fmt.Printf("Deadline Open: %s\n", lcli.EpochTime(cd.CurrentEpoch, cd.Open))
|
|
|
|
fmt.Printf("Deadline Close: %s\n", lcli.EpochTime(cd.CurrentEpoch, cd.Close))
|
|
|
|
fmt.Printf("Deadline Challenge: %s\n", lcli.EpochTime(cd.CurrentEpoch, cd.Challenge))
|
|
|
|
fmt.Printf("Deadline FaultCutoff: %s\n", lcli.EpochTime(cd.CurrentEpoch, cd.FaultCutoff))
|
2020-04-17 22:02:04 +00:00
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
var provingDeadlinesCmd = &cli.Command{
|
2020-06-15 09:43:42 +00:00
|
|
|
Name: "deadlines",
|
|
|
|
Usage: "View the current proving period deadlines information",
|
2020-04-17 22:02:04 +00:00
|
|
|
Action: func(cctx *cli.Context) error {
|
2020-07-14 12:31:15 +00:00
|
|
|
color.NoColor = !cctx.Bool("color")
|
|
|
|
|
2020-04-17 22:02:04 +00:00
|
|
|
nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer closer()
|
|
|
|
|
|
|
|
api, acloser, err := lcli.GetFullNodeAPI(cctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer acloser()
|
|
|
|
|
|
|
|
ctx := lcli.ReqContext(cctx)
|
|
|
|
|
2020-07-03 17:45:21 +00:00
|
|
|
maddr, err := getActorAddress(ctx, nodeApi, cctx.String("actor"))
|
2020-04-17 22:02:04 +00:00
|
|
|
if err != nil {
|
2020-07-03 17:35:20 +00:00
|
|
|
return err
|
2020-04-17 22:02:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
deadlines, err := api.StateMinerDeadlines(ctx, maddr, types.EmptyTSK)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("getting deadlines: %w", err)
|
|
|
|
}
|
|
|
|
|
2020-04-24 17:12:30 +00:00
|
|
|
di, err := api.StateMinerProvingDeadline(ctx, maddr, types.EmptyTSK)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("getting deadlines: %w", err)
|
|
|
|
}
|
|
|
|
|
2020-07-14 12:31:15 +00:00
|
|
|
fmt.Printf("Miner: %s\n", color.BlueString("%s", maddr))
|
|
|
|
|
2020-06-04 23:38:38 +00:00
|
|
|
tw := tabwriter.NewWriter(os.Stdout, 2, 4, 2, ' ', 0)
|
2020-07-27 16:15:47 +00:00
|
|
|
_, _ = fmt.Fprintln(tw, "deadline\tpartitions\tsectors (faults)\tproven partitions")
|
2020-06-04 23:38:38 +00:00
|
|
|
|
2020-07-14 20:14:37 +00:00
|
|
|
for dlIdx, deadline := range deadlines {
|
|
|
|
partitions, err := api.StateMinerPartitions(ctx, maddr, uint64(dlIdx), types.EmptyTSK)
|
2020-04-17 22:02:04 +00:00
|
|
|
if err != nil {
|
2020-07-14 20:14:37 +00:00
|
|
|
return xerrors.Errorf("getting partitions for deadline %d: %w", dlIdx, err)
|
2020-04-17 22:02:04 +00:00
|
|
|
}
|
|
|
|
|
2020-07-14 20:14:37 +00:00
|
|
|
provenPartitions, err := deadline.PostSubmissions.Count()
|
2020-04-24 17:12:30 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-07-27 16:15:47 +00:00
|
|
|
sectors := uint64(0)
|
|
|
|
faults := uint64(0)
|
|
|
|
|
|
|
|
for _, partition := range partitions {
|
2020-09-17 08:17:14 +00:00
|
|
|
sc, err := partition.AllSectors.Count()
|
2020-07-27 16:15:47 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
sectors += sc
|
|
|
|
|
2020-09-17 08:17:14 +00:00
|
|
|
fc, err := partition.FaultySectors.Count()
|
2020-07-27 16:15:47 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
faults += fc
|
|
|
|
}
|
|
|
|
|
2020-06-04 23:38:38 +00:00
|
|
|
var cur string
|
2020-07-14 20:14:37 +00:00
|
|
|
if di.Index == uint64(dlIdx) {
|
2020-06-04 23:38:38 +00:00
|
|
|
cur += "\t(current)"
|
2020-04-24 17:12:30 +00:00
|
|
|
}
|
2020-07-27 16:15:47 +00:00
|
|
|
_, _ = fmt.Fprintf(tw, "%d\t%d\t%d (%d)\t%d%s\n", dlIdx, len(partitions), sectors, faults, provenPartitions, cur)
|
2020-04-17 22:02:04 +00:00
|
|
|
}
|
|
|
|
|
2020-06-04 23:38:38 +00:00
|
|
|
return tw.Flush()
|
2020-04-17 22:02:04 +00:00
|
|
|
},
|
2020-04-17 22:02:43 +00:00
|
|
|
}
|
2020-09-23 16:53:03 +00:00
|
|
|
|
|
|
|
var provingDeadlineInfoCmd = &cli.Command{
|
|
|
|
Name: "deadline",
|
|
|
|
Usage: "View the current proving period deadline information by its index ",
|
|
|
|
ArgsUsage: "<deadlineIdx>",
|
|
|
|
Action: func(cctx *cli.Context) error {
|
|
|
|
|
|
|
|
if cctx.Args().Len() != 1 {
|
|
|
|
return xerrors.Errorf("must pass deadline index")
|
|
|
|
}
|
|
|
|
|
|
|
|
dlIdx, err := strconv.ParseUint(cctx.Args().Get(0), 10, 64)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("could not parse deadline index: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer closer()
|
|
|
|
|
|
|
|
api, acloser, err := lcli.GetFullNodeAPI(cctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer acloser()
|
|
|
|
|
|
|
|
ctx := lcli.ReqContext(cctx)
|
|
|
|
|
|
|
|
maddr, err := getActorAddress(ctx, nodeApi, cctx.String("actor"))
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
deadlines, err := api.StateMinerDeadlines(ctx, maddr, types.EmptyTSK)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("getting deadlines: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
di, err := api.StateMinerProvingDeadline(ctx, maddr, types.EmptyTSK)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("getting deadlines: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
partitions, err := api.StateMinerPartitions(ctx, maddr, dlIdx, types.EmptyTSK)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("getting partitions for deadline %d: %w", dlIdx, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
provenPartitions, err := deadlines[dlIdx].PostSubmissions.Count()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Printf("Deadline Index: %d\n", dlIdx)
|
|
|
|
fmt.Printf("Partitions: %d\n", len(partitions))
|
|
|
|
fmt.Printf("Proven Partitions: %d\n", provenPartitions)
|
|
|
|
fmt.Printf("Current: %t\n\n", di.Index == dlIdx)
|
|
|
|
|
|
|
|
for pIdx, partition := range partitions {
|
|
|
|
sectorCount, err := partition.AllSectors.Count()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
sectorNumbers, err := partition.AllSectors.All(sectorCount)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
faultsCount, err := partition.FaultySectors.Count()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
fn, err := partition.FaultySectors.All(faultsCount)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Printf("Partition Index: %d\n", pIdx)
|
|
|
|
fmt.Printf("Sectors: %d\n", sectorCount)
|
|
|
|
fmt.Printf("Sector Numbers: %v\n", sectorNumbers)
|
|
|
|
fmt.Printf("Faults: %d\n", faultsCount)
|
|
|
|
fmt.Printf("Faulty Sectors: %d\n", fn)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|
2020-11-26 07:02:43 +00:00
|
|
|
|
|
|
|
var provingCheckProvableCmd = &cli.Command{
|
|
|
|
Name: "check",
|
|
|
|
Usage: "Check sectors provable",
|
|
|
|
ArgsUsage: "<deadlineIdx>",
|
|
|
|
Flags: []cli.Flag{
|
|
|
|
&cli.BoolFlag{
|
|
|
|
Name: "only-bad",
|
|
|
|
Usage: "print only bad sectors",
|
|
|
|
Value: false,
|
|
|
|
},
|
2020-12-01 23:32:01 +00:00
|
|
|
&cli.BoolFlag{
|
|
|
|
Name: "slow",
|
|
|
|
Usage: "run slower checks",
|
|
|
|
},
|
2020-11-26 07:02:43 +00:00
|
|
|
},
|
|
|
|
Action: func(cctx *cli.Context) error {
|
|
|
|
if cctx.Args().Len() != 1 {
|
|
|
|
return xerrors.Errorf("must pass deadline index")
|
|
|
|
}
|
|
|
|
|
|
|
|
dlIdx, err := strconv.ParseUint(cctx.Args().Get(0), 10, 64)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("could not parse deadline index: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
api, closer, err := lcli.GetFullNodeAPI(cctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer closer()
|
|
|
|
|
|
|
|
sapi, scloser, err := lcli.GetStorageMinerAPI(cctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer scloser()
|
|
|
|
|
|
|
|
ctx := lcli.ReqContext(cctx)
|
|
|
|
|
|
|
|
addr, err := sapi.ActorAddress(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
mid, err := address.IDFromAddress(addr)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
info, err := api.StateMinerInfo(ctx, addr, types.EmptyTSK)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
pf, err := info.SealProofType.RegisteredWindowPoStProof()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
partitions, err := api.StateMinerPartitions(ctx, addr, dlIdx, types.EmptyTSK)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
tw := tabwriter.NewWriter(os.Stdout, 2, 4, 2, ' ', 0)
|
|
|
|
_, _ = fmt.Fprintln(tw, "deadline\tpartition\tsector\tstatus")
|
|
|
|
|
|
|
|
for parIdx, par := range partitions {
|
|
|
|
sectors := make(map[abi.SectorNumber]struct{})
|
|
|
|
|
2020-12-17 12:03:09 +00:00
|
|
|
sectorInfos, err := api.StateMinerSectors(ctx, addr, &par.LiveSectors, types.EmptyTSK)
|
2020-11-27 15:34:41 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-11-26 07:02:43 +00:00
|
|
|
|
|
|
|
var tocheck []storage.SectorRef
|
|
|
|
for _, info := range sectorInfos {
|
|
|
|
sectors[info.SectorNumber] = struct{}{}
|
|
|
|
tocheck = append(tocheck, storage.SectorRef{
|
|
|
|
ProofType: info.SealProof,
|
|
|
|
ID: abi.SectorID{
|
|
|
|
Miner: abi.ActorID(mid),
|
|
|
|
Number: info.SectorNumber,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-12-01 23:32:01 +00:00
|
|
|
bad, err := sapi.CheckProvable(ctx, pf, tocheck, cctx.Bool("slow"))
|
2020-11-26 07:02:43 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
for s := range sectors {
|
|
|
|
if err, exist := bad[s]; exist {
|
|
|
|
_, _ = fmt.Fprintf(tw, "%d\t%d\t%d\t%s\n", dlIdx, parIdx, s, color.RedString("bad")+fmt.Sprintf(" (%s)", err))
|
|
|
|
} else if !cctx.Bool("only-bad") {
|
|
|
|
_, _ = fmt.Fprintf(tw, "%d\t%d\t%d\t%s\n", dlIdx, parIdx, s, color.GreenString("good"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return tw.Flush()
|
|
|
|
},
|
|
|
|
}
|