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: introduce cli commands for the upgrade module #2910

Merged
merged 12 commits into from
Dec 8, 2023
Merged

Conversation

cmwaters
Copy link
Contributor

@cmwaters cmwaters commented Dec 6, 2023

Addresses: #2875

This also adds an integration test to the upgrade module

Copy link
Contributor

coderabbitai bot commented Dec 6, 2023

Walkthrough

Walkthrough

The changes across various files indicate an update to the upgrade module in a blockchain application, likely built on the Cosmos SDK. The updates include the addition of new RPC functions and message types for upgrade attempts, modifications to keeper logic and tallying of votes, and enhancements to testing suites to cover the new functionality. The changes suggest a shift towards a more dynamic and possibly governance-driven upgrade process.

Changes

File Path Change Summary
app/app.go, proto/.../tx.proto Modified UpgradeKeeper initialization; added ResetTally call in EndBlocker. Added TryUpgrade RPC function and related message types.
test/util/test_app.go, x/upgrade/cli/cli_test.go Added import; modified SetupTestAppWithGenesisValSet to set Version. Added test functions and setup function; updated imports.
x/upgrade/cli/query.go, x/upgrade/cli/tx.go Introduced cli package; added CmdQueryTally, GetTxCmd, CmdSignalVersion, and CmdTryUpgrade functions.
x/upgrade/integration_test.go, x/upgrade/keeper.go Added TestUpgradeIntegration test function. Changed Keeper to pointer receiver; added TryUpgrade and ResetTally methods; modified VersionTally and TallyVotingPower.
x/upgrade/module.go, x/upgrade/tally_test.go Added import; changed parameter to pointer; removed EndBlock function. Added TestEmptyStore function; refactored setup function; added newMockStakingKeeper constructor.
x/upgrade/types/msgs.go, app/test/std_sdk_test.go Added MsgTryUpgrade entity and related methods; modified MsgSignalVersion declaration. Added import; added cfg field; added methods; added test cases.
test/util/genesis/genesis.go, test/util/testnode/config.go Removed import; changed function call; removed DefaultConsensusParams function. Removed import; modified DefaultConfig function.

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

@celestia-bot celestia-bot requested a review from a team December 6, 2023 16:11
x/upgrade/tally_test.go Show resolved Hide resolved
x/upgrade/integration_test.go Show resolved Hide resolved
x/upgrade/cli/query.go Outdated Show resolved Hide resolved
x/upgrade/cli/tx.go Show resolved Hide resolved
evan-forbes
evan-forbes previously approved these changes Dec 6, 2023
Copy link
Member

@evan-forbes evan-forbes left a comment

Choose a reason for hiding this comment

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

dope!

do you think its worth it to run the msgs through the anti handlers in some way? perhaps we could just add them to

func (s *StandardSDKIntegrationTestSuite) TestStandardSDK() {
(and maybe rename that test)

it might be overly paranoid, but the reason being that we could remove the output to something like the getsigners method (or other critical piece) atm and all tests would pass.

rootulp
rootulp previously approved these changes Dec 6, 2023
Copy link
Collaborator

@rootulp rootulp left a comment

Choose a reason for hiding this comment

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

LGTM

x/upgrade/cli/query.go Outdated Show resolved Hide resolved
x/upgrade/cli/query.go Outdated Show resolved Hide resolved
x/upgrade/cli/tx.go Outdated Show resolved Hide resolved
})
require.NoError(t, err)
require.EqualValues(t, 1, res.VotingPower)
require.EqualValues(t, 0, res.ThresholdPower)
Copy link
Collaborator

Choose a reason for hiding this comment

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

[optional] this threshold power seems weird b/c it makes me think that no votes are needed to trigger an upgrade.
Is it possible for this test case to have a non-zero threshold power potentially by adding another validator with some voting power?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So currently as it stands, there has to be strictly greater than the threshold power for the upgrade to occur. If we think it is better to present threshold as "greater or equal to" then I can increment this buy 1. Whatever we feel is more intuitive for users

x/upgrade/tally_test.go Show resolved Hide resolved
@cmwaters cmwaters dismissed stale reviews from rootulp and evan-forbes via 6f6c72a December 7, 2023 10:33
@celestia-bot celestia-bot requested a review from a team December 7, 2023 10:33
Comment on lines +63 to +70
func CmdTryUpgrade() *cobra.Command {
cmd := &cobra.Command{
Use: "try-upgrade",
Short: "Try to perform a software upgrade",
Long: `This command will submit a TryUpgrade message to tally all
the signal votes. If a quorum has been reached, the network will upgrade
to the signalled version at the following height.
`,
Copy link
Contributor

Choose a reason for hiding this comment

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

The CmdTryUpgrade command's description provides information on the tallying of votes and the upgrade process. It would be beneficial to include additional details or output examples in the help text or documentation to guide users on what to expect after executing this command, especially regarding how they can confirm that an upgrade is in progress or will occur.

@cmwaters
Copy link
Contributor Author

cmwaters commented Dec 7, 2023

FYI: I've modified the meaning of threshold here from "strictly greater" to "greater than equal" which I think is more intuitive for users. I've added some test cases to make sure my math is right

@cmwaters
Copy link
Contributor Author

cmwaters commented Dec 7, 2023

do you think its worth it to run the msgs through the anti handlers in some way? perhaps we could just add them to

func (s *StandardSDKIntegrationTestSuite) TestStandardSDK() {

(and maybe rename that test)
it might be overly paranoid, but the reason being that we could remove the output to something like the getsigners method (or other critical piece) atm and all tests would pass.

Yup! done

evan-forbes
evan-forbes previously approved these changes Dec 7, 2023
rootulp
rootulp previously approved these changes Dec 7, 2023
Copy link
Collaborator

@rootulp rootulp left a comment

Choose a reason for hiding this comment

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

🚢 great work!

@cmwaters cmwaters dismissed stale reviews from rootulp and evan-forbes via 2e29003 December 7, 2023 21:54
@celestia-bot celestia-bot requested a review from a team December 7, 2023 21:54
@cmwaters cmwaters merged commit 0c09689 into main Dec 8, 2023
30 checks passed
@cmwaters cmwaters deleted the cal/upgrade-cli branch December 8, 2023 10:56
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.

4 participants