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 6 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

  • Documentation

    • Updated UPGRADING.md with significant Cosmos SDK changes
    • Detailed migration instructions for modules and account management
  • New Features

    • Introduced x/protocolpool and x/validate modules
    • Added support for expedited and cancellable governance proposals
  • Module Changes

    • Removed x/params, x/crisis, and x/distribution modules
    • Extracted x/evidence, x/nft, and x/feegrant as standalone modules
  • Bug Fixes

    • Resolved implementation issue with SoftwareUpgradeProposal
  • Refactor

    • Simplified transaction handling
    • Updated method signatures across various components

…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

The pull request introduces significant modifications to the Cosmos SDK, focusing on modularization, improved transaction handling, and enhanced governance features. Key changes include the removal of several modules like x/params and x/crisis, introduction of new modules such as x/protocolpool and x/validate, and updates to existing modules like x/upgrade and x/gov. The documentation emphasizes migration paths for account management, transaction execution, and module-specific parameter handling, reflecting a substantial restructuring of the SDK's architecture.

Changes

File Change Summary
UPGRADING.md - Removed x/params module
- Introduced migration to x/accounts module
- Updated client package for address codecs
- Simplified SimApp configuration
- Removed/updated x/crisis, x/distribution modules
x/upgrade/types/codec.go - Added import for v1beta1 governance types
- Enhanced interface registration for SoftwareUpgradeProposal
x/upgrade/types/codec_test.go - Added new test function TestInterfaceRegistrationOfContent
x/upgrade/types/proposal.go - Added methods for SoftwareUpgradeProposal:
- GetTitle()
- GetDescription()
- ProposalRoute()
- ProposalType()
- ValidateBasic()
x/upgrade/CHANGELOG.md - Added bug fix entry for missing SoftwareUpgradeProposal implementation
x/upgrade/go.mod - Added direct dependency on cosmossdk.io/x/tx v1.0.0

Sequence Diagram

sequenceDiagram
    participant Client
    participant UpgradeModule
    participant GovModule
    participant AccountsModule

    Client->>UpgradeModule: Submit SoftwareUpgradeProposal
    UpgradeModule->>GovModule: Register Proposal
    GovModule->>Client: Proposal Registered
    Client->>GovModule: Vote on Proposal
    GovModule->>AccountsModule: Prepare Migration
    AccountsModule->>Client: Migration Ready
    Client->>UpgradeModule: Execute Upgrade
    UpgradeModule->>Client: Upgrade Complete
Loading

Possibly related PRs

Suggested labels

C:x/gov, backport/v0.52.x

Suggested reviewers

  • julienrbrt
  • tac0turtle
  • akhilkumarpilli

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

@bearycool11 bearycool11 mentioned this pull request Jan 5, 2025
12 tasks
@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

@julienrbrt
Copy link
Member

Can you run go mod tidy all script?

