Skip to content

Commit

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

* fix e2e

---------

Co-authored-by: czarcas7ic <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
  • Loading branch information
3 people authored Dec 31, 2023
1 parent c5a5147 commit c92bf8b
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"OSMOSIS_E2E_SKIP_UPGRADE": "false",
"OSMOSIS_E2E_SKIP_CLEANUP": "true",
"OSMOSIS_E2E_SKIP_STATE_SYNC": "true",
"OSMOSIS_E2E_UPGRADE_VERSION": "v21",
"OSMOSIS_E2E_UPGRADE_VERSION": "v22",
"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 @@ -40,7 +40,7 @@ LEDGER_ENABLED ?= true
SDK_PACK := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's/ /\@/g')
BUILDDIR ?= $(CURDIR)/build
DOCKER := $(shell which docker)
E2E_UPGRADE_VERSION := "v21"
E2E_UPGRADE_VERSION := "v22"
#SHELL := /bin/bash

# Go version to be used in docker images
Expand Down
3 changes: 2 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ import (
v19 "github.com/osmosis-labs/osmosis/v21/app/upgrades/v19"
v20 "github.com/osmosis-labs/osmosis/v21/app/upgrades/v20"
v21 "github.com/osmosis-labs/osmosis/v21/app/upgrades/v21"
v22 "github.com/osmosis-labs/osmosis/v21/app/upgrades/v22"
v3 "github.com/osmosis-labs/osmosis/v21/app/upgrades/v3"
v4 "github.com/osmosis-labs/osmosis/v21/app/upgrades/v4"
v5 "github.com/osmosis-labs/osmosis/v21/app/upgrades/v5"
Expand Down Expand Up @@ -136,7 +137,7 @@ var (

_ runtime.AppI = (*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, v17.Upgrade, v18.Upgrade, v19.Upgrade, v20.Upgrade, v21.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, v18.Upgrade, v19.Upgrade, v20.Upgrade, v21.Upgrade, v22.Upgrade}
Forks = []upgrades.Fork{v3.Fork, v6.Fork, v8.Fork, v10.Fork}
)

Expand Down
19 changes: 19 additions & 0 deletions app/upgrades/v22/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package v22

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

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

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

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

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/v21/app/keepers"
"github.com/osmosis-labs/osmosis/v21/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
}
}
5 changes: 5 additions & 0 deletions scripts/makefiles/tests.mk
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,17 @@ test-sim-bench:
# Utilizes Go cache.
test-e2e: e2e-setup test-e2e-ci e2e-remove-resources

test-e2e-no-cleanup: e2e-setup test-e2e-ci-no-cleanup

# test-e2e-ci runs a majority of e2e tests, only skipping the ones that are marked as scheduled tests
# does not do any validation about the state of the Docker environment
# As a result, avoid using this locally.
test-e2e-ci:
@VERSION=$(VERSION) OSMOSIS_E2E=True OSMOSIS_E2E_DEBUG_LOG=False OSMOSIS_E2E_UPGRADE_VERSION=$(E2E_UPGRADE_VERSION) go test -mod=readonly -timeout=25m -v $(PACKAGES_E2E) -p 4

test-e2e-ci-no-cleanup:
@VERSION=$(VERSION) OSMOSIS_E2E=True OSMOSIS_E2E_DEBUG_LOG=False OSMOSIS_E2E_SKIP_CLEANUP=True OSMOSIS_E2E_UPGRADE_VERSION=$(E2E_UPGRADE_VERSION) go test -mod=readonly -timeout=25m -v $(PACKAGES_E2E) -p 4

# test-e2e-ci-scheduled runs every e2e test available, and is only run on a scheduled basis
test-e2e-ci-scheduled:
@VERSION=$(VERSION) OSMOSIS_E2E_SCHEDULED=True OSMOSIS_E2E=True OSMOSIS_E2E_DEBUG_LOG=False OSMOSIS_E2E_UPGRADE_VERSION=$(E2E_UPGRADE_VERSION) go test -mod=readonly -timeout=25m -v $(PACKAGES_E2E) -p 4
Expand Down
16 changes: 3 additions & 13 deletions tests/e2e/configurer/chain/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,22 +344,12 @@ func (n *NodeConfig) SubmitProposal(cmdArgs []string, isExpedited bool, propDesc
}

func (n *NodeConfig) SubmitUpgradeProposal(upgradeVersion string, upgradeHeight int64, initialDeposit sdk.Coin, isLegacy bool) int {
var cmd []string
if isLegacy {
cmd = []string{"software-upgrade", upgradeVersion, fmt.Sprintf("--title=\"%s upgrade\"", upgradeVersion), "--summary=\"upgrade proposal submission\"", fmt.Sprintf("--upgrade-height=%d", upgradeHeight), "--upgrade-info=\"\"", "--from=val"}
} else {
cmd = []string{"software-upgrade", upgradeVersion, fmt.Sprintf("--title=\"%s upgrade\"", upgradeVersion), "--description=\"upgrade proposal submission\"", fmt.Sprintf("--upgrade-height=%d", upgradeHeight), "--upgrade-info=\"\"", "--from=val"}
}
return n.SubmitProposal(cmd, false, fmt.Sprintf("upgrade proposal %s for height %d", upgradeVersion, upgradeHeight), isLegacy)
cmd := []string{"software-upgrade", upgradeVersion, fmt.Sprintf("--title=\"%s upgrade\"", upgradeVersion), "--description=\"upgrade proposal submission\"", fmt.Sprintf("--upgrade-height=%d", upgradeHeight), "--upgrade-info=\"\"", "--no-validate", "--from=val"}
return n.SubmitProposal(cmd, false, fmt.Sprintf("upgrade proposal %s for height %d", upgradeVersion, upgradeHeight), true)
}

