From adc3c4d80d7e4625ea642fc37fa70da06871431d Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Thu, 30 Jan 2025 17:53:57 -0800 Subject: [PATCH] set RevSharePercentage for all --- app/upgrades/v0.0.12.go | 26 +++++++++++++++---- .../relayminer_config_localnet_vscode.yaml | 2 +- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/app/upgrades/v0.0.12.go b/app/upgrades/v0.0.12.go index 5d124f73e..4859d8d9d 100644 --- a/app/upgrades/v0.0.12.go +++ b/app/upgrades/v0.0.12.go @@ -10,6 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" "github.com/pokt-network/poktroll/app/keepers" servicetypes "github.com/pokt-network/poktroll/x/service/types" + sharedtypes "github.com/pokt-network/poktroll/x/shared/types" suppliertypes "github.com/pokt-network/poktroll/x/supplier/types" ) @@ -20,11 +21,6 @@ import ( // 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{ PlanName: "v0.0.12", CreateUpgradeHandler: func(mm *module.Manager, @@ -98,6 +94,26 @@ var Upgrade_0_0_12 = Upgrade{ return vm, err } + // Since we changed the type of RevSharePercent from float32 to uint64, we need to update all on-chain data. + // The easiest way to do this is to iterate over all suppliers and services and set the revshare to 100 by default. + suppliers := keepers.SupplierKeeper.GetAllSuppliers(ctx) + logger.Info("Updating all suppliers to have a 100% revshare to the supplier", "num_suppliers", len(suppliers)) + for _, supplier := range suppliers { + for _, service := range supplier.Services { + // Force all services to have a 100% revshare to the supplier. + // Not something we would do on a real mainnet, but it's a quick way to resolve the issue. + // Currently, we don't break any existing suppliers (as all of them have a 100% revshare to the supplier). + service.RevShare = []*sharedtypes.ServiceRevenueShare{ + { + Address: supplier.OperatorAddress, + RevSharePercentage: uint64(100), + }, + } + } + keepers.SupplierKeeper.SetSupplier(ctx, supplier) + logger.Info("Updated supplier", "supplier", supplier.OperatorAddress) + } + logger.Info("Running module migrations") vm, err = mm.RunMigrations(ctx, configurator, vm) if err != nil { diff --git a/localnet/poktrolld/config/relayminer_config_localnet_vscode.yaml b/localnet/poktrolld/config/relayminer_config_localnet_vscode.yaml index 451914f9f..de20c4d13 100644 --- a/localnet/poktrolld/config/relayminer_config_localnet_vscode.yaml +++ b/localnet/poktrolld/config/relayminer_config_localnet_vscode.yaml @@ -23,7 +23,7 @@ metrics: addr: :9070 pocket_node: query_node_rpc_url: tcp://localhost:26657 - query_node_grpc_url: tcp://localhost:36658 + query_node_grpc_url: tcp://localhost:9090 tx_node_rpc_url: tcp://localhost:26657 suppliers: - service_id: anvil