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

R4R: Add tendermint version command #3285

Merged
merged 2 commits into from
Jan 14, 2019
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 PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ BREAKING CHANGES
* https://github.com/cosmos/cosmos-sdk/issues/2838 - Move store keys to constants
* [\#3162](https://github.com/cosmos/cosmos-sdk/issues/3162) The `--gas` flag now takes `auto` instead of `simulate`
in order to trigger a simulation of the tx before the actual execution.
* [\#3285](https://github.com/cosmos/cosmos-sdk/pull/3285) New `gaiad tendermint version` to print libs versions


* SDK
Expand Down
28 changes: 28 additions & 0 deletions server/tm_cmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,20 @@ import (
tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
"github.com/tendermint/tendermint/p2p"
pvm "github.com/tendermint/tendermint/privval"
tversion "github.com/tendermint/tendermint/version"

"github.com/cosmos/cosmos-sdk/client"
sdk "github.com/cosmos/cosmos-sdk/types"
)

const (
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if we need a constant for this. Should we also have a JSON output option like most commands?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't support JSON in either gaiacli version nor gaiad version. I'd keep it simple, really.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually - I think JSON output is a good idea. Lots of higher-level tooling might want to parse the version output, and I'd rather they not try to parse the raw text.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No strong objections from me, will do then

Copy link
Member

Choose a reason for hiding this comment

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

I will add this with the standardization of query outputs. Don't need to worry about this @alessio

versionString = `Tendermint: %s
ABCI: %s
BlockProtocol: %d
P2PProtocol: %d
`
)

// ShowNodeIDCmd - ported from Tendermint, dump node ID to stdout
func ShowNodeIDCmd(ctx *Context) *cobra.Command {
return &cobra.Command{
Expand Down Expand Up @@ -89,6 +98,25 @@ func ShowAddressCmd(ctx *Context) *cobra.Command {
return cmd
}

// VersionCmd prints tendermint and ABCI version numbers.
func VersionCmd(ctx *Context) *cobra.Command {
cmd := &cobra.Command{
Use: "version",
Short: "Print tendermint libraries' version",
Long: `Print protocols' and libraries' version numbers
against which this app has been compiled.
`,
RunE: func(cmd *cobra.Command, args []string) error {

fmt.Printf(versionString, tversion.Version, tversion.ABCIVersion,
tversion.BlockProtocol.Uint64(), tversion.P2PProtocol.Uint64())

return nil
},
}
return cmd
}

func printlnJSON(v interface{}) error {
cdc := codec.New()
codec.RegisterCrypto(cdc)
Expand Down
1 change: 1 addition & 0 deletions server/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ func AddCommands(
ShowNodeIDCmd(ctx),
ShowValidatorCmd(ctx),
ShowAddressCmd(ctx),
VersionCmd(ctx),
)

rootCmd.AddCommand(
Expand Down