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/staking): use cosmossdk.io/core/codec instead of github.com/cosmos/cosmos-sdk/codec #23289

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

Summary by CodeRabbit

  • Dependency Updates

    • Updated codec import from Cosmos SDK to core codec library across multiple staking module files.
  • Error Handling Improvements

    • Enhanced marshaling and unmarshaling processes with explicit error checking.
    • Replaced MustMarshal/Unmarshal methods with more robust error handling techniques.
  • Code Maintenance

    • Standardized error management in staking module type definitions and methods.
    • Migrated codec dependencies to new import path.

@caseylove caseylove requested review from JulianToledano, ziscky and a team as code owners January 10, 2025 02:52
Copy link
Contributor

coderabbitai bot commented Jan 10, 2025

📝 Walkthrough

Walkthrough

This pull request focuses on updating the codec import path from github.com/cosmos/cosmos-sdk/codec to cosmossdk.io/core/codec across multiple files in the staking module. The changes primarily involve modifying import statements and enhancing error handling in various functions. The modifications affect files related to migrations, module configuration, simulation, and type definitions, introducing more explicit error checking mechanisms while maintaining the core functionality of the staking module.

Changes

File Change Summary
x/staking/migrations/v5/store.go Updated codec import path
x/staking/migrations/v6/store.go Updated codec import path
x/staking/module.go - Updated codec import path
- Added explicit error handling in DefaultGenesis and InitGenesis methods
x/staking/simulation/decoder.go - Updated codec import path
- Replaced MustUnmarshal with Unmarshal with error checking
x/staking/types/delegation.go - Updated codec import path
- Enhanced error handling in marshaling functions
x/staking/types/genesis.go - Updated codec import path
- Improved error handling in GetGenesisStateFromAppState
x/staking/types/validator.go - Updated codec import path
- Modified MustMarshalValidator with explicit error handling

Possibly related PRs

Suggested labels

C:CLI, C:x/auth, C:x/upgrade, C:Cosmovisor, C:server/v2, C:x/accounts, C:x/protocolpool, C:x/epochs, C:x/accounts/multisig, C:x/accounts/lockup, backport/v0.52.x

Suggested reviewers

  • kocubinski
  • julienrbrt
  • facundomedica
  • tac0turtle
  • testinginprod
  • raynaudoe

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: 4

🔭 Outside diff range comments (1)
x/staking/module.go (1)

Line range hint 13-21: Fix import ordering

The imports need to be reordered according to the project's guidelines:

--skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order
📜 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 4995d2f.

📒 Files selected for processing (7)
  • x/staking/migrations/v5/store.go (1 hunks)
  • x/staking/migrations/v6/store.go (1 hunks)
  • x/staking/module.go (3 hunks)
  • x/staking/simulation/decoder.go (3 hunks)
  • x/staking/types/delegation.go (4 hunks)
  • x/staking/types/genesis.go (2 hunks)
  • x/staking/types/validator.go (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • x/staking/migrations/v5/store.go
🧰 Additional context used
📓 Path-based instructions (6)
x/staking/types/genesis.go (1)

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

x/staking/simulation/decoder.go (1)

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

x/staking/types/validator.go (1)

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

x/staking/module.go (1)

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

x/staking/types/delegation.go (1)

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

x/staking/migrations/v6/store.go (1)

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

🪛 golangci-lint (1.62.2)
x/staking/simulation/decoder.go

10-10: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

x/staking/types/validator.go

18-18: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

x/staking/types/delegation.go

11-11: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

x/staking/migrations/v6/store.go

8-8: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

🪛 GitHub Actions: Lint
x/staking/simulation/decoder.go

[error] 6-10: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

x/staking/types/validator.go

[error] 14-18: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

x/staking/module.go

[error] 13-21: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

x/staking/types/delegation.go

[error] 8-11: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

x/staking/migrations/v6/store.go

[error] 6-8: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze
  • GitHub Check: Summary
🔇 Additional comments (6)
x/staking/types/genesis.go (2)

8-8: LGTM: Import path updated correctly

The codec import path has been updated to use the new cosmossdk.io/core/codec package.


33-35: LGTM: Improved error handling

The change from MustUnmarshalJSON to UnmarshalJSON with explicit error handling improves the code's robustness and error reporting.

x/staking/simulation/decoder.go (1)

33-38: LGTM: Consistent error handling improvements

The changes from MustUnmarshal to Unmarshal with explicit error handling have been consistently applied across all type unmarshaling operations. This improves error reporting and makes the code more robust.

Also applies to: 49-54, 61-66, 73-78, 84-89, 95-100, 106-111

x/staking/module.go (1)

122-126: LGTM: Improved genesis error handling

The changes improve error handling in both DefaultGenesis and InitGenesis functions by making error handling explicit rather than using Must* functions.

Also applies to: 142-144

x/staking/types/delegation.go (1)

29-33: LGTM: Consistent error handling improvements

The changes from MustMarshal to Marshal with explicit error handling have been consistently applied across all marshaling operations (MustMarshalDelegation, MustMarshalUBD, and MustMarshalRED). This improves error reporting and makes the code more robust.

Also applies to: 150-154, 245-249

x/staking/types/validator.go (1)

155-159: LGTM! Improved error handling in MustMarshalValidator.

The explicit error checking provides better clarity about the source of panics while maintaining the expected behavior.

@@ -7,7 +7,7 @@ import (
"cosmossdk.io/math"
"cosmossdk.io/x/staking/types"

"github.com/cosmos/cosmos-sdk/codec"
"cosmossdk.io/core/codec"
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix import ordering

The imports need to be reordered according to the project's guidelines:

--skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order
🧰 Tools
🪛 golangci-lint (1.62.2)

10-10: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

🪛 GitHub Actions: Lint

[error] 6-10: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

Comment on lines 8 to 11
"cosmossdk.io/core/address"
"cosmossdk.io/math"

"github.com/cosmos/cosmos-sdk/codec"
"cosmossdk.io/core/codec"
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix import ordering

The imports need to be reordered according to the project's guidelines:

--skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order
🧰 Tools
🪛 golangci-lint (1.62.2)

8-8: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)


11-11: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

🪛 GitHub Actions: Lint

[error] 8-11: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

@@ -15,7 +15,7 @@ import (
"cosmossdk.io/errors"
"cosmossdk.io/math"

"github.com/cosmos/cosmos-sdk/codec"
"cosmossdk.io/core/codec"
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix import ordering to match project guidelines.

The imports need to be reordered following the project's guidelines: standard libs, default libs, cosmossdk.io prefixed imports, and github.com/cosmos/cosmos-sdk prefixed imports.

import (
	"bytes"
	"fmt"
	"net/url"
	"sort"
	"strings"
	"time"

	gogoprotoany "github.com/cosmos/gogoproto/types/any"

	"cosmossdk.io/core/address"
	"cosmossdk.io/core/appmodule"
-	"cosmossdk.io/errors"
-	"cosmossdk.io/math"
-	"cosmossdk.io/core/codec"
+	"cosmossdk.io/core/codec"
+	"cosmossdk.io/errors"
+	"cosmossdk.io/math"
	codectypes "github.com/cosmos/cosmos-sdk/codec/types"
	cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
	sdk "github.com/cosmos/cosmos-sdk/types"
	sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"cosmossdk.io/core/codec"
import (
"bytes"
"fmt"
"net/url"
"sort"
"strings"
"time"
gogoprotoany "github.com/cosmos/gogoproto/types/any"
"cosmossdk.io/core/address"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/codec"
"cosmossdk.io/errors"
"cosmossdk.io/math"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
🧰 Tools
🪛 golangci-lint (1.62.2)

18-18: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

🪛 GitHub Actions: Lint

[error] 14-18: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

@@ -5,7 +5,7 @@ import (

storetypes "cosmossdk.io/store/types"

"github.com/cosmos/cosmos-sdk/codec"
"cosmossdk.io/core/codec"
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix import ordering to match project guidelines.

The imports need to be reordered following the project's guidelines: standard libs, default libs, cosmossdk.io prefixed imports, and github.com/cosmos/cosmos-sdk prefixed imports.

import (
	"context"

-	storetypes "cosmossdk.io/store/types"
-	"cosmossdk.io/core/codec"
+	"cosmossdk.io/core/codec"
+	storetypes "cosmossdk.io/store/types"
)

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 golangci-lint (1.62.2)

8-8: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

🪛 GitHub Actions: Lint

[error] 6-8: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

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: 5

🧹 Nitpick comments (4)
x/staking/types/genesis.go (1)

33-35: Consider error propagation instead of panic.

While the error handling is improved by using UnmarshalJSON, consider propagating the error instead of panicking. This would allow better error handling by the caller.

func GetGenesisStateFromAppState(cdc codec.JSONCodec, appState map[string]json.RawMessage) (*GenesisState, error) {
	var genesisState GenesisState

	if appState[ModuleName] != nil {
-		if err := cdc.UnmarshalJSON(appState[ModuleName], &genesisState); err != nil {
-			panic(err)
-		}
+		if err := cdc.UnmarshalJSON(appState[ModuleName], &genesisState); err != nil {
+			return nil, fmt.Errorf("failed to unmarshal %s genesis state: %w", ModuleName, err)
+		}
	}

-	return &genesisState
+	return &genesisState, nil
}
x/staking/simulation/decoder.go (1)

33-38: Reduce error handling duplication.

Consider creating a helper function to handle the repeated unmarshal-and-panic pattern. This would improve code maintainability and reduce duplication.

+func unmarshalOrPanic[T any](cdc codec.Codec, data []byte, v *T) {
+	if err := cdc.Unmarshal(data, v); err != nil {
+		panic(err)
+	}
+}

// Usage example:
-if err := cdc.Unmarshal(kvA.Value, &validatorA); err != nil {
-	panic(err)
-}
+unmarshalOrPanic(cdc, kvA.Value, &validatorA)

Also applies to: 49-54, 61-66, 73-78, 84-89, 95-100, 106-111

x/staking/module.go (2)

122-126: Consider error propagation in DefaultGenesis.

While the error handling is improved by using MarshalJSON, consider propagating the error instead of panicking. This would allow better error handling by the caller.

-func (am AppModule) DefaultGenesis() json.RawMessage {
+func (am AppModule) DefaultGenesis() (json.RawMessage, error) {
	data, err := am.cdc.MarshalJSON(types.DefaultGenesisState())
	if err != nil {
-		panic(err)
+		return nil, fmt.Errorf("failed to marshal default genesis state: %w", err)
	}
-	return data
+	return data, nil
}

142-144: Consider error propagation in InitGenesis.

The error handling could be improved by propagating the error instead of panicking.

	if err := am.cdc.UnmarshalJSON(data, &genesisState); err != nil {
-		panic(err)
+		return nil, fmt.Errorf("failed to unmarshal genesis state: %w", err)
	}
📜 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 4995d2f.

📒 Files selected for processing (7)
  • x/staking/migrations/v5/store.go (1 hunks)
  • x/staking/migrations/v6/store.go (1 hunks)
  • x/staking/module.go (3 hunks)
  • x/staking/simulation/decoder.go (3 hunks)
  • x/staking/types/delegation.go (4 hunks)
  • x/staking/types/genesis.go (2 hunks)
  • x/staking/types/validator.go (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • x/staking/migrations/v5/store.go
🧰 Additional context used
📓 Path-based instructions (6)
x/staking/migrations/v6/store.go (1)

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

x/staking/types/genesis.go (1)

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

x/staking/types/delegation.go (1)

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

x/staking/simulation/decoder.go (1)

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

x/staking/types/validator.go (1)

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

x/staking/module.go (1)

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

🪛 golangci-lint (1.62.2)
x/staking/migrations/v6/store.go

8-8: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

x/staking/types/delegation.go

11-11: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

x/staking/simulation/decoder.go

10-10: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

x/staking/types/validator.go

18-18: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

🪛 GitHub Actions: Lint
x/staking/migrations/v6/store.go

[error] 6-8: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

x/staking/types/delegation.go

[error] 8-11: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

x/staking/simulation/decoder.go

[error] 6-10: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

x/staking/types/validator.go

[error] 14-18: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

x/staking/module.go

[error] 13-21: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze
  • GitHub Check: Summary
🔇 Additional comments (4)
x/staking/types/delegation.go (3)

29-33: LGTM! Improved error handling.

The explicit error handling is a better approach than implicit error handling.


150-154: LGTM! Consistent error handling pattern.

The explicit error handling matches the pattern used in other functions.


245-249: LGTM! Consistent error handling pattern.

The explicit error handling maintains consistency across the codebase.

x/staking/types/validator.go (1)

155-159: LGTM! Consistent error handling pattern.

The explicit error handling maintains consistency with other similar functions in the codebase.

@@ -5,7 +5,7 @@ import (

storetypes "cosmossdk.io/store/types"

"github.com/cosmos/cosmos-sdk/codec"
"cosmossdk.io/core/codec"
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix import ordering.

The imports need to be reordered according to the project's guidelines:

import (
	"context"

	storetypes "cosmossdk.io/store/types"
-	"cosmossdk.io/core/codec"
+
+       "cosmossdk.io/core/codec"
)

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 golangci-lint (1.62.2)

8-8: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

🪛 GitHub Actions: Lint

[error] 6-8: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

@@ -7,7 +7,7 @@ import (
"cosmossdk.io/math"
"cosmossdk.io/x/staking/types"

"github.com/cosmos/cosmos-sdk/codec"
"cosmossdk.io/core/codec"
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix import ordering.

The imports need to be reordered according to the project's guidelines:

import (
	"bytes"
	"fmt"

	"cosmossdk.io/math"
	"cosmossdk.io/x/staking/types"
+	"cosmossdk.io/core/codec"

-	"cosmossdk.io/core/codec"
	sdk "github.com/cosmos/cosmos-sdk/types"
	"github.com/cosmos/cosmos-sdk/types/kv"
)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"cosmossdk.io/core/codec"
import (
"bytes"
"fmt"
"cosmossdk.io/math"
"cosmossdk.io/x/staking/types"
"cosmossdk.io/core/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/kv"
)
🧰 Tools
🪛 golangci-lint (1.62.2)

10-10: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

🪛 GitHub Actions: Lint

[error] 6-10: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

@@ -18,8 +18,8 @@ import (
"cosmossdk.io/x/staking/keeper"
"cosmossdk.io/x/staking/types"

"cosmossdk.io/core/codec"
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix import ordering.

The imports need to be reordered according to the project's guidelines:

import (
	"context"
	"encoding/json"
	"fmt"

	gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
	"github.com/spf13/cobra"
	"google.golang.org/grpc"

	"cosmossdk.io/collections"
	"cosmossdk.io/core/appmodule"
+	"cosmossdk.io/core/codec"
	"cosmossdk.io/core/registry"
	"cosmossdk.io/depinject"
	"cosmossdk.io/schema"
	"cosmossdk.io/x/staking/client/cli"
	"cosmossdk.io/x/staking/keeper"
	"cosmossdk.io/x/staking/types"

-	"cosmossdk.io/core/codec"
	"github.com/cosmos/cosmos-sdk/client"
	"github.com/cosmos/cosmos-sdk/types/module"
)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"cosmossdk.io/core/codec"
import (
"context"
"encoding/json"
"fmt"
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
"google.golang.org/grpc"
"cosmossdk.io/collections"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/codec"
"cosmossdk.io/core/registry"
"cosmossdk.io/depinject"
"cosmossdk.io/schema"
"cosmossdk.io/x/staking/client/cli"
"cosmossdk.io/x/staking/keeper"
"cosmossdk.io/x/staking/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/types/module"
)
🧰 Tools
🪛 GitHub Actions: Lint

[error] 13-21: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

@@ -8,7 +8,7 @@ import (
"cosmossdk.io/core/address"
"cosmossdk.io/math"

"github.com/cosmos/cosmos-sdk/codec"
"cosmossdk.io/core/codec"
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix import ordering.

The imports need to be reordered according to the project's guidelines:

  1. Standard library imports
  2. Third-party imports
  3. cosmossdk.io imports
  4. github.com/cosmos/cosmos-sdk imports
🧰 Tools
🪛 golangci-lint (1.62.2)

11-11: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

🪛 GitHub Actions: Lint

[error] 8-11: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

@@ -15,7 +15,7 @@ import (
"cosmossdk.io/errors"
"cosmossdk.io/math"

"github.com/cosmos/cosmos-sdk/codec"
"cosmossdk.io/core/codec"
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix import ordering.

The imports need to be reordered according to the project's guidelines:

  1. Standard library imports
  2. Third-party imports
  3. cosmossdk.io imports
  4. github.com/cosmos/cosmos-sdk imports
🧰 Tools
🪛 golangci-lint (1.62.2)

18-18: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

🪛 GitHub Actions: Lint

[error] 14-18: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

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: 5

📜 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 4995d2f.

📒 Files selected for processing (7)
  • x/staking/migrations/v5/store.go (1 hunks)
  • x/staking/migrations/v6/store.go (1 hunks)
  • x/staking/module.go (3 hunks)
  • x/staking/simulation/decoder.go (3 hunks)
  • x/staking/types/delegation.go (4 hunks)
  • x/staking/types/genesis.go (2 hunks)
  • x/staking/types/validator.go (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • x/staking/migrations/v5/store.go
🧰 Additional context used
📓 Path-based instructions (6)
x/staking/migrations/v6/store.go (1)

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

x/staking/types/genesis.go (1)

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

x/staking/types/validator.go (1)

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

x/staking/types/delegation.go (1)

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

x/staking/simulation/decoder.go (1)

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

x/staking/module.go (1)

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

🪛 golangci-lint (1.62.2)
x/staking/migrations/v6/store.go

8-8: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

x/staking/types/validator.go

18-18: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

x/staking/types/delegation.go

11-11: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

x/staking/simulation/decoder.go

10-10: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

🪛 GitHub Actions: Lint
x/staking/migrations/v6/store.go

[error] 6-8: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

x/staking/types/validator.go

[error] 14-18: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

x/staking/types/delegation.go

[error] 8-11: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

x/staking/simulation/decoder.go

[error] 6-10: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

x/staking/module.go

[error] 13-21: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze
  • GitHub Check: Summary
🔇 Additional comments (6)
x/staking/migrations/v6/store.go (1)

Line range hint 12-18: LGTM! Migration logic remains unchanged.

The migration function correctly uses the new codec interface without any behavioral changes.

🧰 Tools
🪛 golangci-lint (1.62.2)

6-6: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)


8-8: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

🪛 GitHub Actions: Lint

[error] 6-8: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

x/staking/types/genesis.go (1)

33-35: LGTM! Explicit error handling improves code clarity.

The change from MustUnmarshalJSON to explicit error handling with UnmarshalJSON maintains the same behavior while making the error path more visible.

x/staking/simulation/decoder.go (1)

Line range hint 33-111: LGTM! Consistent error handling improvements.

The changes from MustUnmarshal to Unmarshal with explicit error handling have been consistently applied across all type unmarshaling operations. This improves code clarity while maintaining the same panic behavior on errors.

x/staking/module.go (1)

Line range hint 122-144: LGTM! Consistent error handling improvements.

The changes from MustMarshalJSON/MustUnmarshalJSON to explicit error handling have been consistently applied. This improves code clarity while maintaining the same panic behavior on errors.

x/staking/types/delegation.go (1)

29-33: LGTM! Improved error handling pattern.

The explicit error handling in marshaling functions is more robust and consistent with best practices.

Also applies to: 150-154, 245-249

x/staking/types/validator.go (1)

155-159: LGTM! Consistent error handling pattern.

The explicit error handling in MustMarshalValidator aligns with the improved pattern used throughout the codebase.

@@ -5,7 +5,7 @@ import (

storetypes "cosmossdk.io/store/types"

"github.com/cosmos/cosmos-sdk/codec"
"cosmossdk.io/core/codec"
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix import ordering.

The imports need to be ordered according to the following pattern:

  • standard
  • default
  • prefix(cosmossdk.io)
  • prefix(github.com/cosmos/cosmos-sdk)
import (
	"context"

	storetypes "cosmossdk.io/store/types"
-	"cosmossdk.io/core/codec"
+
+	"cosmossdk.io/core/codec"
)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"cosmossdk.io/core/codec"
import (
"context"
storetypes "cosmossdk.io/store/types"
"cosmossdk.io/core/codec"
)
🧰 Tools
🪛 golangci-lint (1.62.2)

8-8: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

🪛 GitHub Actions: Lint

[error] 6-8: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

@@ -7,7 +7,7 @@ import (
"cosmossdk.io/math"
"cosmossdk.io/x/staking/types"

"github.com/cosmos/cosmos-sdk/codec"
"cosmossdk.io/core/codec"
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix import ordering.

The imports need to be ordered according to the following pattern:

  • standard
  • default
  • prefix(cosmossdk.io)
  • prefix(github.com/cosmos/cosmos-sdk)
import (
	"bytes"
	"fmt"

	"cosmossdk.io/math"
	"cosmossdk.io/x/staking/types"
-	"cosmossdk.io/core/codec"
+
+	"cosmossdk.io/core/codec"
	sdk "github.com/cosmos/cosmos-sdk/types"
	"github.com/cosmos/cosmos-sdk/types/kv"
)

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 golangci-lint (1.62.2)

10-10: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

🪛 GitHub Actions: Lint

[error] 6-10: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

@@ -18,8 +18,8 @@ import (
"cosmossdk.io/x/staking/keeper"
"cosmossdk.io/x/staking/types"

"cosmossdk.io/core/codec"
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix import ordering.

The imports need to be ordered according to the following pattern:

  • standard
  • default
  • prefix(cosmossdk.io)
  • prefix(github.com/cosmos/cosmos-sdk)
import (
	"context"
	"encoding/json"
	"fmt"

	gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
	"github.com/spf13/cobra"
	"google.golang.org/grpc"

	"cosmossdk.io/collections"
	"cosmossdk.io/core/appmodule"
	"cosmossdk.io/core/registry"
	"cosmossdk.io/depinject"
	"cosmossdk.io/schema"
	"cosmossdk.io/x/staking/client/cli"
	"cosmossdk.io/x/staking/keeper"
	"cosmossdk.io/x/staking/types"
-	"cosmossdk.io/core/codec"
+
+	"cosmossdk.io/core/codec"
	"github.com/cosmos/cosmos-sdk/client"
	"github.com/cosmos/cosmos-sdk/types/module"
)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"cosmossdk.io/core/codec"
import (
"context"
"encoding/json"
"fmt"
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
"google.golang.org/grpc"
"cosmossdk.io/collections"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/registry"
"cosmossdk.io/core/codec"
"cosmossdk.io/depinject"
"cosmossdk.io/schema"
"cosmossdk.io/x/staking/client/cli"
"cosmossdk.io/x/staking/keeper"
"cosmossdk.io/x/staking/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/types/module"
)
🧰 Tools
🪛 GitHub Actions: Lint

[error] 13-21: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

@@ -8,7 +8,7 @@ import (
"cosmossdk.io/core/address"
"cosmossdk.io/math"

"github.com/cosmos/cosmos-sdk/codec"
"cosmossdk.io/core/codec"
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix import ordering.

The imports need to be reordered according to the project's guidelines:

 import (
+	"encoding/json"
+	"strings"
+	"time"
+
+	"cosmossdk.io/core/address"
+	"cosmossdk.io/core/codec"
+	"cosmossdk.io/math"
+
+	sdk "github.com/cosmos/cosmos-sdk/types"
 )

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 golangci-lint (1.62.2)

11-11: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

🪛 GitHub Actions: Lint

[error] 8-11: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

@@ -15,7 +15,7 @@ import (
"cosmossdk.io/errors"
"cosmossdk.io/math"

"github.com/cosmos/cosmos-sdk/codec"
"cosmossdk.io/core/codec"
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix import ordering.

The imports need to be reordered according to the project's guidelines:

 import (
+	"bytes"
+	"fmt"
+	"net/url"
+	"sort"
+	"strings"
+	"time"
+
+	gogoprotoany "github.com/cosmos/gogoproto/types/any"
+
+	"cosmossdk.io/core/address"
+	"cosmossdk.io/core/appmodule"
+	"cosmossdk.io/core/codec"
+	"cosmossdk.io/errors"
+	"cosmossdk.io/math"
+
+	codectypes "github.com/cosmos/cosmos-sdk/codec/types"
+	cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
+	sdk "github.com/cosmos/cosmos-sdk/types"
+	sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
 )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"cosmossdk.io/core/codec"
import (
"bytes"
"fmt"
"net/url"
"sort"
"strings"
"time"
gogoprotoany "github.com/cosmos/gogoproto/types/any"
"cosmossdk.io/core/address"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/codec"
"cosmossdk.io/errors"
"cosmossdk.io/math"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
🧰 Tools
🪛 golangci-lint (1.62.2)

18-18: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

🪛 GitHub Actions: Lint

[error] 14-18: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

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 (1)
x/staking/module.go (1)

142-144: Consider consistent error handling with ValidateGenesis

While the explicit error handling is good, consider returning the error instead of panicking to maintain consistency with ValidateGenesis which returns errors.

-	if err := am.cdc.UnmarshalJSON(data, &genesisState); err != nil {
-		panic(err)
-	}
+	if err := am.cdc.UnmarshalJSON(data, &genesisState); err != nil {
+		return nil, fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
+	}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4995d2f and 2d2bd58.

📒 Files selected for processing (6)
  • x/staking/migrations/v5/store.go (1 hunks)
  • x/staking/migrations/v6/store.go (1 hunks)
  • x/staking/module.go (3 hunks)
  • x/staking/simulation/decoder.go (3 hunks)
  • x/staking/types/delegation.go (4 hunks)
  • x/staking/types/validator.go (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • x/staking/migrations/v5/store.go
  • x/staking/migrations/v6/store.go
  • x/staking/types/validator.go
  • x/staking/simulation/decoder.go
🧰 Additional context used
📓 Path-based instructions (2)
x/staking/module.go (1)

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

x/staking/types/delegation.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 (5)
  • GitHub Check: tests (00)
  • GitHub Check: test-simapp-v2
  • GitHub Check: test-system-v2
  • GitHub Check: Analyze
  • GitHub Check: Summary
🔇 Additional comments (4)
x/staking/module.go (1)

122-126: LGTM! Improved error handling in DefaultGenesis

The change from MustMarshalJSON to explicit error handling with MarshalJSON provides better error context while maintaining the same panic behavior.

x/staking/types/delegation.go (3)

29-33: LGTM! Improved error handling in MustMarshalDelegation

The change to explicit error handling provides better error context while maintaining the expected panic behavior indicated by the "Must" prefix.


150-154: LGTM! Improved error handling in MustMarshalUBD

The explicit error handling provides better error context while maintaining the expected panic behavior.


245-249: LGTM! Improved error handling in MustMarshalRED

The explicit error handling provides better error context while maintaining the expected panic behavior.

Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

ACK, thanks!

@julienrbrt julienrbrt added the backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release label Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release C:Simulations C:x/staking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants