Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: View the currently known proving live sectors information #8720

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 40 additions & 13 deletions cmd/lotus-miner/proving.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import (
"text/tabwriter"
"time"

"github.com/fatih/color"
"github.com/filecoin-project/go-address"
"github.com/urfave/cli/v2"

"github.com/fatih/color"
"golang.org/x/xerrors"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/lotus/blockstore"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
Expand Down Expand Up @@ -224,8 +225,7 @@ var provingDeadlinesCmd = &cli.Command{
fmt.Printf("Miner: %s\n", color.BlueString("%s", maddr))

tw := tabwriter.NewWriter(os.Stdout, 2, 4, 2, ' ', 0)
_, _ = fmt.Fprintln(tw, "deadline\tpartitions\tsectors (faults)\tproven partitions")

_, _ = fmt.Fprintln(tw, "deadline\tpartitions\tsectors (faults|recovering|live|active)\tproven partitions")
for dlIdx, deadline := range deadlines {
partitions, err := api.StateMinerPartitions(ctx, maddr, uint64(dlIdx), types.EmptyTSK)
if err != nil {
Expand All @@ -238,38 +238,63 @@ var provingDeadlinesCmd = &cli.Command{
}

sectors := uint64(0)
active := uint64(0)
faults := uint64(0)
live := uint64(0)
recovering := uint64(0)

for _, partition := range partitions {
sc, err := partition.AllSectors.Count()
if err != nil {
return err
}

sectors += sc

fc, err := partition.FaultySectors.Count()
ac, err := partition.ActiveSectors.Count()
if err != nil {
return err
}
active += ac

fc, err := partition.FaultySectors.Count()
if err != nil {
return err
}
faults += fc

rc, err := partition.RecoveringSectors.Count()
if err != nil {
return err
}
recovering += rc

lc, err := partition.LiveSectors.Count()
if err != nil {
return err
}
live += lc
}

var cur string
if di.Index == uint64(dlIdx) {
cur += "\t(current)"
}
_, _ = fmt.Fprintf(tw, "%d\t%d\t%d (%d)\t%d%s\n", dlIdx, len(partitions), sectors, faults, provenPartitions, cur)
_, _ = fmt.Fprintf(tw, "%d\t%d\t%d (%d|%d|%d|%d)\t%d%s\n", dlIdx, len(partitions), sectors, faults, recovering, live, active, provenPartitions, cur)
}

return tw.Flush()
},
}

var provingDeadlineInfoCmd = &cli.Command{
Name: "deadline",
Usage: "View the current proving period deadline information by its index ",
Name: "deadline",
Usage: "View the current proving period deadline information by its index ",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "detailed",
Usage: "print all sector numbers",
},
},
ArgsUsage: "<deadlineIdx>",
Action: func(cctx *cli.Context) error {

Expand Down Expand Up @@ -321,12 +346,12 @@ var provingDeadlineInfoCmd = &cli.Command{
fmt.Printf("Current: %t\n\n", di.Index == dlIdx)

for pIdx, partition := range partitions {
sectorCount, err := partition.AllSectors.Count()
liveSectorCount, err := partition.LiveSectors.Count()
if err != nil {
return err
}

sectorNumbers, err := partition.AllSectors.All(sectorCount)
liveSectorNumbers, err := partition.LiveSectors.All(liveSectorCount)
if err != nil {
return err
}
Expand All @@ -342,8 +367,10 @@ var provingDeadlineInfoCmd = &cli.Command{
}

fmt.Printf("Partition Index: %d\n", pIdx)
fmt.Printf("Sectors: %d\n", sectorCount)
fmt.Printf("Sector Numbers: %v\n", sectorNumbers)
fmt.Printf("Live Sectors: %d\n", liveSectorCount)
if cctx.IsSet("detailed") {
fmt.Printf("Live Sector Numbers: %v\n", liveSectorNumbers)
}
fmt.Printf("Faults: %d\n", faultsCount)
fmt.Printf("Faulty Sectors: %d\n", fn)
}
Expand Down
1 change: 1 addition & 0 deletions documentation/en/cli-lotus-miner.md
Original file line number Diff line number Diff line change
Expand Up @@ -2097,6 +2097,7 @@ USAGE:
lotus-miner proving deadlines [command options] [arguments...]

OPTIONS:
--detailed print each partition deadlines information (default: false)
--help, -h show help (default: false)

```
Expand Down