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 chain head --height to print epoch number #12609

Merged
merged 1 commit into from
Oct 17, 2024
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
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Reduce size of embedded genesis CAR files by removing WASM actor blocks and compressing with zstd. This reduces the `lotus` binary size by approximately 10 MiB. ([filecoin-project/lotus#12439](https://github.com/filecoin-project/lotus/pull/12439))
- Add ChainSafe operated Calibration archival node to the bootstrap list ([filecoin-project/lotus#12517](https://github.com/filecoin-project/lotus/pull/12517))
- Fix hotloop in F3 pariticpation API ([filecoin-project/lotus#12575](https://github.com/filecoin-project/lotus/pull/12575))
- `lotus chain head` now supports a `--height` flag to print just the epoch number of the current chain head ([filecoin-project/lotus#12609](https://github.com/filecoin-project/lotus/pull/12609))

## Bug Fixes
- Fix a bug in the `lotus-shed indexes backfill-events` command that may result in either duplicate events being backfilled where there are existing events (such an operation *should* be idempotent) or events erroneously having duplicate `logIndex` values when queried via ETH APIs. ([filecoin-project/lotus#12567](https://github.com/filecoin-project/lotus/pull/12567))
Expand All @@ -15,8 +16,6 @@

## Improvements

## Improvements

## Deps

# UNRELEASED Node v1.30.0
Expand Down
14 changes: 12 additions & 2 deletions cli/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ var ChainCmd = &cli.Command{
var ChainHeadCmd = &cli.Command{
Name: "head",
Usage: "Print chain head",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "height",
Usage: "print just the epoch number of the chain head",
},
},
Action: func(cctx *cli.Context) error {
afmt := NewAppFmt(cctx.App)

Expand All @@ -87,8 +93,12 @@ var ChainHeadCmd = &cli.Command{
return err
}

for _, c := range head.Cids() {
afmt.Println(c)
if cctx.Bool("height") {
afmt.Println(head.Height())
} else {
for _, c := range head.Cids() {
afmt.Println(c)
}
}
return nil
},
Expand Down
1 change: 1 addition & 0 deletions documentation/en/cli-lotus.md
Original file line number Diff line number Diff line change
Expand Up @@ -1616,6 +1616,7 @@ USAGE:
lotus chain head [command options] [arguments...]

OPTIONS:
--height print just the epoch number of the chain head (default: false)
--help, -h show help
```

Expand Down
Loading