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(x/upgrade): register missing implementation for SoftwareUpgradeProposal #23179

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

mmsqe
Copy link
Contributor

@mmsqe mmsqe commented Jan 4, 2025

to avoid no concrete type registered for type URL /cosmos.upgrade.v1beta1.SoftwareUpgradeProposal against interface *v1beta1.Content error

Description

Closes: #XXXX


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, you can find examples of the prefixes below:
  • confirmed ! in 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
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • 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.

Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Resolved an issue in the upgrade module where SoftwareUpgradeProposal was missing a concrete type registration
    • Improved error handling for software upgrade proposals
  • Module Changes

    • Removed deprecated modules: x/params, x/crisis, x/distribution
    • Added new modules: x/protocolpool, x/validate
  • Documentation

    • Updated UPGRADING.md with comprehensive migration instructions for developers
    • Enhanced module-specific upgrade and migration guidelines
  • Governance

    • Introduced support for expedited and cancellable proposals in the governance module

These changes enhance the Cosmos SDK's modularity, error handling, and upgrade processes.

…oposal

to avoid no concrete type registered
for type URL /cosmos.upgrade.v1beta1.SoftwareUpgradeProposal against interface *v1beta1.Content error
Copy link
Contributor

coderabbitai bot commented Jan 4, 2025

📝 Walkthrough

Walkthrough

This pull request focuses on enhancing the Cosmos SDK's upgrade module by addressing a registration issue for SoftwareUpgradeProposal. The changes span multiple files in the x/upgrade module, including CHANGELOG.md, UPGRADING.md, and various type-related files. The primary goal is to register the missing implementation for SoftwareUpgradeProposal to prevent runtime errors when handling upgrade proposals, while also updating documentation and testing infrastructure.

Changes

File Change Summary
CHANGELOG.md Added bug fix entry for x/upgrade module registration
UPGRADING.md Comprehensive documentation updates for module migrations and changes
x/upgrade/types/codec.go Added import and interface registration for SoftwareUpgradeProposal
x/upgrade/types/codec_test.go Added new test function for interface registration validation
x/upgrade/types/proposal.go Implemented methods for SoftwareUpgradeProposal handling

Possibly related PRs

Suggested Labels

T:Docs

Suggested Reviewers

  • tac0turtle
  • julienrbrt
  • akhilkumarpilli
  • sontrinh16

Finishing Touches

  • 📝 Generate Docstrings (Beta)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

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.

@tac0turtle
Copy link
Member

with messages in gov v1, there shouldnt be a need for this.

@mmsqe
Copy link
Contributor Author

mmsqe commented Jan 5, 2025

with messages in gov v1, there shouldnt be a need for this.

not sure but I need register this when using tx upgrade

@julienrbrt
Copy link
Member

with messages in gov v1, there shouldnt be a need for this.

not sure but I need register this when using tx upgrade

Very weird, tx upgrade uses gov v1:

