Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: multi-network upgrade handler #5959

Merged
merged 48 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
7ec3d77
multi-network upgrade handler
czarcas7ic Aug 4, 2023
3e0650a
run mainnet upgrade handler for e2e network IDs
czarcas7ic Aug 4, 2023
c697de2
fixes
czarcas7ic Aug 4, 2023
bbb644b
fix
czarcas7ic Aug 4, 2023
ab52240
widen tolerance
czarcas7ic Aug 4, 2023
da6324c
more resilient way to calculate coins used
czarcas7ic Aug 4, 2023
f849825
add logs to upgrade handler
czarcas7ic Aug 4, 2023
d70423c
scale error tolerance with spread factor
czarcas7ic Aug 4, 2023
7145a25
change back init tag
czarcas7ic Aug 4, 2023
146faa5
update changelog
devbot-wizard Aug 5, 2023
8049092
Merge branch 'main' into adam/multi-network-upgrade-handler
devbot-wizard Aug 5, 2023
7d7695b
Fix imports
devbot-wizard Aug 5, 2023
b334722
check liquidity prior to creating pool
czarcas7ic Aug 5, 2023
bdb5741
check base/quote rather than all denoms
czarcas7ic Aug 5, 2023
2d02cea
check if pool only has 2 assets
czarcas7ic Aug 6, 2023
a1f3bbe
skip pools that are already linked
czarcas7ic Aug 7, 2023
3a21bd5
add log and fix issue
czarcas7ic Aug 7, 2023
cbedf7a
add an additional log
czarcas7ic Aug 7, 2023
d0eba58
more logs
czarcas7ic Aug 7, 2023
1454538
more prints
czarcas7ic Aug 7, 2023
f04b9c8
skip if incentive gauge duration does not exist
czarcas7ic Aug 7, 2023
3ce1f41
use gogotypes
czarcas7ic Aug 7, 2023
9318fd8
use store.Has
czarcas7ic Aug 7, 2023
cf87cde
error instead of panic on getgaugeId from poolId
czarcas7ic Aug 7, 2023
b9f28f3
Update app/upgrades/v17/upgrades_test.go
czarcas7ic Aug 7, 2023
d793a36
remove extra prints
czarcas7ic Aug 7, 2023
7cdf2d3
Merge branch 'adam/multi-network-upgrade-handler' of https://github.c…
czarcas7ic Aug 7, 2023
68cd773
remove old logs
czarcas7ic Aug 7, 2023
1cfec91
Merge branch 'main' into adam/multi-network-upgrade-handler
czarcas7ic Aug 7, 2023
c8aa647
Merge branch 'main' into adam/multi-network-upgrade-handler
czarcas7ic Aug 7, 2023
449d9a2
enable superfluid assets both chains
czarcas7ic Aug 7, 2023
da5d1ee
remove unused func
czarcas7ic Aug 7, 2023
bedf1a5
setting the default ibc-hooks params
nicolaslara Aug 8, 2023
77616de
Merge branch 'main' into adam/multi-network-upgrade-handler
czarcas7ic Aug 8, 2023
0c2b1e7
separate method for enable superfluid for testnet
czarcas7ic Aug 8, 2023
34cff15
drastically simplify the upgrade handler
czarcas7ic Aug 8, 2023
1801232
check superfluid error type directly
czarcas7ic Aug 8, 2023
3cd0af5
remove use of pointer of coinsUsed and poolLinks
czarcas7ic Aug 8, 2023
168cece
Merge branch 'main' into adam/multi-network-upgrade-handler
czarcas7ic Aug 9, 2023
85abff8
Update app/upgrades/v17/upgrades.go
p0mvn Aug 9, 2023
27e07ca
Update app/upgrades/v17/upgrades.go
p0mvn Aug 9, 2023
d400d36
add spot price check when adding testnet assets
czarcas7ic Aug 9, 2023
2886d7a
fix osmo amount
czarcas7ic Aug 9, 2023
d778f12
add error check
czarcas7ic Aug 9, 2023
ecbb383
Merge branch 'main' into adam/multi-network-upgrade-handler
czarcas7ic Aug 9, 2023
5fdb415
add additional check from testnet to mainnet
czarcas7ic Aug 9, 2023
ffd220d
remove this check from mainnet handler
czarcas7ic Aug 9, 2023
4b63216
fix lingering merge conflict
czarcas7ic Aug 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [#5923] (https://github.com/osmosis-labs/osmosis/pull/5923) CL: Lower gas for initializing ticks
* [#5927] (https://github.com/osmosis-labs/osmosis/pull/5927) Add gas metering to x/tokenfactory trackBeforeSend hook
* [#5890](https://github.com/osmosis-labs/osmosis/pull/5890) feat: CreateCLPool & LinkCFMMtoCL pool into one gov-prop
* [#5959](https://github.com/osmosis-labs/osmosis/pull/5959) allow testing with different chain-id's in E2E testing
* [#5964](https://github.com/osmosis-labs/osmosis/pull/5964) fix e2e test concurrency bugs
* [#5948] (https://github.com/osmosis-labs/osmosis/pull/5948) Parameterizing Pool Type Information in Protorev

Expand Down
316 changes: 251 additions & 65 deletions app/upgrades/v17/upgrades.go

Large diffs are not rendered by default.

230 changes: 205 additions & 25 deletions app/upgrades/v17/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ import (
"github.com/osmosis-labs/osmosis/v17/app/keepers"
v17 "github.com/osmosis-labs/osmosis/v17/app/upgrades/v17"
cltypes "github.com/osmosis-labs/osmosis/v17/x/concentrated-liquidity/types"
poolManagerTypes "github.com/osmosis-labs/osmosis/v17/x/poolmanager/types"
poolmanagertypes "github.com/osmosis-labs/osmosis/v17/x/poolmanager/types"
superfluidtypes "github.com/osmosis-labs/osmosis/v17/x/superfluid/types"
)

type UpgradeTestSuite struct {
Expand Down Expand Up @@ -74,7 +76,7 @@ func (suite *UpgradeTestSuite) TestUpgrade() {
upgrade func(sdk.Context, *keepers.AppKeepers, sdk.Coins, uint64)
}{
{
"Test that the upgrade succeeds",
"Test that the upgrade succeeds: mainnet",
func(ctx sdk.Context, keepers *keepers.AppKeepers) (sdk.Coins, uint64) {
upgradeSetup()

Expand Down Expand Up @@ -102,24 +104,23 @@ func (suite *UpgradeTestSuite) TestUpgrade() {

// Now create the pool with the correct pool ID.
poolCoins := sdk.NewCoins(sdk.NewCoin(assetPair.BaseAsset, sdk.NewInt(10000000000)), sdk.NewCoin(v17.QuoteAsset, sdk.NewInt(10000000000)))
poolId := suite.PrepareBalancerPoolWithCoins(poolCoins...)
suite.PrepareBalancerPoolWithCoins(poolCoins...)

// Send two of the base asset to the community pool.
twoBaseAsset := sdk.NewCoins(sdk.NewCoin(assetPair.BaseAsset, sdk.NewInt(2000000)))
suite.FundAcc(suite.TestAccs[0], twoBaseAsset)
// 0.1 OSMO used to get the respective base asset amount, 0.1 OSMO used to create the position
osmoIn := sdk.NewCoin(v17.QuoteAsset, sdk.NewInt(100000).MulRaw(2))

err := suite.App.DistrKeeper.FundCommunityPool(suite.Ctx, twoBaseAsset, suite.TestAccs[0])
suite.Require().NoError(err)

// Determine approx how much baseAsset will be used from community pool when 1 OSMO used.
oneOsmo := sdk.NewCoin(v17.QuoteAsset, sdk.NewInt(1000000))
pool, err := suite.App.PoolManagerKeeper.GetPool(suite.Ctx, poolId)
suite.Require().NoError(err)
respectiveBaseAsset, err := suite.App.GAMMKeeper.CalcOutAmtGivenIn(suite.Ctx, pool, oneOsmo, assetPair.BaseAsset, sdk.ZeroDec())
suite.Require().NoError(err)
// Add the amount of osmo that will be used to the expectedCoinsUsedInUpgradeHandler.
expectedCoinsUsedInUpgradeHandler = expectedCoinsUsedInUpgradeHandler.Add(osmoIn)

// Add the amount of baseAsset that will be used to the expectedCoinsUsedInUpgradeHandler.
expectedCoinsUsedInUpgradeHandler = expectedCoinsUsedInUpgradeHandler.Add(respectiveBaseAsset)
// Enable the GAMM pool for superfluid if the record says so.
if assetPair.Superfluid {
poolShareDenom := fmt.Sprintf("gamm/pool/%d", assetPair.LinkedClassicPool)
superfluidAsset := superfluidtypes.SuperfluidAsset{
Denom: poolShareDenom,
AssetType: superfluidtypes.SuperfluidAssetTypeLPShare,
}
suite.App.SuperfluidKeeper.SetSuperfluidAsset(suite.Ctx, superfluidAsset)
}

// Update the lastPoolID to the current pool ID.
lastPoolID = poolID
Expand All @@ -137,6 +138,8 @@ func (suite *UpgradeTestSuite) TestUpgrade() {
communityPoolAddress := suite.App.AccountKeeper.GetModuleAddress(distrtypes.ModuleName)
communityPoolBalancePre := suite.App.BankKeeper.GetAllBalances(suite.Ctx, communityPoolAddress)

numPoolPreUpgrade := suite.App.PoolManagerKeeper.GetNextPoolId(suite.Ctx) - 1

// Run upgrade handler.
dummyUpgrade(suite)
suite.Require().NotPanics(func() {
Expand All @@ -150,12 +153,6 @@ func (suite *UpgradeTestSuite) TestUpgrade() {
assetPairs := v17.InitializeAssetPairs(ctx, keepers)

for i, assetPair := range assetPairs {
// Validate that the community pool balance has been reduced by the amount of baseAsset that was used to create the pool.
suite.Require().Equal(communityPoolBalancePre.AmountOf(assetPair.BaseAsset).Sub(expectedCoinsUsedInUpgradeHandler.AmountOf(assetPair.BaseAsset)).String(), communityPoolBalancePost.AmountOf(assetPair.BaseAsset).String())

// Validate that the fee pool community pool balance has been decreased by the amount of baseAsset that was used to create the pool.
suite.Require().Equal(communityPoolBalancePost.AmountOf(assetPair.BaseAsset).String(), feePoolCommunityPoolPost.AmountOf(assetPair.BaseAsset).TruncateInt().String())

// Get balancer pool's spot price.
balancerSpotPrice, err := suite.App.GAMMKeeper.CalculateSpotPrice(suite.Ctx, assetPair.LinkedClassicPool, v17.QuoteAsset, assetPair.BaseAsset)
suite.Require().NoError(err)
Expand Down Expand Up @@ -192,9 +189,16 @@ func (suite *UpgradeTestSuite) TestUpgrade() {
lastPoolID++
}

// Check osmo balance (was used in every pool creation)
suite.Require().Equal(0, multiplicativeTolerance.Compare(communityPoolBalancePre.AmountOf(v17.QuoteAsset), communityPoolBalancePost.AmountOf(v17.QuoteAsset).Sub(expectedCoinsUsedInUpgradeHandler.AmountOf(v17.QuoteAsset))))
suite.Require().Equal(communityPoolBalancePost.AmountOf(v17.QuoteAsset).String(), feePoolCommunityPoolPost.AmountOf(v17.QuoteAsset).TruncateInt().String())
// Validate that the community pool balance has been reduced by the amount of osmo that was used to create the pool.
suite.Require().Equal(communityPoolBalancePre.Sub(expectedCoinsUsedInUpgradeHandler).String(), communityPoolBalancePost.String())

// Validate that the fee pool community pool balance has been decreased by the amount of osmo that was used to create the pool.
suite.Require().Equal(sdk.NewDecCoinsFromCoins(communityPoolBalancePost...).String(), feePoolCommunityPoolPost.String())

numPoolPostUpgrade := suite.App.PoolManagerKeeper.GetNextPoolId(suite.Ctx) - 1

// Number of pools created should be equal to the number of records in the asset pairs.
suite.Require().Equal(len(assetPairs), int(numPoolPostUpgrade-numPoolPreUpgrade))

// Validate that all links were created.
migrationInfo, err := suite.App.GAMMKeeper.GetAllMigrationInfo(suite.Ctx)
Expand All @@ -203,6 +207,182 @@ func (suite *UpgradeTestSuite) TestUpgrade() {

},
},
{
"Test that the upgrade succeeds: testnet",
func(ctx sdk.Context, keepers *keepers.AppKeepers) (sdk.Coins, uint64) {
upgradeSetup()
suite.Ctx = suite.Ctx.WithChainID("osmo-test-5")

var lastPoolID uint64 // To keep track of the last assigned pool ID

sort.Sort(ByLinkedClassicPool(v17.AssetPairsForTestsOnly))
sort.Sort(ByLinkedClassicPool(v17.AssetPairs))

expectedCoinsUsedInUpgradeHandler := sdk.NewCoins()

// Create earlier pools or dummy pools if needed
for _, assetPair := range v17.AssetPairsForTestsOnly {
poolID := assetPair.LinkedClassicPool

// For testnet, we create a CL pool for ANY balancer pool.
// The only thing we use the assetPair list here for to select some pools to enable superfluid for.
for lastPoolID+1 < poolID {
poolCoins := sdk.NewCoins(sdk.NewCoin(assetPair.BaseAsset, sdk.NewInt(10000000000)), sdk.NewCoin(v17.QuoteAsset, sdk.NewInt(10000000000)))
suite.PrepareBalancerPoolWithCoins(poolCoins...)

// 0.1 OSMO used to get the respective base asset amount, 0.1 OSMO used to create the position
osmoIn := sdk.NewCoin(v17.QuoteAsset, sdk.NewInt(100000).MulRaw(2))

// Add the amount of osmo that will be used to the expectedCoinsUsedInUpgradeHandler.
expectedCoinsUsedInUpgradeHandler = expectedCoinsUsedInUpgradeHandler.Add(osmoIn)

lastPoolID++
}

// Enable the GAMM pool for superfluid if the asset pair is marked as superfluid.
if assetPair.Superfluid {
poolShareDenom := fmt.Sprintf("gamm/pool/%d", assetPair.LinkedClassicPool)
superfluidAsset := superfluidtypes.SuperfluidAsset{
Denom: poolShareDenom,
AssetType: superfluidtypes.SuperfluidAssetTypeLPShare,
}
suite.App.SuperfluidKeeper.SetSuperfluidAsset(suite.Ctx, superfluidAsset)
}
}

// We now create various pools that are not balancer pools.
// This is to test if the testnet upgrade handler properly handles pools that are not of type balancer (i.e. should ignore them and move on).

// Stableswap pool
suite.CreatePoolFromType(poolmanagertypes.Stableswap)
// Cosmwasm pool
suite.CreatePoolFromType(poolmanagertypes.CosmWasm)
// CL pool
suite.CreatePoolFromType(poolmanagertypes.Concentrated)

lastPoolID += 3

return expectedCoinsUsedInUpgradeHandler, lastPoolID

},
func(ctx sdk.Context, keepers *keepers.AppKeepers, expectedCoinsUsedInUpgradeHandler sdk.Coins, lastPoolID uint64) {
stakingParams := suite.App.StakingKeeper.GetParams(suite.Ctx)
stakingParams.BondDenom = "uosmo"
suite.App.StakingKeeper.SetParams(suite.Ctx, stakingParams)

// Retrieve the community pool balance before the upgrade
communityPoolAddress := suite.App.AccountKeeper.GetModuleAddress(distrtypes.ModuleName)
communityPoolBalancePre := suite.App.BankKeeper.GetAllBalances(suite.Ctx, communityPoolAddress)

numPoolPreUpgrade := suite.App.PoolManagerKeeper.GetNextPoolId(suite.Ctx) - 1

gammPoolsPreUpgrade, err := suite.App.GAMMKeeper.GetPools(suite.Ctx)
suite.Require().NoError(err)

// Run upgrade handler.
dummyUpgrade(suite)
suite.Require().NotPanics(func() {
suite.App.BeginBlocker(suite.Ctx, abci.RequestBeginBlock{})
})

// Retrieve the community pool balance (and the feePool balance) after the upgrade
communityPoolBalancePost := suite.App.BankKeeper.GetAllBalances(suite.Ctx, communityPoolAddress)
feePoolCommunityPoolPost := suite.App.DistrKeeper.GetFeePool(suite.Ctx).CommunityPool

indexOffset := int(0)
assetListIndex := int(0)

// For testnet, we run through all gamm pools (not just the asset list)
for i, pool := range gammPoolsPreUpgrade {
// Skip pools that are not balancer pools
if pool.GetType() != poolManagerTypes.Balancer {
indexOffset++
continue
}

gammPoolId := pool.GetId()
cfmmPool, err := keepers.GAMMKeeper.GetCFMMPool(ctx, gammPoolId)
suite.Require().NoError(err)

poolCoins := cfmmPool.GetTotalPoolLiquidity(ctx)

// Retrieve quoteAsset and baseAsset from the poolCoins
quoteAsset, baseAsset := "", ""
for _, coin := range poolCoins {
if coin.Denom == v17.QuoteAsset {
quoteAsset = coin.Denom
} else {
baseAsset = coin.Denom
}
}
if quoteAsset == "" || baseAsset == "" {
indexOffset++
continue
}

// Get balancer pool's spot price.
balancerSpotPrice, err := suite.App.GAMMKeeper.CalculateSpotPrice(suite.Ctx, gammPoolId, v17.QuoteAsset, baseAsset)
suite.Require().NoError(err)

// Validate CL pool was created.
concentratedPool, err := suite.App.PoolManagerKeeper.GetPool(suite.Ctx, lastPoolID+1)
suite.Require().NoError(err)
suite.Require().Equal(poolmanagertypes.Concentrated, concentratedPool.GetType())

// Validate that denom0 and denom1 were set correctly
concentratedTypePool, ok := concentratedPool.(cltypes.ConcentratedPoolExtension)
suite.Require().True(ok)
suite.Require().Equal(baseAsset, concentratedTypePool.GetToken0())
suite.Require().Equal(v17.QuoteAsset, concentratedTypePool.GetToken1())

// Validate that the spot price of the CL pool is what we expect
suite.Require().Equal(0, multiplicativeTolerance.CompareBigDec(concentratedTypePool.GetCurrentSqrtPrice().PowerInteger(2), osmomath.BigDecFromSDKDec(balancerSpotPrice)))

// Validate that the link is correct.
migrationInfo, err := suite.App.GAMMKeeper.GetAllMigrationInfo(suite.Ctx)
link := migrationInfo.BalancerToConcentratedPoolLinks[i-indexOffset]
suite.Require().Equal(gammPoolId, link.BalancerPoolId)
suite.Require().Equal(concentratedPool.GetId(), link.ClPoolId)

// Validate the sfs status.
// If the poolId matches a poolId on that asset list that had superfluid enabled, this pool should also be superfluid enabled.
// Otherwise, it should not be superfluid enabled.
assetListPoolId := v17.AssetPairsForTestsOnly[assetListIndex].LinkedClassicPool
clPoolDenom := cltypes.GetConcentratedLockupDenomFromPoolId(concentratedPool.GetId())
_, err = suite.App.SuperfluidKeeper.GetSuperfluidAsset(suite.Ctx, clPoolDenom)
if assetListPoolId == gammPoolId {
suite.Require().NoError(err)
assetListIndex++
for assetListIndex < len(v17.AssetPairsForTestsOnly)-1 && v17.AssetPairsForTestsOnly[assetListIndex].Superfluid == false {
assetListIndex++
}
} else {
suite.Require().Error(err)
}

lastPoolID++
}

// Validate that the community pool balance has been reduced by the amount of osmo that was used to create the pool.
suite.Require().Equal(communityPoolBalancePre.Sub(expectedCoinsUsedInUpgradeHandler).String(), communityPoolBalancePost.String())

// Validate that the fee pool community pool balance has been decreased by the amount of osmo that was used to create the pool.
suite.Require().Equal(sdk.NewDecCoinsFromCoins(communityPoolBalancePost...).String(), feePoolCommunityPoolPost.String())

numPoolPostUpgrade := suite.App.PoolManagerKeeper.GetNextPoolId(suite.Ctx) - 1
numPoolsCreated := numPoolPostUpgrade - numPoolPreUpgrade

// Number of pools created should be equal to the number of pools preUpgrade minus the number of pools that were not eligible for migration.
numPoolsEligibleForMigration := numPoolPreUpgrade - 3
suite.Require().Equal(int(numPoolsEligibleForMigration), int(numPoolsCreated))

// Validate that all links were created.
migrationInfo, err := suite.App.GAMMKeeper.GetAllMigrationInfo(suite.Ctx)
suite.Require().Equal(int(numPoolsEligibleForMigration), len(migrationInfo.BalancerToConcentratedPoolLinks))
suite.Require().NoError(err)

},
},
{
"Fails because CFMM pool is not found",
func(ctx sdk.Context, keepers *keepers.AppKeepers) (sdk.Coins, uint64) {
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/configurer/chain/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ func (n *NodeConfig) SendIBC(srcChain, dstChain *Config, recipient string, token

return balancePost.Amount.Equal(balancePre.Amount.Add(token.Amount))
},
2*time.Minute,
3*time.Minute,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to reviewer: This is a drive by "fix". It became apparent to me that some packets get stuck, so a minute at times in not enough to wait for the result on the receiving chain.

10*time.Millisecond,
"tx not received on destination chain",
)
Expand Down
24 changes: 1 addition & 23 deletions tests/e2e/configurer/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,27 +143,17 @@ func (uc *UpgradeConfigurer) CreatePreUpgradeState() error {

v17SuperfluidAssets := v17GetSuperfluidAssets()

wg.Add(4)
wg.Add(2)

// Chain A

go func() {
defer wg.Done()
chainANode.FundCommunityPool(initialization.ValidatorWalletName, strAllUpgradeBaseDenoms())
}()

go func() {
defer wg.Done()
chainANode.EnableSuperfluidAsset(chainA, v17SuperfluidAssets)
}()

// Chain B

go func() {
defer wg.Done()
chainBNode.FundCommunityPool(initialization.ValidatorWalletName, strAllUpgradeBaseDenoms())
}()

go func() {
defer wg.Done()
chainBNode.EnableSuperfluidAsset(chainB, v17SuperfluidAssets)
Expand Down Expand Up @@ -452,18 +442,6 @@ func (uc *UpgradeConfigurer) upgradeContainers(chainConfig *chain.Config, propHe

// START: CAN REMOVE POST v17 UPGRADE

func strAllUpgradeBaseDenoms() string {
upgradeBaseDenoms := ""
n := len(v17.AssetPairsForTestsOnly)
for i, assetPair := range v17.AssetPairsForTestsOnly {
upgradeBaseDenoms += "2000000" + assetPair.BaseAsset
if i < n-1 { // Check if it's not the last iteration
upgradeBaseDenoms += ","
}
}
return upgradeBaseDenoms
}

func v17GetSuperfluidAssets() string {
assets := ""
for _, assetPair := range v17.AssetPairsForTestsOnly {
Expand Down
6 changes: 4 additions & 2 deletions tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1829,9 +1829,11 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity_CanonicalPools() {
expectedSpotPrice, err := balancerPool.SpotPrice(sdk.Context{}, v17.QuoteAsset, assetPair.BaseAsset)
s.Require().NoError(err)

// Allow 0.1% margin of error.
// Margin of error should be slightly larger than the gamm pool's spread factor, as the gamm pool is used to
// swap through when creating the initial position. The below implies a 0.1% margin of error.
tollerance := expectedSpreadFactor.Add(sdk.MustNewDecFromStr("0.0001"))
multiplicativeTolerance := osmomath.ErrTolerance{
MultiplicativeTolerance: sdk.MustNewDecFromStr("0.001"),
MultiplicativeTolerance: tollerance,
}

s.Require().Equal(0, multiplicativeTolerance.CompareBigDec(osmomath.BigDecFromSDKDec(expectedSpotPrice), concentratedPool.GetCurrentSqrtPrice().PowerInteger(2)))
Expand Down
4 changes: 2 additions & 2 deletions x/gamm/keeper/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ func (s *KeeperTestSuite) TestCreateConcentratedPoolFromCFMM() {
poolLiquidity: sdk.NewCoins(desiredDenom0Coin, daiCoin),
cfmmPoolIdToLinkWith: validPoolId,
desiredDenom0: USDCIBCDenom,
expectError: types.NoDesiredDenomInPoolError{USDCIBCDenom},
expectError: types.NoDesiredDenomInPoolError{DesiredDenom: USDCIBCDenom},
},
"error: pool with 3 assets, must have two": {
poolLiquidity: sdk.NewCoins(desiredDenom0Coin, daiCoin, usdcCoin),
Expand Down Expand Up @@ -1124,7 +1124,7 @@ func (s *KeeperTestSuite) TestCreateCanonicalConcentratedLiquidityPoolAndMigrati
poolLiquidity: sdk.NewCoins(desiredDenom0Coin, daiCoin),
cfmmPoolIdToLinkWith: validPoolId,
desiredDenom0: USDCIBCDenom,
expectError: types.NoDesiredDenomInPoolError{USDCIBCDenom},
expectError: types.NoDesiredDenomInPoolError{DesiredDenom: USDCIBCDenom},
},
"error: pool with 3 assets, must have two": {
poolLiquidity: sdk.NewCoins(desiredDenom0Coin, daiCoin, usdcCoin),
Expand Down
7 changes: 4 additions & 3 deletions x/pool-incentives/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,14 @@ func (k Keeper) GetPoolGaugeId(ctx sdk.Context, poolId uint64, lockableDuration

key := types.GetPoolGaugeIdInternalStoreKey(poolId, lockableDuration)
store := ctx.KVStore(k.storeKey)
bz := store.Get(key)

if len(bz) == 0 {
if !store.Has(key) {
return 0, types.NoGaugeAssociatedWithPoolError{PoolId: poolId, Duration: lockableDuration}
}

return sdk.BigEndianToUint64(bz), nil
bz := store.Get(key)
gaugeId := sdk.BigEndianToUint64(bz)
return gaugeId, nil
}

// GetNoLockGaugeIdsFromPool returns all the NoLock gauge ids associated with the pool id.
Expand Down