-
Notifications
You must be signed in to change notification settings - Fork 39
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
base: main
Are you sure you want to change the base?
Fix: Add node flag to WASM queries (build-address) #2194
Conversation
WalkthroughThe changes in this pull request focus on enhancing the command-line interface of the Changes
Poem
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
📒 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 SubcommandsEnsure 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:
@@ -222,6 +222,7 @@ func queryCommand() *cobra.Command { | |||
) | |||
|
|||
cmd.PersistentFlags().String(flags.FlagChainID, "", "The network chain ID") | |||
cmd.PersistentFlags().String(flags.FlagNode, "","The node to connect to (IP:Port)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider Adding the --node
Flag to the Root Command for Consistency
While adding the --node
flag to the queryCommand
enhances configurability for query operations, users may also benefit from specifying custom nodes for other commands, such as transactions or status checks. To provide a consistent user experience across all commands, consider adding the --node
flag to the root command. This ensures that the custom node endpoint is available globally and aligns with common CLI practices.
Apply this diff to add the --node
flag to the root command in the Execute
function:
func Execute(rootCmd *cobra.Command) error {
// existing code...
rootCmd.PersistentFlags().BoolP(config.EnvTypeFlag, "t", false, "Indicates this command should use the testnet configuration (default: false [mainnet])")
rootCmd.PersistentFlags().String(flags.FlagLogLevel, zerolog.InfoLevel.String(), "The logging level (trace|debug|info|warn|error|fatal|panic)")
rootCmd.PersistentFlags().String(flags.FlagLogFormat, cmtconfig.LogFormatPlain, "The logging format (json|plain)")
+ rootCmd.PersistentFlags().String(flags.FlagNode, "", "The node to connect to (IP:Port)")
// existing code...
executor := cmtcli.PrepareBaseCmd(rootCmd, "", app.DefaultNodeHome)
return executor.ExecuteContext(ctx)
}
Committable suggestion was skipped due to low confidence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the correct way to approach this. Each command will add the appropriate flags using the collection found with flags.AddTxFlagsToCmd(cmd)
if they are required. They should not be individually added as indicated here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iramiller, thank you for the clarification. You're absolutely correct that flags should be added to each command using flags.AddTxFlagsToCmd(cmd)
instead of individually adding them. I'll keep this in mind for future reviews.
(_/)
(•‿•)?
✏️ Learnings added
Learnt from: iramiller
PR: provenance-io/provenance#2194
File: cmd/provenanced/cmd/root.go:225-225
Timestamp: 2024-10-21T17:12:02.195Z
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.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
@@ -222,6 +222,7 @@ func queryCommand() *cobra.Command { | |||
) | |||
|
|||
cmd.PersistentFlags().String(flags.FlagChainID, "", "The network chain ID") | |||
cmd.PersistentFlags().String(flags.FlagNode, "","The node to connect to (IP:Port)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally speaking each command will have flags.AddQueryFlagsToCmd(cmd)
added (as appropriate). As one example the server.QueryBlockCmd()
already registers the required flag.
The |
Description
This PR adds a new
--node
flag to support custom endpoints for node connections while making Wasm queries specificallybuild-address
. This update ensures that theprovenanced q wasm build-address
command works correctly with custom node configurations.Issue:
While creating the predictable contract address I encountered the following error:
This occurred when running the following command:
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
(I haven't created any issue for this minor fix.)
docs/
) or specification (x/<module>/spec/
)..changelog/unreleased
(see Adding Changes).Files changed
in the Github PR explorer.Summary by CodeRabbit
New Features
Improvements
Miscellaneous Adjustments