Skip to content

Commit

Permalink
Problem: sim tests fails
Browse files Browse the repository at this point in the history
Solution:
- add icahost wiring, but disable in parameters
  • Loading branch information
yihuang committed Apr 15, 2024
1 parent eda35d7 commit 8f3947a
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### State Machine Breaking

* [#1377](https://github.com/crypto-org-chain/cronos/pull/1377) Upgrade sdk to 0.50, and integrate block-stm parallel tx execution.
* [#]() Add icahost wirings but disable in parameters.

### Improvements

Expand Down
19 changes: 18 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ import (
icacontroller "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller"
icacontrollerkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/keeper"
icacontrollertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types"
icahost "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host"
icahostkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/keeper"
icahosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types"
icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types"
ibcfee "github.com/cosmos/ibc-go/v8/modules/apps/29-fee"
ibcfeekeeper "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/keeper"
Expand Down Expand Up @@ -244,6 +247,7 @@ func StoreKeys() (
// ica keys
icacontrollertypes.StoreKey,
icaauthtypes.StoreKey,
icahosttypes.StoreKey,
// ethermint keys
evmtypes.StoreKey, feemarkettypes.StoreKey,
// this line is used by starport scaffolding # stargate/app/storeKey
Expand Down Expand Up @@ -299,6 +303,7 @@ type App struct {
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
IBCFeeKeeper ibcfeekeeper.Keeper
ICAControllerKeeper icacontrollerkeeper.Keeper
ICAHostKeeper icahostkeeper.Keeper
ICAAuthKeeper icaauthkeeper.Keeper
EvidenceKeeper evidencekeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper
Expand Down Expand Up @@ -424,6 +429,7 @@ func New(
scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibcexported.ModuleName)
scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName)
scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName)
scopedICAAuthKeeper := app.CapabilityKeeper.ScopeToModule(icaauthtypes.ModuleName)

// Applications that wish to enforce statically created ScopedKeepers should call `Seal` after creating
Expand Down Expand Up @@ -550,7 +556,12 @@ func New(
scopedICAControllerKeeper, app.MsgServiceRouter(),
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

app.ICAHostKeeper = icahostkeeper.NewKeeper(
appCodec, keys[icahosttypes.StoreKey], app.GetSubspace(icahosttypes.SubModuleName),
app.IBCFeeKeeper, // ISC4 Wrapper: fee IBC middleware
app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper,
app.AccountKeeper, scopedICAHostKeeper, app.MsgServiceRouter(),

Check failure on line 563 in app/app.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

not enough arguments in call to icahostkeeper.NewKeeper

Check failure on line 563 in app/app.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

not enough arguments in call to icahostkeeper.NewKeeper

Check failure on line 563 in app/app.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

not enough arguments in call to icahostkeeper.NewKeeper

Check failure on line 563 in app/app.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

not enough arguments in call to icahostkeeper.NewKeeper
)
icaModule := ica.NewAppModule(&app.ICAControllerKeeper, nil)

// Create Transfer Keepers
Expand Down Expand Up @@ -665,12 +676,17 @@ func New(
// we don't limit gas usage here, because the cronos keeper will use network parameter to control it.
icaControllerStack = ibccallbacks.NewIBCMiddleware(icaControllerStack, app.IBCFeeKeeper, app.CronosKeeper, math.MaxUint64)

var icaHostStack porttypes.IBCModule
icaHostStack = icahost.NewIBCModule(app.ICAHostKeeper)
icaHostStack = ibcfee.NewIBCMiddleware(icaHostStack, app.IBCFeeKeeper)

// Create static IBC router, add transfer route, then set and seal it
ibcRouter := porttypes.NewRouter()
// Add ontroller & ica auth modules to IBC router
ibcRouter.
AddRoute(icaauthtypes.ModuleName, icaControllerStack).
AddRoute(icacontrollertypes.SubModuleName, icaControllerStack).
AddRoute(icahosttypes.SubModuleName, icaHostStack).
AddRoute(ibctransfertypes.ModuleName, transferStack)

// this line is used by starport scaffolding # ibc/app/router
Expand Down Expand Up @@ -1290,6 +1306,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(ibcexported.ModuleName).WithKeyTable(keyTable)
paramsKeeper.Subspace(ibctransfertypes.ModuleName).WithKeyTable(ibctransfertypes.ParamKeyTable())
paramsKeeper.Subspace(icacontrollertypes.SubModuleName).WithKeyTable(icacontrollertypes.ParamKeyTable())
paramsKeeper.Subspace(icahosttypes.SubModuleName)
paramsKeeper.Subspace(icaauthtypes.ModuleName)
paramsKeeper.Subspace(evmtypes.ModuleName).WithKeyTable(v0evmtypes.ParamKeyTable()) //nolint: staticcheck
paramsKeeper.Subspace(feemarkettypes.ModuleName).WithKeyTable(feemarkettypes.ParamKeyTable())
Expand Down
31 changes: 30 additions & 1 deletion app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,45 @@ package app

import (
"context"
"fmt"

storetypes "cosmossdk.io/store/types"
upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
icahosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types"
clientkeeper "github.com/cosmos/ibc-go/v8/modules/core/02-client/keeper"
)

func (app *App) RegisterUpgradeHandlers(cdc codec.BinaryCodec, clientKeeper clientkeeper.Keeper) {
planName := "v1.3"
app.UpgradeKeeper.SetUpgradeHandler(planName, func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return app.ModuleManager.RunMigrations(ctx, app.configurator, fromVM)
m, err := app.ModuleManager.RunMigrations(ctx, app.configurator, fromVM)
if err != nil {
return m, err
}

sdkCtx := sdk.UnwrapSDKContext(ctx)
{
params := app.ICAHostKeeper.GetParams(sdkCtx)
params.HostEnabled = false
app.ICAHostKeeper.SetParams(sdkCtx, params)
}
return m, nil
})

upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(fmt.Sprintf("failed to read upgrade info from disk %s", err))
}
if !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
if upgradeInfo.Name == planName {
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storetypes.StoreUpgrades{
Added: []string{
icahosttypes.StoreKey,
},
}))
}
}
}

0 comments on commit 8f3947a

Please sign in to comment.