Skip to content

Commit

Permalink
Fix upgrade (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMarstonConnell authored Jan 31, 2023
2 parents 6b50e4c + 40ac17d commit 59266fe
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 4 deletions.
26 changes: 26 additions & 0 deletions app/upgrades/testnet/fixstrays/store.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package fixstrays

import (
sdk "github.com/cosmos/cosmos-sdk/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/jackalLabs/canine-chain/x/storage/types"
)

// MigrateStore performs in-place store migrations from v2 to v3
// The things done here are the following:
// 1. setting up the next reason id and report id keys for existing subspaces
// 2. setting up the module params
func MigrateStore(ctx sdk.Context, paramsSubspace *paramstypes.Subspace) error {
ctx.Logger().Error("MIGRATING STORAGE STORE!")
// Set the module params

var params types.Params

paramsSubspace.GetParamSet(ctx, &params)

params.ProofWindow = 50

paramsSubspace.SetParamSet(ctx, &params)

return nil
}
5 changes: 4 additions & 1 deletion app/upgrades/testnet/fixstrays/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/jackalLabs/canine-chain/app/upgrades"
"github.com/jackalLabs/canine-chain/types"
storagemodulekeeper "github.com/jackalLabs/canine-chain/x/storage/keeper"
storeagemoduletypes "github.com/jackalLabs/canine-chain/x/storage/types"
)

var _ upgrades.Upgrade = &Upgrade{}
Expand Down Expand Up @@ -36,7 +37,9 @@ func (u *Upgrade) Name() string {
// Handler implements upgrades.Upgrade
func (u *Upgrade) Handler() upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
if types.IsTestnet(ctx.ChainID()) {
if types.IsTestnet(ctx.ChainID()) || ctx.ChainID() == "test" {

fromVM[storeagemoduletypes.ModuleName] = 2

newVM, err := u.mm.RunMigrations(ctx, u.configurator, fromVM)
if err != nil {
Expand Down
6 changes: 4 additions & 2 deletions scripts/upgrade-test.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/bin/bash

OLD_VERSION=1.1.2-hotfix
OLD_VERSION=23.01-beta
UPGRADE_HEIGHT=20
HOME=mytestnet
ROOT=$(pwd)
DENOM=ujkl
SOFTWARE_UPGRADE_NAME=bouncybulldog
SOFTWARE_UPGRADE_NAME=fixstrays

# underscore so that go tool will not take gocache into account
mkdir -p ${ROOT}/../_build/gocache
Expand All @@ -27,6 +27,8 @@ fi
# start old node
screen -dmS node1 bash scripts/run-upgrade-node.sh ./../_build/old/canined $DENOM

./../_build/old/canined version --home $HOME

sleep 20

./../_build/old/canined tx gov submit-proposal software-upgrade "$SOFTWARE_UPGRADE_NAME" --upgrade-height $UPGRADE_HEIGHT --upgrade-info "temp" --title "upgrade" --description "upgrade" --from test1 --keyring-backend test --chain-id test --home $HOME -y
Expand Down
5 changes: 5 additions & 0 deletions x/storage/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ func NewMigrator(keeper Keeper) Migrator {
func (m Migrator) Migrate1to2(ctx sdk.Context) error {
return v2.MigrateStore(ctx, &m.k.paramstore)
}

// Migrate2to3 migrates from version 2 to 3.
func (m Migrator) Migrate2to3(ctx sdk.Context) error {
return v2.MigrateStore(ctx, &m.k.paramstore)
}
6 changes: 5 additions & 1 deletion x/storage/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
if err != nil {
panic(err)
}
err = cfg.RegisterMigration(types.ModuleName, 2, m.Migrate2to3)
if err != nil {
panic(err)
}
}

// RegisterInvariants registers the capability module's invariants.
Expand All @@ -171,7 +175,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
}

// ConsensusVersion implements ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 { return 2 }
func (AppModule) ConsensusVersion() uint64 { return 3 }

// BeginBlock executes all ABCI BeginBlock logic respective to the capability module.
func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { // Every x blocks we check for proven deals
Expand Down

0 comments on commit 59266fe

Please sign in to comment.