-
Notifications
You must be signed in to change notification settings - Fork 589
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: standardise sub keeper usage in core ibc #6081
Conversation
WalkthroughThe overarching change involves standardizing the usage of pointers for keepers across various IBC-related modules, ensuring consistency and preventing subtle bugs related to keeper instances. This adjustment facilitates a more reliable and error-free management of keeper references, enhancing the codebase's integrity and functionality. Changes
Assessment against linked issues
Possibly related issues
Poem
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.
Actionable comments posted: 1
Review Status
Configuration used: CodeRabbit UI
Files selected for processing (19)
- modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go (1 hunks)
- modules/apps/27-interchain-accounts/host/keeper/keeper_test.go (1 hunks)
- modules/apps/29-fee/keeper/keeper_test.go (2 hunks)
- modules/apps/callbacks/ibc_middleware_test.go (1 hunks)
- modules/apps/transfer/keeper/keeper_test.go (1 hunks)
- modules/core/02-client/genesis.go (2 hunks)
- modules/core/02-client/keeper/keeper.go (1 hunks)
- modules/core/02-client/migrations/v7/genesis_test.go (2 hunks)
- modules/core/02-client/types/genesis_test.go (1 hunks)
- modules/core/03-connection/genesis.go (2 hunks)
- modules/core/03-connection/keeper/keeper.go (1 hunks)
- modules/core/03-connection/keeper/migrations.go (1 hunks)
- modules/core/04-channel/genesis.go (2 hunks)
- modules/core/04-channel/keeper/keeper.go (1 hunks)
- modules/core/04-channel/keeper/migrations.go (1 hunks)
- modules/core/05-port/keeper/keeper.go (1 hunks)
- modules/core/genesis.go (1 hunks)
- modules/core/keeper/keeper.go (2 hunks)
- modules/core/migrations/v7/genesis_test.go (2 hunks)
Additional Context Used
Learnings (3)
modules/core/genesis.go (1)
User: likhita-809" PR: cosmos/cosmos-sdk#18471 File: x/protocolpool/keeper/genesis.go:12-51 Timestamp: 2023-11-22T12:32:39.368Z Learning: - The user `likhita-809` has confirmed the changes suggested in the previous interaction. - The file in question is `x/protocolpool/keeper/genesis.go` from a Cosmos SDK module. - The changes involve optimizing the `InitGenesis` function by removing redundant code and ensuring proper handling of start times for budget proposals.
modules/core/02-client/genesis.go (1)
User: likhita-809" PR: cosmos/cosmos-sdk#18471 File: x/protocolpool/keeper/genesis.go:12-51 Timestamp: 2023-11-22T12:32:39.368Z Learning: - The user `likhita-809` has confirmed the changes suggested in the previous interaction. - The file in question is `x/protocolpool/keeper/genesis.go` from a Cosmos SDK module. - The changes involve optimizing the `InitGenesis` function by removing redundant code and ensuring proper handling of start times for budget proposals.
modules/core/02-client/migrations/v7/genesis_test.go (1)
User: likhita-809" PR: cosmos/cosmos-sdk#18471 File: x/protocolpool/keeper/genesis.go:12-51 Timestamp: 2023-11-22T12:32:39.368Z Learning: - The user `likhita-809` has confirmed the changes suggested in the previous interaction. - The file in question is `x/protocolpool/keeper/genesis.go` from a Cosmos SDK module. - The changes involve optimizing the `InitGenesis` function by removing redundant code and ensuring proper handling of start times for budget proposals.
Additional comments not posted (30)
modules/core/04-channel/keeper/migrations.go (2)
11-11
: Change to pointer type forkeeper
field inMigrator
struct aligns with PR objectives to standardize sub-keeper usage.
15-15
: Adjustment inNewMigrator
function parameter to use a pointer type is consistent with the refactor goal.modules/core/genesis.go (2)
16-16
: PassingKeeper
instances by reference inInitGenesis
function aligns with the refactor's goal for consistent keeper usage.
24-24
: Using pointers forKeeper
instances inExportGenesis
function is consistent with the refactor's objective.modules/core/03-connection/keeper/migrations.go (2)
12-12
: Change to pointer type forkeeper
field inMigrator
struct aligns with PR objectives to standardize sub-keeper usage.
16-16
: Adjustment inNewMigrator
function parameter to use a pointer type is consistent with the refactor goal.modules/core/03-connection/genesis.go (2)
12-12
: Using pointers forKeeper
instances inInitGenesis
function is consistent with the refactor's objective for consistent keeper usage.
27-27
: PassingKeeper
instances by reference inExportGenesis
function aligns with the refactor's goal.modules/core/04-channel/genesis.go (2)
14-14
: Using pointers forKeeper
instances inInitGenesis
function is consistent with the refactor's objective for consistent keeper usage.
45-45
: PassingKeeper
instances by reference inExportGenesis
function aligns with the refactor's goal.modules/core/05-port/keeper/keeper.go (1)
24-25
: Change inNewKeeper
function's return type to a pointer aligns with PR objectives to standardize sub-keeper usage.modules/core/02-client/genesis.go (2)
16-16
: Using pointers forKeeper
instances inInitGenesis
function is consistent with the refactor's objective for consistent keeper usage.
64-64
: PassingKeeper
instances by reference inExportGenesis
function aligns with the refactor's goal.modules/core/keeper/keeper.go (2)
32-33
: ChangingConnectionKeeper
andChannelKeeper
fields to pointers aligns with PR objectives to standardize sub-keeper usage.
63-65
: Adjustments inNewKeeper
functions forconnectionkeeper
andchannelkeeper
to use actual values are consistent with the refactor goal.modules/core/02-client/migrations/v7/genesis_test.go (2)
36-36
: Ensure theClientKeeper
is correctly handled as a pointer throughout the codebase.
111-111
: Confirm that the transition to using pointers forClientKeeper
does not affect the expected genesis state.modules/core/migrations/v7/genesis_test.go (2)
64-64
: Ensure theClientKeeper
is correctly handled as a pointer throughout the codebase.
138-138
: Confirm that the transition to using pointers forClientKeeper
does not affect the expected genesis state.modules/core/03-connection/keeper/keeper.go (1)
32-33
: The change to return a pointer fromNewKeeper
aligns with the refactor to use reference types for sub-keepers. Ensure all usages ofNewKeeper
are updated accordingly.modules/apps/transfer/keeper/keeper_test.go (2)
344-344
: The update to the type assertion inTestWithICS4Wrapper
to expect a pointer type aligns with the refactor to use reference types for sub-keepers.
351-351
: Confirm that theWithICS4Wrapper
method correctly handles the transition to using pointers for theChannelKeeper
.modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go (1)
364-364
: The update to the type assertion inTestWithICS4Wrapper
to expect a pointer type aligns with the refactor to use reference types for sub-keepers.modules/apps/29-fee/keeper/keeper_test.go (2)
309-309
: Ensure correct type assertion forchannelkeeper.Keeper
.
320-320
: Ensure correct type assertion forchannelkeeper.Keeper
.modules/apps/27-interchain-accounts/host/keeper/keeper_test.go (2)
414-414
: Ensure correct type assertion forchannelkeeper.Keeper
.
421-421
: Ensure correct type assertion forchannelkeeper.Keeper
.modules/core/02-client/types/genesis_test.go (1)
35-35
: Ensure correct usage ofClientKeeper
inExportGenesis
function call.modules/core/02-client/keeper/keeper.go (1)
36-41
: SwitchingNewKeeper
to return a pointer toKeeper
aligns with the goal of standardizing sub-keeper usage by ensuring consistent references. This change is crucial for eliminating subtle bugs related to keeper instance management.modules/core/04-channel/keeper/keeper.go (1)
46-47
: SwitchingNewKeeper
to return a pointer toKeeper
aligns with the goal of standardizing sub-keeper usage by ensuring consistent references. This change is crucial for eliminating subtle bugs related to keeper instance management.
@@ -89,7 +89,7 @@ func (s *CallbacksTestSuite) TestWithICS4Wrapper() { | |||
cbsMiddleware.WithICS4Wrapper(s.chainA.App.GetIBCKeeper().ChannelKeeper) | |||
ics4Wrapper := cbsMiddleware.GetICS4Wrapper() | |||
|
|||
s.Require().IsType(channelkeeper.Keeper{}, ics4Wrapper) | |||
s.Require().IsType(&channelkeeper.Keeper{}, ics4Wrapper) |
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.
Update type assertion to expect a pointer to channelkeeper.Keeper
.
- s.Require().IsType(&channelkeeper.Keeper{}, ics4Wrapper)
+ s.Require().IsType((*channelkeeper.Keeper)(nil), ics4Wrapper)
This change aligns with the PR's objective to standardize the usage of reference types for sub-keepers, ensuring consistency across the IBC 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.
s.Require().IsType(&channelkeeper.Keeper{}, ics4Wrapper) | |
s.Require().IsType((*channelkeeper.Keeper)(nil), ics4Wrapper) |
modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go
Outdated
Show resolved
Hide resolved
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.
Thanks, @damiannolan!
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.
Love the change! I think it will make things less error prone. I think we should go one step further, and make sure that only the pointer types implement the functions in the expected_keepers.go files.
To make it actually not compile without the pointers being passed. will let you decide if you think that is overkill or not
Quality Gate passed for 'ibc-go'Issues Measures |
Description
Use reference types in favour of value types for ibc sub keepers.
closes: #6058
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
).godoc
comments.Files changed
in the GitHub PR explorer.SonarCloud Report
in the comment section below once CI passes.Summary by CodeRabbit