Skip to content

Commit

Permalink
refactor: add handler migration
Browse files Browse the repository at this point in the history
  • Loading branch information
hoank101 committed Apr 2, 2024
1 parent ce9b9cc commit 69bc4b5
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
24 changes: 21 additions & 3 deletions app/upgrades/v7_0_1/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ package v7_0_1

import (
"context"

upgradetypes "cosmossdk.io/x/upgrade/types"
"encoding/hex"
"fmt"
"github.com/cosmos/cosmos-sdk/runtime"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/notional-labs/composable/v6/app/keepers"
Expand All @@ -15,10 +19,24 @@ func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
_ upgrades.BaseAppParamManager,
_ codec.Codec,
codec codec.Codec,
keepers *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx context.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
return func(goCtx context.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
fmt.Println("start v7.0.1 upgrade")
ctx := sdk.UnwrapSDKContext(goCtx)
store := runtime.NewKVStoreService(keepers.GetKVStoreKey()[types.StoreKey]).OpenKVStore(ctx)
checksumStr, err := hex.DecodeString("58c7623a3ab78f4cb2e4c5d02876ac36c3b38bb472118173a7ec7faa688a66d2")

checksum := types.Checksums{Checksums: [][]byte{checksumStr}}
bz, err := codec.Marshal(&checksum)
if err != nil {
panic(err)
}
err = store.Set([]byte(types.KeyChecksums), bz)
if err != nil {
panic(err)
}
return mm.RunMigrations(ctx, configurator, vm)
}
}
2 changes: 1 addition & 1 deletion scripts/test-upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ OLD_VERSION=v6.5.0
UPGRADE_WAIT=${UPGRADE_WAIT:-20}
HOME=mytestnet
ROOT=$(pwd)
DENOM=upica
DENOM=ppica
CHAIN_ID=localpica
SOFTWARE_UPGRADE_NAME="v7_0_1"
ADDITIONAL_PRE_SCRIPTS=""
Expand Down
2 changes: 1 addition & 1 deletion scripts/testnode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ centaurid add-genesis-account centauri1hj5fveer5cjtn4wd6wstzugjfdxzl0xpzxlwgs "1
# Sign genesis transaction
centaurid genesis gentx $KEY 1000000000000000000000ppica --keyring-backend $KEYRING --chain-id $CHAINID

update_test_genesis '.app_state["gov"]["params"]["voting_period"]="50s"'
update_test_genesis '.app_state["gov"]["params"]["voting_period"]="20s"'
update_test_genesis '.app_state["mint"]["params"]["mint_denom"]="'$DENOM'"'
update_test_genesis '.app_state["gov"]["params"]["min_deposit"]=[{"denom":"'$DENOM'","amount": "0"}]'
update_test_genesis '.app_state["crisis"]["constant_fee"]={"denom":"'$DENOM'","amount":"1000"}'
Expand Down
2 changes: 1 addition & 1 deletion scripts/upload_contracts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ KEYRING="test"
# validate dependencies are installed
command -v jq > /dev/null 2>&1 || { echo >&2 "jq not installed. More info: https://stedolan.github.io/jq/download/"; exit 1; }

./_build/old/centaurid tx 08-wasm push-wasm contracts/ics10_grandpa_cw.wasm --from=mykey --gas 10002152622 --fees 10020166upica --keyring-backend test --chain-id=localpica -y
./_build/old/centaurid tx 08-wasm push-wasm contracts/ics10_grandpa_cw.wasm --from=mykey --gas 10002152622 --fees 10020166ppica --keyring-backend test --chain-id=localpica -y
1 change: 1 addition & 0 deletions scripts/upload_contracts_new.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ KEYRING="test"
command -v jq > /dev/null 2>&1 || { echo >&2 "jq not installed. More info: https://stedolan.github.io/jq/download/"; exit 1; }

centaurid tx ibc-wasm store-code contracts/ics10_grandpa_cw.wasm --from=mykey --title test --summary test --gas 10002152622 --fees 10020166ppica --deposit 100000000ppica --keyring-backend test --chain-id=localpica -y
sleep 5
centaurid tx gov vote 1 yes --from=mykey --gas 10002152622 --fees 10020166ppica --keyring-backend test --chain-id=localpica -y

0 comments on commit 69bc4b5

Please sign in to comment.