Skip to content
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

ICA controller/host submodules #541

Merged
merged 29 commits into from
Nov 18, 2021
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4c32cec
go mod tidy
damiannolan Nov 10, 2021
f369f01
creating new genesis types for controller and host submodules
damiannolan Nov 10, 2021
037e691
removing dead root module code
damiannolan Nov 11, 2021
248ef51
updating genesis helpers and adding newly generated types
damiannolan Nov 11, 2021
63a7495
adding interchain-accounts controller submodule
damiannolan Nov 11, 2021
423a992
adding interchain-accounts host submodule
damiannolan Nov 11, 2021
10bdc33
updating simapp to include controller and host ica submodules
damiannolan Nov 11, 2021
b7524eb
adding errors returns for disallowed handshake directions, removing e…
damiannolan Nov 11, 2021
269e95a
updating simapp to remove nil arg to ica host ibc module
damiannolan Nov 11, 2021
3b0bed1
removing ics4Wrapper arg from ica host submodule
damiannolan Nov 11, 2021
e68338b
cleaning up module.go for controller and host submodules
damiannolan Nov 11, 2021
8eb0293
removing commented out tests
damiannolan Nov 12, 2021
db9233e
commit with broken tests to rebase
damiannolan Nov 15, 2021
8c2c61f
Merge branch 'interchain-accounts' into damian/290-ica-submodules
damiannolan Nov 15, 2021
7a7a72b
disabling app version negotation on controller submodule
damiannolan Nov 15, 2021
f9a8837
fixing tests - now passing
damiannolan Nov 15, 2021
12a69ea
various cleanup, godocs and moving code
damiannolan Nov 15, 2021
86082e6
updating error msgs to conform to pkg split
damiannolan Nov 15, 2021
fdb2ff3
removing commented out code
damiannolan Nov 15, 2021
b3f52bd
adding combined ica genesis, consolidating to single ica AppModule, u…
damiannolan Nov 16, 2021
c26107f
adding missing godocs
damiannolan Nov 16, 2021
f59f0a1
clean up, godocs, rename validate.go -> version.go, move version rela…
damiannolan Nov 16, 2021
6daeac8
updating godocs and code organization
damiannolan Nov 17, 2021
3fc0f71
removing controller module acc, using icatypes module name for module…
damiannolan Nov 17, 2021
f73bd83
correcting panic error msg
damiannolan Nov 17, 2021
1cec8b0
Update modules/apps/27-interchain-accounts/controller/ibc_module.go
damiannolan Nov 17, 2021
70d2d59
Update modules/apps/27-interchain-accounts/types/genesis.go
damiannolan Nov 17, 2021
e61c5c9
updating logger kvs, and simplifying OnRecvPacket
damiannolan Nov 17, 2021
dd4c82f
address nits on error strings and godocs
damiannolan Nov 18, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 21 additions & 48 deletions docs/ibc/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,11 @@

- [ibc/applications/interchain_accounts/v1/genesis.proto](#ibc/applications/interchain_accounts/v1/genesis.proto)
- [ActiveChannel](#ibc.applications.interchain_accounts.v1.ActiveChannel)
- [ControllerGenesisState](#ibc.applications.interchain_accounts.v1.ControllerGenesisState)
- [GenesisState](#ibc.applications.interchain_accounts.v1.GenesisState)
- [HostGenesisState](#ibc.applications.interchain_accounts.v1.HostGenesisState)
- [RegisteredInterchainAccount](#ibc.applications.interchain_accounts.v1.RegisteredInterchainAccount)

- [ibc/applications/interchain_accounts/v1/query.proto](#ibc/applications/interchain_accounts/v1/query.proto)
- [QueryInterchainAccountAddressRequest](#ibc.applications.interchain_accounts.v1.QueryInterchainAccountAddressRequest)
- [QueryInterchainAccountAddressResponse](#ibc.applications.interchain_accounts.v1.QueryInterchainAccountAddressResponse)

- [Query](#ibc.applications.interchain_accounts.v1.Query)

- [ibc/applications/interchain_accounts/v1/types.proto](#ibc/applications/interchain_accounts/v1/types.proto)
- [CosmosTx](#ibc.applications.interchain_accounts.v1.CosmosTx)
- [InterchainAccountPacketData](#ibc.applications.interchain_accounts.v1.InterchainAccountPacketData)
Expand Down Expand Up @@ -329,10 +325,10 @@ ActiveChannel contains a pairing of port ID and channel ID for an active interch



<a name="ibc.applications.interchain_accounts.v1.GenesisState"></a>
<a name="ibc.applications.interchain_accounts.v1.ControllerGenesisState"></a>

### GenesisState
GenesisState defines the interchain accounts genesis state
### ControllerGenesisState
ControllerGenesisState defines the interchain accounts controller genesis state


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



<a name="ibc.applications.interchain_accounts.v1.RegisteredInterchainAccount"></a>
<a name="ibc.applications.interchain_accounts.v1.GenesisState"></a>

### RegisteredInterchainAccount
RegisteredInterchainAccount contains a pairing of controller port ID and associated interchain account address
### GenesisState
GenesisState defines the interchain accounts genesis state


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `port_id` | [string](#string) | | |
| `account_address` | [string](#string) | | |



| `controller_genesis_state` | [ControllerGenesisState](#ibc.applications.interchain_accounts.v1.ControllerGenesisState) | | |
| `host_genesis_state` | [HostGenesisState](#ibc.applications.interchain_accounts.v1.HostGenesisState) | | |


<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->

<!-- end services -->

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


<a name="ibc/applications/interchain_accounts/v1/query.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## ibc/applications/interchain_accounts/v1/query.proto



<a name="ibc.applications.interchain_accounts.v1.QueryInterchainAccountAddressRequest"></a>

### QueryInterchainAccountAddressRequest
Query request for an interchain account address
### HostGenesisState
HostGenesisState defines the interchain accounts host genesis state


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






<a name="ibc.applications.interchain_accounts.v1.QueryInterchainAccountAddressResponse"></a>
<a name="ibc.applications.interchain_accounts.v1.RegisteredInterchainAccount"></a>

### QueryInterchainAccountAddressResponse
Query response for an interchain account address
### RegisteredInterchainAccount
RegisteredInterchainAccount contains a pairing of controller port ID and associated interchain account address


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `interchain_account_address` | [string](#string) | | The corresponding interchain account address on the host chain |
| `port_id` | [string](#string) | | |
| `account_address` | [string](#string) | | |



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

<!-- end HasExtensions -->


<a name="ibc.applications.interchain_accounts.v1.Query"></a>

### Query
Query defines the gRPC querier service.

| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint |
| ----------- | ------------ | ------------- | ------------| ------- | -------- |
| `InterchainAccountAddress` | [QueryInterchainAccountAddressRequest](#ibc.applications.interchain_accounts.v1.QueryInterchainAccountAddressRequest) | [QueryInterchainAccountAddressResponse](#ibc.applications.interchain_accounts.v1.QueryInterchainAccountAddressResponse) | Query to get the address of an interchain account | |

<!-- end services -->


Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ require (
github.com/prometheus/common v0.29.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect
github.com/regen-network/cosmos-proto v0.3.1 // indirect
github.com/rs/cors v1.7.0 // indirect
github.com/rs/zerolog v1.23.0 // indirect
github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa // indirect
Expand All @@ -115,7 +114,6 @@ require (
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect
golang.org/x/text v0.3.6 // indirect
gopkg.in/ini.v1 v1.63.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
nhooyr.io/websocket v1.8.6 // indirect
)
52 changes: 0 additions & 52 deletions modules/apps/27-interchain-accounts/client/cli/query.go

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,38 +1,37 @@
package interchain_accounts
package controller

import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"

"github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/keeper"
"github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/controller/keeper"
"github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types"
channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types"
porttypes "github.com/cosmos/ibc-go/v2/modules/core/05-port/types"
ibcexported "github.com/cosmos/ibc-go/v2/modules/core/exported"
)

// IBCModule implements the ICS26 interface for interchain accounts given the
// interchain account keeper and underlying application.
// IBCModule implements the ICS26 interface for interchain accounts controller chains
type IBCModule struct {
keeper keeper.Keeper
app porttypes.IBCModule
}

// NewIBCModule creates a new IBCModule given the keeper and underlying application
// NewIBCModule creates a new IBCModule given the associated keeper and underlying application
func NewIBCModule(k keeper.Keeper, app porttypes.IBCModule) IBCModule {
return IBCModule{
keeper: k,
app: app,
}
}

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

// OnChanOpenTry implements the IBCModule interface
//
// Host Chain
func (im IBCModule) OnChanOpenTry(
ctx sdk.Context,
order channeltypes.Order,
Expand All @@ -66,16 +63,15 @@ func (im IBCModule) OnChanOpenTry(
version,
counterpartyVersion string,
) error {
return im.keeper.OnChanOpenTry(ctx, order, connectionHops, portID, channelID, chanCap, counterparty, version, counterpartyVersion)
return sdkerrors.Wrap(types.ErrInvalidChannelFlow, "channel handshake must be initiated by controller chain")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Controller submodule returns errors for both OnChanOpenTry and OnChanOpenConfirm handshake callbacks

}

// OnChanOpenAck implements the IBCModule interface. Interchain Accounts is
// implemented to act as middleware for connected authentication modules on
// OnChanOpenAck implements the IBCModule interface
//
// Interchain Accounts is implemented to act as middleware for connected authentication modules on
// the controller side. The connected modules may not change the portID or
// version. They will be allowed to perform custom logic without changing
// the parameters stored within a channel struct.
//
// Controller Chain
func (im IBCModule) OnChanOpenAck(
ctx sdk.Context,
portID,
Expand All @@ -91,14 +87,12 @@ func (im IBCModule) OnChanOpenAck(
}

// OnChanOpenAck implements the IBCModule interface
//
// Host Chain
func (im IBCModule) OnChanOpenConfirm(
ctx sdk.Context,
portID,
channelID string,
) error {
return im.keeper.OnChanOpenConfirm(ctx, portID, channelID)
return sdkerrors.Wrap(types.ErrInvalidChannelFlow, "channel handshake must be initiated by controller chain")
}

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

// OnRecvPacket implements the IBCModule interface
//
// Host Chain
func (im IBCModule) OnRecvPacket(
ctx sdk.Context,
packet channeltypes.Packet,
_ sdk.AccAddress,
) ibcexported.Acknowledgement {
ack := channeltypes.NewResultAcknowledgement([]byte{byte(1)})

// only attempt the application logic if the packet data
// was successfully decoded
if ack.Success() {
err := im.keeper.OnRecvPacket(ctx, packet)
if err != nil {
ack = channeltypes.NewErrorAcknowledgement(err.Error())
}
}

// NOTE: acknowledgement will be written synchronously during IBC handler execution.
return ack
return channeltypes.NewErrorAcknowledgement("cannot receive packet on host controller chain")
damiannolan marked this conversation as resolved.
Show resolved Hide resolved
}

// OnAcknowledgementPacket implements the IBCModule interface
//
// Controller Chain
func (im IBCModule) OnAcknowledgementPacket(
ctx sdk.Context,
packet channeltypes.Packet,
Expand All @@ -157,8 +135,6 @@ func (im IBCModule) OnAcknowledgementPacket(
}

// OnTimeoutPacket implements the IBCModule interface
//
// Controller Chain
func (im IBCModule) OnTimeoutPacket(
ctx sdk.Context,
packet channeltypes.Packet,
Expand All @@ -180,5 +156,5 @@ func (im IBCModule) NegotiateAppVersion(
counterparty channeltypes.Counterparty,
proposedVersion string,
) (string, error) {
return im.keeper.NegotiateAppVersion(ctx, order, connectionID, portID, counterparty, proposedVersion)
return "", sdkerrors.Wrap(types.ErrInvalidChannelFlow, "ICS-27 app version negotiation is unsupported on controller chains")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Controller submodule returns an error for invoking NegotiateAppVersion, for ics27 this should only be provided by the host submodule

}
Loading