Skip to content

Commit

Permalink
feat!: integrate with ibc v10 rc.3 (#4550)
Browse files Browse the repository at this point in the history
* feat!: integrate with ibc v10 rc.2

* build

* bump to rc.3

* updates

* fix

* updates
  • Loading branch information
julienrbrt authored Mar 4, 2025
1 parent c7a4bc2 commit 3d0bf98
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 84 deletions.
2 changes: 0 additions & 2 deletions ignite/templates/app/files/app/app.go.plush
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
icacontrollerkeeper "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/controller/keeper"
icahostkeeper "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/host/keeper"
ibcfeekeeper "github.com/cosmos/ibc-go/v10/modules/apps/29-fee/keeper"
ibctransferkeeper "github.com/cosmos/ibc-go/v10/modules/apps/transfer/keeper"
ibckeeper "github.com/cosmos/ibc-go/v10/modules/core/keeper"
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
Expand Down Expand Up @@ -91,7 +90,6 @@ type App struct {

// ibc keepers
IBCKeeper *ibckeeper.Keeper
IBCFeeKeeper ibcfeekeeper.Keeper
ICAControllerKeeper icacontrollerkeeper.Keeper
ICAHostKeeper icahostkeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper
Expand Down
3 changes: 0 additions & 3 deletions ignite/templates/app/files/app/app_config.go.plush
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ import (
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
icatypes "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/types"
ibcfeetypes "github.com/cosmos/ibc-go/v10/modules/apps/29-fee/types"
ibctransfertypes "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types"
ibcexported "github.com/cosmos/ibc-go/v10/modules/core/exported"
)
Expand All @@ -80,7 +79,6 @@ var (
{Account: govtypes.ModuleName, Permissions: []string{authtypes.Burner}},
{Account: nft.ModuleName},
{Account: ibctransfertypes.ModuleName, Permissions: []string{authtypes.Minter, authtypes.Burner}},
{Account: ibcfeetypes.ModuleName},
{Account: icatypes.ModuleName},
// this line is used by starport scaffolding # stargate/app/maccPerms
}
Expand Down Expand Up @@ -165,7 +163,6 @@ var (
ibcexported.ModuleName,
ibctransfertypes.ModuleName,
icatypes.ModuleName,
ibcfeetypes.ModuleName,
// chain modules
// this line is used by starport scaffolding # stargate/app/initGenesis
},
Expand Down
42 changes: 12 additions & 30 deletions ignite/templates/app/files/app/ibc.go.plush
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ import (
icahostkeeper "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/host/keeper"
icahosttypes "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/host/types"
icatypes "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/types"
ibcfee "github.com/cosmos/ibc-go/v10/modules/apps/29-fee"
ibcfeekeeper "github.com/cosmos/ibc-go/v10/modules/apps/29-fee/keeper"
ibcfeetypes "github.com/cosmos/ibc-go/v10/modules/apps/29-fee/types"
ibctransfer "github.com/cosmos/ibc-go/v10/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v10/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types"
Expand All @@ -40,7 +37,6 @@ func (app *App) registerIBCModules(appOpts servertypes.AppOptions) error {
if err := app.RegisterStores(
storetypes.NewKVStoreKey(ibcexported.StoreKey),
storetypes.NewKVStoreKey(ibctransfertypes.StoreKey),
storetypes.NewKVStoreKey(ibcfeetypes.StoreKey),
storetypes.NewKVStoreKey(icahosttypes.StoreKey),
storetypes.NewKVStoreKey(icacontrollertypes.StoreKey),
); err != nil {
Expand All @@ -66,22 +62,14 @@ func (app *App) registerIBCModules(appOpts servertypes.AppOptions) error {
govModuleAddr,
)

app.IBCFeeKeeper = ibcfeekeeper.NewKeeper(
app.appCodec,
runtime.NewKVStoreService(app.GetKey(ibcfeetypes.StoreKey)),
app.IBCKeeper.ChannelKeeper, // may be replaced with IBC middleware
app.IBCKeeper.ChannelKeeper,
app.AuthKeeper,
app.BankKeeper,
)

// Create IBC transfer keeper
app.TransferKeeper = ibctransferkeeper.NewKeeper(
app.appCodec,
runtime.NewKVStoreService(app.GetKey(ibctransfertypes.StoreKey)),
app.GetSubspace(ibctransfertypes.ModuleName),
app.IBCFeeKeeper,
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.ChannelKeeper,
app.MsgServiceRouter(),
app.AuthKeeper,
app.BankKeeper,
govModuleAddr,
Expand All @@ -104,28 +92,24 @@ func (app *App) registerIBCModules(appOpts servertypes.AppOptions) error {
app.appCodec,
runtime.NewKVStoreService(app.GetKey(icacontrollertypes.StoreKey)),
app.GetSubspace(icacontrollertypes.SubModuleName),
app.IBCFeeKeeper, // use ics29 fee as ics4Wrapper in middleware stack
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.ChannelKeeper,
app.MsgServiceRouter(),
govModuleAddr,
)

// Create IBC modules with ibcfee middleware
transferIBCModule := ibcfee.NewIBCMiddleware(ibctransfer.NewIBCModule(app.TransferKeeper), app.IBCFeeKeeper)

// integration point for custom authentication modules
icaControllerIBCModule := ibcfee.NewIBCMiddleware(
icacontroller.NewIBCMiddleware(app.ICAControllerKeeper),
app.IBCFeeKeeper,
// create IBC module from bottom to top of stack
var (
transferStack porttypes.IBCModule = ibctransfer.NewIBCModule(app.TransferKeeper)
icaControllerStack porttypes.IBCModule = icacontroller.NewIBCMiddleware(app.ICAControllerKeeper)
icaHostStack porttypes.IBCModule = icahost.NewIBCModule(app.ICAHostKeeper)
)

icaHostIBCModule := ibcfee.NewIBCMiddleware(icahost.NewIBCModule(app.ICAHostKeeper), app.IBCFeeKeeper)

// Create static IBC router, add transfer route, then set and seal it
// create static IBC router, add transfer route, then set it on the keeper
ibcRouter := porttypes.NewRouter().
AddRoute(ibctransfertypes.ModuleName, transferIBCModule).
AddRoute(icacontrollertypes.SubModuleName, icaControllerIBCModule).
AddRoute(icahosttypes.SubModuleName, icaHostIBCModule)
AddRoute(ibctransfertypes.ModuleName, transferStack).
AddRoute(icacontrollertypes.SubModuleName, icaControllerStack).
AddRoute(icahosttypes.SubModuleName, icaHostStack)

// this line is used by starport scaffolding # ibc/app/module

Expand All @@ -139,7 +123,6 @@ func (app *App) registerIBCModules(appOpts servertypes.AppOptions) error {
if err := app.RegisterModules(
ibc.NewAppModule(app.IBCKeeper),
ibctransfer.NewAppModule(app.TransferKeeper),
ibcfee.NewAppModule(app.IBCFeeKeeper),
icamodule.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper),
ibctm.NewAppModule(tmLightClientModule),
solomachine.NewAppModule(soloLightClientModule),
Expand All @@ -157,7 +140,6 @@ func RegisterIBC(cdc codec.Codec, registry cdctypes.InterfaceRegistry) map[strin
modules := map[string]appmodule.AppModule{
ibcexported.ModuleName: ibc.NewAppModule(&ibckeeper.Keeper{}),
ibctransfertypes.ModuleName: ibctransfer.NewAppModule(ibctransferkeeper.Keeper{}),
ibcfeetypes.ModuleName: ibcfee.NewAppModule(ibcfeekeeper.Keeper{}),
icatypes.ModuleName: icamodule.NewAppModule(&icacontrollerkeeper.Keeper{}, &icahostkeeper.Keeper{}),
ibctm.ModuleName: ibctm.NewAppModule(ibctm.NewLightClientModule(cdc, ibcclienttypes.StoreProvider{})),
solomachine.ModuleName: solomachine.NewAppModule(solomachine.NewLightClientModule(cdc, ibcclienttypes.StoreProvider{})),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,38 @@
package cmd

import (
"os"
"errors"
"fmt"
"io"
"os"
"strings"

"github.com/spf13/cast"
"github.com/spf13/cobra"
"cosmossdk.io/log"
"cosmossdk.io/math"
storetypes "cosmossdk.io/store/types"
"github.com/cometbft/cometbft/crypto"
"github.com/cometbft/cometbft/libs/bytes"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/client/flags"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
"github.com/cosmos/cosmos-sdk/server"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/spf13/cast"
"github.com/spf13/cobra"

"<%= ModulePath %>/app"
)

const (
valVotingPower int64 = 900000000000000
)
const valVotingPower int64 = 900000000000000

var (
flagAccountsToFund = "accounts-to-fund"
)
var flagAccountsToFund = "accounts-to-fund"

type valArgs struct {
newValAddr bytes.HexBytes
Expand Down Expand Up @@ -86,10 +83,7 @@ func initAppForTestnet(app *app.App, args valArgs) *app.App {

pubkey := &ed25519.PubKey{Key: args.newValPubKey.Bytes()}
pubkeyAny, err := codectypes.NewAnyWithValue(pubkey)
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
handleErr(err)

// STAKING
//
Expand All @@ -116,30 +110,23 @@ func initAppForTestnet(app *app.App, args valArgs) *app.App {
}

validator, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(newVal.GetOperator())
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
handleErr(err)

// Remove all validators from power store
stakingKey := app.GetKey(stakingtypes.ModuleName)
stakingStore := ctx.KVStore(stakingKey)
iterator, err := app.StakingKeeper.ValidatorsPowerStoreIterator(ctx)
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
handleErr(err)

for ; iterator.Valid(); iterator.Next() {
stakingStore.Delete(iterator.Key())
}
iterator.Close()

// Remove all valdiators from last validators store
// Remove all validators from last validators store
iterator, err = app.StakingKeeper.LastValidatorsIterator(ctx)
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
handleErr(err)

for ; iterator.Valid(); iterator.Next() {
stakingStore.Delete(iterator.Key())
}
Expand Down Expand Up @@ -186,16 +173,13 @@ func initAppForTestnet(app *app.App, args valArgs) *app.App {
StartHeight: app.App.LastBlockHeight() - 1,
Tombstoned: false,
}
_ = app.SlashingKeeper.SetValidatorSigningInfo(ctx, newConsAddr, newValidatorSigningInfo)
_ = app.SlashingKeeper.SetValidatorSigningInfo(ctx, newConsAddr, newValidatorSigningInfo)
<% } %>

// BANK
//
bondDenom, err := app.StakingKeeper.BondDenom(ctx)
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
handleErr(err)

defaultCoins := sdk.NewCoins(sdk.NewInt64Coin(bondDenom, 1000000000))

Expand All @@ -204,10 +188,7 @@ func initAppForTestnet(app *app.App, args valArgs) *app.App {
handleErr(app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, defaultCoins))

account, err := app.AuthKeeper.AddressCodec().StringToBytes(accountStr)
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
handleErr(err)

handleErr(app.BankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, account, defaultCoins))
}
Expand All @@ -221,22 +202,22 @@ func getCommandArgs(appOpts servertypes.AppOptions) (valArgs, error) {

newValAddr, ok := appOpts.Get(server.KeyNewValAddr).(bytes.HexBytes)
if !ok {
panic("newValAddr is not of type bytes.HexBytes")
return args, errors.New("newValAddr is not of type bytes.HexBytes")
}
args.newValAddr = newValAddr
newValPubKey, ok := appOpts.Get(server.KeyUserPubKey).(crypto.PubKey)
if !ok {
panic("newValPubKey is not of type crypto.PubKey")
return args, errors.New("newValPubKey is not of type crypto.PubKey")
}
args.newValPubKey = newValPubKey
newOperatorAddress, ok := appOpts.Get(server.KeyNewOpAddr).(string)
if !ok {
panic("newOperatorAddress is not of type string")
return args, errors.New("newOperatorAddress is not of type string")
}
args.newOperatorAddress = newOperatorAddress
upgradeToTrigger, ok := appOpts.Get(server.KeyTriggerTestnetUpgrade).(string)
if !ok {
panic("upgradeToTrigger is not of type string")
return args, errors.New("upgradeToTrigger is not of type string")
}
args.upgradeToTrigger = upgradeToTrigger

Expand All @@ -247,7 +228,7 @@ func getCommandArgs(appOpts servertypes.AppOptions) (valArgs, error) {
// home dir
homeDir := cast.ToString(appOpts.Get(flags.FlagHome))
if homeDir == "" {
return args, fmt.Errorf("invalid home dir")
return args, errors.New("invalid home dir")
}
args.homeDir = homeDir

Expand All @@ -260,4 +241,4 @@ func handleErr(err error) {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
}
}
6 changes: 1 addition & 5 deletions ignite/templates/app/files/go.mod.plush
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ module <%= ModulePath %>

go 1.23.6

replace (
github.com/cosmos/ibc-go/v10 => github.com/cosmos/ibc-go/v10 v10.0.0-beta.0
)

replace (
// fix upstream GHSA-h395-qcrw-5vmq vulnerability.
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.1
Expand Down Expand Up @@ -36,7 +32,7 @@ require (
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.50.12
github.com/cosmos/gogoproto v1.7.0
github.com/cosmos/ibc-go/v10 v10.0.0-beta.0
github.com/cosmos/ibc-go/v10 v10.0.0-rc.3
github.com/golang/protobuf v1.5.4
github.com/gorilla/mux v1.8.1
github.com/grpc-ecosystem/grpc-gateway v1.16.0
Expand Down
4 changes: 2 additions & 2 deletions ignite/templates/module/create/ibc.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ func appIBCModify(replacer placeholder.Replacer, opts *CreateOptions) genny.RunF
}

// create IBC module
templateIBCModule := `%[2]vIBCModule := ibcfee.NewIBCMiddleware(%[2]vmodule.NewIBCModule(app.appCodec, app.%[3]vKeeper), app.IBCFeeKeeper)
ibcRouter.AddRoute(%[2]vmoduletypes.ModuleName, %[2]vIBCModule)
templateIBCModule := `%[2]vIBCModule := %[2]vmodule.NewIBCModule(app.appCodec, app.%[3]vKeeper)
ibcRouter.AddRoute(%[2]vmoduletypes.ModuleName, %[2]vIBCModule)
%[1]v`
replacementIBCModule := fmt.Sprintf(
templateIBCModule,
Expand Down

0 comments on commit 3d0bf98

Please sign in to comment.