From 494bb03e64236b39293286e6ceaedb894d85d2e7 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 27 Aug 2023 12:41:40 -0500 Subject: [PATCH 1/3] Fix v18 handler --- app/upgrades/v19/constants.go | 4 ++-- app/upgrades/v19/upgrades.go | 8 +++++--- x/lockup/keeper/lock.go | 4 ++++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/upgrades/v19/constants.go b/app/upgrades/v19/constants.go index 6591e8ea4d8..719ce80d496 100644 --- a/app/upgrades/v19/constants.go +++ b/app/upgrades/v19/constants.go @@ -1,4 +1,4 @@ -package v18 +package v19 import ( "github.com/osmosis-labs/osmosis/v19/app/upgrades" @@ -7,7 +7,7 @@ import ( ) // UpgradeName defines the on-chain upgrade name for the Osmosis v18 upgrade. -const UpgradeName = "v18" +const UpgradeName = "v19" var Upgrade = upgrades.Upgrade{ UpgradeName: UpgradeName, diff --git a/app/upgrades/v19/upgrades.go b/app/upgrades/v19/upgrades.go index 7547d3849c7..10a19366101 100644 --- a/app/upgrades/v19/upgrades.go +++ b/app/upgrades/v19/upgrades.go @@ -1,10 +1,12 @@ -package v18 +package v19 import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + gammtypes "github.com/osmosis-labs/osmosis/v19/x/gamm/types" + "github.com/osmosis-labs/osmosis/v19/app/keepers" "github.com/osmosis-labs/osmosis/v19/app/upgrades" ) @@ -34,6 +36,6 @@ func CreateUpgradeHandler( } func resetSuperfluidSumtree(keepers *keepers.AppKeepers, ctx sdk.Context, id uint64) { - // denom := gammtypes.GetPoolShareDenom(id) - // keepers.LockupKeeper.RebuildAccumulationStoreForDenom(ctx, denom) + denom := gammtypes.GetPoolShareDenom(id) + keepers.LockupKeeper.RebuildAccumulationStoreForDenom(ctx, denom) } diff --git a/x/lockup/keeper/lock.go b/x/lockup/keeper/lock.go index 7462626e62e..6378a070734 100644 --- a/x/lockup/keeper/lock.go +++ b/x/lockup/keeper/lock.go @@ -311,6 +311,10 @@ func (k Keeper) RebuildAccumulationStoreForDenom(ctx sdk.Context, denom string) k.writeDurationValuesToAccumTree(ctx, denom, mapDurationToAmount) } +func (k Keeper) RebuildSuperfluidAccumulationStoresForDenom(ctx sdk.Context, denom string) { + k.RebuildAccumulationStoreForDenom(ctx, denom) +} + func (k Keeper) ClearAccumulationStores(ctx sdk.Context) { k.clearKeysByPrefix(ctx, types.KeyPrefixLockAccumulation) } From dd1823b31c5eb112dfa45a90d0b15c9315adc536 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 27 Aug 2023 13:05:52 -0500 Subject: [PATCH 2/3] Synth denom --- app/upgrades/v19/upgrades.go | 2 +- x/lockup/keeper/lock.go | 30 +++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/app/upgrades/v19/upgrades.go b/app/upgrades/v19/upgrades.go index 10a19366101..09ac1d3c3e8 100644 --- a/app/upgrades/v19/upgrades.go +++ b/app/upgrades/v19/upgrades.go @@ -37,5 +37,5 @@ func CreateUpgradeHandler( func resetSuperfluidSumtree(keepers *keepers.AppKeepers, ctx sdk.Context, id uint64) { denom := gammtypes.GetPoolShareDenom(id) - keepers.LockupKeeper.RebuildAccumulationStoreForDenom(ctx, denom) + keepers.LockupKeeper.RebuildSuperfluidAccumulationStoresForDenom(ctx, denom) } diff --git a/x/lockup/keeper/lock.go b/x/lockup/keeper/lock.go index 6378a070734..7d6235d7d03 100644 --- a/x/lockup/keeper/lock.go +++ b/x/lockup/keeper/lock.go @@ -312,7 +312,35 @@ func (k Keeper) RebuildAccumulationStoreForDenom(ctx sdk.Context, denom string) } func (k Keeper) RebuildSuperfluidAccumulationStoresForDenom(ctx sdk.Context, denom string) { - k.RebuildAccumulationStoreForDenom(ctx, denom) + superfluidPrefix := denom + "/super" + superfluidStorePrefix := accumulationStorePrefix(superfluidPrefix) + k.clearKeysByPrefix(ctx, superfluidStorePrefix) + + accumulationStoreEntries := make(map[string]map[time.Duration]sdk.Int) + locks := k.GetLocksDenom(ctx, denom) + for _, lock := range locks { + synthLock, found, err := k.GetSyntheticLockupByUnderlyingLockId(ctx, lock.ID) + if err != nil || !found { + continue + } + + var curDurationMap map[time.Duration]sdk.Int + if durationMap, ok := accumulationStoreEntries[synthLock.SynthDenom]; ok { + curDurationMap = durationMap + } else { + curDurationMap = make(map[time.Duration]sdk.Int) + } + newAmt := lock.Coins.AmountOf(denom) + if curAmt, ok := curDurationMap[synthLock.Duration]; ok { + newAmt = newAmt.Add(curAmt) + } + curDurationMap[synthLock.Duration] = newAmt + accumulationStoreEntries[synthLock.SynthDenom] = curDurationMap + } + + for synthDenom, durationMap := range accumulationStoreEntries { + k.writeDurationValuesToAccumTree(ctx, synthDenom, durationMap) + } } func (k Keeper) ClearAccumulationStores(ctx sdk.Context) { From a39015d435b86006b1734e79f192a9146aac44e7 Mon Sep 17 00:00:00 2001 From: devbot-wizard <141283918+devbot-wizard@users.noreply.github.com> Date: Sun, 27 Aug 2023 21:58:44 +0000 Subject: [PATCH 3/3] update changelog --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 227dcac496b..ca7c450da58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,19 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### State Breaking + +### Bug Fixes +* [#6190](https://github.com/osmosis-labs/osmosis/pull/6190) v19 upgrade handler superfluid fix + +### Misc Improvements + +### Minor improvements & Bug Fixes + +### Security + ## v18.0.0 ### Misc Improvements