Skip to content

Commit

Permalink
Diego/proto 2855 migrate v8 (#710)
Browse files Browse the repository at this point in the history
<!-- < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < ☺
v           ✰  Thanks for creating a PR! You're awesome! ✰
v Please note that maintainers will only review those PRs with a
completed PR template.
☺ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >  -->

## Purpose of Changes and their Description
Auxiliary branch - using `v0_8_0`, and `v7` protos

## Link(s) to Ticket(s) or Issue(s) resolved by this PR

## Are these changes tested and documented?

- [x] If tested, please describe how. If not, why tests are not needed.
-- Modified unit tests, and also tested query params and update params
before and after.
- [ ] If documented, please describe where. If not, describe why docs
are not needed.
- [ ] Added to `Unreleased` section of `CHANGELOG.md`?
  • Loading branch information
xmariachi authored Dec 17, 2024
1 parent 18c9fdf commit 2cf6957
Show file tree
Hide file tree
Showing 34 changed files with 192,117 additions and 12,000 deletions.
6 changes: 3 additions & 3 deletions Dockerfile.upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ FROM golang:1.22-bookworm AS builder

ENV GO111MODULE=on
ENV GOMODCACHE=/gocache
ENV BASELINE_VERSION_TAG=v0.6.6
ENV BASELINE_VERSION_TAG=v0.7.0
# VERSION: Used to force the version on the binary, if generated from branch or different commit
ENV VERSION=v0.6.6
ENV UPGRADE_VERSION_TAG=v0.7.0
# ENV VERSION=v0.7.0
ENV UPGRADE_VERSION_TAG=v0.8.0
ENV GIT_STASH_MESSAGE="Docker build"


Expand Down
2 changes: 2 additions & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/allora-network/allora-chain/app/upgrades/v0_5_0"
"github.com/allora-network/allora-chain/app/upgrades/v0_6_0"
"github.com/allora-network/allora-chain/app/upgrades/v0_7_0"
"github.com/allora-network/allora-chain/app/upgrades/v0_8_0"
)

var upgradeHandlers = []upgrades.Upgrade{
Expand All @@ -19,6 +20,7 @@ var upgradeHandlers = []upgrades.Upgrade{
v0_5_0.Upgrade,
v0_6_0.Upgrade,
v0_7_0.Upgrade,
v0_8_0.Upgrade,
// Add more upgrade handlers here
// ...
}
Expand Down
40 changes: 40 additions & 0 deletions app/upgrades/v0_8_0/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package v0_8_0 //nolint:revive // var-naming: don't use an underscore in package name

import (
"context"

storetypes "cosmossdk.io/store/types"
upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/allora-network/allora-chain/app/keepers"
"github.com/allora-network/allora-chain/app/upgrades"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
)

const (
UpgradeName = "v0.8.0"
)

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: storetypes.StoreUpgrades{Added: nil, Renamed: nil, Deleted: nil},
}

func CreateUpgradeHandler(
moduleManager *module.Manager,
configurator module.Configurator,
keepers *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx context.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
sdkCtx := sdk.UnwrapSDKContext(ctx)
sdkCtx.Logger().Info("RUN MIGRATIONS")
vm, err := moduleManager.RunMigrations(ctx, configurator, vm)
if err != nil {
return vm, err
}

sdkCtx.Logger().Info("MIGRATIONS COMPLETED")
return vm, nil
}
}
9 changes: 5 additions & 4 deletions test/integration/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"

upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/allora-network/allora-chain/app/upgrades/v0_7_0"
v0_8_0 "github.com/allora-network/allora-chain/app/upgrades/v0_8_0"
testCommon "github.com/allora-network/allora-chain/test/common"
sdktypes "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
Expand Down Expand Up @@ -57,7 +57,7 @@ func voteOnProposal(m testCommon.TestConfig, proposalId uint64) {
// propose an upgrade to the v0.5.0 software version
func proposeUpgrade(m testCommon.TestConfig) (proposalId uint64, proposalHeight int64) {
ctx := context.Background()
name := v0_7_0.UpgradeName
name := v0_8_0.UpgradeName
summary := "Upgrade to " + name + " software version"

currHeight, err := m.Client.BlockHeight(ctx)
Expand Down Expand Up @@ -129,6 +129,7 @@ func getEmissionsVersion(m testCommon.TestConfig) uint64 {
ModuleName: "emissions",
}
moduleVersions, err := m.Client.QueryUpgrade().ModuleVersions(ctx, queryModuleVersionsRequest)
m.T.Logf("Module Versions: %+v", moduleVersions)
require.NoError(m.T, err)
require.NotNil(m.T, moduleVersions)
require.Len(m.T, moduleVersions.ModuleVersions, 1)
Expand Down Expand Up @@ -161,7 +162,7 @@ func getAppliedVersionHeight(m testCommon.TestConfig, version string) int64 {
}

func UpgradeChecks(m testCommon.TestConfig) {
versionName := v0_7_0.UpgradeName
versionName := v0_8_0.UpgradeName
m.T.Log("--- Getting Emissions Module Version Before Upgrade ---")
emissionsVersionBefore := getEmissionsVersion(m)
m.T.Logf("--- Propose Upgrade to %s software version from v0 (%d) ---", versionName, emissionsVersionBefore)
Expand All @@ -178,5 +179,5 @@ func UpgradeChecks(m testCommon.TestConfig) {
require.Greater(m.T, emissionsVersionAfter, emissionsVersionBefore)
height := getAppliedVersionHeight(m, versionName)
m.T.Log("--- Checking upgrade has been applied at the proposed height ---")
require.Equal(m.T, proposalHeight, height)
require.Equal(m.T, height, proposalHeight)
}
Loading

0 comments on commit 2cf6957

Please sign in to comment.