Skip to content

Commit

Permalink
set RevSharePercentage for all
Browse files Browse the repository at this point in the history
  • Loading branch information
okdas committed Jan 31, 2025
1 parent f187c35 commit adc3c4d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
26 changes: 21 additions & 5 deletions app/upgrades/v0.0.12.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit adc3c4d

Please sign in to comment.