From c07dbc615f25f423dfe3ec675ffc219e96f544d9 Mon Sep 17 00:00:00 2001 From: Yaroms <103432884+Yaroms@users.noreply.github.com> Date: Sun, 15 Dec 2024 14:50:02 +0200 Subject: [PATCH] add one year to all periodic accounts that have not started yet (#1824) Co-authored-by: Yaroms --- 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 54056cf870..9a86e4e8cf 100644 --- a/app/app.go +++ b/app/app.go @@ -168,6 +168,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) + } +}