cosmos-sdk/x/distribution/spec
Rikard Hjort a3feeed665
docs: x/distribution spec (#8928)
* EndBlock => BeginBlock

* Add high-level algorithm

* Update documentation on params invariant

* Comment fix

* Update and extend BeginBlock documentation

* Update hooks documentation

* New intro to the concepts

* Update messages documentation

* Write in full sentences

Co-authored-by: Robert Zaremba <robert@zaremba.ch>

* spelling error

* change link

* slashing spec clarification

* Revert "slashing spec clarification"

This reverts commit b08b5a8533ca9d355a0afb0e58254b95487ce880.

* Update x/distribution/spec/04_messages.md

Co-authored-by: Robert Zaremba <robert@zaremba.ch>

* Update x/distribution/spec/03_begin_block.md

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>

* update link to latest version

* Update x/distribution/spec/04_messages.md

Co-authored-by: Robert Zaremba <robert@zaremba.ch>

* clarify note on removed validator

* clarify validator removed hook

* clarify validator created hook

* clarify delegation modified/created hook

* clarify slash hook

* clarify possesive singular situation

* clarify hooks.go

* Move comment to clearer position

* Update x/distribution/spec/01_concepts.md

Co-authored-by: Barrie Byron <barrie.byron@tendermint.com>

* clarifications in concepts file

* Clarify introductory paragraphs

* communitytax => community_tax

* Apply suggestions from code review

Co-authored-by: Barrie Byron <barrie.byron@tendermint.com>
Co-authored-by: Robert Zaremba <robert@zaremba.ch>

* Update delegator rewards descirption

* Remove "this"

* Fix error in non-proposer validator rewards spec

* Clarify validator rewards high level description

* Update x/distribution/spec/04_messages.md

* Clarify what fees are

* Misc grammar and style fixes

* Apply suggestions from code review

Co-authored-by: Barrie Byron <barrie.byron@tendermint.com>

* Apply suggestions from code review

Co-authored-by: Barrie Byron <barrie.byron@tendermint.com>
Co-authored-by: Ethan Buchman <ethan@coinculture.info>

Co-authored-by: Jack Zampolin <jack.zampolin@gmail.com>
Co-authored-by: Marko <marbar3778@yahoo.com>
Co-authored-by: Robert Zaremba <robert@zaremba.ch>
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: Barrie Byron <barrie.byron@tendermint.com>
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
Co-authored-by: Ethan Buchman <ethan@coinculture.info>
2021-05-03 18:40:34 +00:00
..
01_concepts.md docs: x/distribution spec (#8928) 2021-05-03 18:40:34 +00:00
02_state.md docs: x/distribution spec (#8928) 2021-05-03 18:40:34 +00:00
03_begin_block.md docs: x/distribution spec (#8928) 2021-05-03 18:40:34 +00:00
04_messages.md docs: x/distribution spec (#8928) 2021-05-03 18:40:34 +00:00
05_hooks.md docs: x/distribution spec (#8928) 2021-05-03 18:40:34 +00:00
06_events.md Docs: hide frontmatter, bugfixes (#5413) 2019-12-17 08:44:44 -03:00
07_params.md docs: x/distribution spec (#8928) 2021-05-03 18:40:34 +00:00
README.md docs: x/distribution spec (#8928) 2021-05-03 18:40:34 +00:00

README.md

distribution

Overview

This simple distribution mechanism describes a functional way to passively distribute rewards between validators and delegators. Note that this mechanism does not distribute funds in as precisely as active reward distribution mechanisms and will therefore be upgraded in the future.

The mechanism operates as follows. Collected rewards are pooled globally and divided out passively to validators and delegators. Each validator has the opportunity to charge commission to the delegators on the rewards collected on behalf of the delegators. Fees are collected directly into a global reward pool and validator proposer-reward pool. Due to the nature of passive accounting, whenever changes to parameters which affect the rate of reward distribution occurs, withdrawal of rewards must also occur.

  • Whenever withdrawing, one must withdraw the maximum amount they are entitled to, leaving nothing in the pool.
  • Whenever bonding, unbonding, or re-delegating tokens to an existing account, a full withdrawal of the rewards must occur (as the rules for lazy accounting change).
  • Whenever a validator chooses to change the commission on rewards, all accumulated commission rewards must be simultaneously withdrawn.

The above scenarios are covered in hooks.md.

The distribution mechanism outlined herein is used to lazily distribute the following rewards between validators and associated delegators:

  • multi-token fees to be socially distributed
  • proposer reward pool
  • inflated atom provisions
  • validator commission on all rewards earned by their delegators stake

Fees are pooled within a global pool, as well as validator specific proposer-reward pools. The mechanisms used allow for validators and delegators to independently and lazily withdraw their rewards.

Shortcomings

As a part of the lazy computations, each delegator holds an accumulation term specific to each validator which is used to estimate what their approximate fair portion of tokens held in the global fee pool is owed to them.

entitlement = delegator-accumulation / all-delegators-accumulation

Under the circumstance that there was constant and equal flow of incoming reward tokens every block, this distribution mechanism would be equal to the active distribution (distribute individually to all delegators each block). However, this is unrealistic so deviations from the active distribution will occur based on fluctuations of incoming reward tokens as well as timing of reward withdrawal by other delegators.

If you happen to know that incoming rewards are about to significantly increase, you are incentivized to not withdraw until after this event, increasing the worth of your existing accum. See #2764 for further details.

Effect on Staking

Charging commission on Atom provisions while also allowing for Atom-provisions to be auto-bonded (distributed directly to the validators bonded stake) is problematic within BPoS. Fundamentally, these two mechanisms are mutually exclusive. If both commission and auto-bonding mechanisms are simultaneously applied to the staking-token then the distribution of staking-tokens between any validator and its delegators will change with each block. This then necessitates a calculation for each delegation records for each block - which is considered computationally expensive.

In conclusion, we can only have Atom commission and unbonded atoms provisions or bonded atom provisions with no Atom commission, and we elect to implement the former. Stakeholders wishing to rebond their provisions may elect to set up a script to periodically withdraw and rebond rewards.

Contents

  1. Concepts
  2. State
  3. Begin Block
  4. Messages
  5. Hooks
  6. Events
  7. Parameters