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 5 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
51 changes: 42 additions & 9 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 @@ -197,6 +198,12 @@ var provingInfoCmd = &cli.Command{
var provingDeadlinesCmd = &cli.Command{
Name: "deadlines",
Usage: "View the current proving period deadlines information",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "detailed",
Usage: "print each partition deadlines information",
},
},
Action: func(cctx *cli.Context) error {
api, acloser, err := lcli.GetFullNodeAPI(cctx)
if err != nil {
Expand Down Expand Up @@ -224,7 +231,11 @@ 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")
if !cctx.IsSet("detailed") {
_, _ = fmt.Fprintln(tw, "deadline\tpartitions\tsectors (faults|recovering|live|active)\tproven partitions")
} else {
_, _ = fmt.Fprintln(tw, "deadline\tpartitions\tsectors (faults|recovering|live|active)\t")
}

for dlIdx, deadline := range deadlines {
partitions, err := api.StateMinerPartitions(ctx, maddr, uint64(dlIdx), types.EmptyTSK)
Expand All @@ -238,29 +249,51 @@ var provingDeadlinesCmd = &cli.Command{
}

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

for _, partition := range partitions {
for partIdx, 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
if cctx.IsSet("detailed") {
_, _ = fmt.Fprintf(tw, "%d\t%d\t%d (%d|%d|%d|%d)\t\n", dlIdx, partIdx, sc, fc, rc, lc, ac)
swift-mx marked this conversation as resolved.
Show resolved Hide resolved
}
}

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)
swift-mx marked this conversation as resolved.
Show resolved Hide resolved
}

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

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

sectorNumbers, err := partition.AllSectors.All(sectorCount)
sectorNumbers, err := partition.ActiveSectors.All(sectorCount)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a flag all to this function to give the user the option to get info for AllSectors

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe AllSectors is useless to the user

return err
}
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