Skip to content

feat(client/v2): support gov proposals#18461

Merged
julienrbrt merged 14 commits into
mainfrom
julien/gov-autocli
Nov 15, 2023
Merged

feat(client/v2): support gov proposals#18461
julienrbrt merged 14 commits into
mainfrom
julien/gov-autocli

Conversation

@julienrbrt
Copy link
Copy Markdown
Contributor

@julienrbrt julienrbrt commented Nov 14, 2023

Description

Closes: #18376
ref: #17222

  • Let autocli create gov proposals
  • Update autocli config of modules to support that

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
  • added ! to 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
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • run make lint and make test
  • 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 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)

Summary by CodeRabbit

  • New Features

    • Introduced support for governance proposals across various modules, allowing users to submit proposals for updating module parameters.
    • Added new CLI commands for creating governance proposals in different modules such as auth, bank, consensus, crisis, distribution, gov, mint, slashing, and staking.
    • Implemented new flags to control command behavior, including disabling prompts and proposal submissions.
  • Enhancements

    • Improved AutoCLI functionality to automatically create governance proposals by setting a field in RpcCommandOptions.
    • Enhanced command-line interface options with additional fields for usage, description, examples, and positional arguments.
  • Bug Fixes

    • Corrected capitalization in the README heading for consistency.
    • Fixed validation functions to correctly handle sdk.Coins and URLs.
  • Documentation

    • Updated README to include tips on creating governance proposals using AutoCLI.
    • Provided usage examples and descriptions for new CLI commands related to governance proposals.
  • Refactor

    • Renamed functions and updated comments to better reflect their purpose and functionality.
  • Style

    • Standardized capitalization in documentation headings.
  • Tests

    • Added tests for new validation functions to ensure proper handling of user input.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 14, 2023

Walkthrough

Walkthrough

The updates across various files introduce a new feature for governance proposals, allowing users to submit proposals to update module parameters via the CLI. This includes new commands, flags, and validation functions to support the feature. Breaking changes are made by removing address codecs from certain options, and the context now handles address codecs. The autocli package sees significant enhancements to handle government proposals, and new validation functions are added to ensure user input is correct.

Changes

