From be948cf4a187876048a5d645a7b17e64f4778c61 Mon Sep 17 00:00:00 2001 From: Srinivas Baride Date: Thu, 8 Dec 2022 16:37:28 +0530 Subject: [PATCH] Included upgrade handler for VPN module --- app.go | 4 ++-- upgrades/handler.go | 56 ++++++++++++++++++++++++++++----------------- 2 files changed, 37 insertions(+), 23 deletions(-) diff --git a/app.go b/app.go index 814e636c..b48e7794 100644 --- a/app.go +++ b/app.go @@ -464,7 +464,7 @@ func NewApp( authtypes.FeeCollectorName, ) - wasmDir := filepath.Join(homePath, "wasm") + wasmDir := filepath.Join(homePath, "data") wasmConfig, err := wasm.ReadWasmConfig(appOpts) if err != nil { @@ -668,7 +668,7 @@ func NewApp( app.upgradeKeeper.SetUpgradeHandler( hubupgrades.Name, - hubupgrades.Handler(app.moduleManager, app.configurator, app.wasmKeeper), + hubupgrades.Handler(app.moduleManager, app.configurator, app.vpnKeeper, app.wasmKeeper), ) upgradeInfo, err := app.upgradeKeeper.ReadUpgradeInfoFromDisk() diff --git a/upgrades/handler.go b/upgrades/handler.go index c6ac4111..bf5fe8d5 100644 --- a/upgrades/handler.go +++ b/upgrades/handler.go @@ -15,29 +15,33 @@ import ( ibcicacontrollertypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller/types" ibcicahosttypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/types" ibcicatypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types" + + vpnkeeper "github.com/sentinel-official/hub/x/vpn/keeper" ) -func Handler(mm *module.Manager, configurator module.Configurator, wasmKeeper wasmkeeper.Keeper) upgradetypes.UpgradeHandler { - return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - controllerParams := ibcicacontrollertypes.Params{} - hostParams := ibcicahosttypes.Params{ - HostEnabled: true, - AllowMessages: []string{ - sdk.MsgTypeURL(&authz.MsgExec{}), - sdk.MsgTypeURL(&authz.MsgGrant{}), - sdk.MsgTypeURL(&authz.MsgRevoke{}), - sdk.MsgTypeURL(&banktypes.MsgSend{}), - sdk.MsgTypeURL(&distributiontypes.MsgFundCommunityPool{}), - sdk.MsgTypeURL(&distributiontypes.MsgSetWithdrawAddress{}), - sdk.MsgTypeURL(&distributiontypes.MsgWithdrawDelegatorReward{}), - sdk.MsgTypeURL(&distributiontypes.MsgWithdrawValidatorCommission{}), - sdk.MsgTypeURL(&govtypes.MsgVote{}), - sdk.MsgTypeURL(&stakingtypes.MsgBeginRedelegate{}), - sdk.MsgTypeURL(&stakingtypes.MsgCreateValidator{}), - sdk.MsgTypeURL(&stakingtypes.MsgDelegate{}), - sdk.MsgTypeURL(&stakingtypes.MsgEditValidator{}), - }, - } +func Handler(mm *module.Manager, configurator module.Configurator, vpnKeeper vpnkeeper.Keeper, wasmKeeper wasmkeeper.Keeper) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + var ( + controllerParams = ibcicacontrollertypes.Params{} + hostParams = ibcicahosttypes.Params{ + HostEnabled: true, + AllowMessages: []string{ + sdk.MsgTypeURL(&authz.MsgExec{}), + sdk.MsgTypeURL(&authz.MsgGrant{}), + sdk.MsgTypeURL(&authz.MsgRevoke{}), + sdk.MsgTypeURL(&banktypes.MsgSend{}), + sdk.MsgTypeURL(&distributiontypes.MsgFundCommunityPool{}), + sdk.MsgTypeURL(&distributiontypes.MsgSetWithdrawAddress{}), + sdk.MsgTypeURL(&distributiontypes.MsgWithdrawDelegatorReward{}), + sdk.MsgTypeURL(&distributiontypes.MsgWithdrawValidatorCommission{}), + sdk.MsgTypeURL(&govtypes.MsgVote{}), + sdk.MsgTypeURL(&stakingtypes.MsgBeginRedelegate{}), + sdk.MsgTypeURL(&stakingtypes.MsgCreateValidator{}), + sdk.MsgTypeURL(&stakingtypes.MsgDelegate{}), + sdk.MsgTypeURL(&stakingtypes.MsgEditValidator{}), + }, + } + ) icaModule, ok := mm.Modules[ibcicatypes.ModuleName].(ibcica.AppModule) if !ok { @@ -46,6 +50,16 @@ func Handler(mm *module.Manager, configurator module.Configurator, wasmKeeper wa icaModule.InitModule(ctx, controllerParams, hostParams) + providerParams := vpnKeeper.Provider.GetParams(ctx) + providerParams.StakingShare = sdk.NewDecWithPrec(2, 1) + vpnKeeper.Provider.SetParams(ctx, providerParams) + + nodeParams := vpnKeeper.Node.GetParams(ctx) + nodeParams.MaxPrice = sdk.NewCoins(sdk.NewInt64Coin("udvpn", 1000*1e6)) + nodeParams.MinPrice = sdk.NewCoins(sdk.NewInt64Coin("udvpn", 100*1e6)) + nodeParams.StakingShare = sdk.NewDecWithPrec(2, 1) + vpnKeeper.Node.SetParams(ctx, nodeParams) + wasmParams := wasmKeeper.GetParams(ctx) wasmParams.CodeUploadAccess = wasmtypes.AllowNobody wasmKeeper.SetParams(ctx, wasmParams)