Skip to content

Commit

Permalink
Merge pull request #1070 from public-awesome/jhernandezb/v14-update
Browse files Browse the repository at this point in the history
v14 upgrade
  • Loading branch information
jhernandezb authored Jun 24, 2024
2 parents e3f6301 + 039b7c3 commit 7ee5dde
Show file tree
Hide file tree
Showing 9 changed files with 239 additions and 324 deletions.
58 changes: 32 additions & 26 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ steps:
branch: no-cache

- name: test
image: publicawesome/golang:1.21.3-devtooling
image: publicawesome/golang:1.22.3-devtooling
volumes:
- name: cache
path: /go
Expand All @@ -42,7 +42,7 @@ steps:
environment:
GOPROXY: http://goproxy
- name: build
image: golang:1.21.3-alpine3.17
image: golang:1.22.3-alpine3.18
volumes:
- name: cache
path: /go
Expand Down Expand Up @@ -77,12 +77,12 @@ steps:
password:
from_secret: docker_password
tags:
- 13.0.0-beta.9
- 14.0.0-upgrade
when:
event:
- push
branch:
- spoorthi/ica-controller
- jhernandezb/v14-update
- name: docker_release
image: plugins/docker
settings:
Expand All @@ -98,7 +98,7 @@ steps:
- tag

- name: release
image: golang:1.21.3
image: golang:1.22.3
environment:
GITHUB_TOKEN:
from_secret: github_token
Expand Down Expand Up @@ -193,7 +193,7 @@ steps:
environment:
GOPROXY: http://goproxy
- name: stargaze
image: publicawesome/golang:1.21.3-devtooling
image: publicawesome/golang:1.22.3-devtooling
volumes:
- name: cache
path: /go
Expand Down Expand Up @@ -281,7 +281,7 @@ steps:
when:
branch: no-cache
- name: build-wrapper
image: publicawesome/golang:1.21.3-devtooling
image: publicawesome/golang:1.22.3-devtooling
volumes:
- name: cache
path: /go
Expand Down Expand Up @@ -314,7 +314,7 @@ steps:
environment:
GOPROXY: http://goproxy
- name: stargaze
image: publicawesome/stargaze:12.0.0
image: publicawesome/stargaze:13.2.1
commands:
- ./scripts/ci/upgrade/setup-preinstalled-stargaze.sh
environment:
Expand All @@ -332,26 +332,27 @@ steps:
- http://osmosis:26657
- http://icad:26657
- name: relayer
image: publicawesome/hermes:0.15.0
image: publicawesome/hermes:1.7.3
commands:
- /bin/bash ./scripts/ci/setup-relayer.sh
- sleep 10
- /bin/bash ./scripts/ci/setup-hermes-1.7.sh