File(s) Change Summary
client/v2/CHANGELOG.md Introduced support for governance proposals and API breaking changes by removing address codecs from options.
client/v2/README.md, client/v2/autocli/msg.go Added tips and handling for creating gov proposals with AutoCLI.
client/v2/autocli/flag/builder.go Modified addMessageFlags function to adjust the assignment of flagOptsByFlagName.
client/v2/autocli/msg.go, x/*/autocli.go Added new functions and commands for handling gov proposals and updating module params.
client/v2/internal/flags/flags.go, x/gov/client/cli/tx.go Introduced new flags for disabling prompts and proposal creation.
client/v2/internal/prompt/..., client/prompt_validation.go Added new validation functions and tests for user input, including non-empty, URL, and sdk.Coins validation.
x/auth/autocli.go, x/bank/autocli.go, x/consensus/autocli.go, x/crisis/autocli.go, x/distribution/autocli.go, x/gov/autocli.go, x/mint/autocli.go, x/slashing/autocli.go, x/staking/autocli.go Added or updated CLI commands and options for submitting proposals to update module parameters, marked as governance proposals.
x/upgrade/autocli.go, x/upgrade/client/cli/tx.go Modified and removed functions related to upgrade proposals, marking some as government proposals.
x/gov/client/cli/prompt.go, x/gov/client/cli/util.go Commented on using proto messages for simplification and refactored flag reading functions.

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

@julienrbrt julienrbrt marked this pull request as ready for review November 14, 2023 12:47
Comment thread x/auth/autocli.go
Short: "Submit a proposal to update auth module params. Note: the entire params must be provided.",
Example: fmt.Sprintf(`%s tx auth update-params-proposal '{ "max_memo_characters": 0, "tx_sig_limit": 0, "tx_size_cost_per_byte": 0, "sig_verify_cost_ed25519": 0, "sig_verify_cost_secp256k1": 0 }'`, version.AppName),
PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "params"}},
GovProposal: true,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is optional, if the authority is set to an multsig how would this change the flow of logic here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is there a flag allowing users to set this to false?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We can add a flag and skip the gov proposal. I initially didn't do it, as it already didn't existed, but we can easily support this yes.

Copy link
Copy Markdown
Contributor Author

@julienrbrt julienrbrt Nov 14, 2023

Choose a reason for hiding this comment

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

Majority of users will have their module authority be gov so that's why it's done like that.

@julienrbrt julienrbrt disabled auto-merge November 14, 2023 18:32
Copy link
Copy Markdown
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 17cbc97 and e329e20.
Files selected for processing (3)
  • client/v2/README.md (2 hunks)
  • client/v2/autocli/msg.go (5 hunks)
  • client/v2/internal/flags/flags.go (1 hunks)
Files skipped from review due to trivial changes (2)
  • client/v2/README.md
  • client/v2/internal/flags/flags.go
Additional comments: 5
client/v2/autocli/msg.go (5)
  • 120-126: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [120-130]

The context is being set on the command, but it's not clear if this context is being used properly downstream. Ensure that the context set here is being utilized in all subsequent calls that require a context, especially since it's being overwritten with a new value containing the client.ClientContextKey.

  • 152-165: The code is using a custom address codec to convert the signer's address from bytes to a string. This is a critical operation and should be handled with care. Ensure that the address codec is thoroughly tested, especially for edge cases and invalid inputs.

  • 187-189: The proto.Merge function is used to merge the input message into a new dynamic message. This is necessary because the SDK only supports proto v1 messages, while AutoCLI uses proto v2 messages. Ensure that this conversion does not lose any information or introduce any inconsistencies.

  • 203-210: The command's usage is silenced, which is a common practice for subcommands to avoid cluttering the output. However, ensure that this does not hinder the user experience, especially when it comes to understanding how to use the command or troubleshooting errors.

  • 215-252: The handleGovProposal function is setting the authority field of the message to the gov module address and creating a gov proposal. This is a significant change in behavior and should be carefully reviewed to ensure that it aligns with the intended governance proposal flow. Additionally, the error messages should be clear and informative to aid in debugging.

Copy link
Copy Markdown
Contributor

@odeke-em odeke-em left a comment

Choose a reason for hiding this comment

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

Thanks Julien, just some minor drive-by comments.

Comment thread client/prompt_validation.go Outdated
Comment thread client/v2/autocli/msg.go Outdated
Comment thread client/v2/autocli/msg.go Outdated
Copy link
Copy Markdown
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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between e329e20 and 75863fa.
Files selected for processing (3)
  • client/prompt_validation.go (1 hunks)
  • client/v2/autocli/msg.go (5 hunks)
  • client/v2/internal/prompt/validation.go (1 hunks)
Additional comments: 6
client/v2/internal/prompt/validation.go (1)
  • 1-36: The new prompt package and its functions for input validation are well-defined and follow good coding practices. The use of fmt.Errorf to wrap underlying errors with additional context is particularly good for debugging and user feedback. Ensure that these functions are being used wherever user input is accepted in the CLI to maintain consistency.
client/v2/autocli/msg.go (5)
  • 123-125: The context is being set on the command, but it's not clear if this context is being used properly downstream. Ensure that the context set here is being propagated and utilized in all subsequent calls that require a context.

  • 152-165: The code is checking if the address field is empty and then setting it to the signer's address. This is a good use of default values, but ensure that this behavior is documented and expected by the users of the function. If the address field is supposed to be set by the caller, this might override their input unexpectedly.

  • 187-189: The proto.Merge function is used to merge the input message into a new dynamic message. This is necessary because the SDK only supports proto v1 messages, while AutoCLI uses proto v2 messages. Ensure that this conversion does not lead to any data loss or transformation issues.

  • 203-210: The command is being configured to not show usage on error if it's a subcommand. This is a common pattern for CLI tools to avoid cluttering the output with usage text when the error is not related to command syntax. The addition of governance proposal flags is also a good practice to allow users to control the behavior of the command.

  • 215-253: The handleGovProposal function is setting the authority field to the governance module address and creating a governance proposal. This is a critical piece of functionality that should be thoroughly tested to ensure that it behaves correctly. The error handling and message setting seem appropriate, but it's important to ensure that the governance proposal is created with all the necessary information and that any errors are handled gracefully.

Comment on lines 47 to 53
return fmt.Errorf("invalid address: %w", err)
}

// ValidatePromptYesNo validates that the input is valid sdk.COins
// ValidatePromptCoins validates that the input contains valid sdk.Coins
func ValidatePromptCoins(input string) error {
if _, err := sdk.ParseCoinsNormalized(input); err != nil {
return fmt.Errorf("invalid coins: %w", err)
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot Nov 15, 2023

Choose a reason for hiding this comment

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

The change from sdk.COins to sdk.Coins corrects a typo in the function ValidatePromptCoins, ensuring that the function checks for valid sdk.Coins objects. This is a necessary fix for the function to work correctly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

lol. Changing a comment does not change the function behavior :D

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@julienrbrt You're absolutely right, updating the comment itself doesn't alter the function's behavior. The correction was made to ensure that the comment accurately reflects what the function does, which is important for code readability and maintainability. If there's anything else that needs attention in the code or comments, please let me know!

@julienrbrt julienrbrt enabled auto-merge November 15, 2023 11:08
@julienrbrt julienrbrt added this pull request to the merge queue Nov 15, 2023
Merged via the queue into main with commit 9c3386f Nov 15, 2023
@julienrbrt julienrbrt deleted the julien/gov-autocli branch November 15, 2023 11:30
mergify Bot pushed a commit that referenced this pull request Nov 15, 2023
(cherry picked from commit 9c3386f)

# Conflicts:
#	client/v2/CHANGELOG.md
#	client/v2/autocli/msg.go
#	client/v2/go.mod
#	client/v2/go.sum
#	go.mod
#	go.sum
#	simapp/go.mod
#	tests/go.mod
#	tests/starship/tests/go.mod
#	x/accounts/go.mod
#	x/auth/go.mod
#	x/auth/go.sum
#	x/authz/go.mod
#	x/bank/autocli.go
#	x/bank/go.mod
#	x/bank/go.sum
#	x/circuit/go.mod
#	x/circuit/go.sum
#	x/distribution/go.mod
#	x/distribution/go.sum
#	x/evidence/go.mod
#	x/evidence/go.sum
#	x/feegrant/go.mod
#	x/feegrant/go.sum
#	x/gov/go.mod
#	x/group/go.mod
#	x/group/go.sum
#	x/mint/go.mod
#	x/mint/go.sum
#	x/nft/go.mod
#	x/nft/go.sum
#	x/params/go.mod
#	x/params/go.sum
#	x/protocolpool/go.mod
#	x/protocolpool/go.sum
#	x/slashing/go.mod
#	x/slashing/go.sum
#	x/staking/go.mod
#	x/staking/go.sum
#	x/upgrade/client/cli/tx.go
#	x/upgrade/go.mod
#	x/upgrade/go.sum
github-merge-queue Bot pushed a commit that referenced this pull request Apr 3, 2025
Co-authored-by: Alex | Interchain Labs <alex@interchainlabs.io>
mergify Bot pushed a commit that referenced this pull request Apr 3, 2025
Co-authored-by: Alex | Interchain Labs <alex@interchainlabs.io>
(cherry picked from commit a2cf15c)

# Conflicts:
#	client/v2/CHANGELOG.md
#	client/v2/go.sum
github-merge-queue Bot pushed a commit that referenced this pull request Apr 3, 2025
mergify Bot added a commit that referenced this pull request Apr 4, 2025
…24359) (#24369)

Co-authored-by: julienrbrt <julien@rbrt.fr>
(cherry picked from commit 75a0e6a)

# Conflicts:
#	client/v2/go.mod
#	client/v2/go.sum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve support authority-gated/gov proposal commands in AutoCLI

4 participants