Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct Discrepancies with Whitepaper modified reward fractions vs plain EMA #704

Merged
merged 1 commit into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## v0.X.X

### Added

### Changed

### Deprecated

### Removed

### Fixed

* [#699](https://github.com/allora-network/allora-chain/pull/699) Make install script manage new release assets naming
* [#704](https://github.com/allora-network/allora-chain/pull/704) Correct Discrepancies with Whitepaper modified reward fractions vs plain EMA

### Security

## [Released]

## v0.7.0

Expand Down Expand Up @@ -104,8 +119,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* [#682](https://github.com/allora-network/allora-chain/pull/682) Ensure IBC `MsgTransfer` funds are received

## [Released]

## v0.6.0

### Added
Expand Down
19 changes: 9 additions & 10 deletions x/emissions/module/rewards/reputer_rewards.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,21 @@ func GetReputerTaskEntropy(
if len(emaRewardFractions) == 0 {
return alloraMath.Dec{}, errors.Wrapf(types.ErrInvalidReward, "invalid reward fractions after EMA")
}
// Calculate modified reward fractions and persist for next round
numberRatio, err := NumberRatio(emaRewardFractions)
if err != nil {
return alloraMath.Dec{}, errors.Wrapf(err, "failed to calculate reputer number ratio")
for i, reputer := range reputers {
err := k.SetPreviousReputerRewardFraction(ctx, topicId, reputer, emaRewardFractions[i])
if err != nil {
return alloraMath.Dec{}, errors.Wrapf(err, "failed to set previous reputer reward fraction")
}
}
// Calculate modified reward fractions and persist for next round
modifiedRewardFractions, err := ModifiedRewardFractions(emaRewardFractions)
if err != nil {
return alloraMath.Dec{}, errors.Wrapf(err, "failed to calculate modified reward fractions")
}
for i, reputer := range reputers {
err := k.SetPreviousReputerRewardFraction(ctx, topicId, reputer, modifiedRewardFractions[i])
if err != nil {
return alloraMath.Dec{}, errors.Wrapf(err, "failed to set previous reputer reward fraction")
}
numberRatio, err := NumberRatio(modifiedRewardFractions)
if err != nil {
return alloraMath.Dec{}, errors.Wrapf(err, "failed to calculate reputer number ratio")
}

if numReputers > 1 {
entropy, err = Entropy(
modifiedRewardFractions,
Expand Down
22 changes: 11 additions & 11 deletions x/emissions/module/rewards/worker_rewards.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,30 +182,30 @@ func getInferenceOrForecastTaskEntropy(
if len(emaRewardFractions) == 0 {
return alloraMath.Dec{}, errors.Wrapf(types.ErrInvalidReward, "invalid reward fractions after EMA calculation")
}
// Calculate modified reward fractions and persist for next round
numberRatio, err := NumberRatio(emaRewardFractions)
if err != nil {
return alloraMath.Dec{}, errors.Wrapf(err, "failed to calculate number ratio")
}
modifiedRewardFractions, err := ModifiedRewardFractions(emaRewardFractions)
if err != nil {
return alloraMath.Dec{}, errors.Wrapf(err, "failed to calculate modified reward fractions")
}
if which == taskInference {
for i, worker := range workers {
err := k.SetPreviousInferenceRewardFraction(ctx, topicId, worker, modifiedRewardFractions[i])
err := k.SetPreviousInferenceRewardFraction(ctx, topicId, worker, emaRewardFractions[i])
if err != nil {
return alloraMath.Dec{}, errors.Wrapf(err, "failed to set previous inference reward fraction")
}
}
} else { // taskForecast
for i, worker := range workers {
err := k.SetPreviousForecastRewardFraction(ctx, topicId, worker, modifiedRewardFractions[i])
err := k.SetPreviousForecastRewardFraction(ctx, topicId, worker, emaRewardFractions[i])
if err != nil {
return alloraMath.Dec{}, errors.Wrapf(err, "failed to set previous forecast reward fraction")
}
}
}
// Calculate modified reward fractions and persist for next round
modifiedRewardFractions, err := ModifiedRewardFractions(emaRewardFractions)
if err != nil {
return alloraMath.Dec{}, errors.Wrapf(err, "failed to calculate modified reward fractions")
}
numberRatio, err := NumberRatio(modifiedRewardFractions)
if err != nil {
return alloraMath.Dec{}, errors.Wrapf(err, "failed to calculate number ratio")
}

if numWorkers > 1 {
entropy, err = Entropy(
Expand Down
Loading