-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
R4R: lamborghini distribution & inflation spec upgrade #1702
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #1702 +/- ##
========================================
Coverage 63.44% 63.44%
========================================
Files 117 117
Lines 6937 6937
========================================
Hits 4401 4401
Misses 2281 2281
Partials 255 255 |
docs/spec/distribution/end_block.md
Outdated
and global pool. When the validator is the proposer of the round, that | ||
validator (and their delegators) receives between 1% and 5% of fee rewards, the | ||
reserve tax is then charged, then the remainder is distributed socially by | ||
voting power to all validators including the proposer validator. The amount of |
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.
Is the remainder distributed to all the validators from the validator set or only to the ones who voted on the pre-commit
/pre-vote
phase ?
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.
All bonded validators. Not just ones that voted, the only way to not get the social distribution is to get kicked out (which will happen if you're not live enough) - I'll make this text more explicit.
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.
As discussed previously, even though it may not be the best place here, it would help tremendously if some naive examples were linked somehow (similar to the ones on the cosmos.network/docs).
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.
Added more text to make this explicit (addressed)
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.
Thanks for updating the spec! I left some general comments/remarks.
This stuff can get pretty complex and difficult to just sift through and so I think examples would help greatly (those on cosmos.network/docs helped me greatly), but I know that the spec may not be the best place for those.
It might help to think of ways to introduce the notion of examples somehow.
PENDING.md
Outdated
@@ -38,6 +38,7 @@ IMPROVEMENTS | |||
* [tools] Remove `rm -rf vendor/` from `make get_vendor_deps` | |||
* [x/auth] Recover ErrorOutOfGas panic in order to set sdk.Result attributes correctly | |||
* [x/stake] Add revoked to human-readable validator | |||
* [spec] Inflation and distribution specs drastically improved |
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.
Lets add the issue (#967) number here 👍
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.
addressed
### Power Change | ||
|
||
Within the current implementation all power changes ever made are indefinitely stored | ||
within the current state. In the future this state should be trimmed on an epoch basis. Delegators |
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.
This this data be pruned on all nodes? Archive nodes will have to keep this, correct?
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.
It won't be pruned since it's kept in the current state. If we don't need power changes older than an epoch for any calculations, we should be able to remove them from the current state (and then nodes with pruning enabled will delete them).
Is the reason we're not doing this initially because it's complex to implement?
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.
We need all the calculations in the current state for an epoch equal to what we want the maximum allowable time withdrawal your fees is.. I'm guessing at minimum this is something like a couple months and at maximum is something like a year. - There is some complexity surrounding tracking what the last required power change is but the bigger problem is figuring out what to do / the appropriate lazy mechanism which plays nice with the existing fees distribution mechanism for everyone who hasn't withdrawn their fees by that time. There are a number of options: But this is the discussion grounds for that:
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.
Agreed that this merits discussion but it probably can be safely tabled to post-launch as long as we put in place the store key prefixes (block height) to prune easily in the future.
docs/spec/distribution/overview.md
Outdated
delegators. Each validator has the opportunity to charge commission to the | ||
delegators on the fees collected on behalf of the delegators by the validators. | ||
Fees are paid directly into a global fee pool, and validator proposer-reward | ||
pool. Due to the nature of of passive accounting whenever changes to parameters |
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.
of of
typo
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.
addressed
docs/spec/distribution/overview.md
Outdated
which affect the rate of fee distribution occurs, withdrawal of fees must also | ||
occur. | ||
|
||
- when withdrawing one must withdrawal the maximum amount they are entitled |
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.
Capitalization and punctuation should be consistent here 👍
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.
addressed (lower bullet points from here - using lower case in bullet points be cause not sentences.
docs/spec/distribution/overview.md
Outdated
- when a validator chooses to change the commission on fees, all accumulated | ||
commission fees must be simultaneously withdrawn. | ||
|
||
The above scenarios are covered is `triggers.md`. |
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.
Wording is a bit confusing here.
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.
lol thanks - was a type is
-> in
docs/spec/distribution/triggers.md
Outdated
- triggered-by: `stake.TxCreateValidator` | ||
|
||
Whenever a totally new validator is added to the Tendermint validator set they | ||
are entitled to begin earning rewards of atom provisions and fess. At 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.
fees
*
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.
addressed
docs/spec/inflation/end_block.md
Outdated
# End Block | ||
|
||
``` | ||
EndBlock() |
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.
What are these for?
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.
Unnecessary - removing
docs/spec/inflation/end_block.md
Outdated
|
||
Validator provisions are minted on an hourly basis (the first block of a new | ||
hour). The annual target of between 7% and 20%. The long-term target ratio of | ||
bonded tokens to unbonded tokens is 67%. |
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.
Would it be possible to describe why the exact target of 67% in a concise manner?
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.
Agreed - or cite the whitepaper / relevant source.
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 disagree this IS the spec, it supersedes the white paper - it's not a place where choices always need to be justified. This number for instance comes out of a bunch of conversations with Jae - there is no good reason it just seems like a fine value. For y'alls record if the value is to small its a security concern, if it's to large then there isn't enough liquidity for price discovery -> 67% seems fine.
inflation = nextInflation(hrsPerYr).Round(precision) | ||
SetInflation(inflation) | ||
|
||
provisions = inflation * (pool.TotalSupply() / hrsPerYr) |
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.
Is the pool.TotalSupply()
here the total number of bonded tokens in the validator set?
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.
No, it's the total token supply - all tokens bonded, unbonded, deposited-in-governance-proposals, etc.
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.
comment addressed by cwgoes
|
||
bondedRatio = pool.BondedPool / pool.TotalSupply() | ||
|
||
inflationRateChangePerYear = (1 - bondedRatio / params.GoalBonded) * params.InflationRateChange |
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.
What exactly is params.InflationRateChange
?
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.
Rate of change in the inflation rate (second derivative of the total supply)
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.
comment addressed by cwgoes
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.
Many comments!
docs/spec/distribution/end_block.md
Outdated
At each endblock, the fees received are sorted to the proposer, community fund, | ||
and global pool. When the validator is the proposer of the round, that | ||
validator (and their delegators) receives between 1% and 5% of fee rewards, the | ||
reserve tax is then charged, then the remainder is distributed socially by |
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.
What do you mean "socially"? Perhaps "proportionally"?
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.
Well I did actually mean social distribution which means that you get coins even if you weren't the proposer - but proportional makes more sense in this instance, so I'll change, but then name is the social distribution
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.
OK makes sense - if you just define "social distribution" once that's fine.
docs/spec/distribution/end_block.md
Outdated
validator (and their delegators) receives between 1% and 5% of fee rewards, the | ||
reserve tax is then charged, then the remainder is distributed socially by | ||
voting power to all validators including the proposer validator. The amount of | ||
proposer reward is calculated from pre-commits Tendermint messages. All |
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.
Let's cite why, e.g. "in order to incentivize validators to wait and include additional pre-commits in the block".
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.
sure, included.
* sumPowerPrecommitValidators / totalBondedTokens) | ||
proposer.ProposerPool += proposerReward | ||
|
||
communityFunding = feesCollectedDec * communityTax |
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.
This is the reserve pool? Maybe "tax" is not quite the right name (nbd though).
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.
leaving for now - open to suggestions still
### Power Change | ||
|
||
Within the current implementation all power changes ever made are indefinitely stored | ||
within the current state. In the future this state should be trimmed on an epoch basis. Delegators |
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.
It won't be pruned since it's kept in the current state. If we don't need power changes older than an epoch for any calculations, we should be able to remove them from the current state (and then nodes with pruning enabled will delete them).
Is the reason we're not doing this initially because it's complex to implement?
docs/spec/distribution/overview.md
Outdated
- Multi-token fees to be socially distributed | ||
- Proposer reward pool | ||
- Inflated atom provisions | ||
- Validator commission on delegators |
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.
Commission on atom provisions from delegated stake?
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.
Updated to commission on all rewards earned by their delegators
for that distributor had static shares (equal to the current shares), and no | ||
recipients had ever withdrawn their entitled rewards. The projected pool | ||
represents the anticipated recipient's entitlement to the distributors tokens | ||
base on the current blocks token input to the distributor, and the |
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.
"token input" = "contributing stake"?
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.
Good point to clarify, no token input refers to the new input from fees/provision-reward etc. updated to say token input (for example fees reward received)
@@ -0,0 +1,396 @@ | |||
# Transactions |
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 find it really difficult to reason through the correctness of the transaction procedures in this file, likely because we're trying to implement a simple strict model with a lazy process.
I think it would be helpful if we outline for each transaction what the calculation would be in the strict, inefficient case (iterating over everything), then explain our lazy implementation, and even ideally provide a quick (rough) demonstration of equivalence.
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.
Coming up with a good way to comprehend this efficient fee distribution module is going to be an ongoing challenge - Due to this, I agree that equivalent outcome in a "simple" module for each transaction should be documented within the spec beside the complex "efficient" situation already provided.
With regards to the example - this is a tug of worlds here - I don't think that we want to have non-spec information in the spec - to me, the example described doesn't actually belong in the spec itself HOWEVER I think it's super valuable and I think we should have it somewhere. I think maybe IN The spec we could have a non-spec section which actually works through what you're describing. - I think that this is a separate task which should be completed soon, but is a lower priority than distribution implementation to me
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 mean include an example (although that might be a good idea too), I mean include equations that demonstrate why the complex implementation reduces to the same effects as the simple one (weren't those written up somewhere previously)?
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.
Or "parameterized examples"!
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.
Leaving this for now as we're likely moving away from pre-launch implementation however here is an issue for more discussion #1906
docs/spec/distribution/triggers.md
Outdated
|
||
## Create validator distribution | ||
|
||
- triggered-by: `stake.TxCreateValidator` |
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.
Every time or only when the new validator candidate is bonded?
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.
(and in the latter case - then also by another validator unbonding, for example?)
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.
Also, do we need to anything when a validator is unbonded?
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.
Every time or only when the new validator candidate is bonded?
Good observation, this only happens when the validator enters the bonded validator set. updated.
Also, do we need to anything when a validator is unbonded?
For other validators:
When a validator is unbonded - the power change is be recorded and thus all other's passive calculations will incorporate the changes passively as expected. So nothing additional or special is required for an unbond for them.
For the affected validator:
With regards to everyone affected by the unbond - we will need to incorporate a new mechanism to passively account for this - Just opened up an issue to think about this a bit more #1905.
I'm certain that the appropriate mechanism can be added onto what is spec'd here to account for this situation. THANK YOU FOR BRINGING THIS UP.
@@ -0,0 +1,31 @@ | |||
# Triggers |
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.
What about slashing events (which modify validator stake and delegation stake, and not necessarily in the same proportion)?
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.
Also, what about parameter changes (e.g. enacted by ParameterChangeProposal
s)?
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.
Slashing events is a situation that needs to be considered:
Side note: Equal slashing of delegators and validators is a design constraint of this system - we can talk about it more outside of github if you'd like.
These slashing events will need to have a new special computation not yet outlined in this spec: can be processed similarly with a new pool as per to unbonding validators. more discussion here: #1905
Parameter changes will not trigger any new changes because parameters relevant to distribution affect the tokens flowing into the distribution system but do not affect the tokens already contained within this distribution system.
docs/spec/distribution/triggers.md
Outdated
|
||
## Create or modify delegation distribution | ||
|
||
- triggered-by: `stake.TxDelegate` |
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.
Or TxBeginRedelegate
, or TxBeginUnbonding
?
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.
included
I'd like to review this as well before its merged. Chris had recommended that I wait until his comments were resolved first though. Commenting so I get pinged for updates. |
Hopefully can address everything tomorrow -still focused on decimal |
Per discussion with @rigelrozanski we'd like to consider the "piggy bank distribution" instead as a simpler approach for launch. |
Yes more on that - this spec should still be merged and reviewed further and expanded based on some of the new issues I've raised out of this. This model is still something we want - but should likely NOT be a prelaunch requirement - instead we should use the simple piggy bank model which should be spec'd out separately. @cwgoes - I've addressed your comments, although a few of them haven't been fully addressed and I've opened two github issues for further consideration on this mechanism. |
Let's merge this? |
Before we actually implement it in the future, I want to review again re: transaction correctness - but agreed, fine for now. |
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.
utACK
Best description of this mechanism we have at the moment, so merging. Note that transactions have not been reviewed for mathematical equivalence (against the simple model); before we actually implement this (if we do so in the future) they should be further reviewed.
closes #967
docs/
)CHANGELOG.md
cmd/gaia
andexamples/
For Admin Use: