Skip to content

Commit

Permalink
upgrade version v0.9.8 (#426)
Browse files Browse the repository at this point in the history
  • Loading branch information
ranlavanet authored Apr 16, 2023
1 parent 7e084e8 commit 42320db
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ import (
"github.com/lavanet/lava/app/upgrades/v0_9_1"
"github.com/lavanet/lava/app/upgrades/v0_9_6"
"github.com/lavanet/lava/app/upgrades/v0_9_7"
"github.com/lavanet/lava/app/upgrades/v0_9_8"
"github.com/lavanet/lava/docs"
conflictmodule "github.com/lavanet/lava/x/conflict"
conflictmodulekeeper "github.com/lavanet/lava/x/conflict/keeper"
Expand Down Expand Up @@ -152,6 +153,7 @@ var Upgrades = []upgrades.Upgrade{
upgrades.Upgrade_0_9_5,
v0_9_6.Upgrade,
v0_9_7.Upgrade,
v0_9_8.Upgrade,
}

// this line is used by starport scaffolding # stargate/wasm/app/enabledProposals
Expand Down
14 changes: 14 additions & 0 deletions app/upgrades/v0_9_8/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package v0_9_8

import (
store "github.com/cosmos/cosmos-sdk/store/types"
"github.com/lavanet/lava/app/upgrades"
)

const UpgradeName = "v0.9.8"

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName, // upgrade name defined few lines above
CreateUpgradeHandler: CreateUpgradeHandler, // create CreateUpgradeHandler in upgrades.go below
StoreUpgrades: store.StoreUpgrades{}, // StoreUpgrades has 3 fields: Added/Renamed/Deleted any module that fits these description should be added in the way below
}
49 changes: 49 additions & 0 deletions app/upgrades/v0_9_8/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package v0_9_8

import (
"log"

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/lavanet/lava/app/keepers"
"github.com/lavanet/lava/app/upgrades"
epochstoragetypes "github.com/lavanet/lava/x/epochstorage/types"
)

const (
// ClientPaymentStorageKeyPrefix is the prefix to retrieve all ClientPaymentStorage
ClientPaymentStorageKeyPrefix = "ClientPaymentStorage/value/"
// UniquePaymentStorageClientProviderKeyPrefix is the prefix to retrieve all UniquePaymentStorageClientProvider
UniquePaymentStorageClientProviderKeyPrefix = "UniquePaymentStorageClientProvider/value/"
)

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
bpm upgrades.BaseAppParamManager,
keepers *keepers.LavaKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
log.Println("########################")
log.Println("# STARTING UPGRADE #")
log.Println("########################")

chainIDs := keepers.SpecKeeper.GetAllChainIDs(ctx)
for _, chainID := range chainIDs {
storage, found := keepers.EpochstorageKeeper.GetStakeStorageCurrent(ctx, epochstoragetypes.ProviderKey, chainID)
if !found {
continue
}

for _, entry := range storage.StakeEntries {
err := keepers.PairingKeeper.FreezeProvider(ctx, entry.Address, []string{chainID}, "")
if err != nil {
continue
}
}
}

return mm.RunMigrations(ctx, configurator, vm)
}
}

0 comments on commit 42320db

Please sign in to comment.