Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Commit

Permalink
deps: upgradingto ibc-go v6-alpha1 (#139)
Browse files Browse the repository at this point in the history
* upgrading icad to ibc-go v6-alpha1

* adding ibc-go/v6 upgrade handler to app

* updating godocs
  • Loading branch information
damiannolan authored Oct 10, 2022
1 parent 1ec0e0a commit 3dbc8dc
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 110 deletions.
89 changes: 43 additions & 46 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,29 +76,29 @@ import (
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
ica "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts"
icacontroller "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/controller"
icacontrollerkeeper "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/controller/keeper"
icacontrollertypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/controller/types"
icahost "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/host"
icahostkeeper "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/host/keeper"
icahosttypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/host/types"
icatypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/types"
ibcfee "github.com/cosmos/ibc-go/v5/modules/apps/29-fee"
ibcfeekeeper "github.com/cosmos/ibc-go/v5/modules/apps/29-fee/keeper"
ibcfeetypes "github.com/cosmos/ibc-go/v5/modules/apps/29-fee/types"
"github.com/cosmos/ibc-go/v5/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v5/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v5/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v5/modules/core"
ibcclient "github.com/cosmos/ibc-go/v5/modules/core/02-client"
ibcclientclient "github.com/cosmos/ibc-go/v5/modules/core/02-client/client"
ibcclienttypes "github.com/cosmos/ibc-go/v5/modules/core/02-client/types"
porttypes "github.com/cosmos/ibc-go/v5/modules/core/05-port/types"
ibchost "github.com/cosmos/ibc-go/v5/modules/core/24-host"
ibckeeper "github.com/cosmos/ibc-go/v5/modules/core/keeper"
ibctestingtypes "github.com/cosmos/ibc-go/v5/testing/types"
ica "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts"
icacontroller "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/controller"
icacontrollerkeeper "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/controller/keeper"
icacontrollertypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/controller/types"
icagenesistypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/genesis/types"
icahost "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/host"
icahostkeeper "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/host/keeper"
icahosttypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/host/types"
icatypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/types"
ibcfee "github.com/cosmos/ibc-go/v6/modules/apps/29-fee"
ibcfeekeeper "github.com/cosmos/ibc-go/v6/modules/apps/29-fee/keeper"
ibcfeetypes "github.com/cosmos/ibc-go/v6/modules/apps/29-fee/types"
"github.com/cosmos/ibc-go/v6/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v6/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v6/modules/core"
ibcclient "github.com/cosmos/ibc-go/v6/modules/core/02-client"
ibcclienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types"
porttypes "github.com/cosmos/ibc-go/v6/modules/core/05-port/types"
ibchost "github.com/cosmos/ibc-go/v6/modules/core/24-host"
ibckeeper "github.com/cosmos/ibc-go/v6/modules/core/keeper"
appparams "github.com/cosmos/interchain-accounts/app/params"
v6 "github.com/cosmos/interchain-accounts/app/upgrades/v6"
tmjson "github.com/tendermint/tendermint/libs/json"

// this line is used by starport scaffolding # stargate/app/moduleImport
Expand All @@ -109,24 +109,6 @@ import (

const Name = "ica"

// this line is used by starport scaffolding # stargate/wasm/app/enabledProposals

func getGovProposalHandlers() []govclient.ProposalHandler {
var govProposalHandlers []govclient.ProposalHandler
// this line is used by starport scaffolding # stargate/app/govProposalHandlers

govProposalHandlers = append(govProposalHandlers,
paramsclient.ProposalHandler,
distrclient.ProposalHandler,
upgradeclient.LegacyProposalHandler,
upgradeclient.LegacyCancelProposalHandler,
ibcclientclient.UpdateClientProposalHandler, ibcclientclient.UpgradeProposalHandler,
// this line is used by starport scaffolding # stargate/app/govProposalHandler
)

return govProposalHandlers
}

var (
// DefaultNodeHome default home directories for the application daemon
DefaultNodeHome string
Expand Down Expand Up @@ -527,6 +509,8 @@ func New(

app.SetEndBlocker(app.EndBlocker)

app.setupUpgradeHandlers()

if loadLatest {
if err := app.LoadLatestVersion(); err != nil {
tmos.Exit(err.Error())
Expand Down Expand Up @@ -564,7 +548,7 @@ func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.Res

icaRawGenesisState := genesisState[icatypes.ModuleName]

var icaGenesisState icatypes.GenesisState
var icaGenesisState icagenesistypes.GenesisState
if err := app.cdc.UnmarshalJSON(icaRawGenesisState, &icaGenesisState); err != nil {
panic(err)
}
Expand Down Expand Up @@ -716,10 +700,23 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
return paramsKeeper
}

func (*App) OnTxSucceeded(ctx sdk.Context, sourcePort, sourceChannel string, txHash []byte, txBytes []byte) {
}

func (*App) OnTxFailed(ctx sdk.Context, sourcePort, sourceChannel string, txHash []byte, txBytes []byte) {
// setupUpgradeHandlers sets all necessary upgrade handlers for testing purposes
func (app *App) setupUpgradeHandlers() {
// NOTE: The moduleName arg of v6.CreateUpgradeHandler refers to the auth module ScopedKeeper name to which the channel capability should be migrated from.
// This should be the same string value provided upon instantiation of the ScopedKeeper with app.CapabilityKeeper.ScopeToModule()
// TODO: update git tag in link below
// See: https://github.com/cosmos/ibc-go/blob/v5.0.0-rc2/testing/simapp/app.go#L304
app.UpgradeKeeper.SetUpgradeHandler(
v6.UpgradeName,
v6.CreateUpgradeHandler(
app.mm,
app.configurator,
app.appCodec,
app.keys[capabilitytypes.ModuleName],
app.CapabilityKeeper,
intertxtypes.ModuleName,
),
)
}

// TestingApp functions
Expand All @@ -730,7 +727,7 @@ func (app *App) GetBaseApp() *baseapp.BaseApp {
}

// GetStakingKeeper implements the TestingApp interface.
func (app *App) GetStakingKeeper() ibctestingtypes.StakingKeeper {
func (app *App) GetStakingKeeper() stakingkeeper.Keeper {
return app.StakingKeeper
}

Expand Down
35 changes: 35 additions & 0 deletions app/upgrades/v6/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package v6

import (
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

v6 "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/controller/migrations/v6"
)

const (
// UpgradeName defines the on-chain upgrade name for the ibc-go/v6 upgrade.
UpgradeName = "ibc-go/v6"
)

// CreateUpgradeHandler creates an upgrade handler for the ibc-go/v6 upgrade.
func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
cdc codec.BinaryCodec,
capabilityStoreKey *storetypes.KVStoreKey,
capabilityKeeper *capabilitykeeper.Keeper,
moduleName string,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
if err := v6.MigrateICS27ChannelCapability(ctx, cdc, capabilityStoreKey, capabilityKeeper, moduleName); err != nil {
return nil, err
}

return mm.RunMigrations(ctx, configurator, vm)
}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
)

require (
github.com/cosmos/ibc-go/v5 v5.0.0
github.com/cosmos/ibc-go/v6 v6.0.0-alpha1
github.com/golang/protobuf v1.5.2
google.golang.org/genproto v0.0.0-20220725144611-272f38e5d71b
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4
github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw=
github.com/cosmos/iavl v0.19.1 h1:3gaq9b6SjiB0KBTygRnAvEGml2pQlu1TH8uma5g63Ys=
github.com/cosmos/iavl v0.19.1/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw=
github.com/cosmos/ibc-go/v5 v5.0.0 h1:MkObdarpoICPHXoRg/Ne9NRix4j7eQlJZq74/uzH3Zc=
github.com/cosmos/ibc-go/v5 v5.0.0/go.mod h1:Wqsguq98Iuns8tgTv8+xaGYbC+Q8zJfbpjzT6IgMJbs=
github.com/cosmos/ibc-go/v6 v6.0.0-alpha1 h1:FpmkSFqRGwFZPL4HNLJ0V2L4/ILyG+tcVy59+EBn7q4=
github.com/cosmos/ibc-go/v6 v6.0.0-alpha1/go.mod h1:F2p2yeQlr4+L/YslhlY+Rk1uHXAJ2yKPPo6/uDUsYpc=
github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4=
github.com/cosmos/ledger-cosmos-go v0.11.1/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY=
github.com/cosmos/ledger-go v0.9.2 h1:Nnao/dLwaVTk1Q5U9THldpUMMXU94BOTWPddSmVB6pI=
Expand Down
28 changes: 4 additions & 24 deletions x/inter-tx/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ import (
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/cosmos/interchain-accounts/x/inter-tx/keeper"

channeltypes "github.com/cosmos/ibc-go/v5/modules/core/04-channel/types"
porttypes "github.com/cosmos/ibc-go/v5/modules/core/05-port/types"
host "github.com/cosmos/ibc-go/v5/modules/core/24-host"
ibcexported "github.com/cosmos/ibc-go/v5/modules/core/exported"
channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types"
porttypes "github.com/cosmos/ibc-go/v6/modules/core/05-port/types"
ibcexported "github.com/cosmos/ibc-go/v6/modules/core/exported"
)

var _ porttypes.IBCModule = IBCModule{}
Expand Down Expand Up @@ -41,11 +40,6 @@ func (im IBCModule) OnChanOpenInit(
counterparty channeltypes.Counterparty,
version string,
) (string, error) {
// Claim channel capability passed back by IBC module
if err := im.keeper.ClaimCapability(ctx, chanCap, host.ChannelCapabilityPath(portID, channelID)); err != nil {
return "", err
}

return version, nil
}

Expand Down Expand Up @@ -101,9 +95,7 @@ func (im IBCModule) OnChanCloseConfirm(
return nil
}

// OnRecvPacket implements the IBCModule interface. A successful acknowledgement
// is returned if the packet data is succesfully decoded and the receive application
// logic returns without error.
// OnRecvPacket implements the IBCModule interface
func (im IBCModule) OnRecvPacket(
ctx sdk.Context,
packet channeltypes.Packet,
Expand Down Expand Up @@ -157,18 +149,6 @@ func (im IBCModule) OnTimeoutPacket(
return nil
}

// NegotiateAppVersion implements the IBCModule interface
func (im IBCModule) NegotiateAppVersion(
ctx sdk.Context,
order channeltypes.Order,
connectionID string,
portID string,
counterparty channeltypes.Counterparty,
proposedVersion string,
) (string, error) {
return "", nil
}

func handleMsgData(ctx sdk.Context, msgData *sdk.MsgData) (string, error) {
switch msgData.MsgType {
case sdk.MsgTypeURL(&banktypes.MsgSend{}):
Expand Down
2 changes: 1 addition & 1 deletion x/inter-tx/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"google.golang.org/grpc/status"

sdk "github.com/cosmos/cosmos-sdk/types"
icatypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/types"
icatypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/types"

"github.com/cosmos/interchain-accounts/x/inter-tx/types"
)
Expand Down
2 changes: 1 addition & 1 deletion x/inter-tx/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
"github.com/tendermint/tendermint/libs/log"

icacontrollerkeeper "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/controller/keeper"
icacontrollerkeeper "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/controller/keeper"
"github.com/cosmos/interchain-accounts/x/inter-tx/types"
)

Expand Down
6 changes: 3 additions & 3 deletions x/inter-tx/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"github.com/tendermint/tendermint/libs/log"
dbm "github.com/tendermint/tm-db"

icatypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/types"
channeltypes "github.com/cosmos/ibc-go/v5/modules/core/04-channel/types"
ibctesting "github.com/cosmos/ibc-go/v5/testing"
icatypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/types"
channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types"
ibctesting "github.com/cosmos/ibc-go/v6/testing"

icaapp "github.com/cosmos/interchain-accounts/app"
)
Expand Down
17 changes: 2 additions & 15 deletions x/inter-tx/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import (
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
icatypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/types"
channeltypes "github.com/cosmos/ibc-go/v5/modules/core/04-channel/types"
host "github.com/cosmos/ibc-go/v5/modules/core/24-host"
icatypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/types"
"github.com/cosmos/interchain-accounts/x/inter-tx/types"
)

Expand Down Expand Up @@ -43,16 +40,6 @@ func (k msgServer) SubmitTx(goCtx context.Context, msg *types.MsgSubmitTx) (*typ
return nil, err
}

channelID, found := k.icaControllerKeeper.GetActiveChannelID(ctx, msg.ConnectionId, portID)
if !found {
return nil, sdkerrors.Wrapf(icatypes.ErrActiveChannelNotFound, "failed to retrieve active channel for port %s", portID)
}

chanCap, found := k.scopedKeeper.GetCapability(ctx, host.ChannelCapabilityPath(portID, channelID))
if !found {
return nil, sdkerrors.Wrap(channeltypes.ErrChannelCapabilityNotFound, "module does not own channel capability")
}

data, err := icatypes.SerializeCosmosTx(k.cdc, []sdk.Msg{msg.GetTxMsg()})
if err != nil {
return nil, err
Expand All @@ -66,7 +53,7 @@ func (k msgServer) SubmitTx(goCtx context.Context, msg *types.MsgSubmitTx) (*typ
// timeoutTimestamp set to max value with the unsigned bit shifted to sastisfy hermes timestamp conversion
// it is the responsibility of the auth module developer to ensure an appropriate timeout timestamp
timeoutTimestamp := ctx.BlockTime().Add(time.Minute).UnixNano()
_, err = k.icaControllerKeeper.SendTx(ctx, chanCap, msg.ConnectionId, portID, packetData, uint64(timeoutTimestamp))
_, err = k.icaControllerKeeper.SendTx(ctx, nil, msg.ConnectionId, portID, packetData, uint64(timeoutTimestamp))
if err != nil {
return nil, err
}
Expand Down
18 changes: 3 additions & 15 deletions x/inter-tx/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package keeper_test
import (
sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
icatypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/types"
channeltypes "github.com/cosmos/ibc-go/v5/modules/core/04-channel/types"
ibctesting "github.com/cosmos/ibc-go/v5/testing"
icatypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/types"
channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types"
ibctesting "github.com/cosmos/ibc-go/v6/testing"

"github.com/cosmos/interchain-accounts/x/inter-tx/keeper"
"github.com/cosmos/interchain-accounts/x/inter-tx/types"
Expand Down Expand Up @@ -131,18 +131,6 @@ func (suite *KeeperTestSuite) TestSubmitTx() {
connectionId = path.EndpointA.ConnectionID
}, false,
},
{
"failure - module does not own channel capability", func() {
registerInterchainAccount = false
owner = TestOwnerAddress
connectionId = path.EndpointA.ConnectionID
icaMsg = &banktypes.MsgSend{
FromAddress: "source-address",
ToAddress: "destination-address",
Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))),
}
}, false,
},
}

for _, tc := range testCases {
Expand Down
4 changes: 2 additions & 2 deletions x/inter-tx/types/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
icatypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/types"
ibctesting "github.com/cosmos/ibc-go/v5/testing"
icatypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/types"
ibctesting "github.com/cosmos/ibc-go/v6/testing"

"github.com/cosmos/interchain-accounts/x/inter-tx/types"
)
Expand Down

0 comments on commit 3dbc8dc

Please sign in to comment.