Skip to content

Commit

Permalink
upgrade plan (#291)
Browse files Browse the repository at this point in the history
Co-authored-by: Yarom Swisa <[email protected] git config --global user.name Yarom>
  • Loading branch information
Yaroms and Yarom Swisa authored Feb 6, 2023
1 parent c62c1fe commit f6c7330
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ import (
"github.com/lavanet/lava/app/keepers"
"github.com/lavanet/lava/app/upgrades"
"github.com/lavanet/lava/app/upgrades/v0_5_0"
"github.com/lavanet/lava/app/upgrades/v0_5_1"
"github.com/lavanet/lava/docs"
conflictmodule "github.com/lavanet/lava/x/conflict"
conflictmodulekeeper "github.com/lavanet/lava/x/conflict/keeper"
Expand Down Expand Up @@ -116,7 +117,7 @@ const (
)

// Upgrades add here future upgrades (upgrades.Upgrade)
var Upgrades = []upgrades.Upgrade{upgrades.Upgrade_0_4_0, upgrades.Upgrade_0_4_3, upgrades.Upgrade_0_4_4, upgrades.Upgrade_0_4_5, v0_5_0.Upgrade}
var Upgrades = []upgrades.Upgrade{upgrades.Upgrade_0_4_0, upgrades.Upgrade_0_4_3, upgrades.Upgrade_0_4_4, upgrades.Upgrade_0_4_5, v0_5_0.Upgrade, v0_5_1.Upgrade}

// this line is used by starport scaffolding # stargate/wasm/app/enabledProposals

Expand Down
36 changes: 36 additions & 0 deletions app/upgrades/v0_5_1/upgrade.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package v0_5_1

import (
"log"

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

const UpgradeName = "v0.5.1"

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
}

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("########################")

keepers.EpochstorageKeeper.SetUnstakeHoldBlocksStaticRaw(ctx, 1400)
return mm.RunMigrations(ctx, configurator, vm)
}
}
5 changes: 5 additions & 0 deletions x/epochstorage/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ func (k Keeper) UnstakeHoldBlocksStaticRaw(ctx sdk.Context) (res uint64) {
return
}

// UnstakeHoldBlocksRaw sets the UnstakeHoldBlocks param
func (k Keeper) SetUnstakeHoldBlocksStaticRaw(ctx sdk.Context, unstakeHoldBlocksStatic uint64) {
k.paramstore.Set(ctx, types.KeyUnstakeHoldBlocksStatic, unstakeHoldBlocksStatic)
}

// EpochBlocks returns the EpochBlocks fixated param
func (k Keeper) EpochBlocks(ctx sdk.Context, block uint64) (res uint64, err error) {
err = k.GetParamForBlock(ctx, string(types.KeyEpochBlocks), block, &res)
Expand Down

0 comments on commit f6c7330

Please sign in to comment.