-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package upgrades | ||
|
||
import ( | ||
"context" | ||
|
||
"cosmossdk.io/math" | ||
storetypes "cosmossdk.io/store/types" | ||
upgradetypes "cosmossdk.io/x/upgrade/types" | ||
cosmosTypes "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
"github.com/pokt-network/poktroll/app/keepers" | ||
suppliertypes "github.com/pokt-network/poktroll/x/supplier/types" | ||
) | ||
|
||
// Upgrade_0_0_12 is the upgrade handler for v0.0.12 upgrade. | ||
// - Before: v0.0.11 | ||
// - After: v0.0.12 | ||
|
||
// TODO_IN_THIS_PR: WIP. Using this diff as a starting point: https://github.com/pokt-network/poktroll/compare/v0.0.11...feat/proof-endblocker | ||
// TODO_IN_THIS_PR: Wait for https://github.com/pokt-network/poktroll/pull/1042 | ||
var Upgrade_0_0_12 = Upgrade{ | ||
PlanName: "v0.0.12", | ||
CreateUpgradeHandler: func(mm *module.Manager, | ||
keepers *keepers.Keepers, | ||
configurator module.Configurator, | ||
) upgradetypes.UpgradeHandler { | ||
// Adds new parameters using ignite's config.yml as a reference. Assuming we don't need any other parameters. | ||
applyNewParameters := func(ctx context.Context) (err error) { | ||
logger := cosmosTypes.UnwrapSDKContext(ctx).Logger() | ||
logger.Info("Starting parameter updates for v0.0.12") | ||
|
||
// Add supplier module staking_fee. The min stake is set to 1000000 upokt, but we avoid GetParams() to avoid | ||
// potential protobuf issues. | ||
// Validate with: `poktrolld q supplier params --node=https://testnet-validated-validator-rpc.poktroll.com/` | ||
supplierParams := suppliertypes.Params{ | ||
MinStake: &cosmosTypes.Coin{ | ||
Denom: "upokt", | ||
Amount: math.NewInt(1000000), | ||
}, | ||
StakingFee: &cosmosTypes.Coin{ | ||
Denom: "upokt", | ||
// TODO_IN_THIS_PR: 100upokt a good value? | ||
Amount: math.NewInt(100), | ||
}, | ||
} | ||
|
||
// ALL parameters must be present when setting params. | ||
err = keepers.SupplierKeeper.SetParams(ctx, supplierParams) | ||
if err != nil { | ||
logger.Error("Failed to set supplier params", "error", err) | ||
return err | ||
} | ||
logger.Info("Successfully updated supplier params", "new_params", supplierParams) | ||
|
||
// TODO_IN_THIS_PR: RevSharePercent / DefaultRevSharePercent has been changed from float32 to uint64. | ||
// Investigate the impact of this change on existing on-chain data. | ||
// As v0.0.12 in it's current state only has protobufs with `uint64`, we might need to write a module migration | ||
// and maintain two versions of protobuf files IF we need to loop through existing suppliers and update their onchain | ||
// data. | ||
|
||
// TODO_IN_THIS_PR: Add service.params.target_num_relays. | ||
// TODO_IN_THIS_PR: Add tokenomics.params.global_inflation_per_claim. | ||
return | ||
} | ||
|
||
// Returns the upgrade handler for v0.0.12 | ||
return func(ctx context.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { | ||
logger := cosmosTypes.UnwrapSDKContext(ctx).Logger() | ||
logger.Info("Starting v0.0.12 upgrade handler") | ||
|
||
err := applyNewParameters(ctx) | ||
if err != nil { | ||
logger.Error("Failed to apply new parameters", "error", err) | ||
return vm, err | ||
} | ||
|
||
logger.Info("Running module migrations") | ||
vm, err = mm.RunMigrations(ctx, configurator, vm) | ||
if err != nil { | ||
logger.Error("Failed to run migrations", "error", err) | ||
return vm, err | ||
} | ||
|
||
logger.Info("Successfully completed v0.0.12 upgrade handler") | ||
return vm, nil | ||
} | ||
}, | ||
// No changes to the KVStore in this upgrade. | ||
StoreUpgrades: storetypes.StoreUpgrades{}, | ||
} |