-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
refactor!: mv AddressCodecs aliases from runtime -> core #19747
Conversation
WalkthroughWalkthroughThe changes involve consolidating address-related types from the Changes
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Review Status
Actionable comments generated: 0
Configuration used: .coderabbit.yml
Files selected for processing (14)
- baseapp/utils_test.go (2 hunks)
- client/v2/autocli/flag/builder.go (2 hunks)
- core/address/codec.go (1 hunks)
- crypto/armor_test.go (2 hunks)
- crypto/keys/multisig/multisig_test.go (2 hunks)
- runtime/module.go (2 hunks)
- simapp/app_test.go (3 hunks)
- simapp/simd/cmd/root_di.go (2 hunks)
- simapp/simd/cmd/testnet.go (4 hunks)
- testutil/network/network.go (2 hunks)
- x/auth/tx/config/depinject.go (1 hunks)
- x/genutil/client/cli/collect.go (2 hunks)
- x/genutil/collect.go (2 hunks)
- x/staking/depinject.go (3 hunks)
Additional comments: 22
core/address/codec.go (1)
- 12-16: LGTM! The addition of
ValidatorAddressCodec
andConsensusAddressCodec
type aliases is clear and follows the naming conventions appropriately.x/genutil/client/cli/collect.go (2)
- 7-7: The update of the import path for
ValidatorAddressCodec
fromruntime
toaddress
is correctly implemented.- 21-21: The usage of
address.ValidatorAddressCodec
in theCollectGenTxsCmd
function signature is appropriate and follows the refactor's objective.x/staking/depinject.go (2)
- 7-7: The update of the import path for
ValidatorAddressCodec
andConsensusAddressCodec
fromruntime
toaddress
is correctly implemented.- 41-42: The usage of
address.ValidatorAddressCodec
andaddress.ConsensusAddressCodec
in theModuleInputs
struct is appropriate and follows the refactor's objective.simapp/simd/cmd/root_di.go (1)
- 105-106: The usage of
address.ValidatorAddressCodec
andaddress.ConsensusAddressCodec
in theProvideClientContext
function is appropriate and aligns with the refactor's goals.x/genutil/collect.go (2)
- 28-28: The update to use
address.ValidatorAddressCodec
in theGenAppStateFromConfig
function is correctly implemented.- 71-71: The update to use
address.ValidatorAddressCodec
in theCollectTxs
function is correctly implemented.x/auth/tx/config/depinject.go (1)
- 45-45: The update to use
address.ValidatorAddressCodec
in theModuleInputs
struct is correctly implemented.crypto/armor_test.go (1)
- 86-87: The update to use
address.ValidatorAddressCodec
andaddress.ConsensusAddressCodec
in the test setup is correctly implemented.runtime/module.go (3)
- 145-145: The
ProvideInterfaceRegistry
function now correctly usesaddress.ValidatorAddressCodec
as part of its parameters, aligning with the PR's objective to refactor type usage for better architectural integrity. This change ensures that the core types are defined within the core package, which is part of the Dependency Injection (DI) root.- 254-256: The introduction of factory functions for
AddressCodec
,ValidatorAddressCodec
, andConsensusAddressCodec
in theAddressCodecInputs
struct is a significant improvement. It allows for more flexible and decoupled code, facilitating easier testing and future modifications. This change aligns with best practices in software design, promoting modularity and maintainability.- 261-261: The
ProvideAddressCodec
function's implementation to dynamically provideaddress.Codec
,address.ValidatorAddressCodec
, andaddress.ConsensusAddressCodec
based on the provided inputs is a robust solution. It ensures that the application can adapt to different configurations and requirements without hardcoding dependencies. This approach enhances the flexibility and scalability of the codebase.baseapp/utils_test.go (1)
- 49-50: The changes updating
validatorAddressCodec
andconsensusAddressCodec
from theruntime
package to theaddress
package are correctly implemented and align with the PR's objectives.simapp/app_test.go (1)
- 315-316: The updates replacing references to
runtime.ValidatorAddressCodec
andruntime.ConsensusAddressCodec
withaddress.ValidatorAddressCodec
andaddress.ConsensusAddressCodec
are correctly implemented and align with the PR's objectives.Also applies to: 342-343
crypto/keys/multisig/multisig_test.go (1)
- 365-366: The update of references from
runtime.ValidatorAddressCodec
andruntime.ConsensusAddressCodec
toaddress.ValidatorAddressCodec
andaddress.ConsensusAddressCodec
respectively in theTestDisplay
function aligns with the PR's objective to refactor and move these type aliases to thecore/address
package. This change is crucial for resolving dependency issues and improving architectural design within the Cosmos SDK. The usage of these new references in tests ensures that the refactor is consistently applied across the codebase, including test cases, which is a good practice for maintaining code integrity and reliability.client/v2/autocli/flag/builder.go (1)
- 56-57: The update of
ValidatorAddressCodec
andConsensusAddressCodec
fields in theBuilder
struct from theruntime
package to theaddress
package is consistent with the PR's objective to refactor and improve the architectural integrity of the Cosmos SDK. By ensuring that core types are defined within the core package, which is part of the Dependency Injection (DI) root, this change contributes to resolving dependency issues and enhancing the SDK's design. It's important to verify that all references to these codecs throughout the SDK have been updated accordingly to avoid any potential issues with unresolved types.simapp/simd/cmd/testnet.go (3)
- 11-11: The addition of the import statement
"cosmossdk.io/core/address"
is correctly placed and follows Go conventions for organizing imports. Grouping standard library imports separately from third-party packages is a good practice.- 212-212: The update to the function signature of
initTestnetFiles
to useaddress.ValidatorAddressCodec
instead ofruntime.ValidatorAddressCodec
correctly reflects the architectural change. This ensures that the dependency on core types is properly managed within the DI root.- 420-420: Similarly, the update to the function signature of
collectGenFiles
to useaddress.ValidatorAddressCodec
aligns with the architectural improvements aimed at resolving dependency issues and enhancing the SDK's design. This change is consistent and necessary for the refactor.testutil/network/network.go (2)
- 132-133: The update of
ValidatorAddressCodec
andConsensusAddressCodec
types from theruntime
package to theaddress
package in theConfig
struct aligns with the PR's objective to improve architectural integrity by ensuring core types are defined within the core package. This change is crucial for resolving dependency issues and facilitating smoother development processes.- 188-189: The use of
ValidatorAddressCodec
andConsensusAddressCodec
from theaddress
package in theDefaultConfigWithAppConfig
function is consistent with the changes made in theConfig
struct. This ensures that the new types are properly integrated and used throughout the file, contributing to the overall goal of the refactor.
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.
Review Status
Actionable comments generated: 0
Configuration used: .coderabbit.yml
Files selected for processing (1)
- CHANGELOG.md (1 hunks)
Additional comments: 1
CHANGELOG.md (1)
- 153-153: The changelog entry for PR refactor!: mv AddressCodecs aliases from runtime -> core #19747 accurately notes the movement of
ValidatorAddressCodec
andConsensusAddressCodec
fromruntime
tocore
. However, it could be enhanced by specifying the exact new location (core/address
) and briefly mentioning the motivation behind this change, such as resolving dependency issues and enhancing the architectural design of the Cosmos SDK. This additional information would provide more context and clarity to the readers.
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.
lgtm!
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.
just one question, otherwise lgtm
and also linting imports should be fixed
@@ -25,7 +25,7 @@ import ( | |||
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" | |||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" | |||
"github.com/cosmos/cosmos-sdk/crypto/xsalsa20symmetric" | |||
"github.com/cosmos/cosmos-sdk/runtime" | |||
_ "github.com/cosmos/cosmos-sdk/runtime" |
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.
dumb question, why do we still blank import runtime ? is it because of depinject ?
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.
Right, this test uses depinject
to initialize, so without runtime imported the Provider funcs are absent.
To be honest it seems a bit not golang, I'd like to see a composition root where Providers are defined rather than importing packages for side effects.
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.
Review Status
Actionable comments generated: 0
Configuration used: .coderabbit.yml
Files selected for processing (2)
- crypto/armor_test.go (2 hunks)
- crypto/keys/multisig/multisig_test.go (2 hunks)
Files skipped from review as they are similar to previous changes (2)
- crypto/armor_test.go
- crypto/keys/multisig/multisig_test.go
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.
Review Status
Actionable comments generated: 0
Configuration used: .coderabbit.yml
Files selected for processing (4)
- simapp/simd/cmd/testnet.go (4 hunks)
- x/genutil/client/cli/collect.go (2 hunks)
- x/genutil/collect.go (2 hunks)
- x/staking/depinject.go (3 hunks)
Files skipped from review as they are similar to previous changes (4)
- simapp/simd/cmd/testnet.go
- x/genutil/client/cli/collect.go
- x/genutil/collect.go
- x/staking/depinject.go
Co-authored-by: Marko <marbar3778@yahoo.com>
Description
Discovered while working simapp v2.
Problem: runtime v1 is not a part of DI root but it defines types used across modules and the SDK. We should probably lint guard this if I understand correctly? In simapp v2 start up:
Proposed solution: Move type definitions to core next to address.Codec.
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
in the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
Summary by CodeRabbit
address
package across various modules.runtime
and updated function calls for improved performance.