Skip to content

Commit 7efc384

Browse files
ICA controller/host submodules (#541)
* go mod tidy * creating new genesis types for controller and host submodules * removing dead root module code * updating genesis helpers and adding newly generated types * adding interchain-accounts controller submodule * adding interchain-accounts host submodule * updating simapp to include controller and host ica submodules * adding errors returns for disallowed handshake directions, removing embedded app from host module, updating simapp to conform * updating simapp to remove nil arg to ica host ibc module * removing ics4Wrapper arg from ica host submodule * cleaning up module.go for controller and host submodules * removing commented out tests * commit with broken tests to rebase * disabling app version negotation on controller submodule * fixing tests - now passing * various cleanup, godocs and moving code * updating error msgs to conform to pkg split * removing commented out code * adding combined ica genesis, consolidating to single ica AppModule, updating app.go * adding missing godocs * clean up, godocs, rename validate.go -> version.go, move version related funcs * updating godocs and code organization * removing controller module acc, using icatypes module name for module acc in host submodule * correcting panic error msg * Update modules/apps/27-interchain-accounts/controller/ibc_module.go * Update modules/apps/27-interchain-accounts/types/genesis.go Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * updating logger kvs, and simplifying OnRecvPacket * address nits on error strings and godocs Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>
1 parent b8bc1a8 commit 7efc384

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+3205
-2475
lines changed

docs/ibc/proto-docs.md

+21-48
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,11 @@
99

1010
- [ibc/applications/interchain_accounts/v1/genesis.proto](#ibc/applications/interchain_accounts/v1/genesis.proto)
1111
- [ActiveChannel](#ibc.applications.interchain_accounts.v1.ActiveChannel)
12+
- [ControllerGenesisState](#ibc.applications.interchain_accounts.v1.ControllerGenesisState)
1213
- [GenesisState](#ibc.applications.interchain_accounts.v1.GenesisState)
14+
- [HostGenesisState](#ibc.applications.interchain_accounts.v1.HostGenesisState)
1315
- [RegisteredInterchainAccount](#ibc.applications.interchain_accounts.v1.RegisteredInterchainAccount)
1416

15-
- [ibc/applications/interchain_accounts/v1/query.proto](#ibc/applications/interchain_accounts/v1/query.proto)
16-
- [QueryInterchainAccountAddressRequest](#ibc.applications.interchain_accounts.v1.QueryInterchainAccountAddressRequest)
17-
- [QueryInterchainAccountAddressResponse](#ibc.applications.interchain_accounts.v1.QueryInterchainAccountAddressResponse)
18-
19-
- [Query](#ibc.applications.interchain_accounts.v1.Query)
20-
2117
- [ibc/applications/interchain_accounts/v1/types.proto](#ibc/applications/interchain_accounts/v1/types.proto)
2218
- [CosmosTx](#ibc.applications.interchain_accounts.v1.CosmosTx)
2319
- [InterchainAccountPacketData](#ibc.applications.interchain_accounts.v1.InterchainAccountPacketData)
@@ -329,10 +325,10 @@ ActiveChannel contains a pairing of port ID and channel ID for an active interch
329325

330326

331327

332-
<a name="ibc.applications.interchain_accounts.v1.GenesisState"></a>
328+
<a name="ibc.applications.interchain_accounts.v1.ControllerGenesisState"></a>
333329

334-
### GenesisState
335-
GenesisState defines the interchain accounts genesis state
330+
### ControllerGenesisState
331+
ControllerGenesisState defines the interchain accounts controller genesis state
336332

337333

338334
| Field | Type | Label | Description |
@@ -346,62 +342,49 @@ GenesisState defines the interchain accounts genesis state
346342

347343

348344

349-
<a name="ibc.applications.interchain_accounts.v1.RegisteredInterchainAccount"></a>
345+
<a name="ibc.applications.interchain_accounts.v1.GenesisState"></a>
350346

351-
### RegisteredInterchainAccount
352-
RegisteredInterchainAccount contains a pairing of controller port ID and associated interchain account address
347+
### GenesisState
348+
GenesisState defines the interchain accounts genesis state
353349

354350

355351
| Field | Type | Label | Description |
356352
| ----- | ---- | ----- | ----------- |
357-
| `port_id` | [string](#string) | | |
358-
| `account_address` | [string](#string) | | |
359-
360-
361-
353+
| `controller_genesis_state` | [ControllerGenesisState](#ibc.applications.interchain_accounts.v1.ControllerGenesisState) | | |
354+
| `host_genesis_state` | [HostGenesisState](#ibc.applications.interchain_accounts.v1.HostGenesisState) | | |
362355

363356

364-
<!-- end messages -->
365357

366-
<!-- end enums -->
367358

368-
<!-- end HasExtensions -->
369359

370-
<!-- end services -->
371360

361+
<a name="ibc.applications.interchain_accounts.v1.HostGenesisState"></a>
372362

373-
374-
<a name="ibc/applications/interchain_accounts/v1/query.proto"></a>
375-
<p align="right"><a href="#top">Top</a></p>
376-
377-
## ibc/applications/interchain_accounts/v1/query.proto
378-
379-
380-
381-
<a name="ibc.applications.interchain_accounts.v1.QueryInterchainAccountAddressRequest"></a>
382-
383-
### QueryInterchainAccountAddressRequest
384-
Query request for an interchain account address
363+
### HostGenesisState
364+
HostGenesisState defines the interchain accounts host genesis state
385365

386366

387367
| Field | Type | Label | Description |
388368
| ----- | ---- | ----- | ----------- |
389-
| `counterparty_port_id` | [string](#string) | | Counterparty PortID is the portID on the controller chain |
369+
| `active_channels` | [ActiveChannel](#ibc.applications.interchain_accounts.v1.ActiveChannel) | repeated | |
370+
| `interchain_accounts` | [RegisteredInterchainAccount](#ibc.applications.interchain_accounts.v1.RegisteredInterchainAccount) | repeated | |
371+
| `port` | [string](#string) | | |
390372

391373

392374

393375

394376

395377

396-
<a name="ibc.applications.interchain_accounts.v1.QueryInterchainAccountAddressResponse"></a>
378+
<a name="ibc.applications.interchain_accounts.v1.RegisteredInterchainAccount"></a>
397379

398-
### QueryInterchainAccountAddressResponse
399-
Query response for an interchain account address
380+
### RegisteredInterchainAccount
381+
RegisteredInterchainAccount contains a pairing of controller port ID and associated interchain account address
400382

401383

402384
| Field | Type | Label | Description |
403385
| ----- | ---- | ----- | ----------- |
404-
| `interchain_account_address` | [string](#string) | | The corresponding interchain account address on the host chain |
386+
| `port_id` | [string](#string) | | |
387+
| `account_address` | [string](#string) | | |
405388

406389

407390

@@ -413,16 +396,6 @@ Query response for an interchain account address
413396

414397
<!-- end HasExtensions -->
415398

416-
417-
<a name="ibc.applications.interchain_accounts.v1.Query"></a>
418-
419-
### Query
420-
Query defines the gRPC querier service.
421-
422-
| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint |
423-
| ----------- | ------------ | ------------- | ------------| ------- | -------- |
424-
| `InterchainAccountAddress` | [QueryInterchainAccountAddressRequest](#ibc.applications.interchain_accounts.v1.QueryInterchainAccountAddressRequest) | [QueryInterchainAccountAddressResponse](#ibc.applications.interchain_accounts.v1.QueryInterchainAccountAddressResponse) | Query to get the address of an interchain account | |
425-
426399
<!-- end services -->
427400

428401

go.mod

-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ require (
9494
github.com/prometheus/common v0.29.0 // indirect
9595
github.com/prometheus/procfs v0.6.0 // indirect
9696
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect
97-
github.com/regen-network/cosmos-proto v0.3.1 // indirect
9897
github.com/rs/cors v1.7.0 // indirect
9998
github.com/rs/zerolog v1.23.0 // indirect
10099
github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa // indirect
@@ -115,7 +114,6 @@ require (
115114
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect
116115
golang.org/x/text v0.3.6 // indirect
117116
gopkg.in/ini.v1 v1.63.2 // indirect
118-
gopkg.in/yaml.v2 v2.4.0 // indirect
119117
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
120118
nhooyr.io/websocket v1.8.6 // indirect
121119
)

modules/apps/27-interchain-accounts/client/cli/query.go

-52
This file was deleted.

modules/apps/27-interchain-accounts/ibc_module.go modules/apps/27-interchain-accounts/controller/ibc_module.go

+15-39
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,37 @@
1-
package interchain_accounts
1+
package controller
22

33
import (
44
sdk "github.com/cosmos/cosmos-sdk/types"
55
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
66
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
77

8-
"github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/keeper"
8+
"github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/controller/keeper"
9+
"github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types"
910
channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types"
1011
porttypes "github.com/cosmos/ibc-go/v2/modules/core/05-port/types"
1112
ibcexported "github.com/cosmos/ibc-go/v2/modules/core/exported"
1213
)
1314

14-
// IBCModule implements the ICS26 interface for interchain accounts given the
15-
// interchain account keeper and underlying application.
15+
// IBCModule implements the ICS26 interface for interchain accounts controller chains
1616
type IBCModule struct {
1717
keeper keeper.Keeper
1818
app porttypes.IBCModule
1919
}
2020

21-
// NewIBCModule creates a new IBCModule given the keeper and underlying application
21+
// NewIBCModule creates a new IBCModule given the associated keeper and underlying application
2222
func NewIBCModule(k keeper.Keeper, app porttypes.IBCModule) IBCModule {
2323
return IBCModule{
2424
keeper: k,
2525
app: app,
2626
}
2727
}
2828

29-
// OnChanOpenInit implements the IBCModule interface. Interchain Accounts is
30-
// implemented to act as middleware for connected authentication modules on
29+
// OnChanOpenInit implements the IBCModule interface
30+
//
31+
// Interchain Accounts is implemented to act as middleware for connected authentication modules on
3132
// the controller side. The connected modules may not change the controller side portID or
3233
// version. They will be allowed to perform custom logic without changing
3334
// the parameters stored within a channel struct.
34-
//
35-
// Controller Chain
3635
func (im IBCModule) OnChanOpenInit(
3736
ctx sdk.Context,
3837
order channeltypes.Order,
@@ -53,8 +52,6 @@ func (im IBCModule) OnChanOpenInit(
5352
}
5453

5554
// OnChanOpenTry implements the IBCModule interface
56-
//
57-
// Host Chain
5855
func (im IBCModule) OnChanOpenTry(
5956
ctx sdk.Context,
6057
order channeltypes.Order,
@@ -66,16 +63,15 @@ func (im IBCModule) OnChanOpenTry(
6663
version,
6764
counterpartyVersion string,
6865
) error {
69-
return im.keeper.OnChanOpenTry(ctx, order, connectionHops, portID, channelID, chanCap, counterparty, version, counterpartyVersion)
66+
return sdkerrors.Wrap(types.ErrInvalidChannelFlow, "channel handshake must be initiated by controller chain")
7067
}
7168

72-
// OnChanOpenAck implements the IBCModule interface. Interchain Accounts is
73-
// implemented to act as middleware for connected authentication modules on
69+
// OnChanOpenAck implements the IBCModule interface
70+
//
71+
// Interchain Accounts is implemented to act as middleware for connected authentication modules on
7472
// the controller side. The connected modules may not change the portID or
7573
// version. They will be allowed to perform custom logic without changing
7674
// the parameters stored within a channel struct.
77-
//
78-
// Controller Chain
7975
func (im IBCModule) OnChanOpenAck(
8076
ctx sdk.Context,
8177
portID,
@@ -91,14 +87,12 @@ func (im IBCModule) OnChanOpenAck(
9187
}
9288

9389
// OnChanOpenAck implements the IBCModule interface
94-
//
95-
// Host Chain
9690
func (im IBCModule) OnChanOpenConfirm(
9791
ctx sdk.Context,
9892
portID,
9993
channelID string,
10094
) error {
101-
return im.keeper.OnChanOpenConfirm(ctx, portID, channelID)
95+
return sdkerrors.Wrap(types.ErrInvalidChannelFlow, "channel handshake must be initiated by controller chain")
10296
}
10397

10498
// OnChanCloseInit implements the IBCModule interface
@@ -121,31 +115,15 @@ func (im IBCModule) OnChanCloseConfirm(
121115
}
122116

123117
// OnRecvPacket implements the IBCModule interface
124-
//
125-
// Host Chain
126118
func (im IBCModule) OnRecvPacket(
127119
ctx sdk.Context,
128120
packet channeltypes.Packet,
129121
_ sdk.AccAddress,
130122
) ibcexported.Acknowledgement {
131-
ack := channeltypes.NewResultAcknowledgement([]byte{byte(1)})
132-
133-
// only attempt the application logic if the packet data
134-
// was successfully decoded
135-
if ack.Success() {
136-
err := im.keeper.OnRecvPacket(ctx, packet)
137-
if err != nil {
138-
ack = channeltypes.NewErrorAcknowledgement(err.Error())
139-
}
140-
}
141-
142-
// NOTE: acknowledgement will be written synchronously during IBC handler execution.
143-
return ack
123+
return channeltypes.NewErrorAcknowledgement("cannot receive packet on controller chain")
144124
}
145125

146126
// OnAcknowledgementPacket implements the IBCModule interface
147-
//
148-
// Controller Chain
149127
func (im IBCModule) OnAcknowledgementPacket(
150128
ctx sdk.Context,
151129
packet channeltypes.Packet,
@@ -157,8 +135,6 @@ func (im IBCModule) OnAcknowledgementPacket(
157135
}
158136

159137
// OnTimeoutPacket implements the IBCModule interface
160-
//
161-
// Controller Chain
162138
func (im IBCModule) OnTimeoutPacket(
163139
ctx sdk.Context,
164140
packet channeltypes.Packet,
@@ -180,5 +156,5 @@ func (im IBCModule) NegotiateAppVersion(
180156
counterparty channeltypes.Counterparty,
181157
proposedVersion string,
182158
) (string, error) {
183-
return im.keeper.NegotiateAppVersion(ctx, order, connectionID, portID, counterparty, proposedVersion)
159+
return "", sdkerrors.Wrap(types.ErrInvalidChannelFlow, "ICS-27 app version negotiation is unsupported on controller chains")
184160
}

0 commit comments

Comments
 (0)