Skip to content

Commit 83aa279

Browse files
authored
Merge pull request cosmos#4 from informalsystems/interchain-security-2-v3.0.0-rebase
Interchain security 2 v3.0.0 rebase
2 parents 1317331 + 235b82b commit 83aa279

Some content is hidden

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

51 files changed

+1228
-500
lines changed

CHANGELOG.md

+93-16
Large diffs are not rendered by default.

docs/.vuepress/config.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -109,37 +109,37 @@ module.exports = {
109109
{
110110
title: "Interchain Accounts",
111111
directory: true,
112-
path: "/app-modules",
112+
path: "/apps",
113113
children: [
114114
{
115115
title: "Overview",
116116
directory: false,
117-
path: "/app-modules/interchain-accounts/overview.html"
117+
path: "/apps/interchain-accounts/overview.html"
118118
},
119119
{
120120
title: "Authentication Modules",
121121
directory: false,
122-
path: "/app-modules/interchain-accounts/auth-modules.html"
122+
path: "/apps/interchain-accounts/auth-modules.html"
123123
},
124124
{
125125
title: "Active Channels",
126126
directory: false,
127-
path: "/app-modules/interchain-accounts/active-channels.html"
127+
path: "/apps/interchain-accounts/active-channels.html"
128128
},
129129
{
130130
title: "Integration",
131131
directory: false,
132-
path: "/app-modules/interchain-accounts/integration.html"
132+
path: "/apps/interchain-accounts/integration.html"
133133
},
134134
{
135135
title: "Parameters",
136136
directory: false,
137-
path: "/app-modules/interchain-accounts/parameters.html"
137+
path: "/apps/interchain-accounts/parameters.html"
138138
},
139139
{
140140
title: "Transactions",
141141
directory: false,
142-
path: "/app-modules/interchain-accounts/transactions.html"
142+
path: "/apps/interchain-accounts/transactions.html"
143143
},
144144
]
145145
},
Binary file not shown.

docs/app-modules/interchain-accounts/auth-modules.md renamed to docs/apps/interchain-accounts/auth-modules.md

+14-7
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,13 @@ If the controller chain is connected to a host chain using the host module on ib
220220

221221
Begin by unmarshaling the acknowledgement into sdk.TxMsgData:
222222
```go
223+
var ack channeltypes.Acknowledgement
224+
if err := channeltypes.SubModuleCdc.UnmarshalJSON(acknowledgement, &ack); err != nil {
225+
return err
226+
}
227+
223228
txMsgData := &sdk.TxMsgData{}
224-
if err := proto.Unmarshal(ack.Acknowledgement(), txMsgData); err != nil {
229+
if err := proto.Unmarshal(ack.GetResult(), txMsgData); err != nil {
225230
return err
226231
}
227232
```
@@ -232,6 +237,8 @@ The auth module should interpret the txMsgData.Data as follows:
232237
```go
233238
switch len(txMsgData.Data) {
234239
case 0:
240+
// see documentation below for SDK 0.46.x or greater
241+
default:
235242
for _, msgData := range txMsgData.Data {
236243
if err := handler(msgData); err != nil {
237244
return err
@@ -246,24 +253,24 @@ A router could be used, or more simply a switch statement.
246253

247254
```go
248255
func handler(msgData sdk.MsgData) error {
249-
switch msgData.TypeURL {
250-
case banktypes.MsgSend:
256+
switch msgData.MsgType {
257+
case sdk.MsgTypeURL(&banktypes.MsgSend{}):
251258
msgResponse := &banktypes.MsgSendResponse{}
252259
if err := proto.Unmarshal(msgData.Data, msgResponse}; err != nil {
253260
return err
254261
}
255262

256263
handleBankSendMsg(msgResponse)
257264

258-
case stakingtypes.MsgDelegate:
265+
case sdk.MsgTypeURL(&stakingtypes.MsgDelegate{}):
259266
msgResponse := &stakingtypes.MsgDelegateResponse{}
260267
if err := proto.Unmarshal(msgData.Data, msgResponse}; err != nil {
261268
return err
262269
}
263270

264271
handleStakingDelegateMsg(msgResponse)
265272

266-
case transfertypes.MsgTransfer:
273+
case sdk.MsgTypeURL(&transfertypes.MsgTransfer{}):
267274
msgResponse := &transfertypes.MsgTransferResponse{}
268275
if err := proto.Unmarshal(msgData.Data, msgResponse}; err != nil {
269276
return err
@@ -281,8 +288,8 @@ The auth module should interpret the txMsgData.Responses as follows:
281288

282289
```go
283290
...
284-
// switch statement from above continued
285-
default:
291+
// switch statement from above
292+
case 0:
286293
for _, any := range txMsgData.MsgResponses {
287294
if err := handleAny(any); err != nil {
288295
return err

docs/ibc/integration.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ func NewApp(...args) *App {
9292

9393
// Create IBC Keeper
9494
app.IBCKeeper = ibckeeper.NewKeeper(
95-
appCodec, keys[ibchost.StoreKey], app.StakingKeeper, scopedIBCKeeper,
95+
appCodec, keys[ibchost.StoreKey], app.GetSubspace(ibchost.ModuleName), app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper,
9696
)
9797

9898
// Create Transfer Keepers
9999
app.TransferKeeper = ibctransferkeeper.NewKeeper(
100-
appCodec, keys[ibctransfertypes.StoreKey],
101-
app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper,
100+
appCodec, keys[ibctransfertypes.StoreKey], app.GetSubspace(ibctransfertypes.ModuleName),
101+
app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper,
102102
app.AccountKeeper, app.BankKeeper, scopedTransferKeeper,
103103
)
104104
transferModule := transfer.NewAppModule(app.TransferKeeper)

docs/ibc/proto-docs.md

+35
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@
127127
- [MsgTimeoutOnCloseResponse](#ibc.core.channel.v1.MsgTimeoutOnCloseResponse)
128128
- [MsgTimeoutResponse](#ibc.core.channel.v1.MsgTimeoutResponse)
129129

130+
- [ResponseResultType](#ibc.core.channel.v1.ResponseResultType)
131+
130132
- [Msg](#ibc.core.channel.v1.Msg)
131133

132134
- [ibc/core/client/v1/genesis.proto](#ibc/core/client/v1/genesis.proto)
@@ -1738,6 +1740,11 @@ MsgAcknowledgement receives incoming IBC acknowledgement
17381740
MsgAcknowledgementResponse defines the Msg/Acknowledgement response type.
17391741

17401742

1743+
| Field | Type | Label | Description |
1744+
| ----- | ---- | ----- | ----------- |
1745+
| `result` | [ResponseResultType](#ibc.core.channel.v1.ResponseResultType) | | |
1746+
1747+
17411748

17421749

17431750

@@ -1954,6 +1961,11 @@ MsgRecvPacket receives incoming IBC packet
19541961
MsgRecvPacketResponse defines the Msg/RecvPacket response type.
19551962

19561963

1964+
| Field | Type | Label | Description |
1965+
| ----- | ---- | ----- | ----------- |
1966+
| `result` | [ResponseResultType](#ibc.core.channel.v1.ResponseResultType) | | |
1967+
1968+
19571969

19581970

19591971

@@ -2003,6 +2015,11 @@ MsgTimeoutOnClose timed-out packet upon counterparty channel closure.
20032015
MsgTimeoutOnCloseResponse defines the Msg/TimeoutOnClose response type.
20042016

20052017

2018+
| Field | Type | Label | Description |
2019+
| ----- | ---- | ----- | ----------- |
2020+
| `result` | [ResponseResultType](#ibc.core.channel.v1.ResponseResultType) | | |
2021+
2022+
20062023

20072024

20082025

@@ -2013,11 +2030,29 @@ MsgTimeoutOnCloseResponse defines the Msg/TimeoutOnClose response type.
20132030
MsgTimeoutResponse defines the Msg/Timeout response type.
20142031

20152032

2033+
| Field | Type | Label | Description |
2034+
| ----- | ---- | ----- | ----------- |
2035+
| `result` | [ResponseResultType](#ibc.core.channel.v1.ResponseResultType) | | |
2036+
2037+
20162038

20172039

20182040

20192041
<!-- end messages -->
20202042

2043+
2044+
<a name="ibc.core.channel.v1.ResponseResultType"></a>
2045+
2046+
### ResponseResultType
2047+
ResponseResultType defines the possible outcomes of the execution of a message
2048+
2049+
| Name | Number | Description |
2050+
| ---- | ------ | ----------- |
2051+
| RESPONSE_RESULT_UNSPECIFIED | 0 | Default zero value enumeration |
2052+
| RESPONSE_RESULT_NOOP | 1 | The message did not call the IBC application callbacks (because, for example, the packet had already been relayed) |
2053+
| RESPONSE_RESULT_SUCCESS | 2 | The message was executed successfully |
2054+
2055+
20212056
<!-- end enums -->
20222057

20232058
<!-- end HasExtensions -->

docs/ibc/relayer.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ a module event emission with the attribute value `ibc_<submodulename>` (02-clien
2727

2828
### Subscribing with Tendermint
2929

30-
Calling the Tendermint RPC method `Subscribe` via [Tendermint's Websocket](https://docs.tendermint.com/master/rpc/) will return events using
30+
Calling the Tendermint RPC method `Subscribe` via [Tendermint's Websocket](https://docs.tendermint.com/v0.35/rpc/) will return events using
3131
Tendermint's internal representation of them. Instead of receiving back a list of events as they
3232
were emitted, Tendermint will return the type `map[string][]string` which maps a string in the
3333
form `<event_type>.<attribute_key>` to `attribute_value`. This causes extraction of the event

docs/migrations/v2-to-v3.md

+109-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ No genesis or in-place migrations are required when upgrading from v1 or v2 of i
1818

1919
## Chains
2020

21+
### IS04 - Channel
22+
23+
The `WriteAcknowledgement` API now takes the `exported.Acknowledgement` type instead of passing in the acknowledgement byte array directly.
24+
This is an API breaking change and as such IBC application developers will have to update any calls to `WriteAcknowledgement`.
25+
26+
2127
### ICS20
2228

2329
The `transferkeeper.NewKeeper(...)` now takes in an ICS4Wrapper.
@@ -26,7 +32,101 @@ The ICS4Wrapper should be the IBC Channel Keeper unless ICS 20 is being connecte
2632
### ICS27
2733

2834
ICS27 Interchain Accounts has been added as a supported IBC application of ibc-go.
29-
Please see the [ICS27 documentation](../app-modules/interchain-accounts/overview.md) for more information.
35+
Please see the [ICS27 documentation](../apps/interchain-accounts/overview.md) for more information.
36+
37+
### Upgrade Proposal
38+
39+
If the chain will adopt ICS27, it must set the appropriate params during the execution of the upgrade handler in `app.go`:
40+
```go
41+
app.UpgradeKeeper.SetUpgradeHandler("v3",
42+
func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
43+
// set the ICS27 consensus version so InitGenesis is not run
44+
fromVM[icatypes.ModuleName] = icamodule.ConsensusVersion()
45+
46+
// create ICS27 Controller submodule params
47+
controllerParams := icacontrollertypes.Params{
48+
ControllerEnabled: true,
49+
}
50+
51+
// create ICS27 Host submodule params
52+
hostParams := icahosttypes.Params{
53+
HostEnabled: true,
54+
AllowMessages: []string{"/cosmos.bank.v1beta1.MsgSend", ...},
55+
}
56+
57+
// initialize ICS27 module
58+
icamodule.InitModule(ctx, controllerParams, hostParams)
59+
60+
...
61+
62+
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
63+
})
64+
65+
```
66+
67+
The host and controller submodule params only need to be set if the chain integrates those submodules.
68+
For example, if a chain chooses not to integrate a controller submodule, it may pass empty params into `InitModule`.
69+
70+
#### Add `StoreUpgrades` for ICS27 module
71+
72+
For ICS27 it is also necessary to [manually add store upgrades](https://docs.cosmos.network/v0.44/core/upgrade.html#add-storeupgrades-for-new-modules) for the new ICS27 module and then configure the store loader to apply those upgrades in `app.go`:
73+
74+
```go
75+
if upgradeInfo.Name == "v3" && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
76+
storeUpgrades := store.StoreUpgrades{
77+
Added: []string{icacontrollertypes.StoreKey, icahosttypes.StoreKey},
78+
}
79+
80+
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
81+
}
82+
```
83+
84+
This ensures that the new module's stores are added to the multistore before the migrations begin.
85+
The host and controller submodule keys only need to be added if the chain integrates those submodules.
86+
For example, if a chain chooses not to integrate a controller submodule, it does not need to add the controller key to the `Added` field.
87+
88+
89+
### Genesis migrations
90+
91+
If the chain will adopt ICS27 and chooses to upgrade via a genesis export, then the ICS27 parameters must be set during genesis migration.
92+
93+
The migration code required may look like:
94+
95+
```go
96+
controllerGenesisState := icatypes.DefaultControllerGenesis()
97+
// overwrite parameters as desired
98+
controllerGenesisState.Params = icacontrollertypes.Params{
99+
ControllerEnabled: true,
100+
}
101+
102+
hostGenesisState := icatypes.DefaultHostGenesis()
103+
// overwrite parameters as desired
104+
hostGenesisState.Params = icahosttypes.Params{
105+
HostEnabled: true,
106+
AllowMessages: []string{"/cosmos.bank.v1beta1.MsgSend", ...},
107+
}
108+
109+
icaGenesisState := icatypes.NewGenesisState(controllerGenesisState, hostGenesisState)
110+
111+
// set new ics27 genesis state
112+
appState[icatypes.ModuleName] = clientCtx.JSONCodec.MustMarshalJSON(icaGenesisState)
113+
```
114+
115+
### Ante decorator
116+
117+
The field of type `channelkeeper.Keeper` in the `AnteDecorator` structure has been replaced with a field of type `*keeper.Keeper`:
118+
119+
```diff
120+
type AnteDecorator struct {
121+
- k channelkeeper.Keeper
122+
+ k *keeper.Keeper
123+
}
124+
125+
- func NewAnteDecorator(k channelkeeper.Keeper) AnteDecorator {
126+
+ func NewAnteDecorator(k *keeper.Keeper) AnteDecorator {
127+
return AnteDecorator{k: k}
128+
}
129+
```
30130

31131
## IBC Apps
32132

@@ -39,6 +139,10 @@ IBC applications must perform application version negoitation in `OnChanOpenTry`
39139
The negotiated application version then must be returned in `OnChanOpenTry` to core IBC.
40140
Core IBC will set this version in the TRYOPEN channel.
41141

142+
### `OnChanOpenAck` will take additional `counterpartyChannelID` argument
143+
The `OnChanOpenAck` application callback has been modified.
144+
The arguments now include the counterparty channel id.
145+
42146
### `NegotiateAppVersion` removed from `IBCModule` interface
43147

44148
Previously this logic was handled by the `NegotiateAppVersion` function.
@@ -64,6 +168,10 @@ As apart of this release, the mock module now supports middleware testing. Pleas
64168

65169
Please review the [mock](../../testing/mock/ibc_module.go) and [transfer](../../modules/apps/transfer/ibc_module.go) modules as examples. Additionally, [simapp](../../testing/simapp/app.go) provides an example of how `IBCModule` types should now be added to the IBC router in favour of `AppModule`.
66170

171+
### IBC testing package
172+
173+
`TestChain`s are now created with chainID's beginning from an index of 1. Any calls to `GetChainID(0)` will now fail. Please increment all calls to `GetChainID` by 1.
174+
67175
## Relayers
68176

69177
`AppVersion` gRPC has been removed.

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alp
66

77
require (
88
github.com/armon/go-metrics v0.3.10
9-
github.com/confio/ics23/go v0.6.6
9+
github.com/confio/ics23/go v0.7.0
1010
github.com/cosmos/cosmos-sdk v0.45.2-0.20220210215401-58c103ca4daf
1111
github.com/gogo/protobuf v1.3.3
1212
github.com/golang/protobuf v1.5.2

go.sum

+2-1
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,9 @@ github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:z
184184
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
185185
github.com/coinbase/rosetta-sdk-go v0.7.0 h1:lmTO/JEpCvZgpbkOITL95rA80CPKb5CtMzLaqF2mCNg=
186186
github.com/coinbase/rosetta-sdk-go v0.7.0/go.mod h1:7nD3oBPIiHqhRprqvMgPoGxe/nyq3yftRmpsy29coWE=
187-
github.com/confio/ics23/go v0.6.6 h1:pkOy18YxxJ/r0XFDCnrl4Bjv6h4LkBSpLS6F38mrKL8=
188187
github.com/confio/ics23/go v0.6.6/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg=
188+
github.com/confio/ics23/go v0.7.0 h1:00d2kukk7sPoHWL4zZBZwzxnpA2pec1NPdwbSokJ5w8=
189+
github.com/confio/ics23/go v0.7.0/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg=
189190
github.com/containerd/console v1.0.2/go.mod h1:ytZPjGgY2oeTkAONYafi2kSj0aYggsf8acV1PGKCbzQ=
190191
github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6 h1:NmTXa/uVnDyp0TY5MKi197+3HWcnYWfnHGyaFthlnGw=
191192
github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ func (im IBCModule) OnChanOpenAck(
8080
ctx sdk.Context,
8181
portID,
8282
channelID string,
83+
counterpartyChannelID string,
8384
counterpartyVersion string,
8485
) error {
8586
if !im.keeper.IsControllerEnabled(ctx) {
@@ -91,7 +92,7 @@ func (im IBCModule) OnChanOpenAck(
9192
}
9293

9394
// call underlying app's OnChanOpenAck callback with the counterparty app version.
94-
return im.app.OnChanOpenAck(ctx, portID, channelID, counterpartyVersion)
95+
return im.app.OnChanOpenAck(ctx, portID, channelID, counterpartyChannelID, counterpartyVersion)
9596
}
9697

9798
// OnChanOpenAck implements the IBCModule interface

0 commit comments

Comments
 (0)