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

Fix: Add node flag to WASM queries (build-address) #2194

Closed

Conversation

GunanshuJoshi
Copy link

@GunanshuJoshi GunanshuJoshi commented Oct 21, 2024

Description

This PR adds a new --node flag to support custom endpoints for node connections while making Wasm queries specifically build-address. This update ensures that the provenanced q wasm build-address command works correctly with custom node configurations.

Issue:

While creating the predictable contract address I encountered the following error:

unknown flag: --node

This occurred when running the following command:

provenanced query wasm build-address <code-hash> <creator-address> <salt> --node https://rpc.test.provenance.io:443

It seems the flag is not being recognized properly. I suspect there might be an issue with either the flag registration in the command definition (root.go) or how the CLI parser processes the command.

The main file updated is:

  • cmd/provenanced/cmd/root.go

closes: n/a
I haven't created any particular issue for this change. However, this was discussed on Discord, where it was agreed that the node flag should function correctly.
Reference: Discord conversation.


Checklist

  • 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.
    (I haven't created any issue for this minor fix.)
  • Wrote unit and integration tests (see Testing Guidelines).
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/).
  • Added relevant GoDoc comments (GoDoc Documentation).
  • Added relevant changelog entries under .changelog/unreleased (see Adding Changes).
  • Re-reviewed Files changed in the Github PR explorer.
  • Reviewed Codecov report in the comment section below once CI passes.

Summary by CodeRabbit

  • New Features

    • Introduced new command flags for custom denomination and message fee floor price.
    • Added a flag to specify the node connection for enhanced configurability.
    • Enhanced query wasm build-addr command with additional query flags for improved usability.
  • Improvements

    • Enhanced error handling for better user experience, including automatic creation of the snapshot directory.
    • Updated command initialization to disable the start command upon error, preventing misleading usage information.
    • Improved telemetry configuration for better flexibility.
  • Miscellaneous Adjustments

    • Removed shorthand options for conflicting flags and ensured correct command aliasing.

@GunanshuJoshi GunanshuJoshi requested a review from a team as a code owner October 21, 2024 16:41
Copy link
Contributor

coderabbitai bot commented Oct 21, 2024

Walkthrough

The changes in this pull request focus on enhancing the command-line interface of the cmd/provenanced/cmd/root.go file. Key updates include the addition of new command flags for custom denomination and message fee floor price, improvements to error handling, and refinements in command initialization. The logic for telemetry configuration has been encapsulated for better flexibility, and minor adjustments have been made to flag handling and command aliases.

Changes

File Path Change Summary
cmd/provenanced/cmd/root.go - Added persistent flags: config.CustomDenomFlag, config.CustomMsgFeeFloorPriceFlag, and flags.FlagNode.
- Improved error handling in newApp function.
- Updated initRootCmd to manage command initialization and error handling.
- Encapsulated telemetry configuration in getTelemetryGlobalLabels.
- Removed shorthand options for conflicting flags and adjusted command aliases.
- Updated method signatures for NewRootCmd, Execute, queryCommand, and txCommand.
.changelog/unreleased/bug-fixes/2194-fix-wasm-build-addr.md - Updated query wasm build-addr command to include additional query flags.

Possibly related PRs

  • Fix deprecated wasm issues. #1988: This PR addresses changes related to the wasm module, which may intersect with the command-line interface improvements in the main PR, particularly regarding the handling of query flags that could be relevant to the fixQueryWasmBuildAddressFlags function introduced in the main PR.

Suggested reviewers

  • iramiller

Poem

In the land of code where rabbits play,
New flags and features come out to stay.
With error handling fine-tuned just right,
Our command-line hops into the night!
So gather 'round, let’s cheer and sing,
For robust commands and the joy they bring! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d2c62a3 and d6c1c61.

