Skip to content

Commit

Permalink
Remove unused emissions module parameter, fix imports in tests (#131)
Browse files Browse the repository at this point in the history
quick cleanup pr

`PercentRewardsReputersWorkers` -> `ValidatorsVsAlloraPercentReward` in
PR #94 and somehow the original variable persisted probably due to merge
errors
  • Loading branch information
relyt29 authored Apr 11, 2024
1 parent 9f30fbf commit 3e4da21
Show file tree
Hide file tree
Showing 14 changed files with 1,830 additions and 2,192 deletions.
1,690 changes: 774 additions & 916 deletions x/emissions/api/v1/tx.pulsar.go

Large diffs are not rendered by default.

1,103 changes: 510 additions & 593 deletions x/emissions/api/v1/types.pulsar.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package inference_synthesis_test

import (
alloraMath "github.com/allora-network/allora-chain/math"
inference_synthesis "github.com/allora-network/allora-chain/x/emissions/module/inference_synthesis"
inference_synthesis "github.com/allora-network/allora-chain/x/emissions/keeper/inference_synthesis"
emissions "github.com/allora-network/allora-chain/x/emissions/types"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package inference_synthesis_test
import (
alloraMath "github.com/allora-network/allora-chain/math"

inference_synthesis "github.com/allora-network/allora-chain/x/emissions/module/inference_synthesis"
inference_synthesis "github.com/allora-network/allora-chain/x/emissions/keeper/inference_synthesis"
emissions "github.com/allora-network/allora-chain/x/emissions/types"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

alloraMath "github.com/allora-network/allora-chain/math"

"github.com/allora-network/allora-chain/x/emissions/module/inference_synthesis"
"github.com/allora-network/allora-chain/x/emissions/keeper/inference_synthesis"
emissions "github.com/allora-network/allora-chain/x/emissions/types"
)

Expand Down
8 changes: 0 additions & 8 deletions x/emissions/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,14 +571,6 @@ func (k *Keeper) GetParamsMaxRequestCadence(ctx context.Context) (BlockHeight, e
return params.MaxRequestCadence, nil
}

func (k *Keeper) GetParamsPercentRewardsReputersWorkers(ctx context.Context) (alloraMath.Dec, error) {
params, err := k.GetParams(ctx)
if err != nil {
return alloraMath.Dec{}, err
}
return params.PercentRewardsReputersWorkers, nil
}

func (k *Keeper) GetParamsEpsilon(ctx context.Context) (alloraMath.Dec, error) {
params, err := k.GetParams(ctx)
if err != nil {
Expand Down
28 changes: 13 additions & 15 deletions x/emissions/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -703,20 +703,19 @@ func (s *KeeperTestSuite) TestSetParams() {
ctx := s.ctx
keeper := s.emissionsKeeper
params := types.Params{
Version: "v1.0.0",
RewardCadence: 60 * 60 * 24 * 7 * 24,
MinTopicUnmetDemand: cosmosMath.NewUint(100),
MaxTopicsPerBlock: 1000,
MinRequestUnmetDemand: cosmosMath.NewUint(1),
MaxMissingInferencePercent: alloraMath.NewDecFromInt64(10),
RequiredMinimumStake: cosmosMath.NewUint(1),
RemoveStakeDelayWindow: 172800,
MinEpochLength: 60,
MaxInferenceRequestValidity: 60 * 60 * 24 * 7 * 24,
MaxRequestCadence: 60 * 60 * 24 * 7 * 24,
PercentRewardsReputersWorkers: alloraMath.NewDecFromInt64(50),
MaxWorkersPerTopicRequest: 10,
MaxReputersPerTopicRequest: 10,
Version: "v1.0.0",
RewardCadence: 60 * 60 * 24 * 7 * 24,
MinTopicUnmetDemand: cosmosMath.NewUint(100),
MaxTopicsPerBlock: 1000,
MinRequestUnmetDemand: cosmosMath.NewUint(1),
MaxMissingInferencePercent: alloraMath.NewDecFromInt64(10),
RequiredMinimumStake: cosmosMath.NewUint(1),
RemoveStakeDelayWindow: 172800,
MinEpochLength: 60,
MaxInferenceRequestValidity: 60 * 60 * 24 * 7 * 24,
MaxRequestCadence: 60 * 60 * 24 * 7 * 24,
MaxWorkersPerTopicRequest: 10,
MaxReputersPerTopicRequest: 10,
}

// Set params
Expand All @@ -737,7 +736,6 @@ func (s *KeeperTestSuite) TestSetParams() {
s.Require().Equal(params.MinEpochLength, paramsFromKeeper.MinEpochLength, "Params should be equal to the set params: MinEpochLength")
s.Require().Equal(params.MaxInferenceRequestValidity, paramsFromKeeper.MaxInferenceRequestValidity, "Params should be equal to the set params: MaxInferenceRequestValidity")
s.Require().Equal(params.MaxRequestCadence, paramsFromKeeper.MaxRequestCadence, "Params should be equal to the set params: MaxRequestCadence")
s.Require().Equal(params.PercentRewardsReputersWorkers, paramsFromKeeper.PercentRewardsReputersWorkers, "Params should be equal to the set params: PercentRewardsReputersWorkers")
s.Require().Equal(params.MaxWorkersPerTopicRequest, paramsFromKeeper.MaxWorkersPerTopicRequest, "Params should be equal to the set params: MaxWorkersPerTopicRequest")
s.Require().Equal(params.MaxReputersPerTopicRequest, paramsFromKeeper.MaxReputersPerTopicRequest, "Params should be equal to the set params: MaxReputersPerTopicRequest")
}
3 changes: 0 additions & 3 deletions x/emissions/keeper/msgserver/msg_server_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ func (ms msgServer) UpdateParams(ctx context.Context, msg *types.MsgUpdateParams
if len(newParams.MaxRequestCadence) == 1 {
existingParams.MaxRequestCadence = newParams.MaxRequestCadence[0]
}
if len(newParams.PercentRewardsReputersWorkers) == 1 {
existingParams.PercentRewardsReputersWorkers = newParams.PercentRewardsReputersWorkers[0]
}
if len(newParams.Sharpness) == 1 {
existingParams.Sharpness = newParams.Sharpness[0]
}
Expand Down
43 changes: 21 additions & 22 deletions x/emissions/module/demand_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,27 @@ import (
func (s *ModuleTestSuite) UtilSetParams() {
s.emissionsKeeper.SetParams(s.ctx, types.Params{

Version: "0.0.3", // version of the protocol should be in lockstep with github release tag version
RewardCadence: int64(5), // length of an "epoch" for rewards payouts in blocks
MinTopicUnmetDemand: cosmosMath.NewUint(100), // total unmet demand for a topic < this => don't run inference solicatation or weight-adjustment
MaxTopicsPerBlock: uint64(1000), // max number of topics to run cadence for per block
MinRequestUnmetDemand: cosmosMath.NewUint(1), // delete requests if they have below this demand remaining
MaxMissingInferencePercent: alloraMath.MustNewDecFromString("0.1"), // if a worker has this percentage of inferences missing, they are penalized
RequiredMinimumStake: cosmosMath.NewUint(1), // minimum stake required to be a worker
RemoveStakeDelayWindow: int64(172800), // 2 days in seconds
MinEpochLength: int64(60), // 1 minute in seconds
MaxInferenceRequestValidity: int64(60 * 60 * 24 * 7 * 24), // 24 weeks approximately 6 months in seconds
MaxRequestCadence: int64(60 * 60 * 24 * 7 * 24), // 24 weeks approximately 6 months in seconds
PercentRewardsReputersWorkers: alloraMath.MustNewDecFromString("0.5"), // 50% of rewards go to workers and reputers, 50% to cosmos validators
MaxWorkersPerTopicRequest: uint64(10),
MaxReputersPerTopicRequest: uint64(10),
Sharpness: alloraMath.MustNewDecFromString("0.0"),
BetaEntropy: alloraMath.MustNewDecFromString("0.0"),
DcoefAbs: alloraMath.MustNewDecFromString("0.0"),
LearningRate: alloraMath.MustNewDecFromString("0.0"),
MaxGradientThreshold: alloraMath.MustNewDecFromString("0.0"),
MinStakeFraction: alloraMath.MustNewDecFromString("0.0"),
Epsilon: alloraMath.MustNewDecFromString("0.1"),
PInferenceSynthesis: alloraMath.MustNewDecFromString("0.1"),
Version: "0.0.3", // version of the protocol should be in lockstep with github release tag version
RewardCadence: int64(5), // length of an "epoch" for rewards payouts in blocks
MinTopicUnmetDemand: cosmosMath.NewUint(100), // total unmet demand for a topic < this => don't run inference solicatation or weight-adjustment
MaxTopicsPerBlock: uint64(1000), // max number of topics to run cadence for per block
MinRequestUnmetDemand: cosmosMath.NewUint(1), // delete requests if they have below this demand remaining
MaxMissingInferencePercent: alloraMath.MustNewDecFromString("0.1"), // if a worker has this percentage of inferences missing, they are penalized
RequiredMinimumStake: cosmosMath.NewUint(1), // minimum stake required to be a worker
RemoveStakeDelayWindow: int64(172800), // 2 days in seconds
MinEpochLength: int64(60), // 1 minute in seconds
MaxInferenceRequestValidity: int64(60 * 60 * 24 * 7 * 24), // 24 weeks approximately 6 months in seconds
MaxRequestCadence: int64(60 * 60 * 24 * 7 * 24), // 24 weeks approximately 6 months in seconds
MaxWorkersPerTopicRequest: uint64(10),
MaxReputersPerTopicRequest: uint64(10),
Sharpness: alloraMath.MustNewDecFromString("0.0"),
BetaEntropy: alloraMath.MustNewDecFromString("0.0"),
DcoefAbs: alloraMath.MustNewDecFromString("0.0"),
LearningRate: alloraMath.MustNewDecFromString("0.0"),
MaxGradientThreshold: alloraMath.MustNewDecFromString("0.0"),
MinStakeFraction: alloraMath.MustNewDecFromString("0.0"),
Epsilon: alloraMath.MustNewDecFromString("0.1"),
PInferenceSynthesis: alloraMath.MustNewDecFromString("0.1"),
})
}

Expand Down
42 changes: 20 additions & 22 deletions x/emissions/proto/emissions/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -91,45 +91,43 @@ message OptionalParams {
repeated int64 min_epoch_length = 9;
repeated int64 max_inference_request_validity = 10;
repeated int64 max_request_cadence = 11;
repeated string percent_rewards_reputers_workers = 12
repeated string sharpness = 12
[(gogoproto.customtype) = "github.com/allora-network/allora-chain/math.Dec", (gogoproto.nullable) = false];
repeated string sharpness = 13
repeated string beta_entropy = 13
[(gogoproto.customtype) = "github.com/allora-network/allora-chain/math.Dec", (gogoproto.nullable) = false];
repeated string beta_entropy = 14
repeated string dcoef_abs = 14
[(gogoproto.customtype) = "github.com/allora-network/allora-chain/math.Dec", (gogoproto.nullable) = false];
repeated string dcoef_abs = 15
repeated string learning_rate = 15
[(gogoproto.customtype) = "github.com/allora-network/allora-chain/math.Dec", (gogoproto.nullable) = false];
repeated string learning_rate = 16
repeated string max_gradient_threshold = 16
[(gogoproto.customtype) = "github.com/allora-network/allora-chain/math.Dec", (gogoproto.nullable) = false];
repeated string max_gradient_threshold = 17
repeated string min_stake_fraction = 17
[(gogoproto.customtype) = "github.com/allora-network/allora-chain/math.Dec", (gogoproto.nullable) = false];
repeated string min_stake_fraction = 18
repeated uint64 max_workers_per_topic_request = 18;
repeated uint64 max_reputers_per_topic_request = 19;
repeated string epsilon = 20
[(gogoproto.customtype) = "github.com/allora-network/allora-chain/math.Dec", (gogoproto.nullable) = false];
repeated uint64 max_workers_per_topic_request = 19;
repeated uint64 max_reputers_per_topic_request = 20;
repeated string epsilon = 21
repeated string p_inference_synthesis = 21
[(gogoproto.customtype) = "github.com/allora-network/allora-chain/math.Dec", (gogoproto.nullable) = false];
repeated string p_inference_synthesis = 22
repeated string alpha_regret = 22
[(gogoproto.customtype) = "github.com/allora-network/allora-chain/math.Dec", (gogoproto.nullable) = false];
repeated string alpha_regret = 23
repeated uint64 max_unfulfilled_worker_requests = 23;
repeated uint64 max_unfulfilled_reputer_requests = 24;
repeated uint64 number_expected_inference_sybils = 25;
repeated uint64 sybil_tax_exponent = 26;
repeated string topic_reward_stake_importance = 27
[(gogoproto.customtype) = "github.com/allora-network/allora-chain/math.Dec", (gogoproto.nullable) = false];
repeated uint64 max_unfulfilled_worker_requests = 24;
repeated uint64 max_unfulfilled_reputer_requests = 25;
repeated uint64 number_expected_inference_sybils = 26;
repeated uint64 sybil_tax_exponent = 27;
repeated string topic_reward_stake_importance = 28
repeated string topic_reward_fee_revenue_importance = 28
[(gogoproto.customtype) = "github.com/allora-network/allora-chain/math.Dec", (gogoproto.nullable) = false];
repeated string topic_reward_fee_revenue_importance = 29
repeated string topic_reward_alpha = 29
[(gogoproto.customtype) = "github.com/allora-network/allora-chain/math.Dec", (gogoproto.nullable) = false];
repeated string topic_reward_alpha = 30
[(gogoproto.customtype) = "github.com/allora-network/allora-chain/math.Dec", (gogoproto.nullable) = false];
repeated string validators_vs_allora_percent_reward = 31 [
repeated string validators_vs_allora_percent_reward = 30 [
(cosmos_proto.scalar) = "cosmos.LegacyDec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true
];
repeated uint64 max_samples_to_scale_scores = 32;
repeated uint64 max_samples_to_scale_scores = 31;
}

/// PARAMS
Expand Down
47 changes: 21 additions & 26 deletions x/emissions/proto/emissions/v1/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -38,76 +38,71 @@ message Params {
int64 min_epoch_length = 9; // fastest allowable topic epoch and cadence of a repeating inference request
int64 max_inference_request_validity = 10; // longest time a subscription of inferences is allowed to be valid
int64 max_request_cadence = 11; // slowest (largest) amount of time a subscription can take between inferences
string percent_rewards_reputers_workers = 12 [
(gogoproto.customtype) = "github.com/allora-network/allora-chain/math.Dec",
(gogoproto.nullable) = false
]; // rewards (tx fees + inflation) paid to workers/reputers. Validators get the rest
string sharpness = 13 [
string sharpness = 12 [
(gogoproto.customtype) = "github.com/allora-network/allora-chain/math.Dec",
(gogoproto.nullable) = false
]; // controls going from stake-weighted consensus at low values to majority vote of above-average stake holders at
// high values
string beta_entropy = 14 [
string beta_entropy = 13 [
(gogoproto.customtype) = "github.com/allora-network/allora-chain/math.Dec",
(gogoproto.nullable) = false
]; // controls resilience of reward payouts against copycat workers
string dcoef_abs = 15 [
string dcoef_abs = 14 [
(gogoproto.customtype) = "github.com/allora-network/allora-chain/math.Dec",
(gogoproto.nullable) = false
]; // delta for numerical differentiation
string learning_rate = 16 [
string learning_rate = 15 [
(gogoproto.customtype) = "github.com/allora-network/allora-chain/math.Dec",
(gogoproto.nullable) = false
]; // speed of gradient descent
string max_gradient_threshold = 17 [
string max_gradient_threshold = 16 [
(gogoproto.customtype) = "github.com/allora-network/allora-chain/math.Dec",
(gogoproto.nullable) = false
]; // gradient descent stops when gradient falls below this
string min_stake_fraction = 18 [
string min_stake_fraction = 17 [
(gogoproto.customtype) = "github.com/allora-network/allora-chain/math.Dec",
(gogoproto.nullable) = false
]; // minimum fraction of stake to listen to when setting consensus listening coefficients
uint64 max_workers_per_topic_request = 19; // max num workers whose inference are used and compensated per request
uint64 max_reputers_per_topic_request = 20; // max num reputers to solicit losses from per loss request
string epsilon = 21 [
uint64 max_workers_per_topic_request = 18; // max num workers whose inference are used and compensated per request
uint64 max_reputers_per_topic_request = 19; // max num reputers to solicit losses from per loss request
string epsilon = 20 [
(gogoproto.customtype) = "github.com/allora-network/allora-chain/math.Dec",
(gogoproto.nullable) = false
]; // small number to prevent division by zero
string p_inference_synthesis = 22 [
string p_inference_synthesis = 21 [
(gogoproto.customtype) = "github.com/allora-network/allora-chain/math.Dec",
(gogoproto.nullable) = false
]; // fiducial value of exponent for Inference Synthesis gradient function
string alpha_regret = 23 [
string alpha_regret = 22 [
(gogoproto.customtype) = "github.com/allora-network/allora-chain/math.Dec",
(gogoproto.nullable) = false
]; // how much to weight the most recent log-loss differences in regret EMA update
uint64 max_unfulfilled_worker_requests = 24; // max num worker request nonces to keep track of per topic
uint64 max_unfulfilled_reputer_requests = 25; // max num reputer request nonces to keep track of per topic
uint64 number_expected_inference_sybils = 26; // global number for calculation tax of worker reward
uint64 sybil_tax_exponent = 27; // global parameter for calculation tax of worker reward
string topic_reward_stake_importance = 28 [
uint64 max_unfulfilled_worker_requests = 23; // max num worker request nonces to keep track of per topic
uint64 max_unfulfilled_reputer_requests = 24; // max num reputer request nonces to keep track of per topic
uint64 number_expected_inference_sybils = 25; // global number for calculation tax of worker reward
uint64 sybil_tax_exponent = 26; // global parameter for calculation tax of worker reward
string topic_reward_stake_importance = 27 [
(gogoproto.customtype) = "github.com/allora-network/allora-chain/math.Dec",
(gogoproto.nullable) = false
]; // The exponent μ represents the importance of stake in the reward of a topic and has a fiduciary value of 0.5
string topic_reward_fee_revenue_importance = 29 [
string topic_reward_fee_revenue_importance = 28 [
(gogoproto.customtype) = "github.com/allora-network/allora-chain/math.Dec",
(gogoproto.nullable) = false
]; // The exponent ν represents the importance of fee revenue in the reward of a topic and has a fiduciary value of
// 0.5
string topic_reward_alpha = 30 [
string topic_reward_alpha = 29 [
(gogoproto.customtype) = "github.com/allora-network/allora-chain/math.Dec",
(gogoproto.nullable) = false
]; // global exponential moving average parameter. Fiduciary value of 0.9375 on a monthly timescale, 0.5 for weekly
// updates
string validators_vs_allora_percent_reward = 31 [
string validators_vs_allora_percent_reward = 30 [
(cosmos_proto.scalar) = "cosmos.LegacyDec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true
]; // percent of total supply rewarded to cosmos network validators, rest goes to allora reputers workers etc
uint64 max_samples_to_scale_scores = 32; // number of scores to use for standard deviation calculation
uint64 create_topic_fee = 33;
// topic registration fee
uint64 max_samples_to_scale_scores = 31; // number of scores to use for standard deviation calculation
uint64 create_topic_fee = 32; // topic registration fee
}

/// TOPICS
Expand Down
5 changes: 0 additions & 5 deletions x/emissions/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ func DefaultParams() Params {
MinEpochLength: 1, // 1 block
MaxInferenceRequestValidity: int64(6 * 60 * 24 * 7 * 52), // approximately 1 year in number of blocks
MaxRequestCadence: int64(6 * 60 * 24 * 7 * 52), // approximately 1 year in number of blocks
PercentRewardsReputersWorkers: alloraMath.MustNewDecFromString("0.75"), // 75% of rewards go to workers and reputers, 25% to cosmos validators
Sharpness: alloraMath.MustNewDecFromString("20"), // controls going from stake-weighted consensus at low values to majority vote of above-average stake holders at high values
BetaEntropy: alloraMath.MustNewDecFromString("0.25"), // controls resilience of reward payouts against copycat workers
DcoefAbs: alloraMath.MustNewDecFromString("0.001"), // delta for numerical differentiation
Expand Down Expand Up @@ -90,10 +89,6 @@ func DefaultParamsMaxRequestCadence() BlockHeight {
return DefaultParams().MaxRequestCadence
}

func DefaultParamsPercentRewardsReputersWorkers() alloraMath.Dec {
return DefaultParams().PercentRewardsReputersWorkers
}

func DefaultParamsSharpness() alloraMath.Dec {
return DefaultParams().Sharpness
}
Expand Down
Loading

0 comments on commit 3e4da21

Please sign in to comment.