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

Fee Revenue Decay Rate set to per topic's epoch rather than global fixed constant #529

Merged
merged 5 commits into from
Aug 21, 2024

Conversation

relyt29
Copy link
Contributor

@relyt29 relyt29 commented Aug 16, 2024

Purpose of Changes and their Description

Currently, we use a global parameter to drip revenue to the same extent across all topics, regardless of their epoch length. This is somewhat unfair, as topics of larger epochs then get dripped comparatively less than those with shorter epoch lengths.

@jmdkastro proposes a more appropriate way of updating effective revenue, that actually takes the topic epoch length into consideration (through calculation of "epochs per week"). Relevant text from the whitepaper:

The quantity C_{t,i} decays each epoch by subtracting an amount ∆ C_{t,i} = N_{epochs,w} * C_{t,i} (where N_{epochs,w} is the number of epochs per week) and thus captures recent revenue.

This PR modifies the keeper.go DripTopicFeeRevenue function to do the following: identify if we have dripped yet this epoch. If we have not, then calculate the number of blocksPerWeek based on the blocksPerMonth, get the epochs per block from the topic, then do the math to calculate how much to decay for this epoch. Then it overwrites the fee revenue for this topic, and marks this epoch as having been decayed.

This change add a new data structure to the keeper called lastDripBlock. This change also deletes the global emissions module parameter TopicFeeRevenueDecayRate

Link(s) to Ticket(s) or Issue(s) resolved by this PR

PROTO-2150
RES-302

Are these changes tested and documented?

Our existing unit tests were adapted to fit this new change, as some of them had broke from the different algorithms.

@relyt29 relyt29 self-assigned this Aug 16, 2024
relyt29 added a commit that referenced this pull request Aug 17, 2024
## Purpose of Changes and their Description

#528 and others overwite the protobuf in the v2 folder of the emissions
module. this is the incorrect way to perform software upgrades.

Future changes to protobufs must go in their own v3 folder and the v2
must stay pinned to v0.3.0

This PR reverts the changes and introduces a new v3 folder for working
with.

## Link(s) to Ticket(s) or Issue(s) resolved by this PR

No written linear tasks.

## Are these changes tested and documented?

Covered by existing unit tests.

## Still Left Todo

Migrations for the new parameters in #528. I already wrote migration
code in #525 and #529 so I recommend either basing off of those or
waiting for at a miniumum, #525 to be merged.
Base automatically changed from tyler/proto-2052-apply-parameter-tunings2 to dev August 17, 2024 12:38
@relyt29 relyt29 changed the title [WIP] Fee Revenue Decay Rate set to per Epoch rather than global fixed constant [WIP] Fee Revenue Decay Rate set to per topic's epoch rather than global fixed constant Aug 19, 2024
@relyt29
Copy link
Contributor Author

relyt29 commented Aug 19, 2024

this will wait until after 532, 533 are merged

Copy link

github-actions bot commented Aug 19, 2024

The latest Buf updates on your PR. Results from workflow Buf Linter / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed⏩ skippedAug 21, 2024, 6:54 PM

@relyt29 relyt29 force-pushed the tyler/proto-2150-update-effective-revenue-decay-rate branch from 78d9700 to 62a41f1 Compare August 19, 2024 19:31
@relyt29 relyt29 changed the title [WIP] Fee Revenue Decay Rate set to per topic's epoch rather than global fixed constant Fee Revenue Decay Rate set to per topic's epoch rather than global fixed constant Aug 20, 2024
@relyt29 relyt29 marked this pull request as ready for review August 20, 2024 00:40
@@ -156,6 +156,9 @@ type Keeper struct {
// map of (topic) -> unfulfilled nonces
unfulfilledReputerNonces collections.Map[TopicId, types.ReputerRequestNonces]

// map of (topic) -> last dripped block
lastDripBlock collections.Map[TopicId, BlockHeight]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a migration for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so I added it to x/emissions/keeper/genesis.go InitGenesis and ExportGenesis functions, but as far as I can tell... no? because we would expect it to be initialized to zero, so there is no action for a migration function to take?

if you think otherwise I am all ears

Copy link
Contributor

@guilherme-brandao guilherme-brandao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just left a comment

@@ -1345,6 +1367,25 @@ func (k *Keeper) ExportGenesis(ctx context.Context) (*types.GenesisState, error)
return nil, errors.Wrap(err, "failed to get previous percentage reward to staked reputers")
}

// openWorkerWindows
openWorkerWindows := make([]*types.BlockHeightAndTopicIds, 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to create a specific structure just for the import/export? Is it the only way?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand the import export, but based on my partial understanding yes, this is what we have to do

@relyt29 relyt29 merged commit d23be2d into dev Aug 21, 2024
8 checks passed
@relyt29 relyt29 deleted the tyler/proto-2150-update-effective-revenue-decay-rate branch August 21, 2024 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants