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(cli): lotus state sectors --show-partitions + CSV #12834

Merged
merged 1 commit into from
Jan 22, 2025
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Refactored Ethereum API implementation into smaller, more manageable modules in a new `github.com/filecoin-project/lotus/node/impl/eth` package. ([filecoin-project/lotus#12796](https://github.com/filecoin-project/lotus/pull/12796))
- Generate the cli docs directly from the code instead compiling and executing binaries' `help` output. ([filecoin-project/lotus#12717](https://github.com/filecoin-project/lotus/pull/12717))
- Add `lotus-shed msg --gas-stats` to show summarised gas stats for a given message. ([filecoin-project/lotus#12817](https://github.com/filecoin-project/lotus/pull/12817))
- `lotus state sectors` now outputs CSV format and supports an optional `--show-partitions` to list sector deadlines and partitions. ([filecoin-project/lotus#12834](https://github.com/filecoin-project/lotus/pull/12834))

# UNRELEASED v.1.32.0

Expand Down
23 changes: 22 additions & 1 deletion cli/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@ var StateSectorsCmd = &cli.Command{
Name: "sectors",
Usage: "Query the sector set of a miner",
ArgsUsage: "[minerAddress]",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "show-partitions",
Usage: "show sector deadlines and partitions",
},
},
Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx)
if err != nil {
Expand Down Expand Up @@ -268,8 +274,23 @@ var StateSectorsCmd = &cli.Command{
return err
}

showPartitions := cctx.Bool("show-partitions")
header := "Sector Number, Sealed CID"
if showPartitions {
header = "Sector Number, Deadline, Partition, Sealed CID"
}
fmt.Println(header)

for _, s := range sectors {
fmt.Printf("%d: %s\n", s.SectorNumber, s.SealedCID)
if showPartitions {
sp, err := api.StateSectorPartition(ctx, maddr, s.SectorNumber, ts.Key())
if err != nil {
return err
}
fmt.Printf("%d, %d, %d, %s\n", s.SectorNumber, sp.Deadline, sp.Partition, s.SealedCID)
} else {
fmt.Printf("%d, %s\n", s.SectorNumber, s.SealedCID)
}
}

return nil
Expand Down
3 changes: 2 additions & 1 deletion documentation/en/cli-lotus.md
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,8 @@ USAGE:
lotus state sectors [command options] [minerAddress]

OPTIONS:
--help, -h show help
--show-partitions show sector deadlines and partitions (default: false)
--help, -h show help
```

### lotus state active-sectors
Expand Down
Loading