Skip to content

Commit

Permalink
Merge pull request #869 from public-awesome/jhernandezb/v12-upgrade
Browse files Browse the repository at this point in the history
v12 upgrade handler
  • Loading branch information
jhernandezb authored Aug 22, 2023
2 parents b288b51 + 725d8d0 commit 49feb54
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 156 deletions.
28 changes: 8 additions & 20 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ steps:
password:
from_secret: docker_password
tags:
- v11.0.0-beta.2
- 12.0.0-alpha.1
when:
event:
- push
branch:
- jhernandezb/remove-spm-dep
- jhernandezb/v12-upgrade
- name: docker_release
image: plugins/docker
settings:
Expand Down Expand Up @@ -244,7 +244,7 @@ steps:

trigger:
branch:
- main
- release/v12.x
event:
- pull_request
- push
Expand Down Expand Up @@ -313,7 +313,7 @@ steps:
environment:
GOPROXY: http://goproxy
- name: stargaze
image: publicawesome/stargaze:10.0.1
image: publicawesome/stargaze:11.0.0
commands:
- ./scripts/ci/upgrade/setup-preinstalled-stargaze.sh
environment:
Expand Down Expand Up @@ -345,12 +345,12 @@ steps:
commands:
- /bin/bash ./scripts/ci/transfer-relayer.sh
- name: proposal
image: publicawesome/stargaze:10.0.1
image: publicawesome/stargaze:11.0.0
commands:
- ./scripts/ci/upgrade/proposal.sh
- name: stargaze-upgraded
pull: always
image: publicawesome/stargaze:v11.0.0-beta.2
image: publicawesome/stargaze:12.0.0-alpha.1
commands:
- ./scripts/ci/upgrade/run-upgrade.sh
environment:
Expand All @@ -367,18 +367,6 @@ steps:
- http://gaia:26657
- http://osmosis:26657
- http://icad:26657
- name: check-params
pull: always
image: publicawesome/stargaze:v11.0.0-beta.2
commands:
- starsd q mint params --node http://stargaze-upgraded:26657
- starsd q alloc params --node http://stargaze-upgraded:26657
- starsd q tokenfactory params --node http://stargaze-upgraded:26657
- starsd q bank balances stars1mnyrspq208uv5m2krdctan2dkyht0szje9s43h --node http://stargaze-upgraded:26657
- starsd q bank balances stars103y4f6h80lc45nr8chuzr3fyzqywm9n0gnr394 --node http://stargaze-upgraded:26657
- starsd q distribution community-pool --node http://stargaze-upgraded:26657
environment:
GOPROXY: http://goproxy
- name: relayer-upgrade-start
image: publicawesome/hermes:0.15.0
commands:
Expand All @@ -405,7 +393,7 @@ steps:

trigger:
branch:
- main
- release/v12.x
event:
- pull_request
- push
Expand All @@ -416,6 +404,6 @@ volumes:

---
kind: signature
hmac: 080a970b32e1116f813eb85afec92aa95a77ec11f20da1baafc48d40a9a99c6f
hmac: a41a2d807eb0a057b55afc2f3a5addc67d3df8923eca45ce85d548a495b01a25

...
46 changes: 26 additions & 20 deletions .github/workflows/interchaintest.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
name: Run InterchainTest

on:
on:
pull_request:
branches:
- main

- release/v12.x

release:
types: published

workflow_dispatch:

jobs:
Expand All @@ -22,7 +23,7 @@ jobs:
- name: Set up Golang
uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
go-version-file: "go.mod"

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Expand All @@ -33,7 +34,7 @@ jobs:
context: .
tags: publicawesome/stargaze:local-dev
outputs: type=docker,dest=/tmp/sg.tar

- name: Upload the Docker image # Uploading as artifact so that all the tests which run as different jobs can use this image
uses: actions/upload-artifact@v3
with:
Expand All @@ -54,49 +55,55 @@ jobs:
- name: Set up Golang
uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
go-version-file: "go.mod"

- name: Build Interchaintest
run: make interchaintest

- name: Upload binary as artifact # Uploading as artifact so that all the tests which run as different jobs can use this binary
uses: actions/upload-artifact@v3
with:
name: interchaintest
path: ./bin/interchaintest
retention-days: 1
name: interchaintest
path: ./bin/interchaintest
retention-days: 1

run_gaia_interchaintest:
name: gaia ⚛️
needs: [build_interchaintest,build_sg_image]
needs: [build_interchaintest, build_sg_image]
uses: ./.github/workflows/interchaintest_runner.yml
with:
test-matrix: 'interchain_test/gaia.matrix.json'
test-matrix: "interchain_test/gaia.matrix.json"

