Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade version v0.9.8 #426

Merged
merged 1 commit into from
Apr 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
}