func (n *NodeConfig) SubmitSuperfluidProposal(asset string, isLegacy bool) int {
var cmd []string
if isLegacy {
cmd = []string{"set-superfluid-assets-proposal", fmt.Sprintf("--superfluid-assets=%s", asset), "--title=\"superfluid asset prop\"", fmt.Sprintf("--summary=\"%s superfluid asset\"", asset), "--from=val", "--gas=700000", "--fees=5000uosmo"}
} else {
cmd = []string{"set-superfluid-assets-proposal", fmt.Sprintf("--superfluid-assets=%s", asset), "--title=\"superfluid asset prop\"", fmt.Sprintf("--description=\"%s superfluid asset\"", asset), "--from=val", "--gas=700000", "--fees=5000uosmo"}
}
cmd := []string{"set-superfluid-assets-proposal", fmt.Sprintf("--superfluid-assets=%s", asset), "--title=\"superfluid asset prop\"", fmt.Sprintf("--summary=\"%s superfluid asset\"", asset), "--from=val", "--gas=700000", "--fees=5000uosmo"}

// TODO: no expedited flag for some reason
return n.SubmitProposal(cmd, false, fmt.Sprintf("superfluid proposal for asset %s", asset), isLegacy)
Expand Down
10 changes: 5 additions & 5 deletions tests/e2e/configurer/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (uc *UpgradeConfigurer) CreatePreUpgradeState() error {
defer wg.Done()
preUpgradePoolId[0] = chainANode.CreateBalancerPool("pool1A.json", initialization.ValidatorWalletName)
poolShareDenom[0] = fmt.Sprintf("gamm/pool/%d", preUpgradePoolId[0])
chainANode.EnableSuperfluidAsset(chainA, poolShareDenom[0], false)
chainANode.EnableSuperfluidAsset(chainA, poolShareDenom[0], true)
}()

go func() {
Expand All @@ -168,7 +168,7 @@ func (uc *UpgradeConfigurer) CreatePreUpgradeState() error {
defer wg.Done()
preUpgradePoolId[1] = chainBNode.CreateBalancerPool("pool1B.json", initialization.ValidatorWalletName)
poolShareDenom[1] = fmt.Sprintf("gamm/pool/%d", preUpgradePoolId[1])
chainBNode.EnableSuperfluidAsset(chainB, poolShareDenom[1], false)
chainBNode.EnableSuperfluidAsset(chainB, poolShareDenom[1], true)
}()

go func() {
Expand Down Expand Up @@ -258,7 +258,7 @@ func (uc *UpgradeConfigurer) CreatePreUpgradeState() error {
go func() {
defer wg.Done()
uc.t.Logf("Uploading rate limiting contract to chainA")
_, err := chainANode.SetupRateLimiting("", chainANode.QueryGovModuleAccount(), chainA, false)
_, err := chainANode.SetupRateLimiting("", chainANode.QueryGovModuleAccount(), chainA, true)
errCh <- err
}()

Expand All @@ -279,7 +279,7 @@ func (uc *UpgradeConfigurer) CreatePreUpgradeState() error {
go func() {
defer wg.Done()
uc.t.Logf("Uploading rate limiting contract to chainB")
_, err := chainBNode.SetupRateLimiting("", chainBNode.QueryGovModuleAccount(), chainB, false)
_, err := chainBNode.SetupRateLimiting("", chainBNode.QueryGovModuleAccount(), chainB, true)
errCh <- err
}()

Expand Down Expand Up @@ -347,7 +347,7 @@ func (uc *UpgradeConfigurer) runProposalUpgrade() error {
return err
}
chainConfig.UpgradePropHeight = currentHeight + int64(chainConfig.VotingPeriod) + int64(config.PropSubmitBlocks) + int64(config.PropBufferBlocks)
propNumber := node.SubmitUpgradeProposal(uc.upgradeVersion, chainConfig.UpgradePropHeight, sdk.NewCoin(appparams.BaseCoinUnit, osmomath.NewInt(config.InitialMinDeposit)), false)
propNumber := node.SubmitUpgradeProposal(uc.upgradeVersion, chainConfig.UpgradePropHeight, sdk.NewCoin(appparams.BaseCoinUnit, osmomath.NewInt(config.InitialMinDeposit)), true)

node.DepositProposal(propNumber, false)

Expand Down
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"
previousVersionOsmoTag = "20.1.0-alpine"
previousVersionOsmoTag = "21.1.5-alpine"
// Pre-upgrade repo/tag for osmosis initialization (this should be one version below upgradeVersion)
previousVersionInitRepository = "osmolabs/osmosis-e2e-init-chain"
previousVersionInitTag = "20.1.0"
previousVersionInitTag = "v21.1.5"
// Hermes repo/version for relayer
relayerRepository = "informalsystems/hermes"
relayerTag = "1.5.1"
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/initialization/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ func (n *internalNode) createAppConfig(nodeConfig *NodeConfig) {
appConfig.MinGasPrices = fmt.Sprintf("%s%s", MinGasPrice, OsmoDenom)
appConfig.StateSync.SnapshotInterval = nodeConfig.SnapshotInterval
appConfig.StateSync.SnapshotKeepRecent = nodeConfig.SnapshotKeepRecent
appConfig.GRPC.Address = "0.0.0.0:9090"
appConfig.API.Address = "tcp://0.0.0.0:1317"

srvconfig.WriteConfigFile(appCfgPath, appConfig)
}
Expand Down

0 comments on commit c92bf8b

Please sign in to comment.