From 18c395ba01dbd650eac3d276991782faa28270ae Mon Sep 17 00:00:00 2001 From: Yaroms Date: Wed, 4 Dec 2024 15:03:30 +0200 Subject: [PATCH] add one year to all periodic accounts that have not started yet --- app/app.go | 1 + app/upgrades/empty_upgrades.go | 6 ++++++ app/upgrades/upgrade_0_35_0.go | 35 ---------------------------------- app/upgrades/upgrade_4_2_0.go | 32 +++++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 35 deletions(-) delete mode 100644 app/upgrades/upgrade_0_35_0.go create mode 100644 app/upgrades/upgrade_4_2_0.go diff --git a/app/app.go b/app/app.go index d219fb6c69..ee6eba092f 100644 --- a/app/app.go +++ b/app/app.go @@ -169,6 +169,7 @@ var Upgrades = []upgrades.Upgrade{ upgrades.Upgrade_3_1_0, upgrades.Upgrade_4_0_0, upgrades.Upgrade_4_1_0, + upgrades.Upgrade_4_2_0, } // this line is used by starport scaffolding # stargate/wasm/app/enabledProposals diff --git a/app/upgrades/empty_upgrades.go b/app/upgrades/empty_upgrades.go index 3cb03b74e0..2d0a9a89ae 100644 --- a/app/upgrades/empty_upgrades.go +++ b/app/upgrades/empty_upgrades.go @@ -57,3 +57,9 @@ var Upgrade_4_1_0 = Upgrade{ CreateUpgradeHandler: defaultUpgradeHandler, StoreUpgrades: store.StoreUpgrades{}, } + +var Upgrade_4_2_0 = Upgrade{ + UpgradeName: "v4.2.0", + CreateUpgradeHandler: v_4_2_0, + StoreUpgrades: store.StoreUpgrades{}, +} diff --git a/app/upgrades/upgrade_0_35_0.go b/app/upgrades/upgrade_0_35_0.go deleted file mode 100644 index 76ebe64cf6..0000000000 --- a/app/upgrades/upgrade_0_35_0.go +++ /dev/null @@ -1,35 +0,0 @@ -package upgrades - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - "github.com/cosmos/gogoproto/proto" - ibctypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - "github.com/lavanet/lava/v4/app/keepers" - protocoltypes "github.com/lavanet/lava/v4/x/protocol/types" - spectypes "github.com/lavanet/lava/v4/x/spec/types" -) - -func v_35_0( - m *module.Manager, - c module.Configurator, - _ BaseAppParamManager, - lk *keepers.LavaKeepers, -) upgradetypes.UpgradeHandler { - return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { - // reset allowlist to empty - lk.SpecKeeper.AllowlistReset(ctx) - - params := lk.SpecKeeper.GetParams(ctx) - params.AllowlistedExpeditedMsgs = []string{ - proto.MessageName(&protocoltypes.MsgSetVersion{}), - proto.MessageName(&spectypes.SpecAddProposal{}), - proto.MessageName(&ibctypes.ClientUpdateProposal{}), - proto.MessageName(&ibctypes.UpgradeProposal{}), - } - lk.SpecKeeper.SetParams(ctx, params) - - return m.RunMigrations(ctx, c, vm) - } -} diff --git a/app/upgrades/upgrade_4_2_0.go b/app/upgrades/upgrade_4_2_0.go new file mode 100644 index 0000000000..d41b614b56 --- /dev/null +++ b/app/upgrades/upgrade_4_2_0.go @@ -0,0 +1,32 @@ +package upgrades + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + "github.com/lavanet/lava/v4/app/keepers" +) + +func v_4_2_0( + m *module.Manager, + c module.Configurator, + _ BaseAppParamManager, + lk *keepers.LavaKeepers, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + accounts := lk.AccountKeeper.GetAllAccounts(ctx) + year := int64(12 * 30 * 24 * 60 * 60) + for _, account := range accounts { + if vaccount, ok := account.(*authtypes.PeriodicVestingAccount); ok { + if vaccount.StartTime > ctx.BlockTime().Unix() { + vaccount.StartTime += year + vaccount.EndTime += year + lk.AccountKeeper.SetAccount(ctx, vaccount) + } + } + } + + return m.RunMigrations(ctx, c, vm) + } +}