Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: integrating ica to rho #1530

Merged
merged 39 commits into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
fc5a399
add ica proto
May 24, 2022
ed1f43c
add ica module
May 24, 2022
8fcd891
fix: ica keeper
May 25, 2022
317d4e9
add third party proto files
May 25, 2022
0792569
bump ibc-go
Jun 2, 2022
f00d4ca
Merge branch 'main' into yaru/ica
Jun 9, 2022
6ce90e9
bump: go to 1.8
Jun 9, 2022
5cd8c91
integrating: icahost, intertx, fix keeper_test.go
Jun 9, 2022
d6a23ea
fix: lint
Jun 9, 2022
39ae2e1
formatting
Jun 9, 2022
e3c02da
refactor:intertx -> icamauth
Jun 9, 2022
5730299
fix: icacontroller err
Jun 14, 2022
84869d9
fix: lint
Jun 14, 2022
161c399
merge main, bump icamauth
Aug 4, 2022
f0e23de
Merge branch 'main' into yaru/ica
Aug 4, 2022
19f44f5
fix: grpc
Aug 10, 2022
c882e77
fix: grpc, merge main
Aug 10, 2022
43c80fe
update with interchain-account-demo
Aug 10, 2022
323a79d
fix: lint
Aug 11, 2022
f33a6a6
fix: dead link
Aug 11, 2022
50e9229
docs: update icamauth readme
Aug 11, 2022
9608aac
chore: update endpoint url
Aug 11, 2022
1354cb1
refactor: move icamauth proto file to proto/gaia/icamauth/v1beta1
Aug 11, 2022
d0b5f4e
remove: handleMsgData, controller does not check tx err on host side
Aug 12, 2022
b4d402b
merge main
Aug 12, 2022
46e2435
fix: lint
Aug 12, 2022
982d426
fix: lint
Aug 17, 2022
a85c039
add: unit tests
Aug 17, 2022
495778c
Merge branch 'main' into yaru/ica
Aug 25, 2022
0f66822
update go.work.sum
Aug 25, 2022
c2ce18c
update: icamauth module
Sep 6, 2022
efccdab
Merge branch 'main' into yaru/ica
yaruwangway Sep 6, 2022
0f26f52
remove keeper and msg_server tests (temporary)
Sep 14, 2022
be04951
Merge branch 'main' into yaru/ica
okwme Sep 14, 2022
4d39446
Update x/icamauth/README.md
yaruwangway Sep 14, 2022
f4b5e77
update: app.go
Sep 14, 2022
5ea0dda
Merge branch 'main' into yaru/ica
okwme Sep 14, 2022
5fc21b8
chore: clean comments
Sep 16, 2022
e8f99ac
test: add back unit test in icamauth
Sep 16, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 104 additions & 20 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package gaia
import (
"fmt"
"io"
stdlog "log"
"net/http"
"os"
"path/filepath"

stdlog "log"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
Expand Down Expand Up @@ -83,6 +84,8 @@ import (
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"
Expand Down Expand Up @@ -117,6 +120,9 @@ import (
gaiaante "github.com/cosmos/gaia/v8/ante"
gaiaappparams "github.com/cosmos/gaia/v8/app/params"
"github.com/cosmos/gaia/v8/x/globalfee"
"github.com/cosmos/gaia/v8/x/icamauth"
icamauthkeeper "github.com/cosmos/gaia/v8/x/icamauth/keeper"
icamauthtypes "github.com/cosmos/gaia/v8/x/icamauth/types"

// unnamed import of statik for swagger UI support
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"
Expand Down Expand Up @@ -161,6 +167,7 @@ var (
liquidity.AppModuleBasic{},
router.AppModuleBasic{},
ica.AppModuleBasic{},
icamauth.AppModuleBasic{},
globalfee.AppModule{},
)

Expand All @@ -175,6 +182,8 @@ var (
govtypes.ModuleName: {authtypes.Burner},
liquiditytypes.ModuleName: {authtypes.Minter, authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
// todo: check here from interchain-acount-demo
okwme marked this conversation as resolved.
Show resolved Hide resolved
// ibcfeetypes.ModuleName: nil,
}
)

Expand Down Expand Up @@ -211,21 +220,25 @@ type GaiaApp struct { //nolint: revive
UpgradeKeeper upgradekeeper.Keeper
ParamsKeeper paramskeeper.Keeper
// IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
IBCKeeper *ibckeeper.Keeper
ICAHostKeeper icahostkeeper.Keeper
EvidenceKeeper evidencekeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
GroupKeeper groupkeeper.Keeper
AuthzKeeper authzkeeper.Keeper
LiquidityKeeper liquiditykeeper.Keeper
IBCKeeper *ibckeeper.Keeper
ICAControllerKeeper icacontrollerkeeper.Keeper
ICAHostKeeper icahostkeeper.Keeper
ICAMauthKeeper icamauthkeeper.Keeper
EvidenceKeeper evidencekeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
GroupKeeper groupkeeper.Keeper
AuthzKeeper authzkeeper.Keeper
LiquidityKeeper liquiditykeeper.Keeper

RouterKeeper routerkeeper.Keeper

// make scoped keepers public for test purposes
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
ScopedICAControllerKeeper capabilitykeeper.ScopedKeeper
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
ScopedICAMauthKeeper capabilitykeeper.ScopedKeeper

// the module manager
mm *module.Manager
Expand Down Expand Up @@ -275,7 +288,7 @@ func NewGaiaApp(
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey,
evidencetypes.StoreKey, liquiditytypes.StoreKey, ibctransfertypes.StoreKey,
capabilitytypes.StoreKey, feegrant.StoreKey, authzkeeper.StoreKey, routertypes.StoreKey, icahosttypes.StoreKey, group.StoreKey,
capabilitytypes.StoreKey, feegrant.StoreKey, authzkeeper.StoreKey, routertypes.StoreKey, icacontrollertypes.StoreKey, icahosttypes.StoreKey, icamauthtypes.StoreKey, group.StoreKey,
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
Expand Down Expand Up @@ -313,7 +326,10 @@ func NewGaiaApp(
app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey])
scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibchost.ModuleName)
scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
scopedICAMauthKeeper := app.CapabilityKeeper.ScopeToModule(icamauthtypes.ModuleName)
scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName)
scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName)

app.CapabilityKeeper.Seal()

// add keepers
Expand Down Expand Up @@ -467,10 +483,16 @@ func NewGaiaApp(
app.BankKeeper,
scopedTransferKeeper,
)

transferModule := transfer.NewAppModule(app.TransferKeeper)
transferIBCModule := transfer.NewIBCModule(app.TransferKeeper)

app.ICAControllerKeeper = icacontrollerkeeper.NewKeeper(
appCodec, keys[icacontrollertypes.StoreKey], app.GetSubspace(icacontrollertypes.SubModuleName),
app.IBCKeeper.ChannelKeeper, // may be replaced with middleware such as ics29 fee
app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper,
scopedICAControllerKeeper, app.MsgServiceRouter(),
)

app.ICAHostKeeper = icahostkeeper.NewKeeper(
appCodec, keys[icahosttypes.StoreKey],
app.GetSubspace(icahosttypes.SubModuleName),
Expand All @@ -480,17 +502,28 @@ func NewGaiaApp(
scopedICAHostKeeper,
app.MsgServiceRouter(),
)
icaModule := ica.NewAppModule(nil, &app.ICAHostKeeper)
icaHostIBCModule := icahost.NewIBCModule(app.ICAHostKeeper)
icaModule := ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper)

app.ICAMauthKeeper = icamauthkeeper.NewKeeper(
appCodec,
keys[icamauthtypes.StoreKey],
app.ICAControllerKeeper,
scopedICAMauthKeeper,
)
icaMauthModule := icamauth.NewAppModule(appCodec, app.ICAMauthKeeper)
icaMauthIBCModule := icamauth.NewIBCModule(app.ICAMauthKeeper)

icaControllerIBCModule := icacontroller.NewIBCMiddleware(icaMauthIBCModule, app.ICAControllerKeeper)
icaHostIBCModule := icahost.NewIBCModule(app.ICAHostKeeper)
app.RouterKeeper = routerkeeper.NewKeeper(appCodec, keys[routertypes.StoreKey], app.GetSubspace(routertypes.ModuleName), app.TransferKeeper, app.DistrKeeper)

routerModule := router.NewAppModule(app.RouterKeeper, transferIBCModule)
// create static IBC router, add transfer route, then set and seal it
ibcRouter := porttypes.NewRouter()
ibcRouter.AddRoute(icahosttypes.SubModuleName, icaHostIBCModule).
AddRoute(ibctransfertypes.ModuleName, transferIBCModule)

ibcRouter.AddRoute(icacontrollertypes.SubModuleName, icaControllerIBCModule).
AddRoute(icahosttypes.SubModuleName, icaHostIBCModule).
AddRoute(ibctransfertypes.ModuleName, transferIBCModule).
AddRoute(icamauthtypes.ModuleName, icaControllerIBCModule)
app.IBCKeeper.SetRouter(ibcRouter)

// create evidence keeper with router
Expand Down Expand Up @@ -532,10 +565,11 @@ func NewGaiaApp(
ibc.NewAppModule(app.IBCKeeper),
params.NewAppModule(app.ParamsKeeper),
liquidity.NewAppModule(appCodec, app.LiquidityKeeper, app.AccountKeeper, app.BankKeeper, app.DistrKeeper),
globalfee.NewAppModule(app.GetSubspace(globalfee.ModuleName)),
transferModule,
icaModule,
icaMauthModule,
routerModule,
globalfee.NewAppModule(app.GetSubspace(globalfee.ModuleName)),
routerModule,
)

Expand Down Expand Up @@ -568,6 +602,8 @@ func NewGaiaApp(
group.ModuleName,
paramstypes.ModuleName,
vestingtypes.ModuleName,
icatypes.ModuleName,
icamauthtypes.ModuleName,
globalfee.ModuleName,
)
app.mm.SetOrderEndBlockers(
Expand All @@ -593,6 +629,8 @@ func NewGaiaApp(
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
icatypes.ModuleName,
icamauthtypes.ModuleName,
globalfee.ModuleName,
)

Expand Down Expand Up @@ -622,6 +660,8 @@ func NewGaiaApp(
feegrant.ModuleName,
group.ModuleName,
routertypes.ModuleName,
icatypes.ModuleName,
icamauthtypes.ModuleName,
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
Expand Down Expand Up @@ -777,6 +817,9 @@ func NewGaiaApp(

app.ScopedIBCKeeper = scopedIBCKeeper
app.ScopedTransferKeeper = scopedTransferKeeper
app.ScopedICAControllerKeeper = scopedICAControllerKeeper
app.ScopedICAHostKeeper = scopedICAHostKeeper
app.ScopedICAMauthKeeper = scopedICAMauthKeeper

return app
}
Expand Down Expand Up @@ -959,8 +1002,49 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(ibchost.ModuleName)

paramsKeeper.Subspace(routertypes.ModuleName).WithKeyTable(routertypes.ParamKeyTable())
paramsKeeper.Subspace(icacontrollertypes.SubModuleName)
paramsKeeper.Subspace(icahosttypes.SubModuleName)
paramsKeeper.Subspace(globalfee.ModuleName)

return paramsKeeper
}

// todo check
// func (*App) OnTxSucceeded(ctx sdk.Context, sourcePort, sourceChannel string, txHash []byte, txBytes []byte) {}
yaruwangway marked this conversation as resolved.
Show resolved Hide resolved
//
// func (*App) OnTxFailed(ctx sdk.Context, sourcePort, sourceChannel string, txHash []byte, txBytes []byte) {}

// TestingApp functions

// GetBaseApp implements the TestingApp interface.
func (app *GaiaApp) GetBaseApp() *baseapp.BaseApp {
return app.BaseApp
}

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

// GetIBCKeeper implements the TestingApp interface.
func (app *GaiaApp) GetIBCKeeper() *ibckeeper.Keeper {
return app.IBCKeeper
}

// GetScopedIBCKeeper implements the TestingApp interface.
func (app *GaiaApp) GetScopedIBCKeeper() capabilitykeeper.ScopedKeeper {
return app.ScopedIBCKeeper
}

// GetTxConfig implements the TestingApp interface.
func (app *GaiaApp) GetTxConfig() client.TxConfig {
return MakeTestEncodingConfig().TxConfig
}

// EmptyAppOptions is a stub implementing AppOptions
type EmptyAppOptions struct{}

// Get implements AppOptions
func (ao EmptyAppOptions) Get(o string) interface{} {
return nil
}
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ require (
github.com/gorilla/mux v1.8.0
github.com/gravity-devs/liquidity/v2 v2.0.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/pkg/errors v0.9.1
github.com/rakyll/statik v0.1.7
github.com/spf13/cast v1.5.0
github.com/spf13/cobra v1.5.0
github.com/spf13/viper v1.12.0 // indirect
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.12.0
github.com/strangelove-ventures/packet-forward-middleware/v2 v2.1.4-0.20220802012200-5a62a55a7f1d
github.com/stretchr/testify v1.8.0
github.com/tendermint/tendermint v0.34.21
Expand Down Expand Up @@ -195,7 +197,6 @@ require (
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
github.com/phayes/checkstyle v0.0.0-20170904204023-bfd46e6a821d // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/polyfloyd/go-errorlint v1.0.2 // indirect
github.com/prometheus/client_golang v1.12.2 // indirect
Expand Down Expand Up @@ -226,7 +227,6 @@ require (
github.com/sourcegraph/go-diff v0.6.1 // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect
github.com/stbenjam/no-sprintf-host-port v0.1.1 // indirect
github.com/stretchr/objx v0.4.0 // indirect
Expand Down
Loading