Skip to content

Commit

Permalink
feat: add tm inspect cmd (#11548)
Browse files Browse the repository at this point in the history
## Description

Closes: #11495 

Add the `inspect` command to the `tendermint` sub-command.

---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed 
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
  • Loading branch information
alexanderbez committed Apr 5, 2022
1 parent 4ca61c1 commit b9f5283
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -39,6 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Features

* (cli) [\#11548](https://github.com/cosmos/cosmos-sdk/pull/11548) Add Tendermint's `inspect` command to the `tendermint` sub-command.
* (tx) [#\11533](https://github.com/cosmos/cosmos-sdk/pull/11533) Register [`EIP191`](https://eips.ethereum.org/EIPS/eip-191) as an available `SignMode` for chains to use.
* (x/genutil) [\#11500](https://github.com/cosmos/cosmos-sdk/pull/11500) Fix GenTx validation and adjust error messages
* [\#11430](https://github.com/cosmos/cosmos-sdk/pull/11430) Introduce a new `grpc-only` flag, such that when enabled, will start the node in a query-only mode. Note, gRPC MUST be enabled with this flag.
Expand Down
21 changes: 15 additions & 6 deletions server/tm_cmds.go
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"

"github.com/spf13/cobra"
tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
tmcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
pvm "github.com/tendermint/tendermint/privval"
tversion "github.com/tendermint/tendermint/version"
"sigs.k8s.io/yaml"
Expand All @@ -29,6 +29,7 @@ func ShowNodeIDCmd() *cobra.Command {
if err != nil {
return err
}

fmt.Println(nodeKey)
return nil
},
Expand All @@ -48,19 +49,23 @@ func ShowValidatorCmd() *cobra.Command {
if err != nil {
return err
}

pk, err := privValidator.GetPubKey(cmd.Context())
if err != nil {
return err
}

sdkPK, err := cryptocodec.FromTmPubKeyInterface(pk)
if err != nil {
return err
}

clientCtx := client.GetClientContextFromCmd(cmd)
bz, err := clientCtx.Codec.MarshalInterfaceJSON(sdkPK)
if err != nil {
return err
}

fmt.Println(string(bz))
return nil
},
Expand All @@ -82,6 +87,7 @@ func ShowAddressCmd() *cobra.Command {
if err != nil {
return err
}

valConsAddr := (sdk.ConsAddress)(privValidator.GetAddress())
fmt.Println(valConsAddr.String())
return nil
Expand All @@ -96,9 +102,7 @@ func VersionCmd() *cobra.Command {
return &cobra.Command{
Use: "version",
Short: "Print tendermint libraries' version",
Long: `Print protocols' and libraries' version numbers
against which this app has been compiled.
`,
Long: "Print protocols' and libraries' version numbers against which this app has been compiled.",
RunE: func(cmd *cobra.Command, args []string) error {
bs, err := yaml.Marshal(&struct {
Tendermint string
Expand Down Expand Up @@ -130,8 +134,13 @@ func UnsafeResetAllCmd() *cobra.Command {
serverCtx := GetServerContextFromCmd(cmd)
cfg := serverCtx.Config

tcmd.ResetAll(cfg.DBDir(), cfg.P2P.AddrBookFile(), cfg.PrivValidator.KeyFile(), cfg.PrivValidator.StateFile(), serverCtx.Logger)
return nil
return tmcmd.ResetAll(
cfg.DBDir(),
cfg.P2P.AddrBookFile(),
cfg.PrivValidator.KeyFile(),
cfg.PrivValidator.StateFile(),
serverCtx.Logger,
)
},
}
}
3 changes: 3 additions & 0 deletions server/util.go
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/spf13/viper"
tmcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
tmcfg "github.com/tendermint/tendermint/config"
tmlog "github.com/tendermint/tendermint/libs/log"
dbm "github.com/tendermint/tm-db"
Expand Down Expand Up @@ -271,7 +272,9 @@ func AddCommands(rootCmd *cobra.Command, defaultNodeHome string, appCreator type
ShowValidatorCmd(),
ShowAddressCmd(),
VersionCmd(),
tmcmd.InspectCmd,
)

startCmd := StartCmd(appCreator, defaultNodeHome)
addStartFlags(startCmd)

Expand Down

0 comments on commit b9f5283

Please sign in to comment.