Skip to content

Commit

Permalink
Sdk v0.46.* and ibc-go v5.1.0 (#349)
Browse files Browse the repository at this point in the history
Co-authored-by: Son Trinh <sontrinh@Sons-MacBook-Pro.local>
Co-authored-by: Jacob Gadikian <jacobgadikian@gmail.com>
Co-authored-by: Aidan Salzmann <aidan@stridelabs.co>
Co-authored-by: DongLieu <duongduydongtq@gmail.com>
Co-authored-by: Nguyen Thanh Nhan <thanhnhan98qh@gmail.com>
Co-authored-by: sampocs <sam.pochyly@gmail.com>
Co-authored-by: sampocs <sam@stridelabs.co>
  • Loading branch information
8 people authored Jan 11, 2023
1 parent 6889888 commit e55f6f2
Show file tree
Hide file tree
Showing 123 changed files with 1,949 additions and 1,222 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
path = deps/hermes
url = https://github.com/informalsystems/ibc-rs.git
[submodule "deps/relayer"]
# Commit: 6e53d10622a943e13b339d82854aa205f276208d
# Branch: aidan/client_icq_patch
# Commit: 7f78a4d608329b2ae07a6512381bbadffee66be6
# Branch: andrew/client_icq
path = deps/relayer
url = https://github.com/Stride-Labs/relayer
url = https://github.com/cosmos/relayer.git
[submodule "deps/gaia"]
# Commit: 5b47714dd5607993a1a91f2b06a6d92cbb504721
path = deps/gaia
Expand Down
107 changes: 57 additions & 50 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ import (
"os"
"path/filepath"

porttypes "github.com/cosmos/ibc-go/v3/modules/core/05-port/types"
porttypes "github.com/cosmos/ibc-go/v5/modules/core/05-port/types"

"github.com/Stride-Labs/stride/v4/utils"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
"github.com/cosmos/cosmos-sdk/client/rpc"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/server/api"
Expand All @@ -22,7 +21,6 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
Expand Down Expand Up @@ -56,6 +54,8 @@ import (
govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
govtypesv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"

claimvesting "github.com/Stride-Labs/stride/v4/x/claim/vesting"
claimvestingtypes "github.com/Stride-Labs/stride/v4/x/claim/vesting/types"
Expand All @@ -79,32 +79,32 @@ 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"
"github.com/cosmos/ibc-go/v3/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v3/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v3/modules/core"
ibcclient "github.com/cosmos/ibc-go/v3/modules/core/02-client"
ibcclientclient "github.com/cosmos/ibc-go/v3/modules/core/02-client/client"
ibcclienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types"
ibcporttypes "github.com/cosmos/ibc-go/v3/modules/core/05-port/types"
ibchost "github.com/cosmos/ibc-go/v3/modules/core/24-host"
ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper"
ibctesting "github.com/cosmos/ibc-go/v3/testing"
"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"
ibcporttypes "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"
ibctesting "github.com/cosmos/ibc-go/v5/testing"
"github.com/spf13/cast"
abci "github.com/tendermint/tendermint/abci/types"
tmjson "github.com/tendermint/tendermint/libs/json"
"github.com/tendermint/tendermint/libs/log"
tmos "github.com/tendermint/tendermint/libs/os"
dbm "github.com/tendermint/tm-db"

ica "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts"
icacontroller "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller"
icacontrollerkeeper "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller/keeper"
icacontrollertypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller/types"
icahost "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host"
icahostkeeper "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/keeper"
icahosttypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/types"
icatypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/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"

// monitoringp "github.com/tendermint/spn/x/monitoringp"
// monitoringpkeeper "github.com/tendermint/spn/x/monitoringp/keeper"
Expand All @@ -130,7 +130,12 @@ import (
stakeibcclient "github.com/Stride-Labs/stride/v4/x/stakeibc/client"
stakeibcmodulekeeper "github.com/Stride-Labs/stride/v4/x/stakeibc/keeper"
stakeibcmoduletypes "github.com/Stride-Labs/stride/v4/x/stakeibc/types"

// this line is used by starport scaffolding # stargate/app/moduleImport
storetypes "github.com/cosmos/cosmos-sdk/store/types"
ibcfeekeeper "github.com/cosmos/ibc-go/v5/modules/apps/29-fee/keeper"
ibcfeetypes "github.com/cosmos/ibc-go/v5/modules/apps/29-fee/types"
ibctestingtypes "github.com/cosmos/ibc-go/v5/testing/types"
)

const (
Expand All @@ -148,8 +153,8 @@ func getGovProposalHandlers() []govclient.ProposalHandler {
govProposalHandlers = append(govProposalHandlers,
paramsclient.ProposalHandler,
distrclient.ProposalHandler,
upgradeclient.ProposalHandler,
upgradeclient.CancelProposalHandler,
upgradeclient.LegacyProposalHandler,
upgradeclient.LegacyCancelProposalHandler,
ibcclientclient.UpdateClientProposalHandler,
ibcclientclient.UpgradeProposalHandler,
stakeibcclient.AddValidatorProposalHandler,
Expand All @@ -175,7 +180,7 @@ var (
staking.AppModuleBasic{},
mint.AppModuleBasic{},
distr.AppModuleBasic{},
gov.NewAppModuleBasic(getGovProposalHandlers()...),
gov.NewAppModuleBasic(getGovProposalHandlers()),
params.AppModuleBasic{},
crisis.AppModuleBasic{},
slashing.AppModuleBasic{},
Expand Down Expand Up @@ -242,9 +247,9 @@ type StrideApp struct {
invCheckPeriod uint

// keys to access the substores
keys map[string]*sdk.KVStoreKey
tkeys map[string]*sdk.TransientStoreKey
memKeys map[string]*sdk.MemoryStoreKey
keys map[string]*storetypes.KVStoreKey
tkeys map[string]*storetypes.TransientStoreKey
memKeys map[string]*storetypes.MemoryStoreKey

// keepers
AccountKeeper authkeeper.AccountKeeper
Expand Down Expand Up @@ -346,7 +351,7 @@ func NewStrideApp(
app.ParamsKeeper = initParamsKeeper(appCodec, cdc, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey])

// set the BaseApp's parameter store
bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramskeeper.ConsensusParamsKeyTable()))
bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()))

// add capability keeper and ScopeToModule for ibc module
app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey])
Expand All @@ -360,13 +365,14 @@ func NewStrideApp(

// add keepers
app.AccountKeeper = authkeeper.NewAccountKeeper(
appCodec, keys[authtypes.StoreKey], app.GetSubspace(authtypes.ModuleName), authtypes.ProtoBaseAccount, maccPerms,
appCodec, keys[authtypes.StoreKey], app.GetSubspace(authtypes.ModuleName), authtypes.ProtoBaseAccount, maccPerms, AccountAddressPrefix,
)

app.AuthzKeeper = authzkeeper.NewKeeper(
keys[authzkeeper.StoreKey],
appCodec,
app.BaseApp.MsgServiceRouter(),
app.AccountKeeper,
)

app.BankKeeper = bankkeeper.NewBaseKeeper(
Expand All @@ -381,7 +387,7 @@ func NewStrideApp(
)
app.DistrKeeper = distrkeeper.NewKeeper(
appCodec, keys[distrtypes.StoreKey], app.GetSubspace(distrtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
&stakingKeeper, authtypes.FeeCollectorName, app.ModuleAccountAddrs(),
&stakingKeeper, authtypes.FeeCollectorName,
)
app.SlashingKeeper = slashingkeeper.NewKeeper(
appCodec, keys[slashingtypes.StoreKey], &stakingKeeper, app.GetSubspace(slashingtypes.ModuleName),
Expand All @@ -397,7 +403,7 @@ func NewStrideApp(
app.BankKeeper, app.StakingKeeper, app.DistrKeeper, epochsKeeper)

app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.AccountKeeper)
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp)
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp, authtypes.NewModuleAddress(govtypes.ModuleName).String())

// register the staking hooks
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
Expand Down Expand Up @@ -510,8 +516,8 @@ func NewStrideApp(
stakeibcIBCModule := stakeibcmodule.NewIBCModule(app.StakeibcKeeper)

// Register Gov (must be registerd after stakeibc)
govRouter := govtypes.NewRouter()
govRouter.AddRoute(govtypes.RouterKey, govtypes.ProposalHandler).
govRouter := govtypesv1beta1.NewRouter()
govRouter.AddRoute(govtypes.RouterKey, govtypesv1beta1.ProposalHandler).
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)).
Expand All @@ -520,7 +526,7 @@ func NewStrideApp(

app.GovKeeper = govkeeper.NewKeeper(
appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
&stakingKeeper, govRouter,
&stakingKeeper, govRouter, app.MsgServiceRouter(), govtypes.DefaultConfig(),
)

// Register ICQ callbacks
Expand Down Expand Up @@ -552,13 +558,19 @@ func NewStrideApp(
}

// this line is used by starport scaffolding # stargate/app/keeperDefinition
ibcFeeKeeper := ibcfeekeeper.NewKeeper(
appCodec, app.keys[ibcfeetypes.StoreKey], app.GetSubspace(ibcfeetypes.ModuleName),
app.IBCKeeper.ChannelKeeper, // may be replaced with IBC middleware
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper, app.AccountKeeper, app.BankKeeper,
)

// create IBC middleware stacks by combining middleware with base application
app.ICAHostKeeper = icahostkeeper.NewKeeper(
appCodec, keys[icahosttypes.StoreKey], app.GetSubspace(icahosttypes.SubModuleName),
ibcFeeKeeper,
app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper,
app.AccountKeeper, scopedICAHostKeeper, app.MsgServiceRouter(),
)
app.AccountKeeper, scopedICAHostKeeper, app.MsgServiceRouter())
icaModule := ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper)

// Create the middleware stacks
Expand All @@ -571,7 +583,7 @@ func NewStrideApp(
// - base app
var icamiddlewareStack porttypes.IBCModule
icamiddlewareStack = icacallbacksmodule.NewIBCModule(app.IcacallbacksKeeper, stakeibcIBCModule)
icamiddlewareStack = icacontroller.NewIBCModule(app.ICAControllerKeeper, icamiddlewareStack)
icamiddlewareStack = icacontroller.NewIBCMiddleware(icamiddlewareStack, app.ICAControllerKeeper)
icaHostIBCModule := icahost.NewIBCModule(app.ICAHostKeeper)

// Stack two contains
Expand Down Expand Up @@ -818,7 +830,7 @@ func (app *StrideApp) Name() string { return app.BaseApp.Name() }
func (app *StrideApp) GetBaseApp() *baseapp.BaseApp { return app.BaseApp }

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

Expand Down Expand Up @@ -918,21 +930,21 @@ func (app *StrideApp) InterfaceRegistry() types.InterfaceRegistry {
// GetKey returns the KVStoreKey for the provided store key.
//
// NOTE: This is solely to be used for testing purposes.
func (app *StrideApp) GetKey(storeKey string) *sdk.KVStoreKey {
func (app *StrideApp) GetKey(storeKey string) *storetypes.KVStoreKey {
return app.keys[storeKey]
}

// GetTKey returns the TransientStoreKey for the provided store key.
//
// NOTE: This is solely to be used for testing purposes.
func (app *StrideApp) GetTKey(storeKey string) *sdk.TransientStoreKey {
func (app *StrideApp) GetTKey(storeKey string) *storetypes.TransientStoreKey {
return app.tkeys[storeKey]
}

// GetMemKey returns the MemStoreKey for the provided mem key.
//
// NOTE: This is solely used for testing purposes.
func (app *StrideApp) GetMemKey(storeKey string) *sdk.MemoryStoreKey {
func (app *StrideApp) GetMemKey(storeKey string) *storetypes.MemoryStoreKey {
return app.memKeys[storeKey]
}

Expand All @@ -948,16 +960,11 @@ func (app *StrideApp) GetSubspace(moduleName string) paramstypes.Subspace {
// API server.
func (app *StrideApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) {
clientCtx := apiSvr.ClientCtx
rpc.RegisterRoutes(clientCtx, apiSvr.Router)
// Register legacy tx routes.
authrest.RegisterTxRoutes(clientCtx, apiSvr.Router)
// Register new tx routes from grpc-gateway.
authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
// Register new tendermint queries routes from grpc-gateway.
tmservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)

// Register legacy and grpc-gateway routes for all modules.
ModuleBasics.RegisterRESTRoutes(clientCtx, apiSvr.Router)
ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
}

Expand All @@ -968,7 +975,7 @@ func (app *StrideApp) RegisterTxService(clientCtx client.Context) {

// RegisterTendermintService implements the Application.RegisterTendermintService method.
func (app *StrideApp) RegisterTendermintService(clientCtx client.Context) {
tmservice.RegisterTendermintService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.interfaceRegistry)
tmservice.RegisterTendermintService(clientCtx, app.BaseApp.GRPCQueryRouter(), app.interfaceRegistry, app.Query)
}

// GetMaccPerms returns a copy of the module account permissions
Expand All @@ -981,7 +988,7 @@ func GetMaccPerms() map[string][]string {
}

// initParamsKeeper init params keeper and its subspaces
func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey sdk.StoreKey) paramskeeper.Keeper {
func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storetypes.StoreKey) paramskeeper.Keeper {
paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey)

paramsKeeper.Subspace(authtypes.ModuleName)
Expand All @@ -990,7 +997,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(minttypes.ModuleName)
paramsKeeper.Subspace(distrtypes.ModuleName)
paramsKeeper.Subspace(slashingtypes.ModuleName)
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govtypes.ParamKeyTable())
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govtypesv1.ParamKeyTable())
paramsKeeper.Subspace(crisistypes.ModuleName)
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibchost.ModuleName)
Expand Down
Loading

0 comments on commit e55f6f2

Please sign in to comment.