Skip to content

Commit

Permalink
chore: use v19 binaries in upgrade tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gartnera committed Aug 12, 2024
1 parent 2329c3b commit 85ee0f0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 88 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,12 @@ start-solana-test: zetanode solana
ifdef UPGRADE_TEST_FROM_SOURCE
zetanode-upgrade: zetanode
@echo "Building zetanode-upgrade from source"
$(DOCKER) build -t zetanode:old -f Dockerfile-localnet --target old-runtime-source --build-arg OLD_VERSION='release/v18' .
$(DOCKER) build -t zetanode:old -f Dockerfile-localnet --target old-runtime-source --build-arg OLD_VERSION='release/v19' .
.PHONY: zetanode-upgrade
else
zetanode-upgrade: zetanode
@echo "Building zetanode-upgrade from binaries"
$(DOCKER) build -t zetanode:old -f Dockerfile-localnet --target old-runtime --build-arg OLD_VERSION='https://github.com/zeta-chain/node/releases/download/v18.0.0' .
$(DOCKER) build -t zetanode:old -f Dockerfile-localnet --target old-runtime --build-arg OLD_VERSION='https://github.com/zeta-chain/node/releases/download/v19.0.0' .
.PHONY: zetanode-upgrade
endif

Expand Down
88 changes: 2 additions & 86 deletions app/setup_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,106 +3,22 @@ package app
import (
"os"

"github.com/cosmos/cosmos-sdk/baseapp"
storetypes "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"
"github.com/cosmos/cosmos-sdk/x/upgrade/types"
"golang.org/x/exp/slices"

"github.com/zeta-chain/zetacore/pkg/constant"
authoritytypes "github.com/zeta-chain/zetacore/x/authority/types"
emissionstypes "github.com/zeta-chain/zetacore/x/emissions/types"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
)

func SetupHandlers(app *App) {
// Set param key table for params module migration
for _, subspace := range app.ParamsKeeper.GetSubspaces() {
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
case emissionstypes.ModuleName:
keyTable = emissionstypes.ParamKeyTable()
default:
continue
}
if !subspace.HasKeyTable() {
subspace.WithKeyTable(keyTable)
}
}
baseAppLegacySS := app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable())
needsForcedMigration := []string{
authtypes.ModuleName,
banktypes.ModuleName,
stakingtypes.ModuleName,
distrtypes.ModuleName,
slashingtypes.ModuleName,
govtypes.ModuleName,
crisistypes.ModuleName,
emissionstypes.ModuleName,
authoritytypes.ModuleName,
observertypes.ModuleName,
}
allUpgrades := upgradeTracker{
upgrades: []upgradeTrackerItem{
{
index: 1714664193,
storeUpgrade: &storetypes.StoreUpgrades{
Added: []string{consensustypes.ModuleName, crisistypes.ModuleName},
},
upgradeHandler: func(ctx sdk.Context, vm module.VersionMap) (module.VersionMap, error) {
// Migrate Tendermint consensus parameters from x/params module to a dedicated x/consensus module
// https://docs.cosmos.network/main/build/migrations/upgrading#xconsensus
baseapp.MigrateParams(ctx, baseAppLegacySS, &app.ConsensusParamsKeeper)

// empty version map happens when upgrading from old versions which did not correctly call
// app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap()) in InitChainer.
// we must populate the version map if we detect this scenario
//
// this will only happen on the first upgrade. mainnet and testnet will not require this condition.
if len(vm) == 0 {
for m, mb := range app.mm.Modules {
if module, ok := mb.(module.HasConsensusVersion); ok {
if slices.Contains(needsForcedMigration, m) {
vm[m] = module.ConsensusVersion() - 1
} else {
vm[m] = module.ConsensusVersion()
}
}
}
}
return vm, nil
},
},
// TODO: enable back IBC
// these commented lines allow for the IBC modules to be added to the upgrade tracker
// https://github.com/zeta-chain/node/issues/2573
//{
// index: 1715624665,
// index: <CURRENT TIMESTAMP>,
// storeUpgrade: &storetypes.StoreUpgrades{
// Added: []string{
// capabilitytypes.ModuleName,
Expand All @@ -112,7 +28,7 @@ func SetupHandlers(app *App) {
// },
//},
//{
// index: 1715707436,
// index: <CURRENT TIMESTAMP>,
// storeUpgrade: &storetypes.StoreUpgrades{
// Added: []string{ibccrosschaintypes.ModuleName},
// },
Expand Down

0 comments on commit 85ee0f0

Please sign in to comment.