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(client): add auto cli for node service #21074

Merged
merged 8 commits into from
Aug 15, 2024

Conversation

zakir-code
Copy link
Contributor

@zakir-code zakir-code commented Jul 25, 2024

Description

Closes: #20971

Hi, @julienrbrt
This should be the simplest implementation method at present, but adding non-modular autoCli to autocli.AppOptions is not very user-friendly. Are there any other good solutions, and are there any plans to improve autocli?


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 in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • 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.

Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

  • New Features

    • Introduced an automated CLI for node services in the Cosmos SDK, enhancing user interaction and usability.
    • Added commands for retrieving node configuration and checking operational status through the AutoCLI framework.
  • Documentation

    • Updated CHANGELOG to reflect the addition of the automated CLI feature for node services.

Copy link
Contributor

coderabbitai bot commented Jul 25, 2024

Walkthrough

Walkthrough

The recent changes introduce a new AutoCLI feature in the Cosmos SDK, enhancing the command-line interface for node services. This includes the implementation of commands for querying node configurations and statuses, improving usability for developers and users. The modifications seamlessly integrate these functionalities into the existing command structure, bolstering the SDK's capabilities while maintaining overall code organization.

Changes

Files Change Summary
CHANGELOG.md Added a new feature entry for "auto cli for node service" under the Features section.
client/grpc/node/autocli.go Introduced a module for AutoCLI integration, defining command options for node configuration and status queries.
simapp/simd/cmd/root.go Integrated nodeservice commands into the root command, enhancing CLI functionality.
simapp/simd/cmd/root_di.go Enhanced NewRootCmd function to incorporate node service commands and options.
simapp/v2/simdv2/cmd/root_di.go Updated NewRootCmd to support node commands, including new import statements for necessary packages.

Assessment against linked issues

