Skip to content

Commit

Permalink
refactor: remove ics27 channel capability migration introduced in v6 (#…
Browse files Browse the repository at this point in the history
…7053)

* refactor: remove ics27 migration introduced in v6

* changelog

* fix: remove v6 upgrade handler from simapp

* chore: remove V5 upgrade handler const
  • Loading branch information
colin-axner authored Aug 8, 2024
1 parent beaf8bc commit 1f50c8f
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 414 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (core/04-channel) [\#6902](https://github.com/cosmos/ibc-go/pull/6902) Add channel version to core application callbacks.
* (core/03-connection, core/02-client) [\#6937](https://github.com/cosmos/ibc-go/pull/6937) Remove 'ConsensusHost' interface, also removing self client and consensus state validation in the connection handshake.
* (core/24-host) [\#6882](https://github.com/cosmos/ibc-go/issues/6882) All functions ending in `Path` have been removed from 24-host in favour of their sybling functions ending in `Key`.
* (apps/27-interchain-accounts) [\#7053](https://github.com/cosmos/ibc-go/pull/7053) Remove ICS27 channel capability migration introduced in v6.

### State Machine Breaking

Expand Down
5 changes: 4 additions & 1 deletion docs/docs/05-migrations/14-v9-to-v10.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ There are four sections based on the four potential user groups of this document

- [Chains](#chains)
- [IBC Apps](#ibc-apps)
- [ICS27 - Interchain Accounts](#ics27---interchain-accounts)
- [Relayers](#relayers)
- [IBC Light Clients](#ibc-light-clients)

Expand All @@ -17,7 +18,9 @@ There are four sections based on the four potential user groups of this document

## IBC Apps

- No relevant changes were made in this release.
### ICS27 - Interchain Accounts

The channel capability migration introduced in v6 has been removed. Chains must upgrade from v6 or higher.

## Relayers

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
package keeper

import (
"fmt"

errorsmod "cosmossdk.io/errors"

sdk "github.com/cosmos/cosmos-sdk/types"

capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
controllertypes "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/controller/types"
icatypes "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/types"
host "github.com/cosmos/ibc-go/v9/modules/core/24-host"
)

// Migrator is a struct for handling in-place store migrations.
Expand All @@ -25,32 +18,6 @@ func NewMigrator(k *Keeper) Migrator {
}
}

// AssertChannelCapabilityMigrations checks that all channel capabilities generated using the interchain accounts controller port prefix
// are owned by the controller submodule and ibc.
func (m Migrator) AssertChannelCapabilityMigrations(ctx sdk.Context) error {
if m.keeper != nil {
filteredChannels := m.keeper.channelKeeper.GetAllChannelsWithPortPrefix(ctx, icatypes.ControllerPortPrefix)
for _, ch := range filteredChannels {
name := host.ChannelCapabilityPath(ch.PortId, ch.ChannelId)
capability, found := m.keeper.scopedKeeper.GetCapability(ctx, name)
if !found {
m.keeper.Logger(ctx).Error(fmt.Sprintf("failed to find capability: %s", name))
return errorsmod.Wrapf(capabilitytypes.ErrCapabilityNotFound, "failed to find capability: %s", name)
}

isAuthenticated := m.keeper.scopedKeeper.AuthenticateCapability(ctx, capability, name)
if !isAuthenticated {
m.keeper.Logger(ctx).Error(fmt.Sprintf("expected capability owner: %s", controllertypes.SubModuleName))
return errorsmod.Wrapf(capabilitytypes.ErrCapabilityNotOwned, "expected capability owner: %s", controllertypes.SubModuleName)
}

m.keeper.SetMiddlewareEnabled(ctx, ch.PortId, ch.ConnectionHops[0])
m.keeper.Logger(ctx).Info("successfully migrated channel capability", "name", name)
}
}
return nil
}

// MigrateParams migrates the controller submodule's parameters from the x/params to self store.
func (m Migrator) MigrateParams(ctx sdk.Context) error {
if m.keeper != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,80 +5,8 @@ import (

icacontrollerkeeper "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/controller/keeper"
icacontrollertypes "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/controller/types"
icatypes "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/types"
channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types"
ibctesting "github.com/cosmos/ibc-go/v9/testing"
)

func (suite *KeeperTestSuite) TestAssertChannelCapabilityMigrations() {
testCases := []struct {
name string
malleate func()
expPass bool
}{
{
"success",
func() {},
true,
},
{
"channel with different port is filtered out",
func() {
portIDWithOutPrefix := ibctesting.MockPort
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.SetChannel(suite.chainA.GetContext(), portIDWithOutPrefix, ibctesting.FirstChannelID, channeltypes.Channel{
ConnectionHops: []string{ibctesting.FirstConnectionID},
})
},
true,
},
{
"capability not found",
func() {
portIDWithPrefix := fmt.Sprintf("%s%s", icatypes.ControllerPortPrefix, "port-without-capability")
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.SetChannel(suite.chainA.GetContext(), portIDWithPrefix, ibctesting.FirstChannelID, channeltypes.Channel{
ConnectionHops: []string{ibctesting.FirstConnectionID},
})
},
false,
},
}

for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} {
for _, tc := range testCases {
tc := tc

suite.Run(tc.name, func() {
suite.SetupTest()

path := NewICAPath(suite.chainA, suite.chainB, ordering)
path.SetupConnections()

err := SetupICAPath(path, ibctesting.TestAccAddress)
suite.Require().NoError(err)

tc.malleate()

migrator := icacontrollerkeeper.NewMigrator(&suite.chainA.GetSimApp().ICAControllerKeeper)
err = migrator.AssertChannelCapabilityMigrations(suite.chainA.GetContext())

if tc.expPass {
suite.Require().NoError(err)

isMiddlewareEnabled := suite.chainA.GetSimApp().ICAControllerKeeper.IsMiddlewareEnabled(
suite.chainA.GetContext(),
path.EndpointA.ChannelConfig.PortID,
path.EndpointA.ConnectionID,
)

suite.Require().True(isMiddlewareEnabled)
} else {
suite.Require().Error(err)
}
})
}
}
}

func (suite *KeeperTestSuite) TestMigratorMigrateParams() {
testCases := []struct {
msg string
Expand Down

This file was deleted.

Loading

0 comments on commit 1f50c8f

Please sign in to comment.