run_osmosis_interchaintest:
name: osmosis 🧪
needs: [build_interchaintest,build_sg_image]
needs: [build_interchaintest, build_sg_image]
uses: ./.github/workflows/interchaintest_runner.yml
with:
test-matrix: 'interchain_test/osmosis.matrix.json'
test-matrix: "interchain_test/osmosis.matrix.json"

run_icad_interchaintest:
name: icad 🔗
needs: [build_interchaintest,build_sg_image]
needs: [build_interchaintest, build_sg_image]
uses: ./.github/workflows/interchaintest_runner.yml
with:
test-matrix: 'interchain_test/icad.matrix.json'
test-matrix: "interchain_test/icad.matrix.json"

run_pfm_interchaintest:
name: pfm ⏩
needs: [build_sg_image]
uses: ./.github/workflows/interchaintest_custom_runner.yml
with:
test-cmd: 'test-pfm'
test-cmd: "test-pfm"

cleanup:
name: Delete artifacts 🗑️
needs: [run_gaia_interchaintest,run_osmosis_interchaintest,run_icad_interchaintest,run_pfm_interchaintest]
needs:
[
run_gaia_interchaintest,
run_osmosis_interchaintest,
run_icad_interchaintest,
run_pfm_interchaintest,
]
runs-on: ubuntu-latest

steps:
Expand All @@ -105,10 +112,9 @@ jobs:
with:
name: interchaintest
failOnError: false

- name: Delete sg # Delete the stargaze docker image from workflow artifacts as its not needed anymore
uses: geekyeggo/delete-artifact@v2
with:
name: sg
failOnError: false

80 changes: 5 additions & 75 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@ package app

import (
"fmt"
"time"

store "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
allocmoduletypes "github.com/public-awesome/stargaze/v12/x/alloc/types"
ibchooks "github.com/public-awesome/stargaze/v12/x/ibchooks/types"
tokenfactorytypes "github.com/public-awesome/stargaze/v12/x/tokenfactory/types"
packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/router/types"
)

// next upgrade name
const upgradeName = "v11"
const upgradeName = "v12"

// RegisterUpgradeHandlers returns upgrade handlers
func (app *App) RegisterUpgradeHandlers(cfg module.Configurator) {
Expand All @@ -25,74 +21,6 @@ func (app *App) RegisterUpgradeHandlers(cfg module.Configurator) {
if err != nil {
return nil, err
}

// Following param changes reflect what was approved by prop 165 and combined in a single upgrade for Prop 1-3
// https://www.mintscan.io/stargaze/proposals/165
// 1- Reduce Emissions to 711k daily this is done by adjusting mint params
// 2- Introduce a new Supplement Amount and Redirect Funds for the next 6 months
// requiring future proposals to refill the module account
// 3- Stop funding community pool and nft incentive allocation
// at the same time this code allows re-enabling incentive allocation
// through param change proposals only

// change mint params to include the new supplement amount
// and store it back to the keeper
mintParams := app.MintKeeper.GetParams(ctx)
// 259.7M to the upgrade happening on the 11th of July 2023
mintParams.InitialAnnualProvisions = sdk.NewDec(259_700_000_000_000)
// reset to 2023-01-01 so there is a thirdening happening on next January 1
mintParams.StartTime = time.Date(2023, 1, 1, 0, 0, 0, 0, time.UTC)
// update blocks per year using 5.9 s avg block time
mintParams.BlocksPerYear = 5345036
app.MintKeeper.SetParams(ctx, mintParams)
denom := app.MintKeeper.GetParams(ctx).MintDenom

// token factory params
params := app.TokenFactoryKeeper.GetParams(ctx)
// 10k STARS
params.DenomCreationFee = sdk.NewCoins(sdk.NewInt64Coin(denom, 10_000_000_000))

app.TokenFactoryKeeper.SetParams(ctx, params)

// set community tax to 0 since the allocation module will now take care of it
// making an accurate allocation of the inflation
distributionParams := app.DistrKeeper.GetParams(ctx)
distributionParams.CommunityTax = sdk.ZeroDec()
app.DistrKeeper.SetParams(ctx, distributionParams)

// change alloc params to set nft incentives to 0% until incentives are live
allocParams := app.AllocKeeper.GetParams(ctx)

// distribution proportions
proportions := allocParams.DistributionProportions
proportions.NftIncentives = sdk.ZeroDec() // nft incentives to 0%
proportions.CommunityPool = sdk.NewDecWithPrec(5, 2) // 5% community pool

allocParams.DistributionProportions = proportions
// supplement amount from the specific module account
// set to 100k STARS daily ~= 6.82 STARS per block using same 5.9s avg block time
allocParams.SupplementAmount = sdk.NewCoins(sdk.NewInt64Coin(denom, 6_828_704)) // 6.9 STARS per block
app.AllocKeeper.SetParams(ctx, allocParams)

// check if the account was previously created if that's the case reset it
supplementPoolAddress := authtypes.NewModuleAddress(allocmoduletypes.SupplementPoolName)
if app.AccountKeeper.HasAccount(ctx, supplementPoolAddress) {
account := app.AccountKeeper.GetAccount(ctx, supplementPoolAddress)
app.AccountKeeper.RemoveAccount(ctx, account)
}
// create module account
supplmentPoolAccount := app.AccountKeeper.GetModuleAccount(ctx, allocmoduletypes.SupplementPoolName)

fundAmount := sdk.NewInt64Coin(denom, 18_300_000_000_000) // 18M STARS
// if there is not enough founds skip
if app.DistrKeeper.GetFeePoolCommunityCoins(ctx).AmountOf(denom).LT(sdk.NewDecCoinFromCoin(fundAmount).Amount) {
return migrations, nil
}
err = app.DistrKeeper.DistributeFromFeePool(ctx, sdk.NewCoins(fundAmount), supplmentPoolAccount.GetAddress())
if err != nil {
return nil, err
}

return migrations, nil
})