Objective Addressed Explanation
Add CLI Command for gRPC Node Service (#[20971])

Possibly related issues

  • AutoCLI Enhancements #18310: The changes enhance the AutoCLI, which aligns with the need for improved user experience in CLI commands mentioned in this issue.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the C:CLI label Jul 25, 2024
@julienrbrt
Copy link
Member

julienrbrt commented Jul 25, 2024

Hi, nope currently that's just the way to do it. For instance check out https://github.com/cosmos/cosmos-sdk/blob/main/client/grpc/cmtservice/autocli.go

AutoCLI has been made for module CLI in mind (for the detection), so best to just use this trick for now.

@zakir-code
Copy link
Contributor Author

Hi, nope currently that's just the way to do it. For instance check out https://github.com/cosmos/cosmos-sdk/blob/main/client/grpc/cmtservice/autocli.go

AutoCLI has been made for module CLI in mind (for the detection), so best to just use this trick for now.

Okay

@julienrbrt
Copy link
Member

Actually a good place to put it is here: https://github.com/cosmos/cosmos-sdk/blob/main/x/consensus/autocli.go#L25-L27
Like we did for the comet one. Then it is always added in a chain as well.

@zakir-code
Copy link
Contributor Author

Sorry for the delay

Actually a good place to put it is here: https://github.com/cosmos/cosmos-sdk/blob/main/x/consensus/autocli.go#L25-L27 Like we did for the comet one. Then it is always added in a chain as well.

comet was added under the consensus CLI, but I’m not sure where to place the node CLI.

@zakir-code zakir-code marked this pull request as ready for review August 14, 2024 13:54
@zakir-code zakir-code requested a review from a team as a code owner August 14, 2024 13:54
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (4)
client/grpc/node/autocli.go (2)

8-22: Consider using a more descriptive variable name.

The variable ServiceAutoCLIDescriptor could be more descriptive to indicate its purpose clearly, such as NodeServiceAutoCLIDescriptor.


30-43: Ensure interface conformity and consider documentation.

The nodeModule struct and its methods appear to conform to an expected interface. Consider adding comments to clarify which interface is being implemented for better readability and maintenance.

simapp/v2/simdv2/cmd/root_di.go (1)

87-90: Consider error handling and documentation.

While the integration of nodeCmds is correct, consider adding documentation to explain the purpose of nodeCmds and its impact on the root command. Additionally, ensure that any potential errors in command enhancement are properly handled.

simapp/simd/cmd/root_di.go (1)

88-91: Consider error handling and documentation.

While the integration of nodeCmds is correct, consider adding documentation to explain the purpose of nodeCmds and its impact on the root command. Additionally, ensure that any potential errors in command enhancement are properly handled.

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7f1dd97 and fbf3797.

Files selected for processing (5)
  • CHANGELOG.md (1 hunks)
  • client/grpc/node/autocli.go (1 hunks)
  • simapp/simd/cmd/root.go (2 hunks)
  • simapp/simd/cmd/root_di.go (2 hunks)
  • simapp/v2/simdv2/cmd/root_di.go (3 hunks)
Files skipped from review due to trivial changes (1)
  • CHANGELOG.md
Additional context used
Path-based instructions (4)
client/grpc/node/autocli.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

simapp/v2/simdv2/cmd/root_di.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

simapp/simd/cmd/root_di.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

simapp/simd/cmd/root.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

Additional comments not posted (5)
client/grpc/node/autocli.go (1)

24-28: LGTM!

The function NewNodeCommands is straightforward and conforms to the style guide.

simapp/v2/simdv2/cmd/root_di.go (1)

Line range hint 6-23: LGTM!

The new imports for autocliv1 and nodeservice are necessary for the new functionality and conform to the style guide.

simapp/simd/cmd/root_di.go (1)

8-9: LGTM!

The new imports for autocliv1 and nodeservice are necessary for the new functionality and conform to the style guide.

simapp/simd/cmd/root.go (2)

9-9: Confirm the necessity of the nodeservice import.

The nodeservice package is imported to add node commands. Ensure that this package is required and correctly used within the file.

Verification successful

The nodeservice import is necessary and correctly used.

The nodeservice.NewNodeCommands function is utilized in multiple files, including simapp/simd/cmd/root.go, confirming the necessity and correctness of the import for adding node commands to the CLI.

  • Files using nodeservice.NewNodeCommands:
    • simapp/v2/simdv2/cmd/root_di.go
    • simapp/simd/cmd/root.go
    • simapp/simd/cmd/root_di.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the `nodeservice` package in the codebase.

# Test: Search for the usage of `nodeservice.NewNodeCommands`. Expect: Occurrences in the codebase.
rg --type go 'nodeservice.NewNodeCommands'

Length of output: 254


126-128: Ensure correct initialization and integration of nodeCmds.

The nodeCmds variable is initialized and its options are added to autoCliOpts.ModuleOptions. Verify that this integration aligns with the intended functionality and best practices.

Verification successful

Verify the implementation of NewNodeCommands and AutoCLIOptions.

To ensure the correct initialization and integration of nodeCmds, verify the implementation of NewNodeCommands and AutoCLIOptions in the codebase. This will confirm if they are correctly defined and used.


Investigate the definition of nodeModule to ensure AutoCLIOptions is implemented.

The NewNodeCommands function returns a nodeModule pointer, but the AutoCLIOptions method implementation was not found. Check the nodeModule struct or interface to verify if AutoCLIOptions is defined and correctly implemented.


Integration of nodeCmds is correctly implemented.

The nodeModule struct and its AutoCLIOptions method are properly defined and implemented in client/grpc/node/autocli.go. This confirms that the integration of nodeCmds with autoCliOpts.ModuleOptions is correct and aligns with the intended functionality.

  • nodeModule struct is defined in client/grpc/node/autocli.go.
  • AutoCLIOptions method is implemented for nodeModule in the same file.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of `nodeCmds` in the codebase.

# Test: Check if `nodeCmds.AutoCLIOptions()` is properly utilized. Expect: Proper integration in the command structure.
rg --type go 'nodeCmds.AutoCLIOptions'

Length of output: 337


Script:

#!/bin/bash
# Find the implementation of `NewNodeCommands` in the codebase.
ast-grep --lang go --pattern 'func NewNodeCommands() $_ { $$$ }'

# Find the implementation of `AutoCLIOptions` method in the codebase.
ast-grep --lang go --pattern 'func (n $_) AutoCLIOptions() $_ { $$$ }'

Length of output: 293


Script:

#!/bin/bash
# Search for the definition of `nodeModule` to check for `AutoCLIOptions` method.
ast-grep --lang go --pattern 'type nodeModule struct { $$$ }'

# Search for interfaces or methods related to `nodeModule` that might define `AutoCLIOptions`.
rg --type go 'AutoCLIOptions'

Length of output: 5684

Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

utACK

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (1)
simapp/v2/simdv2/cmd/root_di.go (1)

87-89: Enhancement of CLI with node commands looks good.

The integration of nodeCmds into autoCliOpts.ModuleOptions effectively enhances the CLI functionalities. Consider adding comments to explain the purpose of these lines for improved readability.

+  // Initialize node commands for CLI enhancements
  nodeCmds := nodeservice.NewNodeCommands()
+  // Populate ModuleOptions with node command AutoCLI options
  autoCliOpts.ModuleOptions = make(map[string]*autocliv1.ModuleOptions)
  autoCliOpts.ModuleOptions[nodeCmds.Name()] = nodeCmds.AutoCLIOptions()
Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fbf3797 and 9d3cf2a.

Files selected for processing (3)
  • simapp/simd/cmd/root.go (2 hunks)
  • simapp/simd/cmd/root_di.go (3 hunks)
  • simapp/v2/simdv2/cmd/root_di.go (3 hunks)
Files skipped from review as they are similar to previous changes (2)
  • simapp/simd/cmd/root.go
  • simapp/simd/cmd/root_di.go
Additional context used
Path-based instructions (1)
simapp/v2/simdv2/cmd/root_di.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

Additional comments not posted (2)
simapp/v2/simdv2/cmd/root_di.go (2)

8-8: Import autocliv1 is appropriate.

The addition of autocliv1 is necessary for integrating automatic CLI options.


23-23: Import nodeservice is appropriate.

The addition of nodeservice is necessary for node command functionalities.

@julienrbrt julienrbrt added the backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release label Aug 15, 2024
@julienrbrt julienrbrt added this pull request to the merge queue Aug 15, 2024
Merged via the queue into cosmos:main with commit 1cb2336 Aug 15, 2024
70 of 75 checks passed
mergify bot pushed a commit that referenced this pull request Aug 15, 2024
(cherry picked from commit 1cb2336)

# Conflicts:
#	CHANGELOG.md
julienrbrt added a commit that referenced this pull request Aug 15, 2024
Co-authored-by: zakir <80246097+zakir-code@users.noreply.github.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
@zakir-code zakir-code deleted the zakir/node-service-cli branch August 16, 2024 01:59
alpe added a commit that referenced this pull request Aug 19, 2024
* main: (76 commits)
  docs: more app v2 renaming (#21336)
  chore: update link in disclaimer (#21339)
  refactor(x/distribution): audit QA (#21316)
  docs: rename app v2 to app di when talking about runtime v0 (#21329)
  feat(schema): specify JSON mapping (#21243)
  fix(x/authz): bring back msg response in `DispatchActions` (#21044)
  chore: fix all lint issue since golangci-lint bump (#21326)
  refactor(x/mint): v0.52 audit x/mint (#21301)
  chore: fix spelling errors (#21327)
  feat: export genesis in simapp v2 (#21199)
  fix(baseapp)!: Halt at height now does not produce the halt height block (#21256)
  refactor(scripts): remove unused variable (#21320)
  chore(schema/testing): upgrade to go 1.23 iterators (#21282)
  chore: readmes + upgrading docs (#21271)
  feat(client): add auto cli for node service (#21074)
  ci: fix github workflow vulnerable to script injection (#21304)
  build(deps): Bump github.com/prometheus/client_golang from 1.19.1 to 1.20.0 (#21307)
  build(deps): use Go 1.23 instead of Go 1.22 (#21280)
  refactor(x/auth): audit x/auth changes (#21146)
  chore: remove todo: "abstract out staking message back to staking" (#21266)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release C:CLI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: Add CLI Command for gRPC Node Service
3 participants