Skip to content

Commit

Permalink
v4 upgrade handler (#583)
Browse files Browse the repository at this point in the history
* add v4 upgrade handler

* add upgrade to ci

* update config to latest hermes

* update config
  • Loading branch information
jhernandezb authored Apr 8, 2022
1 parent 1b87ce5 commit 80cfeaa
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 32 deletions.
134 changes: 133 additions & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,139 @@ volumes:
node:
runner: integration
---
kind: pipeline
type: docker
name: upgrade-integration-test
workspace:
path: /stargaze
steps:
- name: restore-cache
image: meltwater/drone-cache:dev
volumes:
- name: cache
path: /go
environment:
AWS_ACCESS_KEY_ID:
from_secret: minio_key_id
AWS_SECRET_ACCESS_KEY:
from_secret: minio_secret_key
pull: true
settings:
restore: true
bucket:
from_secret: minio_bucket
region: us-east-1
mount:
- '/go/pkg/mod'
- name: build-wrapper
image: publicawesome/golang:1.18.0-devtooling
volumes:
- name: cache
path: /go
commands:
- mkdir -p /stargaze/bin/
- CGO_ENABLED=0 go build -o /stargaze/bin/upgrade-watcher ./testutil/watcher/
- chmod +x /stargaze/bin/upgrade-watcher
environment:
GOPROXY: http://goproxy
- name: gaia
image: publicawesome/gaia:6.0.0
detach: true
commands:
- ./scripts/ci/setup-gaia.sh
environment:
GOPROXY: http://goproxy
- name: osmosis
image: publicawesome/osmosis:7.1.0
detach: true
commands:
- ./scripts/ci/setup-osmosis.sh
environment:
GOPROXY: http://goproxy
- name: stargaze
image: publicawesome/stargaze:3.0.0
commands:
- ./scripts/ci/upgrade/setup-preinstalled-stargaze.sh
environment:
GOPROXY: http://goproxy
detach: true
- name: readiness
image: publicawesome/stargaze-readiness-checker:latest
settings:
timeout: 300
blocks: 10
chain_list:
- http://stargaze:26657
- http://gaia:26657
- http://osmosis:26657
- name: relayer
image: publicawesome/hermes:0.13.0
commands:
- /bin/bash ./scripts/ci/setup-relayer.sh

- name: relayer-start
image: publicawesome/hermes:0.13.0
commands:
- /bin/bash ./scripts/ci/start-relayer.sh
detach: true
- name: relayer-sender
image: publicawesome/hermes:0.13.0
commands:
- /bin/bash ./scripts/ci/transfer-relayer.sh
- name: proposal
image: publicawesome/stargaze:3.0.0
commands:
- ./scripts/ci/upgrade/proposal.sh
- name: stargaze-upgraded
image: publicawesome/stargaze:latest
commands:
- ./scripts/ci/upgrade/run-upgrade.sh
environment:
GOPROXY: http://goproxy
detach: true
- name: readiness-upgrade
image: publicawesome/stargaze-readiness-checker:latest
settings:
timeout: 300
blocks: 10
chain_list:
- http://stargaze-upgraded:26657
- http://gaia:26657
- http://osmosis:26657
- name: relayer-upgrade-start
image: publicawesome/hermes:0.13.0
commands:
- /bin/bash ./scripts/ci/upgrade/start-relayer.sh
detach: true
- name: relayer-ugprade-sender
image: publicawesome/hermes:0.13.0
commands:
- /bin/bash ./scripts/ci/upgrade/transfer-relayer.sh
- name: discord
image: appleboy/drone-discord
settings:
webhook_id:
from_secret: discord_webhook_id
webhook_token:
from_secret: discord_webhook_token
when:
status: [success, failure]

trigger:
branch:
- main
event:
- pull_request
- push
volumes:
- name: cache
temp: {}
node:
runner: integration
depends_on:
- ibc-integration-test
---
kind: signature
hmac: 79fa65281bdbcc548e9581a4af196892a345f4c35e6b68122e76b9f475bb14ea
hmac: 90ae2c601fcc19fc7b9c54f6ac840aad550971fb5aa68957aa5f951ef9ed6f9b

...
23 changes: 3 additions & 20 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,19 @@ package app
import (
"fmt"

"github.com/CosmWasm/wasmd/x/wasm"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
store "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

// next upgrade name
const upgradeName = "v3"
const upgradeName = "v4"

// RegisterUpgradeHandlers returns upgrade handlers
func (app *App) RegisterUpgradeHandlers(cfg module.Configurator) {
app.UpgradeKeeper.SetUpgradeHandler(upgradeName, func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
newVM, err := app.mm.RunMigrations(ctx, cfg, vm)
if err != nil {
return newVM, err
}
// consensus params
// increase max gas as part of the upgrade to handle cosmwam
consensusParams := app.BaseApp.GetConsensusParams(ctx)
consensusParams.Block.MaxGas = 75_000_000 // 75M
app.BaseApp.StoreConsensusParams(ctx, consensusParams)

// wasm params
wasmParams := app.WasmKeeper.GetParams(ctx)
wasmParams.CodeUploadAccess = wasmtypes.AllowNobody
wasmParams.MaxWasmCodeSize = DefaultMaxWasmCodeSize
app.WasmKeeper.SetParams(ctx, wasmParams)
return newVM, err
return app.mm.RunMigrations(ctx, cfg, vm)
})

upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
Expand All @@ -42,7 +25,7 @@ func (app *App) RegisterUpgradeHandlers(cfg module.Configurator) {

if upgradeInfo.Name == upgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := store.StoreUpgrades{
Added: []string{wasm.ModuleName},
Added: []string{},
}
// configure store loader that checks if version == upgradeHeight and applies store upgrades
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
Expand Down
7 changes: 6 additions & 1 deletion scripts/ci/upgrade/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ enabled = false
enabled = true
clear_interval = 100
clear_on_start = true
filter = false
tx_confirmation = true

[[chains]]
Expand Down Expand Up @@ -68,3 +67,9 @@ gas_adjustment = 0.1
clock_drift = '300s'
trusting_period = '2days'
trust_threshold = { numerator = '1', denominator = '3' }

[chains.packet_filter]
policy = 'deny'
list = [
['ica*', '*'], # deny relaying on all channels whose port starts with `ica`
]
15 changes: 5 additions & 10 deletions scripts/ci/upgrade/proposal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,15 @@ apk add -U --no-cache jq tree
STARGAZE_HOME=/stargaze/starsd
starsd config keyring-backend test --home $STARGAZE_HOME

echo "BaseApp Params"
starsd q params subspace baseapp BlockParams --node http://stargaze:26657
starsd q params subspace baseapp EvidenceParams --node http://stargaze:26657
starsd q params subspace baseapp ValidatorParams --node http://stargaze:26657

HEIGHT=$(starsd status --node http://stargaze:26657 --home $STARGAZE_HOME | jq .SyncInfo.latest_block_height -r)
tree -L 2 /stargaze/starsd/

echo "current height $HEIGHT"
HEIGHT=$(expr $HEIGHT + 20)
echo "submit with height $HEIGHT"
starsd tx gov submit-proposal software-upgrade v3 --upgrade-height $HEIGHT \
starsd tx gov submit-proposal software-upgrade v4 --upgrade-height $HEIGHT \
--deposit 10000000ustars \
--description "Add cosmwasm" \
--title "V3 Upgrade" \
--description "V4 Upgrade" \
--title "V4 Upgrade" \
--gas-prices 0.025ustars --gas auto --gas-adjustment 1.5 --from validator \
--chain-id stargaze -b block --yes --node http://stargaze:26657 --home $STARGAZE_HOME --keyring-backend test

Expand All @@ -32,4 +27,4 @@ starsd tx gov vote 1 "yes" --gas-prices 0.025ustars --gas auto --gas-adjustment
--chain-id stargaze -b block --yes --node http://stargaze:26657 --home $STARGAZE_HOME --keyring-backend test
sleep 60
starsd q gov proposals --node http://stargaze:26657 --home $STARGAZE_HOME
sleep 60
sleep 60

0 comments on commit 80cfeaa

Please sign in to comment.