Skip to content

Commit

Permalink
chore: merge feature branch
Browse files Browse the repository at this point in the history
  • Loading branch information
chatton committed Jan 11, 2024
2 parents d58cf6f + 3dedb40 commit 5ae94f1
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,6 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenInit() {
suite.chainA.GetSimApp().ICAControllerKeeper.SetParams(suite.chainA.GetContext(), types.NewParams(false))
}, false,
},
{
"ICA OnChanOpenInit fails - UNORDERED channel", func() {
channel.Ordering = channeltypes.UNORDERED
}, false,
},
{
"ICA auth module callback fails", func() {
suite.chainA.GetSimApp().ICAAuthModule.IBCApp.OnChanOpenInit = func(ctx sdk.Context, order channeltypes.Order, connectionHops []string,
Expand Down
15 changes: 2 additions & 13 deletions modules/apps/27-interchain-accounts/controller/keeper/handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import (
)

// OnChanOpenInit performs basic validation of channel initialization.
// The channel order must be ORDERED, the counterparty port identifier
// must be the host chain representation as defined in the types package,
// The counterparty port identifier must be the host chain representation as defined in the types package,
// the channel version must be equal to the version in the types package,
// there must not be an active channel for the specified port identifier,
// and the interchain accounts module must be able to claim the channel
Expand All @@ -31,10 +30,6 @@ func (k Keeper) OnChanOpenInit(
counterparty channeltypes.Counterparty,
version string,
) (string, error) {
if order != channeltypes.ORDERED {
return "", errorsmod.Wrapf(channeltypes.ErrInvalidChannelOrdering, "expected %s channel, got %s", channeltypes.ORDERED, order)
}

if !strings.HasPrefix(portID, icatypes.ControllerPortPrefix) {
return "", errorsmod.Wrapf(icatypes.ErrInvalidControllerPort, "expected %s{owner-account-address}, got %s", icatypes.ControllerPortPrefix, portID)
}
Expand Down Expand Up @@ -153,19 +148,13 @@ func (Keeper) OnChanCloseConfirm(
// The following may be changed:
// - tx type (must be supported)
// - encoding (must be supported)
// - order
//
// The following may not be changed:
// - order
// - connectionHops (and subsequently host/controller connectionIDs)
// - interchain account address
// - ICS27 protocol version
func (k Keeper) OnChanUpgradeInit(ctx sdk.Context, portID, channelID string, order channeltypes.Order, connectionHops []string, version string) (string, error) {
// verify order has not changed
// support for unordered ICA channels is not implemented yet
if order != channeltypes.ORDERED {
return "", errorsmod.Wrapf(channeltypes.ErrInvalidChannelOrdering, "expected %s channel, got %s", channeltypes.ORDERED, order)
}

// verify connection hops has not changed
connectionID, err := k.GetConnectionID(ctx, portID, channelID)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() {
},
icatypes.ErrInvalidVersion,
},
{
"invalid order - UNORDERED",
func() {
channel.Ordering = channeltypes.UNORDERED
},
channeltypes.ErrInvalidChannelOrdering,
},
{
"invalid port ID",
func() {
Expand Down Expand Up @@ -530,11 +523,11 @@ func (suite *KeeperTestSuite) TestOnChanUpgradeInit() {
nil,
},
{
name: "failure: invalid order",
name: "success: change order",
malleate: func() {
order = channeltypes.UNORDERED
},
expError: channeltypes.ErrInvalidChannelOrdering,
expError: nil,
},
{
name: "failure: connectionID not found",
Expand Down
5 changes: 0 additions & 5 deletions modules/apps/27-interchain-accounts/host/ibc_module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,6 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenTry() {
}
}, true,
},
{
"ICA callback fails - invalid channel order", func() {
channel.Ordering = channeltypes.UNORDERED
}, false,
},
}

for _, tc := range testCases {
Expand Down
12 changes: 1 addition & 11 deletions modules/apps/27-interchain-accounts/host/keeper/handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ func (k Keeper) OnChanOpenTry(
counterparty channeltypes.Counterparty,
counterpartyVersion string,
) (string, error) {
if order != channeltypes.ORDERED {
return "", errorsmod.Wrapf(channeltypes.ErrInvalidChannelOrdering, "expected %s channel, got %s", channeltypes.ORDERED, order)
}

if portID != icatypes.HostPortID {
return "", errorsmod.Wrapf(icatypes.ErrInvalidHostPort, "expected %s, got %s", icatypes.HostPortID, portID)
}
Expand Down Expand Up @@ -139,19 +135,13 @@ func (Keeper) OnChanCloseConfirm(
// The following may be changed:
// - tx type (must be supported)
// - encoding (must be supported)
// - order
//
// The following may not be changed:
// - order
// - connectionHops (and subsequently host/controller connectionIDs)
// - interchain account address
// - ICS27 protocol version
func (k Keeper) OnChanUpgradeTry(ctx sdk.Context, portID, channelID string, order channeltypes.Order, connectionHops []string, counterpartyVersion string) (string, error) {
// verify order has not changed
// support for unordered ICA channels is not implemented yet
if order != channeltypes.ORDERED {
return "", errorsmod.Wrapf(channeltypes.ErrInvalidChannelOrdering, "expected %s channel, got %s", channeltypes.ORDERED, order)
}

if portID != icatypes.HostPortID {
return "", errorsmod.Wrapf(porttypes.ErrInvalidPort, "expected %s, got %s", icatypes.HostPortID, portID)
}
Expand Down
20 changes: 6 additions & 14 deletions modules/apps/27-interchain-accounts/host/keeper/handshake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() {
path.EndpointB.SetChannel(*channel)
}, false,
},

{
"invalid order - UNORDERED",
func() {
channel.Ordering = channeltypes.UNORDERED
},
false,
},
{
"invalid port ID",
func() {
Expand Down Expand Up @@ -458,18 +450,18 @@ func (suite *KeeperTestSuite) TestOnChanUpgradeTry() {
nil,
},
{
name: "failure: invalid port ID",
name: "success: change order",
malleate: func() {
path.EndpointB.ChannelConfig.PortID = "invalid-port-id"
order = channeltypes.UNORDERED
},
expError: porttypes.ErrInvalidPort,
expError: nil,
},
{
name: "failure: invalid order",
name: "failure: invalid port ID",
malleate: func() {
order = channeltypes.UNORDERED
path.EndpointB.ChannelConfig.PortID = "invalid-port-id"
},
expError: channeltypes.ErrInvalidChannelOrdering,
expError: porttypes.ErrInvalidPort,
},
{
name: "failure: invalid proposed connectionHops",
Expand Down

0 comments on commit 5ae94f1

Please sign in to comment.