Skip to content

Commit

Permalink
Merge branch 'main' into damian/add-ica-address-query
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Sep 8, 2022
2 parents c929032 + b836b7f commit 634acaf
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 63 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (apps/27-interchain-accounts) [\#2146](https://github.com/cosmos/ibc-go/pull/2146) ICS27 controller now claims the channel capability passed via ibc core, and passes `nil` to the underlying app callback. The channel capability arg in `SendTx` is now ignored and looked up internally.
* (apps/27-interchain-accounts) [\#2134](https://github.com/cosmos/ibc-go/pull/2134) Adding upgrade handler to ICS27 `controller` submodule for migration of channel capabilities. This upgrade handler migrates ownership of channel capabilities from the underlying application to the ICS27 `controller` submodule.
* (apps/27-interchain-accounts) [\#2157](https://github.com/cosmos/ibc-go/pull/2157) Adding `IsMiddlewareEnabled` functionality to enforce calls to ICS27 msg server to *not* route to the underlying application.
* (apps/27-interchain-accounts) [\#2177](https://github.com/cosmos/ibc-go/pull/2177) Adding `IsMiddlewareEnabled` flag to interchain accounts `ActiveChannel` genesis type.
* (apps/27-interchain-accounts) [\#2140](https://github.com/cosmos/ibc-go/pull/2140) Adding migration handler to ICS27 `controller` submodule to assert ownership of channel capabilities and set middleware enabled flag for existing channels. The ICS27 module consensus version has been bumped from 1 to 2.

### Features
Expand Down
4 changes: 3 additions & 1 deletion docs/ibc/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1750,14 +1750,16 @@ The following parameters may be used to disable the host submodule.
<a name="ibc.applications.interchain_accounts.genesis.v1.ActiveChannel"></a>

### ActiveChannel
ActiveChannel contains a connection ID, port ID and associated active channel ID
ActiveChannel contains a connection ID, port ID and associated active channel ID, as well as boolean flag to indicate
if the channel is middleware enabled


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `connection_id` | [string](#string) | | |
| `port_id` | [string](#string) | | |
| `channel_id` | [string](#string) | | |
| `is_middleware_enabled` | [bool](#bool) | | |



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, state genesistypes.ControllerGe

for _, ch := range state.ActiveChannels {
keeper.SetActiveChannelID(ctx, ch.ConnectionId, ch.PortId, ch.ChannelId)

if ch.IsMiddlewareEnabled {
keeper.SetMiddlewareEnabled(ctx, ch.PortId, ch.ChannelId)
}
}

for _, acc := range state.InterchainAccounts {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ func (suite *KeeperTestSuite) TestInitGenesis() {
genesisState := genesistypes.ControllerGenesisState{
ActiveChannels: []genesistypes.ActiveChannel{
{
ConnectionId: ibctesting.FirstConnectionID,
PortId: TestPortID,
ChannelId: ibctesting.FirstChannelID,
ConnectionId: ibctesting.FirstConnectionID,
PortId: TestPortID,
ChannelId: ibctesting.FirstChannelID,
IsMiddlewareEnabled: true,
},
},
InterchainAccounts: []genesistypes.RegisteredInterchainAccount{
Expand All @@ -34,6 +35,9 @@ func (suite *KeeperTestSuite) TestInitGenesis() {
suite.Require().True(found)
suite.Require().Equal(ibctesting.FirstChannelID, channelID)

isMiddlewareEnabled := suite.chainA.GetSimApp().ICAControllerKeeper.IsMiddlewareEnabled(suite.chainA.GetContext(), TestPortID, ibctesting.FirstChannelID)
suite.Require().True(isMiddlewareEnabled)

accountAdrr, found := suite.chainA.GetSimApp().ICAControllerKeeper.GetInterchainAccountAddress(suite.chainA.GetContext(), ibctesting.FirstConnectionID, TestPortID)
suite.Require().True(found)
suite.Require().Equal(TestAccAddress.String(), accountAdrr)
Expand All @@ -56,6 +60,7 @@ func (suite *KeeperTestSuite) TestExportGenesis() {

suite.Require().Equal(path.EndpointA.ChannelID, genesisState.ActiveChannels[0].ChannelId)
suite.Require().Equal(path.EndpointA.ChannelConfig.PortID, genesisState.ActiveChannels[0].PortId)
suite.Require().True(genesisState.ActiveChannels[0].IsMiddlewareEnabled)

suite.Require().Equal(TestAccAddress.String(), genesisState.InterchainAccounts[0].AccountAddress)
suite.Require().Equal(path.EndpointA.ChannelConfig.PortID, genesisState.InterchainAccounts[0].PortId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,10 @@ func (k Keeper) GetAllActiveChannels(ctx sdk.Context) []genesistypes.ActiveChann
keySplit := strings.Split(string(iterator.Key()), "/")

ch := genesistypes.ActiveChannel{
ConnectionId: keySplit[2],
PortId: keySplit[1],
ChannelId: string(iterator.Value()),
ConnectionId: keySplit[2],
PortId: keySplit[1],
ChannelId: string(iterator.Value()),
IsMiddlewareEnabled: k.IsMiddlewareEnabled(ctx, keySplit[1], string(iterator.Value())),
}

activeChannels = append(activeChannels, ch)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,16 @@ func (suite *KeeperTestSuite) TestGetAllActiveChannels() {

expectedChannels := []genesistypes.ActiveChannel{
{
ConnectionId: ibctesting.FirstConnectionID,
PortId: TestPortID,
ChannelId: path.EndpointA.ChannelID,
ConnectionId: ibctesting.FirstConnectionID,
PortId: TestPortID,
ChannelId: path.EndpointA.ChannelID,
IsMiddlewareEnabled: true,
},
{
ConnectionId: ibctesting.FirstConnectionID,
PortId: expectedPortID,
ChannelId: expectedChannelID,
ConnectionId: ibctesting.FirstConnectionID,
PortId: expectedPortID,
ChannelId: expectedChannelID,
IsMiddlewareEnabled: false,
},
}

Expand Down
137 changes: 91 additions & 46 deletions modules/apps/27-interchain-accounts/genesis/types/genesis.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ message HostGenesisState {
ibc.applications.interchain_accounts.host.v1.Params params = 4 [(gogoproto.nullable) = false];
}

// ActiveChannel contains a connection ID, port ID and associated active channel ID
// ActiveChannel contains a connection ID, port ID and associated active channel ID, as well as a boolean flag to indicate
// if the channel is middleware enabled
message ActiveChannel {
string connection_id = 1 [(gogoproto.moretags) = "yaml:\"connection_id\""];
string port_id = 2 [(gogoproto.moretags) = "yaml:\"port_id\""];
string channel_id = 3 [(gogoproto.moretags) = "yaml:\"channel_id\""];
string connection_id = 1 [(gogoproto.moretags) = "yaml:\"connection_id\""];
string port_id = 2 [(gogoproto.moretags) = "yaml:\"port_id\""];
string channel_id = 3 [(gogoproto.moretags) = "yaml:\"channel_id\""];
bool is_middleware_enabled = 4 [(gogoproto.moretags) = "yaml:\"is_middleware_enabled\""];
}

// RegisteredInterchainAccount contains a connection ID, port ID and associated interchain account address
Expand Down

0 comments on commit 634acaf

Please sign in to comment.