From 4588d88a693ffb73616f91ef9622b849dbe77451 Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Tue, 26 Nov 2024 15:46:11 -0800 Subject: [PATCH 1/6] Alpha TestNet v0.0.11 upgrade --- app/upgrades/v0.0.11.go | 173 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100644 app/upgrades/v0.0.11.go diff --git a/app/upgrades/v0.0.11.go b/app/upgrades/v0.0.11.go new file mode 100644 index 000000000..2536128cf --- /dev/null +++ b/app/upgrades/v0.0.11.go @@ -0,0 +1,173 @@ +package upgrades + +import ( + "context" + "fmt" + "time" + + "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/cosmos/cosmos-sdk/x/authz" + "github.com/pokt-network/poktroll/app/keepers" + prooftypes "github.com/pokt-network/poktroll/x/proof/types" + tokenomicstypes "github.com/pokt-network/poktroll/x/tokenomics/types" +) + +// Upgrade_0_0_11 is the upgrade handler for v0.0.11 Alpha TestNet upgrade +// Beta TestNet was launched with v0.0.11, so this upgrade is exclusively for Alpha TestNet. +// - Before: v0.0.10 +// - After: v0.0.11 +var Upgrade_0_0_11 = Upgrade{ + PlanName: "v0.0.11", + 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. + // https://github.com/pokt-network/poktroll/compare/v0.0.10...v0.0.11-rc + applyNewParameters := func(ctx context.Context) (err error) { + // Add application min stake + // Validate with: `poktrolld q application params --node=https://testnet-validated-validator-rpc.poktroll.com/` + appParams := keepers.ApplicationKeeper.GetParams(ctx) + newMinStakeApp := cosmosTypes.NewCoin("upokt", math.NewInt(100000000)) + appParams.MinStake = &newMinStakeApp + err = keepers.ApplicationKeeper.SetParams(ctx, appParams) + if err != nil { + return err + } + + // Add supplier min stake + // Validate with: `poktrolld q supplier params --node=https://testnet-validated-validator-rpc.poktroll.com/` + supplierParams := keepers.SupplierKeeper.GetParams(ctx) + newMinStakeSupplier := cosmosTypes.NewCoin("upokt", math.NewInt(1000000)) + supplierParams.MinStake = &newMinStakeSupplier + err = keepers.SupplierKeeper.SetParams(ctx, supplierParams) + if err != nil { + return err + } + + // Add gateway min stake + // Validate with: `poktrolld q gateway params --node=https://testnet-validated-validator-rpc.poktroll.com/` + gatewayParams := keepers.GatewayKeeper.GetParams(ctx) + newMinStakeGW := cosmosTypes.NewCoin("upokt", math.NewInt(1000000)) + gatewayParams.MinStake = &newMinStakeGW + err = keepers.GatewayKeeper.SetParams(ctx, gatewayParams) + if err != nil { + return err + } + + // Adjust proof module parameters + // Validate with: `poktrolld q proof params --node=https://testnet-validated-validator-rpc.poktroll.com/` + newProofRequirementThreshold := cosmosTypes.NewCoin("upokt", math.NewInt(20000000)) + newProofMissingPenalty := cosmosTypes.NewCoin("upokt", math.NewInt(320000000)) + newProofSubmissionFee := cosmosTypes.NewCoin("upokt", math.NewInt(1000000)) + proofParams := prooftypes.NewParams( + 0.25, + &newProofRequirementThreshold, + &newProofMissingPenalty, + &newProofSubmissionFee, + ) + + err = keepers.ProofKeeper.SetParams(ctx, proofParams) + if err != nil { + return err + } + + // Add new shared module params + // Validate with: `poktrolld q shared params --node=https://testnet-validated-validator-rpc.poktroll.com/` + sharedParams := keepers.SharedKeeper.GetParams(ctx) + sharedParams.SupplierUnbondingPeriodSessions = uint64(1) + sharedParams.ApplicationUnbondingPeriodSessions = uint64(1) + sharedParams.ComputeUnitsToTokensMultiplier = uint64(42) + err = keepers.SharedKeeper.SetParams(ctx, sharedParams) + if err != nil { + return err + } + + // Set num_suppliers_per_session to 15 + // Validate with: `poktrolld q session params --node=https://testnet-validated-validator-rpc.poktroll.com/` + sessionParams := keepers.SessionKeeper.GetParams(ctx) + sessionParams.NumSuppliersPerSession = uint64(15) + err = keepers.SessionKeeper.SetParams(ctx, sessionParams) + if err != nil { + return err + } + + // Set tokenomics params: + // mint_allocation_percentages: + // dao: 0.1 + // proposer: 0.05 + // supplier: 0.7 + // source_owner: 0.15 + // application: 0.0 + // # The dao reward address SHOULD match that of the "pnf" below (i.e. `make poktrolld_addr ACC_NAME=pnf`). + // # This is the address that will receive the dao/foundation rewards during claim settlement (global mint TLM). + // # TODO_MAINNET(@olshansk): Consolidate the usage of DAO/PNF throughout the configs & codebase. + // dao_reward_address: "pokt1eeeksh2tvkh7wzmfrljnhw4wrhs55lcuvmekkw" + tokenomicsParams := keepers.TokenomicsKeeper.GetParams(ctx) + tokenomicsParams.MintAllocationPercentages = tokenomicstypes.MintAllocationPercentages{ + Dao: 0.1, + Proposer: 0.05, + Supplier: 0.7, + SourceOwner: 0.15, + Application: 0.0, + } + tokenomicsParams.DaoRewardAddress = AlphaTestNetPnfAddress + err = keepers.TokenomicsKeeper.SetParams(ctx, tokenomicsParams) + if err != nil { + return err + } + return + } + + // Adds new authz authorizations from the diff: + // https://github.com/pokt-network/poktroll/compare/v0.0.10...v0.0.11-rc + applyNewAuthorizations := func(ctx context.Context) (err error) { + // Validate before/after with: + // `poktrolld q authz grants-by-granter pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t --node=https://testnet-validated-validator-rpc.poktroll.com/` + grantAuthorizationMessages := []string{ + "/poktroll.session.MsgUpdateParam", + } + + expiration, err := time.Parse(time.RFC3339, "2500-01-01T00:00:00Z") + if err != nil { + return fmt.Errorf("failed to parse time: %w", err) + } + + for _, msg := range grantAuthorizationMessages { + err = keepers.AuthzKeeper.SaveGrant( + ctx, + cosmosTypes.AccAddress(AlphaTestNetPnfAddress), + cosmosTypes.AccAddress(AlphaTestNetAuthorityAddress), + authz.NewGenericAuthorization(msg), + &expiration, + ) + if err != nil { + return fmt.Errorf("failed to save grant for message %s: %w", msg, err) + } + } + return + } + + // Returns the upgrade handler for v0.0.11 + return func(ctx context.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + err := applyNewParameters(ctx) + if err != nil { + return vm, err + } + + err = applyNewAuthorizations(ctx) + if err != nil { + return vm, err + } + + return mm.RunMigrations(ctx, configurator, vm) + } + }, + // No changes to the KVStore in this upgrade. + StoreUpgrades: storetypes.StoreUpgrades{}, +} From a7573b8ebab7c605d579564d4d60eed4cc680a3e Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Tue, 26 Nov 2024 15:51:37 -0800 Subject: [PATCH 2/6] cleanup the upgrade file --- app/upgrades/v0.0.11.go | 75 ++--------------------------------------- 1 file changed, 3 insertions(+), 72 deletions(-) diff --git a/app/upgrades/v0.0.11.go b/app/upgrades/v0.0.11.go index 2536128cf..82b4d5ea9 100644 --- a/app/upgrades/v0.0.11.go +++ b/app/upgrades/v0.0.11.go @@ -5,14 +5,12 @@ import ( "fmt" "time" - "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/cosmos/cosmos-sdk/x/authz" "github.com/pokt-network/poktroll/app/keepers" - prooftypes "github.com/pokt-network/poktroll/x/proof/types" tokenomicstypes "github.com/pokt-network/poktroll/x/tokenomics/types" ) @@ -30,64 +28,6 @@ var Upgrade_0_0_11 = Upgrade{ // Adds new parameters using ignite's config.yml as a reference. Assuming we don't need any other parameters. // https://github.com/pokt-network/poktroll/compare/v0.0.10...v0.0.11-rc applyNewParameters := func(ctx context.Context) (err error) { - // Add application min stake - // Validate with: `poktrolld q application params --node=https://testnet-validated-validator-rpc.poktroll.com/` - appParams := keepers.ApplicationKeeper.GetParams(ctx) - newMinStakeApp := cosmosTypes.NewCoin("upokt", math.NewInt(100000000)) - appParams.MinStake = &newMinStakeApp - err = keepers.ApplicationKeeper.SetParams(ctx, appParams) - if err != nil { - return err - } - - // Add supplier min stake - // Validate with: `poktrolld q supplier params --node=https://testnet-validated-validator-rpc.poktroll.com/` - supplierParams := keepers.SupplierKeeper.GetParams(ctx) - newMinStakeSupplier := cosmosTypes.NewCoin("upokt", math.NewInt(1000000)) - supplierParams.MinStake = &newMinStakeSupplier - err = keepers.SupplierKeeper.SetParams(ctx, supplierParams) - if err != nil { - return err - } - - // Add gateway min stake - // Validate with: `poktrolld q gateway params --node=https://testnet-validated-validator-rpc.poktroll.com/` - gatewayParams := keepers.GatewayKeeper.GetParams(ctx) - newMinStakeGW := cosmosTypes.NewCoin("upokt", math.NewInt(1000000)) - gatewayParams.MinStake = &newMinStakeGW - err = keepers.GatewayKeeper.SetParams(ctx, gatewayParams) - if err != nil { - return err - } - - // Adjust proof module parameters - // Validate with: `poktrolld q proof params --node=https://testnet-validated-validator-rpc.poktroll.com/` - newProofRequirementThreshold := cosmosTypes.NewCoin("upokt", math.NewInt(20000000)) - newProofMissingPenalty := cosmosTypes.NewCoin("upokt", math.NewInt(320000000)) - newProofSubmissionFee := cosmosTypes.NewCoin("upokt", math.NewInt(1000000)) - proofParams := prooftypes.NewParams( - 0.25, - &newProofRequirementThreshold, - &newProofMissingPenalty, - &newProofSubmissionFee, - ) - - err = keepers.ProofKeeper.SetParams(ctx, proofParams) - if err != nil { - return err - } - - // Add new shared module params - // Validate with: `poktrolld q shared params --node=https://testnet-validated-validator-rpc.poktroll.com/` - sharedParams := keepers.SharedKeeper.GetParams(ctx) - sharedParams.SupplierUnbondingPeriodSessions = uint64(1) - sharedParams.ApplicationUnbondingPeriodSessions = uint64(1) - sharedParams.ComputeUnitsToTokensMultiplier = uint64(42) - err = keepers.SharedKeeper.SetParams(ctx, sharedParams) - if err != nil { - return err - } - // Set num_suppliers_per_session to 15 // Validate with: `poktrolld q session params --node=https://testnet-validated-validator-rpc.poktroll.com/` sessionParams := keepers.SessionKeeper.GetParams(ctx) @@ -97,17 +37,8 @@ var Upgrade_0_0_11 = Upgrade{ return err } - // Set tokenomics params: - // mint_allocation_percentages: - // dao: 0.1 - // proposer: 0.05 - // supplier: 0.7 - // source_owner: 0.15 - // application: 0.0 - // # The dao reward address SHOULD match that of the "pnf" below (i.e. `make poktrolld_addr ACC_NAME=pnf`). - // # This is the address that will receive the dao/foundation rewards during claim settlement (global mint TLM). - // # TODO_MAINNET(@olshansk): Consolidate the usage of DAO/PNF throughout the configs & codebase. - // dao_reward_address: "pokt1eeeksh2tvkh7wzmfrljnhw4wrhs55lcuvmekkw" + // Set tokenomics params. The values are based on default values for LocalNet. + // Validate with: `poktrolld q tokenomics params --node=https://testnet-validated-validator-rpc.poktroll.com/` tokenomicsParams := keepers.TokenomicsKeeper.GetParams(ctx) tokenomicsParams.MintAllocationPercentages = tokenomicstypes.MintAllocationPercentages{ Dao: 0.1, @@ -127,7 +58,7 @@ var Upgrade_0_0_11 = Upgrade{ // Adds new authz authorizations from the diff: // https://github.com/pokt-network/poktroll/compare/v0.0.10...v0.0.11-rc applyNewAuthorizations := func(ctx context.Context) (err error) { - // Validate before/after with: + // Validate with: // `poktrolld q authz grants-by-granter pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t --node=https://testnet-validated-validator-rpc.poktroll.com/` grantAuthorizationMessages := []string{ "/poktroll.session.MsgUpdateParam", From bc2a3c44d990d614cc0f31a7a8fb01d39a604b8d Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Tue, 26 Nov 2024 17:48:24 -0800 Subject: [PATCH 3/6] no need to do authz authorization --- api/poktroll/application/event.pulsar.go | 2 +- api/poktroll/application/types.pulsar.go | 2 +- api/poktroll/supplier/event.pulsar.go | 2 +- api/poktroll/supplier/tx.pulsar.go | 2 +- api/poktroll/tokenomics/event.pulsar.go | 2 +- api/poktroll/tokenomics/types.pulsar.go | 2 +- app/upgrades.go | 1 + app/upgrades/v0.0.11.go | 55 ++++++++++-------------- 8 files changed, 29 insertions(+), 39 deletions(-) diff --git a/api/poktroll/application/event.pulsar.go b/api/poktroll/application/event.pulsar.go index 292a46750..09bac55c2 100644 --- a/api/poktroll/application/event.pulsar.go +++ b/api/poktroll/application/event.pulsar.go @@ -3,11 +3,11 @@ package application import ( _ "cosmossdk.io/api/cosmos/base/v1beta1" + _ "github.com/pokt-network/poktroll/api/poktroll/shared" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" - _ "github.com/pokt-network/poktroll/api/poktroll/shared" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" diff --git a/api/poktroll/application/types.pulsar.go b/api/poktroll/application/types.pulsar.go index ca032ba67..f482e77bb 100644 --- a/api/poktroll/application/types.pulsar.go +++ b/api/poktroll/application/types.pulsar.go @@ -3,11 +3,11 @@ package application import ( v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" + shared "github.com/pokt-network/poktroll/api/poktroll/shared" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" - shared "github.com/pokt-network/poktroll/api/poktroll/shared" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" diff --git a/api/poktroll/supplier/event.pulsar.go b/api/poktroll/supplier/event.pulsar.go index 8558365eb..22dcc4989 100644 --- a/api/poktroll/supplier/event.pulsar.go +++ b/api/poktroll/supplier/event.pulsar.go @@ -3,11 +3,11 @@ package supplier import ( _ "cosmossdk.io/api/cosmos/base/v1beta1" + shared "github.com/pokt-network/poktroll/api/poktroll/shared" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" - shared "github.com/pokt-network/poktroll/api/poktroll/shared" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" diff --git a/api/poktroll/supplier/tx.pulsar.go b/api/poktroll/supplier/tx.pulsar.go index 7a709f7f0..1d2057b01 100644 --- a/api/poktroll/supplier/tx.pulsar.go +++ b/api/poktroll/supplier/tx.pulsar.go @@ -5,11 +5,11 @@ import ( _ "cosmossdk.io/api/amino" v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" _ "cosmossdk.io/api/cosmos/msg/v1" + shared "github.com/pokt-network/poktroll/api/poktroll/shared" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" - shared "github.com/pokt-network/poktroll/api/poktroll/shared" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" diff --git a/api/poktroll/tokenomics/event.pulsar.go b/api/poktroll/tokenomics/event.pulsar.go index e62c41344..af0c412dc 100644 --- a/api/poktroll/tokenomics/event.pulsar.go +++ b/api/poktroll/tokenomics/event.pulsar.go @@ -3,10 +3,10 @@ package tokenomics import ( v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" + proof "github.com/pokt-network/poktroll/api/poktroll/proof" fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" - proof "github.com/pokt-network/poktroll/api/poktroll/proof" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" diff --git a/api/poktroll/tokenomics/types.pulsar.go b/api/poktroll/tokenomics/types.pulsar.go index 9ca1a54f9..e48600e95 100644 --- a/api/poktroll/tokenomics/types.pulsar.go +++ b/api/poktroll/tokenomics/types.pulsar.go @@ -3,11 +3,11 @@ package tokenomics import ( v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" + proof "github.com/pokt-network/poktroll/api/poktroll/proof" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" - proof "github.com/pokt-network/poktroll/api/poktroll/proof" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" diff --git a/app/upgrades.go b/app/upgrades.go index 0978f4322..377bb4cb6 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -13,6 +13,7 @@ import ( var allUpgrades = []upgrades.Upgrade{ upgrades.Upgrade_0_0_4, upgrades.Upgrade_0_0_10, + upgrades.Upgrade_0_0_11, } // setUpgrades sets upgrade handlers for all upgrades and executes KVStore migration if an upgrade plan file exists. diff --git a/app/upgrades/v0.0.11.go b/app/upgrades/v0.0.11.go index 82b4d5ea9..c920882f9 100644 --- a/app/upgrades/v0.0.11.go +++ b/app/upgrades/v0.0.11.go @@ -2,14 +2,11 @@ package upgrades import ( "context" - "fmt" - "time" 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/cosmos/cosmos-sdk/x/authz" "github.com/pokt-network/poktroll/app/keepers" tokenomicstypes "github.com/pokt-network/poktroll/x/tokenomics/types" ) @@ -28,18 +25,25 @@ var Upgrade_0_0_11 = Upgrade{ // Adds new parameters using ignite's config.yml as a reference. Assuming we don't need any other parameters. // https://github.com/pokt-network/poktroll/compare/v0.0.10...v0.0.11-rc applyNewParameters := func(ctx context.Context) (err error) { + logger := cosmosTypes.UnwrapSDKContext(ctx).Logger() + logger.Info("Starting parameter updates for v0.0.11") + // Set num_suppliers_per_session to 15 // Validate with: `poktrolld q session params --node=https://testnet-validated-validator-rpc.poktroll.com/` sessionParams := keepers.SessionKeeper.GetParams(ctx) + logger.Info("Current session params", "params", sessionParams) sessionParams.NumSuppliersPerSession = uint64(15) err = keepers.SessionKeeper.SetParams(ctx, sessionParams) if err != nil { + logger.Error("Failed to set session params", "error", err) return err } + logger.Info("Successfully updated session params", "new_params", sessionParams) // Set tokenomics params. The values are based on default values for LocalNet. // Validate with: `poktrolld q tokenomics params --node=https://testnet-validated-validator-rpc.poktroll.com/` tokenomicsParams := keepers.TokenomicsKeeper.GetParams(ctx) + logger.Info("Current tokenomics params", "params", tokenomicsParams) tokenomicsParams.MintAllocationPercentages = tokenomicstypes.MintAllocationPercentages{ Dao: 0.1, Proposer: 0.05, @@ -50,53 +54,38 @@ var Upgrade_0_0_11 = Upgrade{ tokenomicsParams.DaoRewardAddress = AlphaTestNetPnfAddress err = keepers.TokenomicsKeeper.SetParams(ctx, tokenomicsParams) if err != nil { + logger.Error("Failed to set tokenomics params", "error", err) return err } - return - } - - // Adds new authz authorizations from the diff: - // https://github.com/pokt-network/poktroll/compare/v0.0.10...v0.0.11-rc - applyNewAuthorizations := func(ctx context.Context) (err error) { - // Validate with: - // `poktrolld q authz grants-by-granter pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t --node=https://testnet-validated-validator-rpc.poktroll.com/` - grantAuthorizationMessages := []string{ - "/poktroll.session.MsgUpdateParam", - } + logger.Info("Successfully updated tokenomics params", "new_params", tokenomicsParams) - expiration, err := time.Parse(time.RFC3339, "2500-01-01T00:00:00Z") - if err != nil { - return fmt.Errorf("failed to parse time: %w", err) - } - - for _, msg := range grantAuthorizationMessages { - err = keepers.AuthzKeeper.SaveGrant( - ctx, - cosmosTypes.AccAddress(AlphaTestNetPnfAddress), - cosmosTypes.AccAddress(AlphaTestNetAuthorityAddress), - authz.NewGenericAuthorization(msg), - &expiration, - ) - if err != nil { - return fmt.Errorf("failed to save grant for message %s: %w", msg, err) - } - } return } + // The diff shows that the only new authz authorization is for the `poktroll.session.MsgUpdateParam` message. + // However, this message is already authorized for the `pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t` address. + // See here: poktrolld q authz grants-by-granter pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t --node=https://shannon-testnet-grove-seed-rpc.alpha.poktroll.com + // Returns the upgrade handler for v0.0.11 return func(ctx context.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + logger := cosmosTypes.UnwrapSDKContext(ctx).Logger() + logger.Info("Starting v0.0.11 upgrade handler") + err := applyNewParameters(ctx) if err != nil { + logger.Error("Failed to apply new parameters", "error", err) return vm, err } - err = applyNewAuthorizations(ctx) + 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 } - return mm.RunMigrations(ctx, configurator, vm) + logger.Info("Successfully completed v0.0.11 upgrade handler") + return vm, nil } }, // No changes to the KVStore in this upgrade. From 986ed73fd4be269b45402118f7b1fb828d95ff62 Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Wed, 27 Nov 2024 12:46:17 -0800 Subject: [PATCH 4/6] add comment --- app/upgrades/v0.0.11.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/upgrades/v0.0.11.go b/app/upgrades/v0.0.11.go index c920882f9..e23f4843a 100644 --- a/app/upgrades/v0.0.11.go +++ b/app/upgrades/v0.0.11.go @@ -40,7 +40,7 @@ var Upgrade_0_0_11 = Upgrade{ } logger.Info("Successfully updated session params", "new_params", sessionParams) - // Set tokenomics params. The values are based on default values for LocalNet. + // Set tokenomics params. The values are based on default values for LocalNet/Beta TestNet. // Validate with: `poktrolld q tokenomics params --node=https://testnet-validated-validator-rpc.poktroll.com/` tokenomicsParams := keepers.TokenomicsKeeper.GetParams(ctx) logger.Info("Current tokenomics params", "params", tokenomicsParams) From 867a6919b0971bcc286c1d5a5f0f0561b1e3f27a Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Mon, 9 Dec 2024 17:16:22 -0800 Subject: [PATCH 5/6] remove GetParams for an upgrade --- app/upgrades/v0.0.11.go | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/app/upgrades/v0.0.11.go b/app/upgrades/v0.0.11.go index e23f4843a..6f94fa286 100644 --- a/app/upgrades/v0.0.11.go +++ b/app/upgrades/v0.0.11.go @@ -8,6 +8,7 @@ import ( cosmosTypes "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/pokt-network/poktroll/app/keepers" + sessiontypes "github.com/pokt-network/poktroll/x/session/types" tokenomicstypes "github.com/pokt-network/poktroll/x/tokenomics/types" ) @@ -30,9 +31,11 @@ var Upgrade_0_0_11 = Upgrade{ // Set num_suppliers_per_session to 15 // Validate with: `poktrolld q session params --node=https://testnet-validated-validator-rpc.poktroll.com/` - sessionParams := keepers.SessionKeeper.GetParams(ctx) - logger.Info("Current session params", "params", sessionParams) - sessionParams.NumSuppliersPerSession = uint64(15) + sessionParams := sessiontypes.Params{ + NumSuppliersPerSession: uint64(15), + } + + // ALL parameters must be present when setting params. err = keepers.SessionKeeper.SetParams(ctx, sessionParams) if err != nil { logger.Error("Failed to set session params", "error", err) @@ -42,16 +45,18 @@ var Upgrade_0_0_11 = Upgrade{ // Set tokenomics params. The values are based on default values for LocalNet/Beta TestNet. // Validate with: `poktrolld q tokenomics params --node=https://testnet-validated-validator-rpc.poktroll.com/` - tokenomicsParams := keepers.TokenomicsKeeper.GetParams(ctx) - logger.Info("Current tokenomics params", "params", tokenomicsParams) - tokenomicsParams.MintAllocationPercentages = tokenomicstypes.MintAllocationPercentages{ - Dao: 0.1, - Proposer: 0.05, - Supplier: 0.7, - SourceOwner: 0.15, - Application: 0.0, + tokenomicsParams := tokenomicstypes.Params{ + MintAllocationPercentages: tokenomicstypes.MintAllocationPercentages{ + Dao: 0.1, + Proposer: 0.05, + Supplier: 0.7, + SourceOwner: 0.15, + Application: 0.0, + }, + DaoRewardAddress: AlphaTestNetPnfAddress, } - tokenomicsParams.DaoRewardAddress = AlphaTestNetPnfAddress + + // ALL parameters must be present when setting params. err = keepers.TokenomicsKeeper.SetParams(ctx, tokenomicsParams) if err != nil { logger.Error("Failed to set tokenomics params", "error", err) @@ -65,6 +70,7 @@ var Upgrade_0_0_11 = Upgrade{ // The diff shows that the only new authz authorization is for the `poktroll.session.MsgUpdateParam` message. // However, this message is already authorized for the `pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t` address. // See here: poktrolld q authz grants-by-granter pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t --node=https://shannon-testnet-grove-seed-rpc.alpha.poktroll.com + // If this upgrade would have been applied to other networks, we could have added a separate upgrade handler for each network. // Returns the upgrade handler for v0.0.11 return func(ctx context.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { From 42716a97d7864df9fc840ce95c58789a7907e887 Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Tue, 10 Dec 2024 12:44:33 -0800 Subject: [PATCH 6/6] use default config --- cmd/poktrolld/cmd/config.go | 8 +++----- telemetry/defaults.go | 14 ++++++++++++++ telemetry/telemetry.go | 23 +++++++++++++++++++---- 3 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 telemetry/defaults.go diff --git a/cmd/poktrolld/cmd/config.go b/cmd/poktrolld/cmd/config.go index ae9520a41..89536a6a1 100644 --- a/cmd/poktrolld/cmd/config.go +++ b/cmd/poktrolld/cmd/config.go @@ -21,12 +21,10 @@ type PoktrollAppConfig struct { } // poktrollAppConfigDefaults sets default values to render in `app.toml`. -// Checkout `customAppConfigTemplate()` for additional information about each setting. +// Checkout `customAppConfigTemplate()` for additional information about each config parameter. func poktrollAppConfigDefaults() PoktrollAppConfig { return PoktrollAppConfig{ - Telemetry: telemetry.PoktrollTelemetryConfig{ - CardinalityLevel: "medium", - }, + Telemetry: telemetry.DefaultConfig(), } } @@ -104,7 +102,6 @@ func initCometBFTConfig() *cmtcfg.Config { // return "", nil if no custom configuration is required for the application. // TODO_MAINNET: Reconsider values - check `app.toml` for possible options. func initAppConfig() (string, interface{}) { - // The following code snippet is just for reference. type CustomAppConfig struct { serverconfig.Config `mapstructure:",squash"` Poktroll PoktrollAppConfig `mapstructure:"poktroll"` @@ -140,6 +137,7 @@ func initAppConfig() (string, interface{}) { srvCfg.GRPC.Enable = true srvCfg.GRPCWeb.Enable = true + // Create the custom config with both server and poktroll configs customAppConfig := CustomAppConfig{ Config: *srvCfg, Poktroll: poktrollAppConfigDefaults(), diff --git a/telemetry/defaults.go b/telemetry/defaults.go new file mode 100644 index 000000000..e059e2c93 --- /dev/null +++ b/telemetry/defaults.go @@ -0,0 +1,14 @@ +package telemetry + +// Default configuration values for telemetry +const ( + // DefaultCardinalityLevel represents the default cardinality level for metrics collection + DefaultCardinalityLevel = "medium" +) + +// DefaultConfig returns the default telemetry configuration +func DefaultConfig() PoktrollTelemetryConfig { + return PoktrollTelemetryConfig{ + CardinalityLevel: DefaultCardinalityLevel, + } +} diff --git a/telemetry/telemetry.go b/telemetry/telemetry.go index 348b73898..d7b93a879 100644 --- a/telemetry/telemetry.go +++ b/telemetry/telemetry.go @@ -11,16 +11,31 @@ import ( // Set once on initialization and remains constant during runtime. var globalTelemetryConfig PoktrollTelemetryConfig -// PoktrollTelemetryConfig represents the telemetry protion of the custom poktroll config section in `app.toml`. +// PoktrollTelemetryConfig represents the telemetry portion of the custom poktroll config section in `app.toml`. type PoktrollTelemetryConfig struct { CardinalityLevel string `mapstructure:"cardinality-level"` } // New sets the globalTelemetryConfig for telemetry package. func New(appOpts servertypes.AppOptions) error { - // Extract the map from appOpts. - // `poktroll.telemetry` comes from `app.toml` which is parsed into a map. - telemetryMap := appOpts.Get("poktroll.telemetry").(map[string]interface{}) + // Get the poktroll config section. If it doesn't exist, use defaults + poktrollConfig := appOpts.Get("poktroll") + if poktrollConfig == nil { + globalTelemetryConfig = DefaultConfig() + return nil + } + + // Try to get the telemetry subsection + poktrollMap, ok := poktrollConfig.(map[string]interface{}) + if !ok { + return fmt.Errorf("invalid poktroll config format: expected map[string]interface{}, got %T", poktrollConfig) + } + + telemetryMap, ok := poktrollMap["telemetry"].(map[string]interface{}) + if !ok { + globalTelemetryConfig = DefaultConfig() + return nil + } // Use mapstructure to decode the map into the struct if err := mapstructure.Decode(telemetryMap, &globalTelemetryConfig); err != nil {