📒 Files selected for processing (1)
  • cmd/provenanced/cmd/root.go (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • cmd/provenanced/cmd/root.go

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 0bf059c and 8e5cc8e.

📒 Files selected for processing (1)
  • cmd/provenanced/cmd/root.go (1 hunks)
🧰 Additional context used
🔇 Additional comments (1)
cmd/provenanced/cmd/root.go (1)

225-225: Verify Proper Handling of the --node Flag in Query Subcommands

Ensure that all query subcommands correctly utilize the --node flag to connect to the specified node endpoint. This includes verifying that the custom node address is properly passed to any underlying clients or services used by these subcommands.

Run the following script to find usages of the client.GetNodeContext function in query commands, which should respect the --node flag:

cmd/provenanced/cmd/root.go Outdated Show resolved Hide resolved
@SpicyLemon
Copy link
Contributor

SpicyLemon commented Oct 21, 2024

The query wasm build-address command does not add the standard AddQueryFlagsToCmd to it because it doesn't actually attempt to communicate with a node; it just runs some local calculations to output the desired result. So there's no need to provide a --node flag to it because it doesn't use a node; there's nothing in the command's code (defined in the wasmd library) that looks for the flag.

@GunanshuJoshi
Copy link
Author

Yes, it doesn't actually have any dependency on the node but it does tries to connect with the node. Thus, giving the following error:

Error: post failed: Post "http://localhost:26657": dial tcp 127.0.0.1:26657: connect: connection refused

We can also consider removing the validation for this.

@SpicyLemon
Copy link
Contributor

Yes, it doesn't actually have any dependency on the node but it does tries to connect with the node. Thus, giving the following error:

Error: post failed: Post "http://localhost:26657": dial tcp 127.0.0.1:26657: connect: connection refused

We can also consider removing the validation for this.

Sorry. You're right. I was looking at an earlier version of the command, but it looks like the current version does make a request of the node.

@SpicyLemon
Copy link
Contributor

This PR will need a changelog entry.
You can add one using the .changelog/add-change.sh script:

.changelog/add-change.sh 2194 bug-fixes fix-wasm-build-addr 'Add the query flags to the query wasm build-addr command.'

That'll create a file in .changelog/unreleased/bug-fixes that you should then add to this PR.

Copy link

codecov bot commented Oct 23, 2024

Codecov Report

Attention: Patch coverage is 55.55556% with 4 lines in your changes missing coverage. Please review.

Project coverage is 74.24%. Comparing base (a70ac0c) to head (d6c1c61).
Report is 256 commits behind head on main.

Files with missing lines Patch % Lines
cmd/provenanced/cmd/root.go 55.55% 3 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2194      +/-   ##
==========================================
- Coverage   74.50%   74.24%   -0.27%     
==========================================
  Files         318      373      +55     
  Lines       46237    45204    -1033     
==========================================
- Hits        34449    33560     -889     
+ Misses      10381    10187     -194     
- Partials     1407     1457      +50     
Files with missing lines Coverage Δ
cmd/provenanced/cmd/root.go 70.84% <55.55%> (-1.22%) ⬇️

... and 284 files with indirect coverage changes

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 and nitpick comments (1)
cmd/provenanced/cmd/root.go (1)

535-546: Add a changelog entry for this bug fix.

As mentioned in the PR comments, please add a changelog entry using:

.changelog/add-change.sh 2194 bug-fixes fix-wasm-build-addr 'Add the query flags to the query wasm build-addr command.'
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 8e5cc8e and 5656944.

📒 Files selected for processing (1)
  • cmd/provenanced/cmd/root.go (2 hunks)
🧰 Additional context used
📓 Learnings (1)
cmd/provenanced/cmd/root.go (1)
Learnt from: iramiller
PR: provenance-io/provenance#2194
File: cmd/provenanced/cmd/root.go:225-225
Timestamp: 2024-10-21T17:12:02.352Z
Learning: When adding flags in `cmd/provenanced/cmd/root.go`, use `flags.AddTxFlagsToCmd(cmd)` for each command to add the appropriate flags, instead of individually adding flags to the root command.
🔇 Additional comments (2)
cmd/provenanced/cmd/root.go (2)

136-136: LGTM! Correct placement of the fix function call.

The fixQueryWasmBuildAddressFlags function is called right after fixTxWasmInstantiate2Aliases, which is the appropriate location as suggested in the past review comments. This ensures that the fix is applied after all module commands have been added.


535-546: LGTM! Well-implemented fix for the node flag issue.

The implementation correctly:

  1. Follows the same pattern as other fix functions in the file
  2. Uses flags.AddQueryFlagsToCmd(cmd) as recommended
  3. Handles the case where the command might not exist
  4. Includes clear documentation explaining the purpose

The function resolves the issue where the Wasm build-address query was attempting to connect to a node without having the proper flags configured.

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 and nitpick comments (1)
.changelog/unreleased/bug-fixes/2194-fix-wasm-build-addr.md (1)

1-1: Enhance the changelog entry with more specific details.

The current changelog entry is too vague. Consider providing more specific details about the --node flag and the issue it resolves.

Here's a suggested revision:

-* Add the query flags to the query wasm build-addr command [PR 2194](https://github.com/provenance-io/provenance/pull/2194).
+* Add the `--node` flag to the `query wasm build-addr` command to allow specifying custom node endpoints, fixing connection errors when a local node is not available [PR 2194](https://github.com/provenance-io/provenance/pull/2194).
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 5656944 and d2c62a3.

📒 Files selected for processing (1)
  • .changelog/unreleased/bug-fixes/2194-fix-wasm-build-addr.md (1 hunks)

@GunanshuJoshi
Copy link
Author

Hi @SpicyLemon @iramiller
I have made the required changes. Please review and let me know if anything is left.

@SpicyLemon SpicyLemon enabled auto-merge (squash) October 24, 2024 20:21
@SpicyLemon
Copy link
Contributor

Hi SpicyLemon iramiller I have made the required changes. Please review and let me know if anything is left.

Looks good! Thanks for the fix!

@SpicyLemon
Copy link
Contributor

Oh darn. Sorry. We require all commits to be signed, so this can't be merged as it is. I've recreated it as #2199 (with signed commits), and I'll close this one.

Here's more info on signing commits: https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits

Thanks again for the fix!

@SpicyLemon SpicyLemon closed this Oct 24, 2024
auto-merge was automatically disabled October 24, 2024 20:56

Pull request was closed

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.

5 participants