- name: relayer-start
image: publicawesome/hermes:0.15.0
image: publicawesome/hermes:1.7.3
commands:
- /bin/bash ./scripts/ci/start-relayer.sh
- /bin/bash ./scripts/ci/start-relayer-v1.7.sh
detach: true
- name: relayer-sender
image: publicawesome/hermes:0.15.0
image: publicawesome/hermes:1.7.3
commands:
- /bin/bash ./scripts/ci/transfer-relayer.sh
- /bin/bash ./scripts/ci/transfer-relayer-v1.7.sh
- name: proposal
image: publicawesome/stargaze:12.1.0
image: publicawesome/stargaze:13.2.1
commands:
- ./scripts/ci/upgrade/proposal.sh
- name: stargaze-upgraded
pull: always
image: publicawesome/stargaze:13.0.0-beta.9
image: publicawesome/stargaze:14.0.0-upgrade
commands:
- ./scripts/ci/upgrade/run-upgrade.sh
environment:
Expand All @@ -370,15 +371,19 @@ steps:
- http://icad:26657
- name: check-params
pull: always
image: publicawesome/stargaze:13.0.0-beta.9
image: publicawesome/stargaze:14.0.0-upgrade
commands:
- starsd q mint params --node http://stargaze-upgraded:26657
- starsd q alloc params --node http://stargaze-upgraded:26657
- starsd q tokenfactory params --node http://stargaze-upgraded:26657
- starsd q bank balances stars1mnyrspq208uv5m2krdctan2dkyht0szje9s43h --node http://stargaze-upgraded:26657
- starsd q bank balances stars103y4f6h80lc45nr8chuzr3fyzqywm9n0gnr394 --node http://stargaze-upgraded:26657
- starsd q distribution community-pool --node http://stargaze-upgraded:26657
- starsd q interchain-accounts host params --node http://stargaze-upgraded:26657
- starsd config output json
- starsd config node http://stargaze-upgraded:26657
- starsd q staking params
- starsd q gov params
- starsd q mint params
- starsd q alloc params
- starsd q tokenfactory params
- starsd q bank balances stars1mnyrspq208uv5m2krdctan2dkyht0szje9s43h
- starsd q bank balances stars103y4f6h80lc45nr8chuzr3fyzqywm9n0gnr394
- starsd q distribution community-pool
- starsd q interchain-accounts host params
environment:
GOPROXY: http://goproxy
- name: relayer-upgrade-start
Expand Down Expand Up @@ -407,7 +412,8 @@ steps:

trigger:
branch:
- main
- release/v14.x
- jhernandezb/v14-update
event:
- pull_request
- push
Expand All @@ -420,6 +426,6 @@ volumes:

---
kind: signature
hmac: 5731053a92a730984ac3a569c36c712eb78d3c917641f67cf733ddbf9db91a35
hmac: 95e56a942e5f4ba18e9e0088f6683db90726651fd42e9d9b4c3e30388822d8cd

...
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ endif

check_go_version:
@echo "Go version: $(GO_MAJOR_VERSION).$(GO_MINOR_VERSION)"
ifneq ($(GO_MINOR_VERSION),21)
@echo "ERROR: Go version 1.21 is required for this version of Stargaze"
ifneq ($(GO_MINOR_VERSION),22)
@echo "ERROR: Go version 1.22 is required for this version of Stargaze"
exit 1
endif

Expand Down
2 changes: 2 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,8 @@ func NewStargazeApp(
scopedICAHostKeeper,
bApp.MsgServiceRouter(),
)
// set grpc router for ica host
app.ICAHostKeeper.WithQueryRouter(app.GRPCQueryRouter())

icaHostIBCModule := icahost.NewIBCModule(app.ICAHostKeeper)

Expand Down
118 changes: 6 additions & 112 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,130 +3,30 @@ package app
import (
"fmt"

wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
"github.com/cosmos/cosmos-sdk/baseapp"
store "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
icacontrollertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types"
icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types"
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"

ibctmmigrations "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint/migrations"

alloctypes "github.com/public-awesome/stargaze/v13/x/alloc/types"
globalfeetypes "github.com/public-awesome/stargaze/v13/x/globalfee/types"
minttypes "github.com/public-awesome/stargaze/v13/x/mint/types"
tokenfactorytypes "github.com/public-awesome/stargaze/v13/x/tokenfactory/types"
)

// next upgrade name
const upgradeName = "v13"

const claimModuleName = "claim"
const upgradeName = "v14"

