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(08-wasm): expose migrate entry point for 08-wasm #6231

Conversation

kienn6034
Copy link
Contributor

@kienn6034 kienn6034 commented Apr 28, 2024

Description

I think we should expose the migrateContract entry point into the cli

closes: #XXXX


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against the correct branch (see CONTRIBUTING.md).
  • Linked to GitHub issue with discussion and accepted design, OR link to spec that describes this work.
  • Code follows the module structure standards and Go style guide.
  • Wrote unit and integration tests.
  • Updated relevant documentation (docs/).
  • Added relevant godoc comments.
  • Provide a conventional commit message to follow the repository standards.
  • Include a descriptive changelog entry when appropriate. This may be left to the discretion of the PR reviewers. (e.g. chores should be omitted from changelog)
  • Re-reviewed Files changed in the GitHub PR explorer.
  • Review SonarCloud Report in the comment section below once CI passes.

Summary by CodeRabbit

  • New Features
    • Enhanced contract migration capability by introducing a new command for migrating contracts to a new code version, enabling users to update contract functionalities seamlessly.
    • Added a new CLI command migrate-contract in the 08-client.md file to facilitate contract migration for light clients.

Copy link
Contributor

coderabbitai bot commented Apr 28, 2024

Walkthrough

Walkthrough

The recent update enhances the WASM client module by introducing a new command for migrating smart contracts to a newer code version. This command, integrated into the transaction functionality, enables users to manage contract migrations effectively by specifying client ID, checksum, and new code message parameters. The update also includes additional flags and validations to ensure secure and governance-compliant transaction processing.

Changes

File Path Change Summary
modules/light-clients/08-wasm/client/cli/cli.go
modules/light-clients/08-wasm/client/cli/tx.go
Added newMigrateContractCmd() to the txCmd in the NewTxCmd() function in cli.go. Introduced newMigrateContractCmd function for contract migration with new flags and required flag validations.
docs/docs/03-light-clients/04-wasm/08-client.md Documented the new migrate-contract command for contract migration with detailed usage instructions.

Recent Review Details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 0e7b454 and 77b3f6c.
Files selected for processing (1)
  • docs/docs/03-light-clients/04-wasm/08-client.md (1 hunks)
Additional Context Used
LanguageTool (9)
docs/docs/03-light-clients/04-wasm/08-client.md (9)

Near line 16: Possible spelling mistake found.
Context: ...ilable commands: ### Transactions The tx commands allow users to interact with ...


Near line 24: Possible spelling mistake found.
Context: ... to submit a governance proposal with a MsgStoreCode to store the byte code of a Wasm light...


Near line 30: This sentence does not start with an uppercase letter.
Context: ...-file] [flags] ``` path/to/wasm-file is the path to the `.wasm` or `.wasm.gz` f...


Near line 30: Possible spelling mistake found.
Context: ... path/to/wasm-file is the path to the .wasm or .wasm.gz file. #### `migrate-con...


Near line 30: Possible spelling mistake found.
Context: ...asm-fileis the path to the.wasmor.wasm.gzfile. ####migrate-contract` The...


Near line 34: Possible spelling mistake found.
Context: ...users to broadcast a transaction with a MsgMigrateContract to migrate the contract for a given li...


Near line 44: You might be missing the article “the” here.
Context: ...e query commands allow users to query 08-wasm state. ```shell simd query ibc...


Near line 52: Possible spelling mistake found.
Context: ...contracts stored in the Wasm VM via the MsgStoreCode. The checksums are hex-encoded. ```sh...


