-
Notifications
You must be signed in to change notification settings - Fork 608
/
upgrades.go
78 lines (66 loc) · 2.76 KB
/
upgrades.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package v5
import (
"context"
ibcconnectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types"
// bech32ibctypes "github.com/osmosis-labs/bech32-ibc/x/bech32ibc/types"
upgradetypes "cosmossdk.io/x/upgrade/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/authz"
"github.com/osmosis-labs/osmosis/v28/app/keepers"
"github.com/osmosis-labs/osmosis/v28/app/upgrades"
txfeestypes "github.com/osmosis-labs/osmosis/v28/x/txfees/types"
)
func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
_ upgrades.BaseAppParamManager,
keepers *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(context context.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
ctx := sdk.UnwrapSDKContext(context)
// Set IBC updates from {inside SDK} to v1
//
// See: https://github.com/cosmos/ibc-go/blob/main/docs/migrations/ibc-migration-043.md#in-place-store-migrations
keepers.IBCKeeper.ConnectionKeeper.SetParams(ctx, ibcconnectiontypes.DefaultParams())
// Set all modules "old versions" to 1. Then the run migrations logic will
// handle running their upgrade logics.
fromVM := make(map[string]uint64)
for moduleName := range mm.Modules {
fromVM[moduleName] = 1
}
// EXCEPT Auth needs to run AFTER staking.
//
// See: https://github.com/cosmos/cosmos-sdk/issues/10591
//
// So we do this by making auth run last. This is done by setting auth's
// consensus version to 2, running RunMigrations, then setting it back to 1,
// and then running migrations again.
fromVM[authtypes.ModuleName] = 2
// Override versions for authz & bech32ibctypes module as to not skip their
// InitGenesis for txfees module, we will override txfees ourselves.
delete(fromVM, authz.ModuleName)
// delete(fromVM, bech32ibctypes.ModuleName)
newVM, err := mm.RunMigrations(ctx, configurator, fromVM)
if err != nil {
return nil, err
}
// Override txfees genesis here
ctx.Logger().Info("Setting txfees module genesis with actual v5 desired genesis")
feeTokens := InitialWhitelistedFeetokens(ctx, keepers.GAMMKeeper)
stakingParams, err := keepers.StakingKeeper.GetParams(ctx)
if err != nil {
return nil, err
}
keepers.TxFeesKeeper.InitGenesis(ctx, txfeestypes.GenesisState{
Basedenom: stakingParams.BondDenom,
Feetokens: feeTokens,
})
// now update auth version back to v1, to run auth migration last
newVM[authtypes.ModuleName] = 1
ctx.Logger().Info("Now running migrations just for auth, to get auth migration to be last. " +
"(CC https://github.com/cosmos/cosmos-sdk/issues/10591)")
return mm.RunMigrations(ctx, configurator, newVM)
}
}