Skip to content

Commit

Permalink
auto: code-gen upgrade handler v17 (osmosis-labs#5881)
Browse files Browse the repository at this point in the history
* [create-pull-request] automated change

* remove no longer needed v16 specific e2e test

---------

Co-authored-by: czarcas7ic <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
  • Loading branch information
3 people authored Jul 24, 2023
1 parent ccd779d commit 4aeaaa5
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"OSMOSIS_E2E_SKIP_UPGRADE": "true",
"OSMOSIS_E2E_SKIP_CLEANUP": "true",
"OSMOSIS_E2E_SKIP_STATE_SYNC": "true",
"OSMOSIS_E2E_UPGRADE_VERSION": "v16",
"OSMOSIS_E2E_UPGRADE_VERSION": "v17",
"OSMOSIS_E2E_DEBUG_LOG": "false",
},
"preLaunchTask": "e2e-setup"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ GO_VERSION := $(shell cat go.mod | grep -E 'go [0-9].[0-9]+' | cut -d ' ' -f 2)
GO_MODULE := $(shell cat go.mod | grep "module " | cut -d ' ' -f 2)
BUILDDIR ?= $(CURDIR)/build
DOCKER := $(shell which docker)
E2E_UPGRADE_VERSION := "v16"
E2E_UPGRADE_VERSION := "v17"


GO_MAJOR_VERSION = $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1)
Expand Down
3 changes: 2 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import (
v14 "github.com/osmosis-labs/osmosis/v16/app/upgrades/v14"
v15 "github.com/osmosis-labs/osmosis/v16/app/upgrades/v15"
v16 "github.com/osmosis-labs/osmosis/v16/app/upgrades/v16"
v17 "github.com/osmosis-labs/osmosis/v16/app/upgrades/v17"
v3 "github.com/osmosis-labs/osmosis/v16/app/upgrades/v3"
v4 "github.com/osmosis-labs/osmosis/v16/app/upgrades/v4"
v5 "github.com/osmosis-labs/osmosis/v16/app/upgrades/v5"
Expand Down Expand Up @@ -102,7 +103,7 @@ var (

// _ sdksimapp.App = (*OsmosisApp)(nil)

Upgrades = []upgrades.Upgrade{v4.Upgrade, v5.Upgrade, v7.Upgrade, v9.Upgrade, v11.Upgrade, v12.Upgrade, v13.Upgrade, v14.Upgrade, v15.Upgrade, v16.Upgrade}
Upgrades = []upgrades.Upgrade{v4.Upgrade, v5.Upgrade, v7.Upgrade, v9.Upgrade, v11.Upgrade, v12.Upgrade, v13.Upgrade, v14.Upgrade, v15.Upgrade, v16.Upgrade, v17.Upgrade}
Forks = []upgrades.Fork{v3.Fork, v6.Fork, v8.Fork, v10.Fork}
)

Expand Down
2 changes: 1 addition & 1 deletion app/upgrades/v16/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const (
// We want quote asset to be DAI so that when the limit orders on ticks
// are implemented, we have tick spacing in terms of DAI as the quote.
DesiredDenom0 = "uosmo"
TickSpacing = 100
TickSpacing = 100

// isPermissionlessPoolCreationEnabledCL is a boolean that determines if
// concentrated liquidity pools can be created via message. At launch,
Expand Down
19 changes: 19 additions & 0 deletions app/upgrades/v17/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package v17

import (
"github.com/osmosis-labs/osmosis/v16/app/upgrades"

store "github.com/cosmos/cosmos-sdk/store/types"
)

// UpgradeName defines the on-chain upgrade name for the Osmosis v17 upgrade.
const UpgradeName = "v17"

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{
Added: []string{},
Deleted: []string{},
},
}
28 changes: 28 additions & 0 deletions app/upgrades/v17/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package v17

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/osmosis-labs/osmosis/v16/app/keepers"
"github.com/osmosis-labs/osmosis/v16/app/upgrades"
)

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
bpm upgrades.BaseAppParamManager,
keepers *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// Run migrations before applying any other state changes.
// NOTE: DO NOT PUT ANY STATE CHANGES BEFORE RunMigrations().
migrations, err := mm.RunMigrations(ctx, configurator, fromVM)
if err != nil {
return nil, err
}