// RegisterUpgradeHandlers returns upgrade handlers
func (app *App) RegisterUpgradeHandlers(cfg module.Configurator) {
// Set param key table for params module migration
for _, subspace := range app.ParamsKeeper.GetSubspaces() {
subspace := subspace

var keyTable paramstypes.KeyTable
switch subspace.Name() {
case authtypes.ModuleName:
keyTable = authtypes.ParamKeyTable() //nolint:staticcheck
case banktypes.ModuleName:
keyTable = banktypes.ParamKeyTable() //nolint:staticcheck
case stakingtypes.ModuleName:
keyTable = stakingtypes.ParamKeyTable()
case distrtypes.ModuleName:
keyTable = distrtypes.ParamKeyTable() //nolint:staticcheck
case slashingtypes.ModuleName:
keyTable = slashingtypes.ParamKeyTable() //nolint:staticcheck
case govtypes.ModuleName:
keyTable = govv1.ParamKeyTable() //nolint:staticcheck
case crisistypes.ModuleName:
keyTable = crisistypes.ParamKeyTable() //nolint:staticcheck
// ibc types
case ibctransfertypes.ModuleName:
keyTable = ibctransfertypes.ParamKeyTable()
case icahosttypes.SubModuleName:
keyTable = icahosttypes.ParamKeyTable()
case icacontrollertypes.SubModuleName:
keyTable = icacontrollertypes.ParamKeyTable()
// wasm
case wasmtypes.ModuleName:
keyTable = wasmtypes.ParamKeyTable() //nolint

// stargaze modules
case alloctypes.ModuleName:
keyTable = alloctypes.ParamKeyTable()
case globalfeetypes.ModuleName:
keyTable = globalfeetypes.ParamKeyTable()
case minttypes.ModuleName:
keyTable = minttypes.ParamKeyTable()
case tokenfactorytypes.ModuleName:
keyTable = tokenfactorytypes.ParamKeyTable()
default:
continue
}

if !subspace.HasKeyTable() {
subspace.WithKeyTable(keyTable)
}
}

baseAppLegacySS := app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable())

app.UpgradeKeeper.SetUpgradeHandler(upgradeName, func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// Migrate Tendermint consensus parameters from x/params module to a dedicated x/consensus module.
baseapp.MigrateParams(ctx, baseAppLegacySS, &app.ConsensusParamsKeeper)

_, err := ibctmmigrations.PruneExpiredConsensusStates(ctx, app.appCodec, app.IBCKeeper.ClientKeeper)
if err != nil {
return nil, err
}

// run migrations before modifying state
migrations, err := app.mm.RunMigrations(ctx, cfg, fromVM)
if err != nil {
return nil, err
}
// set min deposit ratio to 20%
govParams := app.GovKeeper.GetParams(ctx)
govParams.BurnProposalDepositPrevote = true
govParams.BurnVoteQuorum = true
govParams.BurnVoteVeto = true
govParams.MinInitialDepositRatio = sdk.NewDecWithPrec(20, 2).String()
err = app.GovKeeper.SetParams(ctx, govParams)
tokenFactoryParams := app.TokenFactoryKeeper.GetParams(ctx)
tokenFactoryParams.DenomCreationFee = sdk.NewCoins(sdk.NewInt64Coin("ustars", 100_000_000))
err = app.TokenFactoryKeeper.SetParams(ctx, tokenFactoryParams)
if err != nil {
return nil, err
}

// set min commission to 5%
stakingParams := app.StakingKeeper.GetParams(ctx)
stakingParams.MinCommissionRate = sdk.NewDecWithPrec(5, 2)
err = app.StakingKeeper.SetParams(ctx, stakingParams)
if err != nil {
return nil, err
}

// since params where never initialized start with enabled
icaParams := icacontrollertypes.DefaultParams()
icaParams.ControllerEnabled = true
app.ICAControllerKeeper.SetParams(ctx, icaParams)

return migrations, nil
})

Expand All @@ -137,14 +37,8 @@ func (app *App) RegisterUpgradeHandlers(cfg module.Configurator) {

if upgradeInfo.Name == upgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := store.StoreUpgrades{
Added: []string{
consensustypes.ModuleName,
crisistypes.ModuleName,
icacontrollertypes.StoreKey,
},
Deleted: []string{
claimModuleName,
},
Added: []string{},
Deleted: []string{},
}
// configure store loader that checks if version == upgradeHeight and applies store upgrades
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
Expand Down
Loading

0 comments on commit 7ee5dde

Please sign in to comment.