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

Add cli to submit gov proposal to upgrade multiple channels #5548

Conversation

chatton
Copy link
Contributor

@chatton chatton commented Jan 8, 2024

Description

closes: #5540

This PR adds a CLI to which queries all channels, and allows for specifying a pattern for the portID, and an optional comma separated list for channelIDs which will either generate a proposal.json file which contains MsgChanUpgradeInits, or actually broadcast a MsgSubmitProposal directly.

--dry-run will behave the same way as --json.

I can add documentation in a follow up if this approach gets merged.


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/) or specification (x/<module>/spec/).
  • Added relevant godoc comments.
  • Provide a commit message to be used for the changelog entry in the PR description for review.
  • Re-reviewed Files changed in the Github PR explorer.
  • Review Codecov Report in the comment section below once CI passes.

Comment on lines +102 to +103
msgUpgradeInit := types.NewMsgChannelUpgradeInit(ch.PortId, ch.ChannelId, types.NewUpgradeFields(ch.Ordering, ch.ConnectionHops, versionStr), clientCtx.GetFromAddress().String())
msgs = append(msgs, msgUpgradeInit)
Copy link
Contributor Author

@chatton chatton Jan 8, 2024

Choose a reason for hiding this comment

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

I left ordering and connection hops unchanged, and only the version string changes. Technically we can allow these fields to be updated, but I think the version string will be all that we need 99% of the time. As far as bulk creating MsgChanUpgradeInits is concerned

Copy link
Contributor

@colin-axner colin-axner 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 @chatton! Looks great to me!

Use: "upgrade-channels",
Short: "Upgrade IBC channels",
Long: `Submit a governance proposal to upgrade all open channels whose port matches a specified pattern
(the default is transfer), optionally, specific an exact list of channel IDs with a comma separated list.`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
(the default is transfer), optionally, specific an exact list of channel IDs with a comma separated list.`,
(the default is transfer), optionally, an exact list of comma separated channel IDs may be specified.`,

Copy link
Contributor

Choose a reason for hiding this comment

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

should we specify in this docstring that if channel IDs are specified then it must match the specified port? or leave that for the longer documentation?

Copy link
Contributor

@charleenfei charleenfei left a comment

Choose a reason for hiding this comment

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

just one doc related comment, thanks @chatton!

Use: "upgrade-channels",
Short: "Upgrade IBC channels",
Long: `Submit a governance proposal to upgrade all open channels whose port matches a specified pattern
(the default is transfer), optionally, specific an exact list of channel IDs with a comma separated list.`,
Copy link
Contributor

Choose a reason for hiding this comment

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

should we specify in this docstring that if channel IDs are specified then it must match the specified port? or leave that for the longer documentation?

@charleenfei charleenfei added the channel-upgradability Channel upgradability feature label Jan 8, 2024
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 for the quick turnaround, @chatton! I just left a suggestion to maybe simplify some code.

Comment on lines 40 to 76
depositStr := args[0]
versionStr := args[1]

metadata, err := cmd.Flags().GetString(flagMetadata)
if err != nil {
return err
}

summary, err := cmd.Flags().GetString(flagSummary)
if err != nil {
return err
}

title, err := cmd.Flags().GetString(flagTitle)
if err != nil {
return err
}

portPattern, err := cmd.Flags().GetString(flagPortPattern)
if err != nil {
return err
}

commaSeparatedChannelIDs, err := cmd.Flags().GetString(flagChannelIDs)
if err != nil {
return err
}

displayJSON, err := cmd.Flags().GetBool(flagJSON)
if err != nil {
return err
}

expidited, err := cmd.Flags().GetBool(flagExpedited)
if err != nil {
return err
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can maybe simplify all this code about the gov flags with a call ReadGovPropFlags like here, including the deposit parameter. And that function will return us a govv1.MsgSubmitProposal where we can add the messages.

Copy link
Contributor

Choose a reason for hiding this comment

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

yea, could also add AddGovPropFlagsToCmd though we do set a sensible default here so fine either way (maybe add and override default value?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

great suggestions, will implement these.

return cmd
}

// channelShouldBeUpgraded returns a boolean indicated whether or not the given channel should be upgraded based
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// channelShouldBeUpgraded returns a boolean indicated whether or not the given channel should be upgraded based
// channelShouldBeUpgraded returns a boolean indicating whether or not the given channel should be upgraded based

@DimitrisJim DimitrisJim mentioned this pull request Jan 9, 2024
9 tasks
@chatton
Copy link
Contributor Author

chatton commented Jan 9, 2024

just one doc related comment, thanks @chatton!

I think we can leave this for the longer docs

@@ -50,7 +50,8 @@ func NewTxCmd() *cobra.Command {
}

txCmd.AddCommand(
NewPruneAcknowledgementsTxCmd(),
newUpgradeChannelsTxCmd(),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

unexported this to stay consistent, I don't think this needs to be exported.

@chatton chatton mentioned this pull request Jan 9, 2024
9 tasks
@chatton chatton merged commit 11b301b into main Jan 9, 2024
61 checks passed
@chatton chatton deleted the cian/issue#5540-add-cli-to-submit-gov-proposal-to-upgrade-multiple-channels branch January 9, 2024 11:17
mergify bot pushed a commit that referenced this pull request Jan 9, 2024
damiannolan pushed a commit that referenced this pull request Jan 9, 2024
…5555)

(cherry picked from commit 11b301b)

Co-authored-by: Cian Hatton <cian@interchain.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
channel-upgradability Channel upgradability feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add CLI to submit gov proposal to upgrade multiple channels
5 participants