From 68730a70893b1f4000057df87bada27fd744bf0b Mon Sep 17 00:00:00 2001 From: swelf Date: Tue, 4 Feb 2025 13:46:52 +0300 Subject: [PATCH] added upgrade handler 5.0.7 --- app/app.go | 2 ++ app/upgrades/v5.0.7/constants.go | 18 ++++++++++++++ app/upgrades/v5.0.7/upgrades.go | 35 ++++++++++++++++++++++++++ app/upgrades/v5.0.7/upgrades_test.go | 37 ++++++++++++++++++++++++++++ go.mod | 2 +- go.sum | 2 ++ 6 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 app/upgrades/v5.0.7/constants.go create mode 100644 app/upgrades/v5.0.7/upgrades.go create mode 100644 app/upgrades/v5.0.7/upgrades_test.go diff --git a/app/app.go b/app/app.go index 0772f0f59..969b5d3c5 100644 --- a/app/app.go +++ b/app/app.go @@ -13,6 +13,7 @@ import ( v502 "github.com/neutron-org/neutron/v5/app/upgrades/v5.0.2" v504 "github.com/neutron-org/neutron/v5/app/upgrades/v5.0.4" v505 "github.com/neutron-org/neutron/v5/app/upgrades/v5.0.5" + v507 "github.com/neutron-org/neutron/v5/app/upgrades/v5.0.7" dynamicfeestypes "github.com/neutron-org/neutron/v5/x/dynamicfees/types" "github.com/skip-mev/feemarket/x/feemarket" @@ -234,6 +235,7 @@ var ( v502.Upgrade, v504.Upgrade, v505.Upgrade, + v507.Upgrade, } // DefaultNodeHome default home directories for the application daemon diff --git a/app/upgrades/v5.0.7/constants.go b/app/upgrades/v5.0.7/constants.go new file mode 100644 index 000000000..c81bdf5ef --- /dev/null +++ b/app/upgrades/v5.0.7/constants.go @@ -0,0 +1,18 @@ +package v507 + +import ( + storetypes "cosmossdk.io/store/types" + + "github.com/neutron-org/neutron/v5/app/upgrades" +) + +const ( + // UpgradeName defines the on-chain upgrade name. + UpgradeName = "v5.0.7" +) + +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: CreateUpgradeHandler, + StoreUpgrades: storetypes.StoreUpgrades{}, +} diff --git a/app/upgrades/v5.0.7/upgrades.go b/app/upgrades/v5.0.7/upgrades.go new file mode 100644 index 000000000..f513fdaf3 --- /dev/null +++ b/app/upgrades/v5.0.7/upgrades.go @@ -0,0 +1,35 @@ +package v507 + +import ( + "context" + "fmt" + + upgradetypes "cosmossdk.io/x/upgrade/types" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + + "github.com/neutron-org/neutron/v5/app/upgrades" +) + +func CreateUpgradeHandler( + mm *module.Manager, + configurator module.Configurator, + _ *upgrades.UpgradeKeepers, + _ upgrades.StoreKeys, + _ codec.Codec, +) upgradetypes.UpgradeHandler { + return func(c context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + ctx := sdk.UnwrapSDKContext(c) + + ctx.Logger().Info("Starting module migrations...") + + vm, err := mm.RunMigrations(ctx, configurator, vm) + if err != nil { + return vm, err + } + + ctx.Logger().Info(fmt.Sprintf("Migration {%s} applied", UpgradeName)) + return vm, nil + } +} diff --git a/app/upgrades/v5.0.7/upgrades_test.go b/app/upgrades/v5.0.7/upgrades_test.go new file mode 100644 index 000000000..fd194dafa --- /dev/null +++ b/app/upgrades/v5.0.7/upgrades_test.go @@ -0,0 +1,37 @@ +package v507_test + +import ( + "testing" + + upgradetypes "cosmossdk.io/x/upgrade/types" + "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" + + v507 "github.com/neutron-org/neutron/v5/app/upgrades/v5.0.7" + "github.com/neutron-org/neutron/v5/testutil" +) + +type UpgradeTestSuite struct { + testutil.IBCConnectionTestSuite +} + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(UpgradeTestSuite)) +} + +func (suite *UpgradeTestSuite) SetupTest() { + suite.IBCConnectionTestSuite.SetupTest() +} + +func (suite *UpgradeTestSuite) TestOracleUpgrade() { + app := suite.GetNeutronZoneApp(suite.ChainA) + ctx := suite.ChainA.GetContext().WithChainID("neutron-1") + t := suite.T() + + upgrade := upgradetypes.Plan{ + Name: v507.UpgradeName, + Info: "some text here", + Height: 100, + } + require.NoError(t, app.UpgradeKeeper.ApplyUpgrade(ctx, upgrade)) +} diff --git a/go.mod b/go.mod index 907265be6..77f958c58 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( cosmossdk.io/x/tx v0.13.7 cosmossdk.io/x/upgrade v0.1.4 github.com/CosmWasm/wasmd v0.53.2 - github.com/CosmWasm/wasmvm/v2 v2.1.4 + github.com/CosmWasm/wasmvm/v2 v2.1.5 github.com/cometbft/cometbft v0.38.17 github.com/cosmos/admin-module/v2 v2.0.0-20240430142959-8b3328d1b1a2 github.com/cosmos/cosmos-db v1.1.0 diff --git a/go.sum b/go.sum index 96cda35f9..04a1bc8c8 100644 --- a/go.sum +++ b/go.sum @@ -227,6 +227,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/CosmWasm/wasmvm/v2 v2.1.4 h1:7EUVQjBxXHkVjL2AqqXD7hMEe0dmoNn2li9E4PWRAnA= github.com/CosmWasm/wasmvm/v2 v2.1.4/go.mod h1:bMhLQL4Yp9CzJi9A83aR7VO9wockOsSlZbT4ztOl6bg= +github.com/CosmWasm/wasmvm/v2 v2.1.5 h1:cYI1Ook1IAA5DFA0IVvDQQboorNHZPAZ7emBBHFmXSQ= +github.com/CosmWasm/wasmvm/v2 v2.1.5/go.mod h1:bMhLQL4Yp9CzJi9A83aR7VO9wockOsSlZbT4ztOl6bg= github.com/DataDog/datadog-go v3.2.0+incompatible h1:qSG2N4FghB1He/r2mFrWKCaL7dXCilEuNEeAn20fdD4= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ=