Skip to content

Commit

Permalink
[Tokenomics] Consolidate mint_allocation_<actor> params & CLI clean…
Browse files Browse the repository at this point in the history
…up (#923)

## Summary

- Remove unused and problematic param update CLI code.
- Consolidate `mint_allocation_<actor>` params into a single
`mint_allocation_percentages` param.

## Issue

- `TODO_BETA`

## Type of change

Select one or more from the following:

- [ ] New feature, functionality or library
- [ ] Consensus breaking; add the `consensus-breaking` label if so. See
#791 for details
- [ ] Bug fix
- [x] Code health or cleanup
- [ ] Documentation
- [ ] Other (specify)

## Testing

- [ ] **Documentation**: `make docusaurus_start`; only needed if you
make doc changes
- [x] **Unit Tests**: `make go_develop_and_test`
- [ ] **LocalNet E2E Tests**: `make test_e2e`
- [x] **DevNet E2E Tests**: Add the `devnet-test-e2e` label to the PR.

## Sanity Checklist

- [x] I have tested my changes using the available tooling
- [x] I have commented my code
- [x] I have performed a self-review of my own code; both comments &
source code
- [ ] I create and reference any new tickets, if applicable
- [ ] I have left TODOs throughout the codebase, if applicable

---------

Co-authored-by: Redouane Lakrache <[email protected]>
Co-authored-by: Daniel Olshansky <[email protected]>
  • Loading branch information
3 people authored Nov 19, 2024
1 parent 5f4c116 commit b9c0146
Show file tree
Hide file tree
Showing 31 changed files with 1,594 additions and 1,007 deletions.
1,071 changes: 776 additions & 295 deletions api/poktroll/tokenomics/params.pulsar.go

Large diffs are not rendered by default.

264 changes: 161 additions & 103 deletions api/poktroll/tokenomics/tx.pulsar.go

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,12 @@ genesis:
num_suppliers_per_session: 15
tokenomics:
params:
mint_allocation_dao: 0.1
mint_allocation_proposer: 0.05
mint_allocation_supplier: 0.7
mint_allocation_source_owner: 0.15
mint_allocation_application: 0.0
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_MAINNER(@olshansk): Consolidate the usage of DAO/PNF throughout the configs & codebase.
Expand Down
6 changes: 3 additions & 3 deletions e2e/tests/parse_params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,12 @@ func (s *suite) newMsgUpdateParam(

func (s *suite) newTokenomicsMsgUpdateParam(authority string, param paramAny) (msg proto.Message) {
switch param.typeStr {
case "float64":
case "string":
msg = proto.Message(&tokenomicstypes.MsgUpdateParam{
Authority: authority,
Name: param.name,
AsType: &tokenomicstypes.MsgUpdateParam_AsFloat{
AsFloat: param.value.(float64),
AsType: &tokenomicstypes.MsgUpdateParam_AsString{
AsString: param.value.(string),
},
})
default:
Expand Down
18 changes: 3 additions & 15 deletions makefiles/params.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,9 @@ params_get_tokenomics: ## Get the tokenomics module params
params_update_tokenomics_all: ## Update the tokenomics module params
poktrolld tx authz exec ./tools/scripts/params/tokenomics_all.json $(PARAM_FLAGS)

.PHONY: params_update_tokenomics_mint_allocation_dao
params_update_tokenomics_mint_allocation_dao: ## Update the tokenomics module mint_allocation_dao param
poktrolld tx authz exec ./tools/scripts/params/tokenomics_mint_allocation_dao.json $(PARAM_FLAGS)

.PHONY: params_update_tokenomics_mint_allocation_proposer
params_update_tokenomics_mint_allocation_proposer: ## Update the tokenomics module mint_allocation_proposer param
poktrolld tx authz exec ./tools/scripts/params/tokenomics_mint_allocation_proposer.json $(PARAM_FLAGS)

.PHONY: params_update_tokenomics_mint_allocation_supplier
params_update_tokenomics_mint_allocation_supplier: ## Update the tokenomics module mint_allocation_supplier param
poktrolld tx authz exec ./tools/scripts/params/tokenomics_mint_allocation_supplier.json $(PARAM_FLAGS)

.PHONY: params_update_tokenomics_mint_allocation_source_owner
params_update_tokenomics_mint_allocation_source_owner: ## Update the tokenomics module mint_allocation_source_owner param
poktrolld tx authz exec ./tools/scripts/params/tokenomics_mint_allocation_source_owner.json $(PARAM_FLAGS)
.PHONY: params_update_tokenomics_mint_allocation_percentages
params_update_tokenomics_mint_allocation_percentages: ## Update the tokenomics module mint_allocation_percentages param
poktrolld tx authz exec ./tools/scripts/params/tokenomics_mint_allocation_percentages.json $(PARAM_FLAGS)

### Service Module Params ###
.PHONY: params_get_service
Expand Down
38 changes: 23 additions & 15 deletions proto/poktroll/tokenomics/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package poktroll.tokenomics;

option go_package = "github.com/pokt-network/poktroll/x/tokenomics/types";
option (gogoproto.stable_marshaler_all) = true;
option (gogoproto.equal_all) = true;

import "amino/amino.proto";
import "gogoproto/gogo.proto";
Expand All @@ -14,21 +15,8 @@ message Params {
option (amino.name) = "poktroll/x/tokenomics/Params";
option (gogoproto.equal) = true;

// mint_allocation_dao is the percentage of the minted tokens which are sent
// to the DAO reward address during claim settlement.
double mint_allocation_dao = 1 [(gogoproto.jsontag) = "mint_allocation_dao", (gogoproto.moretags) = "yaml:\"mint_allocation_dao\""];
// mint_allocation_proposer is the percentage of the minted tokens which are sent
// to the block proposer account address during claim settlement.
double mint_allocation_proposer = 2 [(gogoproto.jsontag) = "mint_allocation_proposer", (gogoproto.moretags) = "yaml:\"mint_allocation_proposer\""];
// mint_allocation_supplier is the percentage of the minted tokens which are sent
// to the block supplier account address during claim settlement.
double mint_allocation_supplier = 3 [(gogoproto.jsontag) = "mint_allocation_supplier", (gogoproto.moretags) = "yaml:\"mint_allocation_supplier\""];
// mint_allocation_source_owner is the percentage of the minted tokens which are sent
// to the service source owner account address during claim settlement.
double mint_allocation_source_owner = 4 [(gogoproto.jsontag) = "mint_allocation_source_owner", (gogoproto.moretags) = "yaml:\"mint_allocation_source_owner\""];
// mint_allocation_application is the percentage of the minted tokens which are sent
// to the application account address during claim settlement.
double mint_allocation_application = 5 [(gogoproto.jsontag) = "mint_allocation_application", (gogoproto.moretags) = "yaml:\"mint_allocation_application\""];
MintAllocationPercentages mint_allocation_percentages = 1 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "mint_allocation_proposer", (gogoproto.moretags) = "yaml:\"mint_allocation_percentages\""];

// dao_reward_address is the address to which mint_allocation_dao percentage of the
// minted tokens are at the end of claim settlement.
string dao_reward_address = 6 [(cosmos_proto.scalar) = "cosmos.AddressString", (gogoproto.jsontag) = "dao_reward_address", (gogoproto.moretags) = "yaml:\"dao_reward_address\""]; // Bech32 cosmos address
Expand All @@ -48,3 +36,23 @@ message Params {
// - RevDistr.PercentageToPNF
// - RevDistr.PercentageToDelegators
}

// MintAllocationPercentages represents the distribution of newly minted tokens,
// at the end of claim settlement, as a result of the Global Mint TLM.
message MintAllocationPercentages {
// dao is the percentage of the minted tokens which are sent
// to the DAO reward address during claim settlement.
double dao = 1 [(gogoproto.jsontag) = "dao", (gogoproto.moretags) = "yaml:\"dao\""];
// proposer is the percentage of the minted tokens which are sent
// to the block proposer account address during claim settlement.
double proposer = 2 [(gogoproto.jsontag) = "proposer", (gogoproto.moretags) = "yaml:\"proposer\""];
// supplier is the percentage of the minted tokens which are sent
// to the block supplier account address during claim settlement.
double supplier = 3 [(gogoproto.jsontag) = "supplier", (gogoproto.moretags) = "yaml:\"supplier\""];
// source_owner is the percentage of the minted tokens which are sent
// to the service source owner account address during claim settlement.
double source_owner = 4 [(gogoproto.jsontag) = "source_owner", (gogoproto.moretags) = "yaml:\"source_owner\""];
// allocation_application is the percentage of the minted tokens which are sent
// to the application account address during claim settlement.
double application = 5 [(gogoproto.jsontag) = "application", (gogoproto.moretags) = "yaml:\"application\""];
}
2 changes: 1 addition & 1 deletion proto/poktroll/tokenomics/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ message MsgUpdateParam {
// specified in the `Params` message in `proof/params.proto.`
string name = 2;
oneof as_type {
double as_float = 3 [(gogoproto.jsontag) = "as_float"];
MintAllocationPercentages as_mint_allocation_percentages = 3 [(gogoproto.jsontag) = "as_mint_allocation_percentages", (gogoproto.moretags) = "yaml:\"as_mint_allocation_percentages\""];
string as_string = 4 [(gogoproto.jsontag) = "as_string"];
}
}
Expand Down
10 changes: 0 additions & 10 deletions tests/integration/params/update_param_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ func (s *msgUpdateParamTestSuite) TestUnauthorizedMsgUpdateParamFails() {
validParamsFieldValue := validParamsValue.Field(fieldIdx)
fieldName := validParamsValue.Type().Field(fieldIdx).Name

// Skip fields which in the excludedParams map.
if _, ok := suites.ExcludedParams[fieldName]; ok {
continue
}

testName := fmt.Sprintf("%s_%s", moduleName, fieldName)
s.T().Run(testName, func(t *testing.T) {
// Reset the app state in order to assert that each module
Expand Down Expand Up @@ -93,11 +88,6 @@ func (s *msgUpdateParamTestSuite) TestAuthorizedMsgUpdateParamSucceeds() {
fieldExpectedValue := validParamsValue.Field(fieldIdx)
fieldName := validParamsValue.Type().Field(fieldIdx).Name

// Skip fields which in the excludedParams map.
if _, ok := suites.ExcludedParams[fieldName]; ok {
continue
}

testName := fmt.Sprintf("%s_%s", moduleName, fieldName)
s.T().Run(testName, func(t *testing.T) {
// Reset the app state in order to assert that each module
Expand Down
33 changes: 10 additions & 23 deletions testutil/integration/suites/param_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,15 @@ import (
type ParamType = string

const (
ParamTypeInt64 ParamType = "int64"
ParamTypeUint64 ParamType = "uint64"
ParamTypeFloat64 ParamType = "float64"
ParamTypeString ParamType = "string"
ParamTypeBytes ParamType = "uint8"
ParamTypeCoin ParamType = "Coin"
ParamTypeInt64 ParamType = "int64"
ParamTypeUint64 ParamType = "uint64"
ParamTypeFloat64 ParamType = "float64"
ParamTypeString ParamType = "string"
ParamTypeBytes ParamType = "uint8"
ParamTypeCoin ParamType = "Coin"
ParamTypeMintAllocationPercentages ParamType = "MintAllocationPercentages"
)

// TODO_UPNEXT(@bryanchriswhite): Promote mint_allocation_XXX params to
// a new mint_allocation message type. This map will no longer be needed
var ExcludedParams = map[string]struct{}{
"MintAllocationDao": {},
"MintAllocationProposer": {},
"MintAllocationSupplier": {},
"MintAllocationSourceOwner": {},
"MintAllocationApplication": {},
}

// ModuleParamConfig holds type information about a module's parameters update
// message(s) along with default and valid non-default values and a query constructor
// function for the module. It is used by ParamsSuite to construct and send
Expand Down Expand Up @@ -242,16 +233,12 @@ var (
QueryParamsResponse: tokenomicstypes.QueryParamsResponse{},
},
ValidParams: tokenomicstypes.Params{
MintAllocationDao: tokenomicstypes.DefaultMintAllocationDao,
MintAllocationProposer: tokenomicstypes.DefaultMintAllocationProposer,
MintAllocationSupplier: tokenomicstypes.DefaultMintAllocationSupplier,
MintAllocationSourceOwner: tokenomicstypes.DefaultMintAllocationSourceOwner,
MintAllocationApplication: tokenomicstypes.DefaultMintAllocationApplication,
MintAllocationPercentages: tokenomicstypes.DefaultMintAllocationPercentages,
DaoRewardAddress: sample.AccAddress(),
},
ParamTypes: map[ParamType]any{
ParamTypeFloat64: tokenomicstypes.MsgUpdateParam_AsFloat{},
ParamTypeString: tokenomicstypes.MsgUpdateParam_AsString{},
ParamTypeMintAllocationPercentages: tokenomicstypes.MsgUpdateParam_AsMintAllocationPercentages{},
ParamTypeString: tokenomicstypes.MsgUpdateParam_AsString{},
},
DefaultParams: tokenomicstypes.DefaultParams(),
NewParamClientFn: tokenomicstypes.NewQueryClient,
Expand Down
16 changes: 15 additions & 1 deletion testutil/integration/suites/update_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,18 +244,32 @@ func (s *ParamsSuite) RunUpdateParamAsSigner(
msgAsTypeValue := reflect.New(msgAsTypeType)
switch paramType {
case ParamTypeUint64:
// NB: MsgUpdateParam doesn't currently support uint64 param type.
// =~ msg.AsType.AsUint64 = paramReflectValue.Interface().(uint64)
msgAsTypeValue.Elem().FieldByName("AsUint64").Set(paramReflectValue)
case ParamTypeInt64:
// =~ msg.AsType.AsInt64 = paramReflectValue.Interface().(int64)
msgAsTypeValue.Elem().FieldByName("AsInt64").Set(paramReflectValue)
case ParamTypeFloat64:
// =~ msg.AsType.AsFloat = paramReflectValue.Interface().(float64)
msgAsTypeValue.Elem().FieldByName("AsFloat").Set(paramReflectValue)
case ParamTypeString:
// =~ msg.AsType.AsString = paramReflectValue.Interface().(string)
msgAsTypeValue.Elem().FieldByName("AsString").Set(paramReflectValue)
case ParamTypeBytes:
// =~ msg.AsType.AsBytes = paramReflectValue.Interface().([]byte)
msgAsTypeValue.Elem().FieldByName("AsBytes").Set(paramReflectValue)
case ParamTypeCoin:
// =~ msg.AsType.AsCoin = paramReflectValue.Interface().(*cosmostypes.Coin)
msgAsTypeValue.Elem().FieldByName("AsCoin").Set(paramReflectValue)
case ParamTypeMintAllocationPercentages:
// DEB_NOTE: Params.MintAllocationPercentages is a struct (not a pointer) because
// it is not nullable. As a result, in this case, we need to create a pointer to
// assign the paramValue to (because it won't be a pointer itself).
asMintAllocationPercentagesField := msgAsTypeValue.Elem().FieldByName("AsMintAllocationPercentages")
// =~ msg.AsType.AsMintAllocationPercentages = new(MsgUpdateParam_AsMintAllocationPercentages)
asMintAllocationPercentagesField.Set(reflect.New(paramReflectValue.Type()))
// =~ *msg.AsType.AsMintAllocationPercentages = paramReflectValue.Interface().(MintAllocationPercentages)
asMintAllocationPercentagesField.Elem().Set(paramReflectValue)
default:
t.Fatalf("ERROR: unknown field type %q", paramType)
}
Expand Down
12 changes: 7 additions & 5 deletions tools/scripts/params/tokenomics_all.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
"@type": "/poktroll.tokenomics.MsgUpdateParams",
"authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t",
"params": {
"mint_allocation_dao": 0.1,
"mint_allocation_proposer": 0.05,
"mint_allocation_supplier": 0.7,
"mint_allocation_source_owner": 0.15,
"mint_allocation_application": 0.0
"mint_allocation_percentages": {
"dao": 0.1,
"proposer": 0.05,
"supplier": 0.7,
"source_owner": 0.15,
"application": 0.0
}
}
}
]
Expand Down
12 changes: 0 additions & 12 deletions tools/scripts/params/tokenomics_mint_allocation_application.json

This file was deleted.

12 changes: 0 additions & 12 deletions tools/scripts/params/tokenomics_mint_allocation_dao.json

This file was deleted.

18 changes: 18 additions & 0 deletions tools/scripts/params/tokenomics_mint_allocation_percentages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"body": {
"messages": [
{
"@type": "/poktroll.tokenomics.MsgUpdateParam",
"authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t",
"name": "mint_allocation_percentages",
"as_mint_allocation_percentages": {
"dao": 0.1,
"proposer": 0.05,
"supplier": 0.7,
"source_owner": 0.15,
"application": 0.0
}
}
]
}
}
12 changes: 0 additions & 12 deletions tools/scripts/params/tokenomics_mint_allocation_proposer.json

This file was deleted.

12 changes: 0 additions & 12 deletions tools/scripts/params/tokenomics_mint_allocation_source_owner.json

This file was deleted.

12 changes: 0 additions & 12 deletions tools/scripts/params/tokenomics_mint_allocation_supplier.json

This file was deleted.

14 changes: 3 additions & 11 deletions x/tokenomics/keeper/msg_server_update_param.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,9 @@ func (k msgServer) UpdateParam(
params := k.GetParams(ctx)

switch msg.Name {
case tokenomicstypes.ParamMintAllocationDao:
case tokenomicstypes.ParamMintAllocationProposer:
case tokenomicstypes.ParamMintAllocationSupplier:
case tokenomicstypes.ParamMintAllocationSourceOwner:
case tokenomicstypes.ParamMintAllocationApplication:
return nil, status.Error(
codes.InvalidArgument,
tokenomicstypes.ErrTokenomicsParamInvalid.Wrapf(
"%s cannot be updated individually as all mint allocation percentages MUST ALWAYS sum to 1", msg.Name,
).Error(),
)
case tokenomicstypes.ParamMintAllocationPercentages:
logger = logger.With("param_value", msg.GetAsMintAllocationPercentages())
params.MintAllocationPercentages = *msg.GetAsMintAllocationPercentages()
case tokenomicstypes.ParamDaoRewardAddress:
logger = logger.With("param_value", msg.GetAsString())
params.DaoRewardAddress = msg.GetAsString()
Expand Down
Loading

0 comments on commit b9c0146

Please sign in to comment.