-
Notifications
You must be signed in to change notification settings - Fork 86
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
Fee Revenue Decay Rate set to per topic's epoch rather than global fixed constant #529
Conversation
## 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.
this will wait until after 532, 533 are merged |
The latest Buf updates on your PR. Results from workflow Buf Linter / buf (pull_request).
|
78d9700
to
62a41f1
Compare
@@ -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] |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this 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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
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}
(whereN_{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 parameterTopicFeeRevenueDecayRate
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.