Skip to content

Commit

Permalink
DNM: [uni-a] Standalone Upgrade Patch for Testnet (#821)
Browse files Browse the repository at this point in the history
* uni-a standalone upgrade

* 100m tokens from 1m (oops, thanks dimi!)

* make it easier to read

* Use IAVL v0.20.1 (#826)

* v17: Migrate SubDAOs from distribution module -> gov (#831)

* migrateChainOwnedSubDaos from distr -> gov

* lint

* simplify addr logic

* minor: comment typo

* Fix v17 Upgrade Package Name (#832)

* chore: ci bumps (#840)

---------

Co-authored-by: Matt, Park <[email protected]>
Co-authored-by: Joel Smith <[email protected]>
  • Loading branch information
3 people committed Sep 19, 2023
1 parent 68bfd2f commit d307dff
Show file tree
Hide file tree
Showing 18 changed files with 210 additions and 51 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
name: build
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v4
with:
Expand All @@ -35,15 +35,15 @@ jobs:
with:
go-version: ${{ env.GO_VERSION }}
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Test
run: go test ./...

tidy:
runs-on: ubuntu-latest
name: tidy
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v4
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/build_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
- name: Build without push
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: 'Dependency Review'
uses: actions/dependency-review-action@v2
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: golangci-lint-junod
uses: golangci/golangci-lint-action@v3
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/interchaintest-E2E.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v4
Expand All @@ -36,10 +36,10 @@ jobs:
cache-dependency-path: interchaintest/go.sum

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Build and export
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: .
tags: juno:local
Expand Down Expand Up @@ -80,7 +80,7 @@ jobs:
cache-dependency-path: interchaintest/go.sum

- name: checkout chain
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Download Tarball Artifact
uses: actions/download-artifact@v3
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/push-docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ jobs:
steps:
-
name: Check out the repo
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
Expand All @@ -62,7 +62,7 @@ jobs:
-
name: Build and push
id: build_push_image
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
file: Dockerfile
context: .
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Docker compose
run: STAKE_TOKEN="ujunox" TIMEOUT_COMMIT=500ms docker-compose up -d
Expand Down
25 changes: 0 additions & 25 deletions .github/workflows/test-simulation.yml.archive

This file was deleted.

3 changes: 2 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import (
"github.com/CosmosContracts/juno/v17/app/keepers"
"github.com/CosmosContracts/juno/v17/app/openapiconsole"
upgrades "github.com/CosmosContracts/juno/v17/app/upgrades"
unia "github.com/CosmosContracts/juno/v17/app/upgrades/uni-a"
v10 "github.com/CosmosContracts/juno/v17/app/upgrades/v10"
v11 "github.com/CosmosContracts/juno/v17/app/upgrades/v11"
v12 "github.com/CosmosContracts/juno/v17/app/upgrades/v12"
Expand Down Expand Up @@ -95,7 +96,7 @@ var (
// https://github.com/CosmWasm/wasmd/blob/02a54d33ff2c064f3539ae12d75d027d9c665f05/x/wasm/internal/types/proposal.go#L28-L34
EnableSpecificProposals = ""

Upgrades = []upgrades.Upgrade{v10.Upgrade, v11.Upgrade, v12.Upgrade, v13.Upgrade, v14.Upgrade, v15.Upgrade, v16.Upgrade, v17.Upgrade}
Upgrades = []upgrades.Upgrade{unia.Upgrade, v10.Upgrade, v11.Upgrade, v12.Upgrade, v13.Upgrade, v14.Upgrade, v15.Upgrade, v16.Upgrade, v17.Upgrade}
)

// These constants are derived from the above variables.
Expand Down
16 changes: 16 additions & 0 deletions app/upgrades/uni-a/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package unia

import (
store "github.com/cosmos/cosmos-sdk/store/types"

"github.com/CosmosContracts/juno/v17/app/upgrades"
)

// UpgradeName defines the on-chain upgrade name for the upgrade.
const UpgradeName = "uni-a"

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUniAUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{},
}
52 changes: 52 additions & 0 deletions app/upgrades/uni-a/upgrade_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package unia_test

import (
"testing"

"github.com/stretchr/testify/suite"

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

"github.com/CosmosContracts/juno/v17/app/apptesting"
unia "github.com/CosmosContracts/juno/v17/app/upgrades/uni-a"
)

type UpgradeTestSuite struct {
apptesting.KeeperTestHelper
}

func (s *UpgradeTestSuite) SetupTest() {
s.Setup()
}

func TestKeeperTestSuite(t *testing.T) {
suite.Run(t, new(UpgradeTestSuite))
}

// Ensures the test does not error out.
func (s *UpgradeTestSuite) TestUpgrade() {
s.Setup()

preUpgradeChecks(s)

upgradeHeight := int64(5)
s.ConfirmUpgradeSucceeded(unia.UpgradeName, upgradeHeight)

postUpgradeChecks(s)
}

func preUpgradeChecks(s *UpgradeTestSuite) {
bal := getAccBalance(s, unia.ReeceBech32)
s.Require().Equal(bal, sdk.NewCoins())
}

func postUpgradeChecks(s *UpgradeTestSuite) {
bal := getAccBalance(s, unia.ReeceBech32)
// 100m tokens
s.Require().Equal(bal, sdk.NewCoins(sdk.NewCoin("ujunox", sdk.NewInt(100_000_000*1_000_000))))
}

func getAccBalance(s *UpgradeTestSuite, bech32 string) sdk.Coins {
addr := sdk.MustAccAddressFromBech32(bech32)
return s.App.AppKeepers.BankKeeper.GetAllBalances(s.Ctx, addr)
}
64 changes: 64 additions & 0 deletions app/upgrades/uni-a/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package unia

import (
"fmt"

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/CosmosContracts/juno/v17/app/keepers"
"github.com/CosmosContracts/juno/v17/app/upgrades"
minttypes "github.com/CosmosContracts/juno/v17/x/mint/types"
)

const (
// Reece's validator account.
ReeceBech32 = "juno15twk6xu5rnrrlnf7c5zy92gvykcs4h5ucxzzqq"
)

// TokensAmount is for testnet only.
var TokensAmount = sdk.NewCoins(sdk.NewCoin("ujunox", sdk.NewInt(100_000_000_000000)))

func CreateUniAUpgradeHandler(
mm *module.Manager,
cfg module.Configurator,
keepers *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
logger := ctx.Logger().With("upgrade", UpgradeName)

nativeDenom := upgrades.GetChainsDenomToken(ctx.ChainID())
logger.Info(fmt.Sprintf("With native denom %s", nativeDenom))

// Run migrations
versionMap, err := mm.RunMigrations(ctx, cfg, vm)
if err != nil {
return nil, err
}

// Turn off inflation
minter := keepers.MintKeeper.GetMinter(ctx)
minter.Inflation = sdk.NewDecWithPrec(0, 2)
keepers.MintKeeper.SetMinter(ctx, minter)

// set blocks per year to be very high
mp := keepers.MintKeeper.GetParams(ctx)
mp.BlocksPerYear = 1_000_000_000_000
if err := keepers.MintKeeper.SetParams(ctx, mp); err != nil {
return nil, err
}

// Mint Tokens for Account
acc := sdk.MustAccAddressFromBech32(ReeceBech32)
if err := keepers.BankKeeper.MintCoins(ctx, minttypes.ModuleName, TokensAmount); err != nil {
return nil, err
}

if err := keepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, acc, TokensAmount); err != nil {
return nil, err
}

return versionMap, err
}
}
2 changes: 1 addition & 1 deletion app/upgrades/v17/constants.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v16
package v17

import (
store "github.com/cosmos/cosmos-sdk/store/types"
Expand Down
2 changes: 1 addition & 1 deletion app/upgrades/v17/upgrade_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v16_test
package v17_test

import (
"testing"
Expand Down
Loading

0 comments on commit d307dff

Please sign in to comment.