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

chore(x/accounts): use cosmossdk.io/core/codec instead of github.com/cosmos/cosmos-sdk/codec #23313

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

Conversation

caseylove
Copy link
Contributor

@caseylove caseylove commented Jan 10, 2025

Description

Partially addresses: #23253

Also, this PR is a supplementary of #23300 for test files

Summary by CodeRabbit

  • Dependency Updates

    • Updated codec import from Cosmos SDK to cosmossdk.io/core/codec
    • Replaced legacy codec package references in multiple test utility files
  • Code Maintenance

    • Introduced mockStateCodec struct in test files to implement new codec interface
    • Updated function signatures to use new codec type in account implementation

@caseylove caseylove requested a review from a team as a code owner January 10, 2025 09:29
Copy link
Contributor

coderabbitai bot commented Jan 10, 2025

📝 Walkthrough

Walkthrough

The pull request focuses on updating the codec import across multiple files in the x/accounts module. The changes involve replacing the existing codec import from github.com/cosmos/cosmos-sdk/codec with a new import from cosmossdk.io/core/codec. This modification is consistently applied across test utility files and the implementation file. The mockStateCodec struct is introduced in test files to implement the new codec interface, with minor adjustments to handling nil messages in some cases.

Changes

File Change Summary
x/accounts/defaults/base/utils_test.go Updated codec import from Cosmos SDK to core codec
x/accounts/defaults/lockup/utils_test.go Updated codec import and modified Marshal method to handle nil messages
x/accounts/defaults/multisig/utils_test.go Updated codec import with new mockStateCodec implementation
x/accounts/internal/implementation/implementation.go Updated codec import and modified MakeAccountsMap function parameter type

Possibly related PRs

Suggested labels

C:x/accounts, C:x/accounts/lockup, C:x/upgrade

Suggested reviewers

  • tac0turtle
  • julienrbrt
  • lucaslopezf
  • akhilkumarpilli
  • kocubinski

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.

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/accounts/internal/implementation/implementation.go (1)

Line range hint 19-24: Consider updating the interface definition.

The LegacyStateCodec interface could be updated to use the new codec.Codec type directly instead of defining the interface inline.

-	LegacyStateCodec interface {
-		Marshal(gogoproto.Message) ([]byte, error)
-		Unmarshal([]byte, gogoproto.Message) error
-	}
+	LegacyStateCodec codec.Codec
x/accounts/defaults/multisig/utils_test.go (1)

Line range hint 29-126: Consider simplifying the mock implementation.

While the implementation is thorough, most methods panic with "unimplemented". Consider:

  1. Using a more focused mock that only implements the required methods
  2. Adding TODO comments for methods that might be needed in future tests
type mockStateCodec struct {
	codec.Codec
}

-// GetMsgAnySigners implements codec.Codec.
-func (mockStateCodec) GetMsgAnySigners(msg *types.Any) ([][]byte, protoreflect.Message, error) {
-	panic("unimplemented")
-}
-// ... (remove other unimplemented methods)

// Only keep the methods that are actually used
func (c mockStateCodec) Marshal(m gogoproto.Message) ([]byte, error) {
	if m == nil || gogoproto.Size(m) == 0 {
		return []byte{}, nil
	}
	return gogoproto.Marshal(m)
}

func (c mockStateCodec) Unmarshal(bz []byte, ptr gogoproto.Message) error {
	return gogoproto.Unmarshal(bz, ptr)
}

// TODO: Implement other methods as needed for future tests
📜 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 c0f05e5.

📒 Files selected for processing (4)
  • x/accounts/defaults/base/utils_test.go (1 hunks)
  • x/accounts/defaults/lockup/utils_test.go (1 hunks)
  • x/accounts/defaults/multisig/utils_test.go (1 hunks)
  • x/accounts/internal/implementation/implementation.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
x/accounts/defaults/base/utils_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/accounts/defaults/lockup/utils_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/accounts/defaults/multisig/utils_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/accounts/internal/implementation/implementation.go (1)

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

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: test-simapp-v2
  • GitHub Check: test-system-v2
  • GitHub Check: Analyze
  • GitHub Check: Summary
🔇 Additional comments (6)
x/accounts/defaults/base/utils_test.go (2)

12-12: LGTM: Import change aligns with the PR objective.

The transition to cosmossdk.io/core/codec is correctly implemented.


Line range hint 27-41: LGTM: Robust implementation of mockStateCodec.

The implementation correctly handles:

  • Nil message cases
  • Empty message cases
  • Proper marshaling/unmarshaling
x/accounts/defaults/lockup/utils_test.go (2)

13-13: LGTM: Consistent import update.

The import change aligns with the PR objective and maintains consistency with other files.


Line range hint 28-42: LGTM: Consistent mockStateCodec implementation.

The implementation maintains consistency with other test files and properly handles edge cases.

x/accounts/internal/implementation/implementation.go (1)

12-12: LGTM: Clean import update.

The transition to cosmossdk.io/core/codec is properly implemented in this core file.

x/accounts/defaults/multisig/utils_test.go (1)

15-15: LGTM: Consistent import update.

The import change aligns with the PR objective and maintains consistency across the codebase.

@tac0turtle
Copy link
Member

seems like a few tests are failing, can you look into them

@caseylove
Copy link
Contributor Author

seems like a few tests are failing, can you look into them

Thanks, I'm going to check this

@tac0turtle
Copy link
Member

could you please merge all your prs making the same change in other repos into this pr. It helps reduce the amount of reviews needed

@caseylove
Copy link
Contributor Author

caseylove commented Jan 10, 2025

could you please merge all your prs making the same change in other repos into this pr. It helps reduce the amount of reviews needed

@tac0turtle Hi sir, how about combining all these PRs into three PRs?

@aljo242
Copy link
Contributor

aljo242 commented Jan 10, 2025

could you please merge all your prs making the same change in other repos into this pr. It helps reduce the amount of reviews needed

@tac0turtle Hi sir, how about combining all these PRs into three PRs?

@caseylove just combining all into one (this PR) would be best

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