return migrations, nil
}
}
4 changes: 2 additions & 2 deletions tests/e2e/containers/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ const (
// It should be uploaded to Docker Hub. OSMOSIS_E2E_SKIP_UPGRADE should be unset
// for this functionality to be used.
previousVersionOsmoRepository = "osmolabs/osmosis-dev"
previousVersionOsmoTag = "v15.x-9fa047c2-1687827963"
previousVersionOsmoTag = "16.0"
// Pre-upgrade repo/tag for osmosis initialization (this should be one version below upgradeVersion)
previousVersionInitRepository = "osmolabs/osmosis-e2e-init-chain"
previousVersionInitTag = "v15-fast-vote"
previousVersionInitTag = "16.1.0"
// Hermes repo/version for relayer
relayerRepository = "informalsystems/hermes"
relayerTag = "1.5.1"
Expand Down
64 changes: 0 additions & 64 deletions tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (

"github.com/osmosis-labs/osmosis/osmoutils/osmoassert"
appparams "github.com/osmosis-labs/osmosis/v16/app/params"
v16 "github.com/osmosis-labs/osmosis/v16/app/upgrades/v16"
"github.com/osmosis-labs/osmosis/v16/tests/e2e/configurer/chain"
"github.com/osmosis-labs/osmosis/v16/tests/e2e/configurer/config"
"github.com/osmosis-labs/osmosis/v16/tests/e2e/initialization"
Expand Down Expand Up @@ -127,15 +126,6 @@ func (s *IntegrationTestSuite) TestAllE2E() {
})
}

if s.skipUpgrade {
s.T().Skip("Skipping ConcentratedLiquidity_CanonicalPool_And_Parameters test")
} else {
s.T().Run("ConcentratedLiquidity_CanonicalPool_And_Parameters", func(t *testing.T) {
t.Parallel()
s.ConcentratedLiquidity_CanonicalPool_And_Parameters()
})
}

// IBC Dependent Tests

if s.skipIBC {
Expand Down Expand Up @@ -1753,57 +1743,3 @@ func (s *IntegrationTestSuite) GeometricTWAP() {
// quote assset supply / base asset supply = 1_000_000 / 2_000_000 = 0.5
osmoassert.DecApproxEq(s.T(), sdk.NewDecWithPrec(5, 1), afterSwapTwapBOverA, sdk.NewDecWithPrec(1, 2))
}

// Tests that v16 upgrade correctly creates the canonical OSMO-DAI pool in the upgrade.
// Prefixed with "A" to run before TestConcentratedLiquidity that resets the pool creation
// parameter.
func (s *IntegrationTestSuite) ConcentratedLiquidity_CanonicalPool_And_Parameters() {
if s.skipUpgrade {
s.T().Skip("Skipping v16 canonical pool creation test because upgrade is not enabled")
}

expectedSpreadReward := sdk.MustNewDecFromStr("0.002")

_, chainANode := s.getChainACfgs()

// Taken from: https://app.osmosis.zone/pool/674
concentratedPoolId := chainANode.QueryConcentratedPooIdLinkFromCFMM(config.DaiOsmoPoolIdv16)

concentratedPool := s.updatedConcentratedPool(chainANode, concentratedPoolId)

s.Require().Equal(poolmanagertypes.Concentrated, concentratedPool.GetType())
s.Require().Equal(v16.DesiredDenom0, concentratedPool.GetToken0())
s.Require().Equal(v16.DAIIBCDenom, concentratedPool.GetToken1())
s.Require().Equal(uint64(v16.TickSpacing), concentratedPool.GetTickSpacing())
s.Require().Equal(expectedSpreadReward.String(), concentratedPool.GetSpreadFactor(sdk.Context{}).String())

// Check that the cl pool denom is now an authorized superfluid denom.
superfluidAssets := chainANode.QueryAllSuperfluidAssets()

found := false
for _, superfluidAsset := range superfluidAssets {
if superfluidAsset.Denom == cltypes.GetConcentratedLockupDenomFromPoolId(concentratedPoolId) {
found = true
break
}
}

s.Require().True(found, "concentrated liquidity pool denom not found in superfluid assets")

// Check that the community pool module account possesses a position
communityPoolAddress := chainANode.QueryCommunityPoolModuleAccount()
positions := chainANode.QueryConcentratedPositions(communityPoolAddress)
s.Require().Len(positions, 1)

// This spot price is taken from the balancer pool that was initiated pre upgrade.
balancerDaiOsmoPool := s.updatedCFMMPool(chainANode, config.DaiOsmoPoolIdv16)
expectedSpotPrice, err := balancerDaiOsmoPool.SpotPrice(sdk.Context{}, v16.DAIIBCDenom, v16.DesiredDenom0)
s.Require().NoError(err)

// Allow 0.01% margin of error.
multiplicativeTolerance := osmomath.ErrTolerance{
MultiplicativeTolerance: sdk.MustNewDecFromStr("0.0001"),
}

s.Require().Equal(0, multiplicativeTolerance.CompareBigDec(osmomath.BigDecFromSDKDec(expectedSpotPrice), concentratedPool.GetCurrentSqrtPrice().PowerInteger(2)))
}

0 comments on commit 4aeaaa5

Please sign in to comment.