Expand All @@ -103,7 +31,9 @@ func (app *App) RegisterUpgradeHandlers(cfg module.Configurator) {

if upgradeInfo.Name == upgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := store.StoreUpgrades{
Added: []string{tokenfactorytypes.ModuleName, ibchooks.StoreKey},
Added: []string{
packetforwardtypes.StoreKey,
},
}
// configure store loader that checks if version == upgradeHeight and applies store upgrades
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
Expand Down
6 changes: 0 additions & 6 deletions cmd/starsd/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,6 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command {
}
}

if chainID == "big-bang-1" {
seeds = []string{
"69666f77b6a2355fcfc64c9879520a352b62917e@45.55.57.176:36656",
}
}

// Override default settings in config.toml
config.P2P.Seeds = strings.Join(seeds, ",")
config.P2P.MaxNumInboundPeers = 120
Expand Down
1 change: 1 addition & 0 deletions cmd/starsd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
func addModuleInitFlags(startCmd *cobra.Command) {
crisis.AddModuleInitFlags(startCmd)
wasm.AddModuleInitFlags(startCmd)
startCmd.PreRunE = chainPreRuns(CheckLibwasmVersion, startCmd.PreRunE)
}

func queryCommand() *cobra.Command {
Expand Down
6 changes: 0 additions & 6 deletions cmd/starsd/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cmd
import (
"fmt"

"github.com/CosmWasm/wasmd/x/wasm"
wasmvmapi "github.com/CosmWasm/wasmvm"
"github.com/spf13/cobra"
)
Expand All @@ -21,11 +20,6 @@ func CheckLibwasmVersion(_ *cobra.Command, _ []string) error {
return nil
}

func CustomStart(startCmd *cobra.Command) {
wasm.AddModuleInitFlags(startCmd)
startCmd.PreRunE = chainPreRuns(CheckLibwasmVersion, startCmd.PreRunE)
}

type preRunFn func(cmd *cobra.Command, args []string) error

func chainPreRuns(pfns ...preRunFn) preRunFn {
Expand Down
19 changes: 0 additions & 19 deletions cmd/starsd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,6 @@ import (
"github.com/public-awesome/stargaze/v12/cmd/starsd/cmd"
)

// func main() {
// rootCmd, _ := cosmoscmd.NewRootCmd(
// "stars",
// app.AccountAddressPrefix,
// app.DefaultNodeHome,
// app.Name,
// app.ModuleBasics,
// app.NewStargazeApp,
// cosmoscmd.AddSubCmd(cmd.TestnetCmd(app.ModuleBasics)),
// cosmoscmd.AddCustomInitCmd(cmd.InitCmd(app.ModuleBasics, app.DefaultNodeHome)),
// cosmoscmd.AddSubCmd(cmd.PrepareGenesisCmd(app.DefaultNodeHome, app.ModuleBasics)),
// cosmoscmd.CustomizeStartCmd(cmd.CustomStart),
// // this line is used by starport scaffolding # root/arguments
// )
// if err := svrcmd.Execute(rootCmd, app.DefaultNodeHome); err != nil {
// os.Exit(1)
// }
// }

func main() {
rootCmd, _ := cmd.NewRootCmd()
if err := svrcmd.Execute(rootCmd, app.DefaultNodeHome); err != nil {
Expand Down
Loading

0 comments on commit 49feb54

Please sign in to comment.