Skip to content

Commit

Permalink
Add more param changes
Browse files Browse the repository at this point in the history
  • Loading branch information
okdas committed Jan 30, 2025
1 parent 776cf19 commit 5a3decc
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 9 deletions.
1 change: 1 addition & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var allUpgrades = []upgrades.Upgrade{
upgrades.Upgrade_0_0_4,
upgrades.Upgrade_0_0_10,
upgrades.Upgrade_0_0_11,
upgrades.Upgrade_0_0_12,
}

// setUpgrades sets upgrade handlers for all upgrades and executes KVStore migration if an upgrade plan file exists.
Expand Down
6 changes: 6 additions & 0 deletions app/upgrades/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ import (
const (
// The default PNF/DAO address in the genesis file for Alpha TestNet. Used to create new authz authorizations.
AlphaTestNetPnfAddress = "pokt1r6ja6rz6rpae58njfrsgs5n5sp3r36r2q9j04h"

// Authority address. Defaults to gov module address. Used to create new authz authorizations.
// DEV_NOTE: Use `keepers.UpgradeKeeper.Authority(ctx, &upgradetypes.QueryAuthorityRequest{})` to query the authority
// address for the current network. Keeping this variable for historical upgrades.
AlphaTestNetAuthorityAddress = "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t"

// The default PNF/DAO address in the genesis file for Beta TestNet. Used to create new authz authorizations.
BetaTestNetPnfAddress = "pokt1f0c9y7mahf2ya8tymy8g4rr75ezh3pkklu4c3e"
)

// Upgrade represents a protocol upgrade in code.
Expand Down
42 changes: 33 additions & 9 deletions app/upgrades/v0.0.12.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@ import (
cosmosTypes "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/pokt-network/poktroll/app/keepers"
servicetypes "github.com/pokt-network/poktroll/x/service/types"
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

// This upgrade introduces a type change to RevSharePercent from float32 to uint64, which is introduced as a separate
// protobuf field. As a result, we expect existing on-chain data to switch to default value.
// Investigate the impact of this change on existing on-chain data.
//
// TODO_IN_THIS_PR: decide if we need a proper module migration.

// 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{
Expand All @@ -29,8 +36,8 @@ var Upgrade_0_0_12 = Upgrade{
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.
// Add supplier module staking_fee per `config.yml`. The min stake is set to 1000000 upokt, but we avoid
// GetParams() to avoid potential protobuf issues and all networks have the same value (no need to read).
// Validate with: `poktrolld q supplier params --node=https://testnet-validated-validator-rpc.poktroll.com/`
supplierParams := suppliertypes.Params{
MinStake: &cosmosTypes.Coin{
Expand All @@ -52,14 +59,31 @@ var Upgrade_0_0_12 = Upgrade{
}
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.
// Add service module `target_num_relays` parameter per `config.yml`.
// We don't use `GetParams()` to avoid potential protobuf issues and all networks have the same value (no need to read).
serviceParams := servicetypes.Params{
AddServiceFee: &cosmosTypes.Coin{
Denom: "upokt",
Amount: math.NewInt(1000000000),
},
TargetNumRelays: 100,
}
err = keepers.ServiceKeeper.SetParams(ctx, serviceParams)
if err != nil {
logger.Error("Failed to set service params", "error", err)
return err
}
logger.Info("Successfully updated service params", "new_params", serviceParams)

// TODO_IN_THIS_PR: Add service.params.target_num_relays.
// TODO_IN_THIS_PR: Add tokenomics.params.global_inflation_per_claim.
// Add tokenomics module `global_inflation_per_claim` parameter per `config.yml`.
// We use GetParams() as `DaoRewardAddress` is different between networks and we don't want to hardcode it.
tokenomicsParams := keepers.TokenomicsKeeper.GetParams(ctx)
tokenomicsParams.GlobalInflationPerClaim = 0.1
err = keepers.TokenomicsKeeper.SetParams(ctx, tokenomicsParams)
if err != nil {
logger.Error("Failed to set tokenomics params", "error", err)
return err
}
return
}

Expand Down

0 comments on commit 5a3decc

Please sign in to comment.