Near line 100: Possible spelling mistake found.
Context: ...contracts stored in the Wasm VM via the MsgStoreCode. ```shell ibc.lightclients.wasm.v1.Qu...

Path-based Instructions (1)
docs/docs/03-light-clients/04-wasm/08-client.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

Additional comments not posted (1)
docs/docs/03-light-clients/04-wasm/08-client.md (1)

32-41: The documentation for the migrate-contract command is clear and concise. However, ensure that the example command and the description align with the actual implementation in the codebase.


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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

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

CodeRabbit Configration 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.

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: 1

Comment on lines 123 to 126
err := cmd.MarkFlagRequired(govcli.FlagTitle)
if err != nil {
panic(err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider replacing panic with a more graceful error handling method in the flag setup. Panicking in a CLI application can lead to abrupt termination which might not be user-friendly.

- panic(err)
+ if err != nil {
+     fmt.Fprintf(os.Stderr, "Error setting up required flags: %v\n", err)
+     os.Exit(1)
+ }

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
err := cmd.MarkFlagRequired(govcli.FlagTitle)
if err != nil {
panic(err)
}
err := cmd.MarkFlagRequired(govcli.FlagTitle)
if err != nil {
fmt.Fprintf(os.Stderr, "Error setting up required flags: %v\n", err)
os.Exit(1)
}

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

Out of diff range and nitpick comments (1)
docs/docs/03-light-clients/04-wasm/08-client.md (1)

40-40: Consider enhancing the description of the migrate message.

It would be beneficial to specify what the migrate message should contain or provide a link to further documentation. This would help users understand how to properly format their migration messages.

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: 1

@@ -51,6 +51,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Features

* [#\5821](https://github.com/cosmos/ibc-go/pull/5821) feat: add `VerifyMembershipProof` RPC query (querier approach for conditional clients).
* [#\6231](https://github.com/cosmos/ibc-go/pull/6231) feat: add CLI to broadcast transaction with `MsgMigrateContract`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure consistency in the use of backticks for command names.

- * [#\6231](https://github.com/cosmos/ibc-go/pull/6231) feat: add CLI to broadcast transaction with `MsgMigrateContract`.
+ * [#\6231](https://github.com/cosmos/ibc-go/pull/6231) feat: add CLI to broadcast transaction with `MsgMigrateContract`.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
* [#\6231](https://github.com/cosmos/ibc-go/pull/6231) feat: add CLI to broadcast transaction with `MsgMigrateContract`.
* [#\6231](https://github.com/cosmos/ibc-go/pull/6231) feat: add CLI to broadcast transaction with `MsgMigrateContract`.

Copy link
Contributor

@crodriguezvega crodriguezvega left a comment

Choose a reason for hiding this comment

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

Thank you, @kienn6034! I made a few changes, but this looks good to me now. It's a nice addition!

Did you actually test the CLI to check that it works as expected?

@@ -27,7 +27,7 @@ func newSubmitStoreCodeProposalCmd() *cobra.Command {
Use: "store-code [path/to/wasm-file]",
Short: "Reads wasm code from the file and creates a proposal to store the wasm code",
Long: "Reads wasm code from the file and creates a proposal to store the wasm code",
Example: fmt.Sprintf("%s tx %s wasm [path/to/wasm_file]", version.AppName, ibcexported.ModuleName),
Example: fmt.Sprintf("%s tx %s-wasm store-code [path/to/wasm_file]", version.AppName, ibcexported.ModuleName),
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed this was wrong, so I took the liberty to fix it here.


func newMigrateContractCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "migrate-contract [client-id] [checksum] [migrate-msg]",
Copy link
Contributor

Choose a reason for hiding this comment

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

I renamed new-code-msg to migrate-msg, since this is a JSON-encoded string that is passed to the contract that is being migrated.

Copy link
Member

@damiannolan damiannolan left a comment

Choose a reason for hiding this comment

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

Looks great, just left some doc fixes and a question/suggestion re. path to json file!

docs/docs/03-light-clients/04-wasm/08-client.md Outdated Show resolved Hide resolved
docs/docs/03-light-clients/04-wasm/08-client.md Outdated Show resolved Hide resolved

func newMigrateContractCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "migrate-contract [client-id] [checksum] [migrate-msg]",
Copy link
Member

Choose a reason for hiding this comment

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

Does this cmd also support passing the json msg as a path to a file? We do that on many other cmds that accept some kind of sub msg.

Do you think we should support this? cc. @crodriguezvega @srdtrk

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess most contracts for now will not do anything with this message, so most of the times it will be just {}? I am fine supporting it already now or adding support for it later.

Copy link
Member

@damiannolan damiannolan left a comment

Choose a reason for hiding this comment

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

LGTM!

@crodriguezvega crodriguezvega merged commit 34164ef into cosmos:main Apr 29, 2024
77 of 79 checks passed
mergify bot pushed a commit that referenced this pull request Apr 29, 2024
* feat: expose migrate entry point for 08-wasm

* add CLI documentation

* add changelog

* improve CLI inline docs

* small fix

* rename variable

* remove gov flags

* use double quotes

* fix lint warning

* Apply suggestions from code review

Co-authored-by: Damian Nolan <[email protected]>

---------

Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: Damian Nolan <[email protected]>
(cherry picked from commit 34164ef)
crodriguezvega pushed a commit that referenced this pull request Apr 29, 2024
* feat: expose migrate entry point for 08-wasm

* add CLI documentation

* add changelog

* improve CLI inline docs

* small fix

* rename variable

* remove gov flags

* use double quotes

* fix lint warning

* Apply suggestions from code review

Co-authored-by: Damian Nolan <[email protected]>

---------

Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: Damian Nolan <[email protected]>
(cherry picked from commit 34164ef)

Co-authored-by: Kien <[email protected]>
kienn6034 added a commit to notional-labs/ibc-go that referenced this pull request May 15, 2024
* feat: expose migrate entry point for 08-wasm

* add CLI documentation

* add changelog

* improve CLI inline docs

* small fix

* rename variable

* remove gov flags

* use double quotes

* fix lint warning

* Apply suggestions from code review

Co-authored-by: Damian Nolan <[email protected]>

---------

Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: Damian Nolan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants