-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
base: main
Are you sure you want to change the base?
Conversation
…osmos/cosmos-sdk/codec
📝 WalkthroughWalkthroughThis pull request focuses on updating the codec import path from Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Finishing Touches
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this 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 orderingThe 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
📒 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 correctlyThe codec import path has been updated to use the new
cosmossdk.io/core/codec
package.
33-35
: LGTM: Improved error handlingThe change from
MustUnmarshalJSON
toUnmarshalJSON
with explicit error handling improves the code's robustness and error reporting.x/staking/simulation/decoder.go (1)
33-38
: LGTM: Consistent error handling improvementsThe changes from
MustUnmarshal
toUnmarshal
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 handlingThe changes improve error handling in both
DefaultGenesis
andInitGenesis
functions by making error handling explicit rather than usingMust*
functions.Also applies to: 142-144
x/staking/types/delegation.go (1)
29-33
: LGTM: Consistent error handling improvementsThe changes from
MustMarshal
toMarshal
with explicit error handling have been consistently applied across all marshaling operations (MustMarshalDelegation
,MustMarshalUBD
, andMustMarshalRED
). 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.
x/staking/simulation/decoder.go
Outdated
@@ -7,7 +7,7 @@ import ( | |||
"cosmossdk.io/math" | |||
"cosmossdk.io/x/staking/types" | |||
|
|||
"github.com/cosmos/cosmos-sdk/codec" | |||
"cosmossdk.io/core/codec" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
x/staking/types/delegation.go
Outdated
"cosmossdk.io/core/address" | ||
"cosmossdk.io/math" | ||
|
||
"github.com/cosmos/cosmos-sdk/codec" | ||
"cosmossdk.io/core/codec" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
x/staking/types/validator.go
Outdated
@@ -15,7 +15,7 @@ import ( | |||
"cosmossdk.io/errors" | |||
"cosmossdk.io/math" | |||
|
|||
"github.com/cosmos/cosmos-sdk/codec" | |||
"cosmossdk.io/core/codec" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
"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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this 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
📒 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" |
There was a problem hiding this comment.
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
x/staking/simulation/decoder.go
Outdated
@@ -7,7 +7,7 @@ import ( | |||
"cosmossdk.io/math" | |||
"cosmossdk.io/x/staking/types" | |||
|
|||
"github.com/cosmos/cosmos-sdk/codec" | |||
"cosmossdk.io/core/codec" |
There was a problem hiding this comment.
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.
"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
x/staking/module.go
Outdated
@@ -18,8 +18,8 @@ import ( | |||
"cosmossdk.io/x/staking/keeper" | |||
"cosmossdk.io/x/staking/types" | |||
|
|||
"cosmossdk.io/core/codec" |
There was a problem hiding this comment.
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.
"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
x/staking/types/delegation.go
Outdated
@@ -8,7 +8,7 @@ import ( | |||
"cosmossdk.io/core/address" | |||
"cosmossdk.io/math" | |||
|
|||
"github.com/cosmos/cosmos-sdk/codec" | |||
"cosmossdk.io/core/codec" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix import ordering.
The imports need to be reordered according to the project's guidelines:
- Standard library imports
- Third-party imports
cosmossdk.io
importsgithub.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
x/staking/types/validator.go
Outdated
@@ -15,7 +15,7 @@ import ( | |||
"cosmossdk.io/errors" | |||
"cosmossdk.io/math" | |||
|
|||
"github.com/cosmos/cosmos-sdk/codec" | |||
"cosmossdk.io/core/codec" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix import ordering.
The imports need to be reordered according to the project's guidelines:
- Standard library imports
- Third-party imports
cosmossdk.io
importsgithub.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
There was a problem hiding this 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
📒 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 withUnmarshalJSON
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
toUnmarshal
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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
"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
x/staking/simulation/decoder.go
Outdated
@@ -7,7 +7,7 @@ import ( | |||
"cosmossdk.io/math" | |||
"cosmossdk.io/x/staking/types" | |||
|
|||
"github.com/cosmos/cosmos-sdk/codec" | |||
"cosmossdk.io/core/codec" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
x/staking/module.go
Outdated
@@ -18,8 +18,8 @@ import ( | |||
"cosmossdk.io/x/staking/keeper" | |||
"cosmossdk.io/x/staking/types" | |||
|
|||
"cosmossdk.io/core/codec" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
"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
x/staking/types/delegation.go
Outdated
@@ -8,7 +8,7 @@ import ( | |||
"cosmossdk.io/core/address" | |||
"cosmossdk.io/math" | |||
|
|||
"github.com/cosmos/cosmos-sdk/codec" | |||
"cosmossdk.io/core/codec" |
There was a problem hiding this comment.
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
x/staking/types/validator.go
Outdated
@@ -15,7 +15,7 @@ import ( | |||
"cosmossdk.io/errors" | |||
"cosmossdk.io/math" | |||
|
|||
"github.com/cosmos/cosmos-sdk/codec" | |||
"cosmossdk.io/core/codec" |
There was a problem hiding this comment.
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.
"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
There was a problem hiding this 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 ValidateGenesisWhile 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
📒 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 DefaultGenesisThe change from
MustMarshalJSON
to explicit error handling withMarshalJSON
provides better error context while maintaining the same panic behavior.x/staking/types/delegation.go (3)
29-33
: LGTM! Improved error handling in MustMarshalDelegationThe 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 MustMarshalUBDThe explicit error handling provides better error context while maintaining the expected panic behavior.
245-249
: LGTM! Improved error handling in MustMarshalREDThe explicit error handling provides better error context while maintaining the expected panic behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK, thanks!
Description
Partially addresses #23253
Summary by CodeRabbit
Dependency Updates
Error Handling Improvements
MustMarshal/Unmarshal
methods with more robust error handling techniques.Code Maintenance