Skip to content

Commit

Permalink
fix ibc-transfer, add upgrade handler
Browse files Browse the repository at this point in the history
  • Loading branch information
antstalepresh committed Aug 11, 2023
1 parent 1410d1d commit 40a6ab1
Showing 1 changed file with 4 additions and 44 deletions.
48 changes: 4 additions & 44 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov"
govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
govmigrations "github.com/cosmos/cosmos-sdk/x/gov/migrations/v3"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
Expand Down Expand Up @@ -132,7 +131,7 @@ import (
const (
Bech32Prefix = "chihuahua"
Name = "chihuahua"
UpgradeName = "v500"
UpgradeName = "v501"
NodeDir = ".chihuahuad"
)

Expand Down Expand Up @@ -655,6 +654,7 @@ func New(
ibc.NewAppModule(app.IBCKeeper),
ibcfee.NewAppModule(app.IBCFeeKeeper),
ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper),
transfer.NewAppModule(app.TransferKeeper),
crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), // always be last to make sure that it checks for all invariants and not only part of them
)

Expand Down Expand Up @@ -781,16 +781,7 @@ func New(

if upgradeInfo.Name == UpgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{
feeburnmoduletypes.StoreKey,
consensustypes.StoreKey,
crisistypes.StoreKey,
ibcfeetypes.StoreKey,
group.StoreKey,
icacontrollertypes.StoreKey,
icahosttypes.StoreKey,
nft.StoreKey,
},
Added: []string{},
}

// configure store loader that checks if version == upgradeHeight and applies store upgrades
Expand Down Expand Up @@ -1004,38 +995,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
// RegisterUpgradeHandlers returns upgrade handlers
func (app *App) RegisterUpgradeHandlers(cfg module.Configurator) {
app.UpgradeKeeper.SetUpgradeHandler(UpgradeName, func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
// gov consensus version of v0.45.12-chihuahua is 3, which is different from mainline sdk v0.45.12
// this makes v47 gov migrations do only v3 => v4 and upgrading panics due to not running v2 => v3 migration.
// v2 => v3 migration involves important migration code for converting old type of proposals to new types thus we run that migration manually here.
govmigrations.MigrateStore(ctx, app.keys[govtypes.StoreKey], app.appCodec)
newVm, vmErr := app.mm.RunMigrations(ctx, cfg, vm)

// set fee burn percent to 50%
feeBurnParams := feeburnmoduletypes.Params{
TxFeeBurnPercent: "50",
}
err := app.FeeburnKeeper.SetParams(ctx, feeBurnParams)
if err != nil {
panic(err)
}

// set min initial deposit ratio to 25%
govParams := app.GovKeeper.GetParams(ctx)
govParams.MinInitialDepositRatio = sdk.NewDec(25).Quo(sdk.NewDec(100)).String()
err = app.GovKeeper.SetParams(ctx, govParams)
if err != nil {
panic(err)
}

// set min validator commission to 5%
stakingParams := app.StakingKeeper.GetParams(ctx)
stakingParams.MinCommissionRate = sdk.NewDec(5).Quo(sdk.NewDec(100))
err = app.StakingKeeper.SetParams(ctx, stakingParams)
if err != nil {
panic(err)
}

return newVm, vmErr
return app.mm.RunMigrations(ctx, cfg, vm)
})
}

Expand Down

0 comments on commit 40a6ab1

Please sign in to comment.