CHANGELOG.md Outdated
@@ -56,6 +56,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
* (x/auth/tx) [#23170](https://github.com/cosmos/cosmos-sdk/pull/23170) Avoid panic from newWrapperFromDecodedTx when AuthInfo.Fee is optional in decodedTx.
* (x/auth/tx) [23144](https://github.com/cosmos/cosmos-sdk/pull/23144) Add missing CacheWithValue for ExtensionOptions.
* (x/auth/tx) [#23148](https://github.com/cosmos/cosmos-sdk/pull/23148) Avoid panic from intoAnyV2 when v1.PublicKey is optional.
* (x/upgrade) [#23179](https://github.com/cosmos/cosmos-sdk/pull/23179) Register missing implementation for SoftwareUpgradeProposal to avoid no concrete type registered for type URL /cosmos.upgrade.v1beta1.SoftwareUpgradeProposal against interface *v1beta1.Content error.
Copy link
Member

Choose a reason for hiding this comment

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

Should be under x/upgrade/changelog.md

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 (2)
x/upgrade/CHANGELOG.md (1)

28-30: Add blank lines for better readability.

To maintain consistent formatting throughout the changelog:

 ## [Unreleased]
 
+### Bug Fixes
 
 * (x/upgrade) [#23179](https://github.com/cosmos/cosmos-sdk/pull/23179) Register missing implementation for SoftwareUpgradeProposal to avoid no concrete type registered for type URL /cosmos.upgrade.v1beta1.SoftwareUpgradeProposal against interface *v1beta1.Content error.
🧰 Tools
🪛 Markdownlint (0.37.0)

28-28: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines

(MD022, blanks-around-headings)


29-29: null
Lists should be surrounded by blank lines

(MD032, blanks-around-lists)

x/upgrade/go.mod (1)

14-14: Consider using a more flexible version constraint

The dependency is strictly pinned to v1.0.0. Consider using a more flexible version constraint (e.g., v1.x.x) to allow for minor and patch updates while maintaining compatibility.

-	cosmossdk.io/x/tx v1.0.0
+	cosmossdk.io/x/tx v1.0.0 // indirect
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 81ebfa3 and 2b98de2.

📒 Files selected for processing (2)
  • x/upgrade/CHANGELOG.md (1 hunks)
  • x/upgrade/go.mod (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
x/upgrade/CHANGELOG.md (1)

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

🪛 Markdownlint (0.37.0)
x/upgrade/CHANGELOG.md

28-28: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines

(MD022, blanks-around-headings)


29-29: null
Lists should be surrounded by blank lines

(MD032, blanks-around-lists)

⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: tests (00)
  • GitHub Check: test-simapp-v2
  • GitHub Check: test-system-v2
  • GitHub Check: test-integration
  • GitHub Check: Analyze
  • GitHub Check: build (amd64)
  • GitHub Check: Summary
🔇 Additional comments (3)
x/upgrade/CHANGELOG.md (2)

28-30: LGTM! The changelog entry is well-structured and informative.

The entry follows the changelog guidelines, correctly categorizes the change as a bug fix, and provides clear context about the issue being resolved.

🧰 Tools
🪛 Markdownlint (0.37.0)

28-28: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines

(MD022, blanks-around-headings)


29-29: null
Lists should be surrounded by blank lines

(MD032, blanks-around-lists)


Line range hint 1-27: LGTM! The changelog structure follows best practices.

The file maintains a clear structure with well-defined sections, follows semantic versioning, and includes proper documentation of the guiding principles.

🧰 Tools
🪛 Markdownlint (0.37.0)

28-28: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines

(MD022, blanks-around-headings)


29-29: null
Lists should be surrounded by blank lines

(MD032, blanks-around-lists)

x/upgrade/go.mod (1)

14-14: Verify the necessity of the tx dependency

Given the discussion about gov v1 handling upgrade proposals, please verify if this direct dependency on cosmossdk.io/x/tx is necessary for the SoftwareUpgradeProposal implementation.

Run the following script to analyze the usage of tx package in the upgrade module:

✅ Verification successful

Dependency on cosmossdk.io/x/tx is necessary

The dependency is required for the core type system infrastructure, specifically for interface registration and codec configuration of upgrade proposals. The package provides essential functionality for address coding and validator address handling used in the module's type registration system.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the tx package is actually used for SoftwareUpgradeProposal implementation

# Search for imports of the tx package
echo "Checking for tx package imports:"
rg --type go "cosmossdk.io/x/tx"

# Search for SoftwareUpgradeProposal implementation
echo -e "\nChecking SoftwareUpgradeProposal implementation:"
ast-grep --pattern 'type SoftwareUpgradeProposal struct {
  $$$
}'

Length of output: 11409


Script:

#!/bin/bash
# Check the specific usage of tx package in codec_test.go and any connections to SoftwareUpgradeProposal

echo "Checking codec_test.go content:"
cat x/upgrade/types/codec_test.go

echo -e "\nChecking for any connections between tx and SoftwareUpgradeProposal:"
rg -A 5 -B 5 "SoftwareUpgradeProposal" x/upgrade/types/codec_test.go

Length of output: 1529

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