if err := proposal.SetMsgs([]sdk.Msg{

Are you submitting a legacy upgrade proposal and then querying it on the updated binary?

@mmsqe
Copy link
Contributor Author

mmsqe commented Jan 6, 2025

Are you submitting a legacy upgrade proposal and then querying it on the updated binary?

Upgrade is from sdk50 binary to sdk52 using ethermintd tx upgrade software-upgrade sdk52 -y --no-validate --from community --title 'upgrade test' --note ditto --upgrade-height 48 --summary summary --deposit 10000aphoton

@mmsqe mmsqe marked this pull request as ready for review January 8, 2025 02:10
registrar.RegisterImplementations(
(*v1beta1.Content)(nil),
&SoftwareUpgradeProposal{},
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
)
)
registrar.RegisterImplementations(
(*v1beta1.Content)(nil),
&CancelSoftwareUpgradeProposal{},
)

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

🧹 Nitpick comments (5)
UPGRADING.md (1)

472-480: Consider adding error handling for the migration

The upgrade handler correctly calls MigrateAccountNumberUnsafe but it would be helpful to add some logging or telemetry to track the migration progress, especially for chains with many accounts.

app.UpgradeKeeper.SetUpgradeHandler(planName,
	func(ctx context.Context, _ upgradetypes.Plan, fromVM appmodule.VersionMap) (appmodule.VersionMap, error) {
+		logger := app.Logger()
+		logger.Info("starting account number migration")
		if err := authkeeper.MigrateAccountNumberUnsafe(ctx, &app.AuthKeeper); err != nil {
+			logger.Error("failed to migrate account numbers", "error", err)
			return nil, err
		}
+		logger.Info("completed account number migration")
		return app.ModuleManager.RunMigrations(ctx, app.configurator, fromVM)
	},
)
x/upgrade/types/codec_test.go (1)

17-33: Consider adding error test cases

While the happy path is tested, consider adding test cases for:

  1. Invalid TypeURL in Any
  2. Malformed Value in Any
  3. Missing interface registration
func TestInterfaceRegistrationOfContent(t *testing.T) {
	testCases := []struct {
		name    string
		typeURL string
		value   []byte
		expErr  bool
	}{
		{"valid case", "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal", []byte{}, false},
		{"invalid type url", "/invalid.Type.URL", []byte{}, true},
		{"malformed value", "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal", []byte{0x1}, true},
	}
	
	for _, tc := range testCases {
		t.Run(tc.name, func(t *testing.T) {
			// ... test implementation
		})
	}
}
CHANGELOG.md (3)

Line range hint 1-1: Add missing title to the CHANGELOG

The CHANGELOG file should start with a # title like "# Changelog" for better documentation structure.

+ # Changelog

Line range hint 14-25: Consider adding a table of contents

For better navigation in such a large CHANGELOG, consider adding a table of contents at the top listing the major versions.


Line range hint 2968-2970: Add link to current CHANGELOG

The reference to "CHANGELOG of previous versions" should include a link to the current CHANGELOG file as well for completeness.

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 517839b and 81ebfa3.

📒 Files selected for processing (5)
  • CHANGELOG.md (1 hunks)
  • UPGRADING.md (1 hunks)
  • x/upgrade/types/codec.go (2 hunks)
  • x/upgrade/types/codec_test.go (1 hunks)
  • x/upgrade/types/proposal.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
x/upgrade/types/codec_test.go (2)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.


Pattern **/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"

x/upgrade/types/codec.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

x/upgrade/types/proposal.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

CHANGELOG.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

UPGRADING.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: tests (03)
  • GitHub Check: tests (00)
  • GitHub Check: test-simapp-v2
  • GitHub Check: test-system-v2
  • GitHub Check: test-integration
  • GitHub Check: build (arm64)
  • GitHub Check: build (amd64)
  • GitHub Check: Analyze
  • GitHub Check: golangci-lint
  • GitHub Check: Summary
🔇 Additional comments (6)
UPGRADING.md (1)

482-488: LGTM: Store upgrade configuration is correct

The store upgrade correctly adds the accounts module store key to the list of added stores during the upgrade.

x/upgrade/types/proposal.go (3)

8-15: LGTM: Clean implementation of proposal interface methods

The GetTitle, GetDescription, and ProposalRoute methods are implemented correctly and well documented.


20-21: LGTM: ValidateBasic implementation

The ValidateBasic method correctly delegates to v1beta1.ValidateAbstract for title and description validation.


17-18: Verify ProposalType return value

The method returns v1beta1.ProposalTypeText which seems incorrect for a software upgrade proposal. Consider if this should return a more specific proposal type.

✅ Verification successful

ProposalType implementation is correct

Returning ProposalTypeText is the expected behavior. The gov module provides base proposal types, and modules register their proposal types through the RegisterProposalType function. The recent CHANGELOG entry confirms the SoftwareUpgradeProposal implementation was properly registered.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if there are any other upgrade proposals using ProposalTypeText
rg -A 1 'func.*ProposalType\(\).*string.*{.*return.*ProposalTypeText'

Length of output: 246


Script:

#!/bin/bash
# Search for ProposalType implementations
rg "func.*ProposalType.*string"

# Search for proposal type constants
rg "ProposalType[A-Za-z]+ += +"

# Check the v1beta1 package for proposal types
fd "v1beta1" --type f --exec rg -A 2 "type.*Proposal.*interface|const.*ProposalType"

Length of output: 1170


Script:

#!/bin/bash
# Search for upgrade proposal related constants and types
rg -A 3 "const.*ProposalType|type.*Upgrade.*Proposal"

# Check the content registry for upgrade proposals
rg -A 5 "RegisterProposalType.*upgrade"

Length of output: 4029


Script:

#!/bin/bash
# Check v1beta1 package for proposal type constants
fd "v1beta1" --type f --exec rg "const.*ProposalType.*=|var.*ProposalType.*="

# Check the specific file where ProposalTypeText is used
cat x/gov/types/v1beta1/proposal.go

Length of output: 7256

x/upgrade/types/codec.go (1)

27-30: LGTM: Interface registration is correct

The implementation correctly registers SoftwareUpgradeProposal as a Content interface implementation.

The previous suggestion about adding CancelSoftwareUpgradeProposal has been addressed in the code.

CHANGELOG.md (1)

Line range hint 1-3000: LGTM on overall CHANGELOG structure and content

The CHANGELOG follows good practices:

  • Proper categorization of changes (Features, Bug Fixes, etc.)
  • Clear descriptions with PR/issue links
  • Follows semantic versioning
  • Includes migration notes and breaking changes

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.

3 participants