From e9ff4b245be4bcb169396fc07ce83911529c234d Mon Sep 17 00:00:00 2001 From: zakir <80246097+zakir-code@users.noreply.github.com> Date: Thu, 8 Aug 2024 15:17:58 +0800 Subject: [PATCH] chore: skip upgrade handler on testnet (#635) Co-authored-by: nulnut <151493716+nulnut@users.noreply.github.com> --- app/upgrade_test.go | 1 + app/upgrades/v7/constants.go | 4 ++++ app/upgrades/v7/upgrade.go | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/app/upgrade_test.go b/app/upgrade_test.go index 82bdc6ac..312dfc8d 100644 --- a/app/upgrade_test.go +++ b/app/upgrade_test.go @@ -30,6 +30,7 @@ func Test_UpgradeAndMigrate(t *testing.T) { home := filepath.Join(os.Getenv("HOME"), "tmp") chainId := fxtypes.TestnetChainId // The upgrade test is not related to chainId, do not modify it + fxtypes.SetChainId(chainId) db, err := dbm.NewDB("application", dbm.GoLevelDBBackend, filepath.Join(home, "data")) require.NoError(t, err) diff --git a/app/upgrades/v7/constants.go b/app/upgrades/v7/constants.go index 061ef95e..1044dfcd 100644 --- a/app/upgrades/v7/constants.go +++ b/app/upgrades/v7/constants.go @@ -6,12 +6,16 @@ import ( crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" "github.com/functionx/fx-core/v7/app/upgrades" + fxtypes "github.com/functionx/fx-core/v7/types" ) var Upgrade = upgrades.Upgrade{ UpgradeName: "v7.5.x", CreateUpgradeHandler: CreateUpgradeHandler, StoreUpgrades: func() *storetypes.StoreUpgrades { + if fxtypes.ChainId() == fxtypes.TestnetChainId { + return &storetypes.StoreUpgrades{} + } return &storetypes.StoreUpgrades{ Added: []string{ crisistypes.ModuleName, diff --git a/app/upgrades/v7/upgrade.go b/app/upgrades/v7/upgrade.go index a6eda601..b535adb2 100644 --- a/app/upgrades/v7/upgrade.go +++ b/app/upgrades/v7/upgrade.go @@ -9,12 +9,17 @@ import ( "github.com/functionx/fx-core/v7/app/keepers" "github.com/functionx/fx-core/v7/contract" + fxtypes "github.com/functionx/fx-core/v7/types" crosschaintypes "github.com/functionx/fx-core/v7/x/crosschain/types" fxevmkeeper "github.com/functionx/fx-core/v7/x/evm/keeper" ) func CreateUpgradeHandler(mm *module.Manager, configurator module.Configurator, app *keepers.AppKeepers) upgradetypes.UpgradeHandler { return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + // Testnet skip + if fxtypes.ChainId() == fxtypes.TestnetChainId { + return fromVM, nil + } // Migrate Tendermint consensus parameters from x/params module to a dedicated x/consensus module. baseAppLegacySS, found := app.ParamsKeeper.GetSubspace(baseapp.Paramspace) if !found {