Skip to content

Commit

Permalink
chore: port changes from main (#3583)
Browse files Browse the repository at this point in the history
* fix!: upgrade to include tendermint client to allowed clients (#3578)

* fix upgrade to include tendermint client to allowed clients

* check if tendermint client already exists

* set entire allowlist to desired state

* lint fix

* Add v2 transfer stack w/ middleware (#3582)

---------

Co-authored-by: Vlad J <[email protected]>
  • Loading branch information
Eric-Warehime and vladjdk authored Mar 1, 2025
1 parent 8bd6db4 commit b586a1c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
16 changes: 16 additions & 0 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import (
ratelimit "github.com/cosmos/ibc-apps/modules/rate-limiting/v10"
ratelimitkeeper "github.com/cosmos/ibc-apps/modules/rate-limiting/v10/keeper"
ratelimittypes "github.com/cosmos/ibc-apps/modules/rate-limiting/v10/types"
ratelimitv2 "github.com/cosmos/ibc-apps/modules/rate-limiting/v10/v2"
ibccallbacks "github.com/cosmos/ibc-go/modules/apps/callbacks"
ibccallbacksv2 "github.com/cosmos/ibc-go/modules/apps/callbacks/v2"
ibcwasmkeeper "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/keeper"
ibcwasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
ica "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts"
Expand All @@ -29,9 +31,11 @@ import (
"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"
transferv2 "github.com/cosmos/ibc-go/v10/modules/apps/transfer/v2"
ibcclienttypes "github.com/cosmos/ibc-go/v10/modules/core/02-client/types"
ibcconnectiontypes "github.com/cosmos/ibc-go/v10/modules/core/03-connection/types"
porttypes "github.com/cosmos/ibc-go/v10/modules/core/05-port/types"
ibcapi "github.com/cosmos/ibc-go/v10/modules/core/api"
ibcexported "github.com/cosmos/ibc-go/v10/modules/core/exported"
ibckeeper "github.com/cosmos/ibc-go/v10/modules/core/keeper"
icsprovider "github.com/cosmos/interchain-security/v7/x/ccv/provider"
Expand Down Expand Up @@ -539,6 +543,13 @@ func NewAppKeeper(
appKeepers.ICAControllerKeeper.WithICS4Wrapper(icaICS4Wrapper)
wasmStack := wasm.NewIBCHandler(appKeepers.WasmKeeper, appKeepers.IBCKeeper.ChannelKeeper, appKeepers.IBCKeeper.ChannelKeeper)

// Create IBCv2 Transfer Stack
var transferStackV2 ibcapi.IBCModule
transferStackV2 = transferv2.NewIBCModule(appKeepers.TransferKeeper)
transferStackV2 = ibccallbacksv2.NewIBCMiddleware(transferStackV2, appKeepers.IBCKeeper.ChannelKeeperV2,
wasmStackIBCHandler, appKeepers.IBCKeeper.ChannelKeeperV2, gaiaparams.MaxIBCCallbackGas)
transferStackV2 = ratelimitv2.NewIBCMiddleware(appKeepers.RatelimitKeeper, transferStackV2)

// Create IBC Router & seal
ibcRouter := porttypes.NewRouter().
AddRoute(icahosttypes.SubModuleName, icaHostStack).
Expand All @@ -549,6 +560,11 @@ func NewAppKeeper(

appKeepers.IBCKeeper.SetRouter(ibcRouter)

// Create IBCv2 Router & seal
ibcv2Router := ibcapi.NewRouter().
AddRoute(ibctransfertypes.PortID, transferStackV2)
appKeepers.IBCKeeper.SetRouterV2(ibcv2Router)

return appKeepers
}

Expand Down
15 changes: 5 additions & 10 deletions app/upgrades/v23/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"

ibcwasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
clientkeeper "github.com/cosmos/ibc-go/v10/modules/core/02-client/keeper"
ibctmtypes "github.com/cosmos/ibc-go/v10/modules/light-clients/07-tendermint"

errorsmod "cosmossdk.io/errors"
upgradetypes "cosmossdk.io/x/upgrade/types"
Expand All @@ -30,17 +30,12 @@ func CreateUpgradeHandler(
return vm, errorsmod.Wrapf(err, "running module migrations")
}

// Add the Wasm client type to the allowed clients
Add08WasmToAllowedClients(ctx, *keepers.IBCKeeper.ClientKeeper)
// Set IBC Client AllowedClients
params := keepers.IBCKeeper.ClientKeeper.GetParams(ctx)
params.AllowedClients = []string{ibctmtypes.ModuleName, ibcwasmtypes.ModuleName}
keepers.IBCKeeper.ClientKeeper.SetParams(ctx, params)

ctx.Logger().Info("Upgrade v23 complete")
return vm, nil
}
}

func Add08WasmToAllowedClients(ctx sdk.Context, clientKeeper clientkeeper.Keeper) {
// explicitly update the IBC 02-client params, adding the wasm client type
params := clientKeeper.GetParams(ctx)
params.AllowedClients = append(params.AllowedClients, ibcwasmtypes.Wasm)
clientKeeper.SetParams(ctx, params)
}

0 comments on commit b586a1c

Please sign in to comment.