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

TIP-40: Staking & Delegation #141

Draft
wants to merge 124 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
23888de
Add TIP-40 skeleton
PhilippGackstatter May 5, 2023
db2fe0b
Add Summary and Voting Power calculation
PhilippGackstatter Jun 12, 2023
ad57f45
Update Committee Selection
PhilippGackstatter Jun 12, 2023
f13bf68
Expand MCA
PhilippGackstatter Jun 12, 2023
7cffa95
Add Delegation Output
PhilippGackstatter Jun 13, 2023
0cca107
Update Timing figure
PhilippGackstatter Jun 13, 2023
9156005
Update Timing figure and voting power calc time
PhilippGackstatter Jun 14, 2023
2795914
Add delegation rewards calculation
PhilippGackstatter Jun 14, 2023
27ca8d5
Update Delegation Rewards calculation
PhilippGackstatter Jun 15, 2023
fb1586b
Add Validator Rewards calculation
PhilippGackstatter Jun 15, 2023
95b6480
Add Tracking Data schemas
PhilippGackstatter Jun 15, 2023
ed3e611
Format Markdown
PhilippGackstatter Jun 15, 2023
91d57a6
Add preliminaries on performance factor
PhilippGackstatter Jun 16, 2023
717ae92
Fix `End Epoch` capitalization and format
PhilippGackstatter Jun 16, 2023
e58cd08
Small fixes
daria305 Jun 20, 2023
1cceb01
Update field order
PhilippGackstatter Jun 21, 2023
8692b69
Update delegation output syntax rules
PhilippGackstatter Jun 21, 2023
0390f4e
Add Storage Deposit for Delegation Output
PhilippGackstatter Jul 3, 2023
40a8974
Update tips/TIP-0040/tip-0040.md
PhilippGackstatter Jul 4, 2023
4028da8
Clarify destruction transition
PhilippGackstatter Jul 4, 2023
ef6f480
Use `Validator ID` instead of `Validator`
PhilippGackstatter Jul 6, 2023
69a8295
Update committee selection procedure
PhilippGackstatter Jul 6, 2023
d2d9987
Remove open questions
PhilippGackstatter Jul 6, 2023
43f5b0f
Use `<=` instead of `<` for delegator rewards
PhilippGackstatter Jul 7, 2023
ef5c8fb
Add Rationale section
PhilippGackstatter Jul 7, 2023
22418a3
Replace `voting power` with `pool stake`
PhilippGackstatter Jul 7, 2023
22e1bed
Add motivation section
PhilippGackstatter Jul 12, 2023
be70eed
Add time boundaries for Delegation Output
PhilippGackstatter Jul 17, 2023
8fd05ae
Use Commitment input for rewards calculation
PhilippGackstatter Jul 18, 2023
4c20df0
Specify `n` in registration slot calculation
PhilippGackstatter Jul 18, 2023
f89a55f
Be more loose with Commitment Input requirements
PhilippGackstatter Jul 18, 2023
da35385
Use future bounded idx for end epoch + rationale
PhilippGackstatter Jul 18, 2023
e3d10d8
Calculate mana rewards per epoch, not slot
daria305 Jul 19, 2023
5f8755d
Remove immutable features from Delegation Output
PhilippGackstatter Jul 20, 2023
7281321
Apply format
PhilippGackstatter Jul 20, 2023
54204be
Update rewards calculations
oliviasaa Jul 23, 2023
8436189
parametrisation of the rewards
oliviasaa Jul 24, 2023
8b09456
add a to do
oliviasaa Jul 27, 2023
b9c522c
Fix typo
PhilippGackstatter Aug 2, 2023
135174e
Fix typo
PhilippGackstatter Aug 2, 2023
bf40255
Add offset to delegatin output storage calculation
PhilippGackstatter Aug 15, 2023
2d913ff
Readd Mana Rewards
PhilippGackstatter Aug 18, 2023
a7f0212
Calculation fixes
daria305 Aug 31, 2023
eaab6b8
minor things
oliviasaa Sep 10, 2023
a2170d0
Format schema tables (no content changes)
PhilippGackstatter Sep 21, 2023
355e9b9
Update summary
oliviasaa Sep 21, 2023
2bcb212
Add new address types in Delegation Output
PhilippGackstatter Sep 22, 2023
e27aa48
Update storage deposit with new addr types
PhilippGackstatter Sep 22, 2023
7c19645
motivation
oliviasaa Sep 24, 2023
274c755
Update tips/TIP-0040/tip-0040.md
oliviasaa Sep 24, 2023
e85c303
staking1
oliviasaa Sep 24, 2023
d4540cf
Update tip-0040.md
oliviasaa Sep 24, 2023
ad3b216
Update tip-0040.md
oliviasaa Sep 24, 2023
ac99932
Update tip-0040.md
oliviasaa Sep 24, 2023
7b34adb
staking2
oliviasaa Sep 24, 2023
36ab5b9
Update tip-0040.md
oliviasaa Sep 24, 2023
41f2632
committee selection
oliviasaa Sep 24, 2023
db166e1
coins->tokens
oliviasaa Sep 24, 2023
eaf0a27
committee tasks
oliviasaa Sep 24, 2023
a5cf8c1
delegation
oliviasaa Sep 24, 2023
82595c9
delegId
oliviasaa Sep 24, 2023
1e43fee
Epoch performance factor calculations
oliviasaa Sep 24, 2023
fad3dc7
solve to do
oliviasaa Sep 24, 2023
ccac31c
Update tip-0040.md
oliviasaa Sep 24, 2023
bfc9cd9
Update tip-0040.md
oliviasaa Sep 24, 2023
9e8a974
Update tip-0040.md
oliviasaa Sep 24, 2023
b25ba9c
Update tip-0040.md
oliviasaa Sep 24, 2023
9f7c8c9
add link
oliviasaa Sep 24, 2023
2ba22c6
Update tip-0040.md
oliviasaa Sep 24, 2023
406087c
Update tips/TIP-0040/tip-0040.md
oliviasaa Sep 24, 2023
0db5beb
Update tips/TIP-0040/tip-0040.md
oliviasaa Sep 24, 2023
f9d394c
Update tips/TIP-0040/tip-0040.md
oliviasaa Sep 24, 2023
5b6ec35
Update tips/TIP-0040/tip-0040.md
oliviasaa Sep 24, 2023
74c4d2f
Update tips/TIP-0040/tip-0040.md
oliviasaa Sep 24, 2023
e98e68e
Update tips/TIP-0040/tip-0040.md
oliviasaa Sep 24, 2023
7bbe75f
Update tips/TIP-0040/tip-0040.md
oliviasaa Sep 24, 2023
d42db8c
Update tips/TIP-0040/tip-0040.md
oliviasaa Sep 24, 2023
eb09633
Update tip-0040.md
oliviasaa Sep 24, 2023
a00306c
Update tip-0040.md
oliviasaa Sep 24, 2023
4452b38
Update tip-0040.md
oliviasaa Sep 24, 2023
73eca99
solve do tos
oliviasaa Sep 24, 2023
20a9a27
solve to do
oliviasaa Sep 24, 2023
4c648a0
Rename `ValidatorId` to `ValidatorAddress`
PhilippGackstatter Sep 25, 2023
edb331d
Motivate seat-based committees
PhilippGackstatter Sep 25, 2023
a92dd47
Update tips/TIP-0040/tip-0040.md
PhilippGackstatter Sep 25, 2023
060977b
add nikita's suggestions
oliviasaa Sep 25, 2023
12eaf1f
Update tips/TIP-0040/tip-0040.md
PhilippGackstatter Sep 25, 2023
41471bf
Use protocol parameter Token Supply in amount rule
PhilippGackstatter Sep 29, 2023
916d483
Remove nested address duplication
PhilippGackstatter Oct 4, 2023
b333daf
add author
oliviasaa Oct 16, 2023
c710573
Add author
daria305 Oct 17, 2023
7673c9a
Set new Delegation Output type prefix
PhilippGackstatter Oct 17, 2023
7728aab
Add author
PhilippGackstatter Oct 17, 2023
faa21f5
Format TIP
PhilippGackstatter Oct 17, 2023
4770f7c
Add `Storage Score Offset Delegation`
PhilippGackstatter Oct 17, 2023
16ccd5e
Remove storage deposit table
PhilippGackstatter Oct 17, 2023
28661b4
Remove manually added Table of Contents
PhilippGackstatter Oct 23, 2023
6045fd3
Use passive voice everywhere
PhilippGackstatter Oct 23, 2023
b2c0cdd
Replace `IOTA Tokens` -> `IOTA coins`
PhilippGackstatter Oct 23, 2023
60ad645
Capitalize `Mana`
PhilippGackstatter Oct 23, 2023
5e7c84c
Point protocol params to TIP-49
PhilippGackstatter Oct 23, 2023
29e329b
Update type prefix & add anchor address
PhilippGackstatter Nov 2, 2023
c1e83cc
Format Markdown
PhilippGackstatter Nov 3, 2023
55cff3a
Remove `Amount <= Token Supply` check
PhilippGackstatter Nov 8, 2023
90e1bcc
Fix incorrect epoch index calculation
PhilippGackstatter Nov 8, 2023
b635840
Remove `Amount` rules (moved to TIP-45)
PhilippGackstatter Nov 8, 2023
9110ac3
Apply suggestions from code review
PhilippGackstatter Nov 27, 2023
d277435
Update registration conditions to latest code
PhilippGackstatter Nov 30, 2023
80b37c9
Fix markdown formatting
PhilippGackstatter Dec 6, 2023
8e82bc4
Overhaul committee selection & rewards
PhilippGackstatter Dec 14, 2023
4bf2f67
Change `Validator ID` occurences to `Address`
PhilippGackstatter Dec 14, 2023
38b1803
Parameterize `Pool Stake`
PhilippGackstatter Dec 14, 2023
593e050
Correct storage score offset parameter name
PhilippGackstatter Dec 14, 2023
8a78c71
Add names of Validator & Delegator Reward funcs
PhilippGackstatter Dec 14, 2023
9bd48fd
Add storage score test vector
PhilippGackstatter Dec 21, 2023
9ddcd13
Change Validator Address type to Account Address
PhilippGackstatter Dec 21, 2023
d47dc73
update target rewards calculations
cyberphysic4l Feb 15, 2024
95a526c
Add Commitment Input syntactic requirement
PhilippGackstatter Mar 5, 2024
58eea34
Correct Commitment Input requirement statement
PhilippGackstatter Mar 5, 2024
2e32ec8
add parameter contraints
oliviasaa Mar 28, 2024
510f8e2
fix equation
oliviasaa Mar 28, 2024
fb8742f
fix eq
oliviasaa Mar 28, 2024
0c5d91f
fix LaTeX
oliviasaa Mar 28, 2024
2de6e17
fix LaTeX
oliviasaa Mar 28, 2024
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
Binary file added tips/TIP-0040/assets/delayed-claiming.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tips/TIP-0040/assets/delegation-epochs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tips/TIP-0040/assets/selection-timing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
165 changes: 165 additions & 0 deletions tips/TIP-0040/constraints.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
# Parameters constraints

Due to the use of fixed point arithmetics, some contraints on the rewards parameters are needed to prevent overflowing of the variables used for the calculations.

## Constraints on the Mana Supply

The first and most straighforward contraint is that the total maximum theoretical Mana in the system should not use more than $\text{Bits Count}$ bits.

Let's start by calculating the Mana in the system generated by holding tokens $\text{Mana Holders}(n)$ until epoch $n$.

$$
\text{Mana Holders}(n)=\frac{\text{Token Supply} * \text{Generation Rate}}{1-\text{Decay per Epoch}} * 2^{\text{Slots per Epoch Exp}-\text{Generation Rate Exp}} (1-\text{Decay per Epoch}^{n+1})
$$

with $\text{Decay per Epoch}=\text{Decay per Year}^{\frac{\text{Seconds per Epoch}}{\text{Seconds per Year}}}$.

The maximum Mana in the system generated by holding tokens $\text{Max Mana Holders}$ is equivalent to the potential Mana generated by an output holding $\text{Token Supply}$ IOTA coins until epoch $n$, for $n$ large enough. This results:

$$
\begin{align*}
\text{Max Mana Holders} = \frac{\text{Token Supply} * \text{Generation Rate}}{1-\text{Decay per Epoch}}2^{\text{Slots per Epoch Exp}-\text{Generation Rate Exp}}
\end{align*}
$$

We denote by $\text{Max Reward Rate}(n) = \text{Max to Target Ratio} * \text{Target Rewards Rate}(n)$ the theoretical maximum reward distributed at epoch $n$.
In the case of fixed or top stakers based committees, the actual reward distributed per epoch is at most $\text{Target Rewards Rate}(n)$, i.e., $\text{Max to Target Ratio} = 1$.
For random committees, see [Random committees](#random-committees).

### Mana Supply in the bootstrapping Phase

In the bootstrapping Phase, the target reward decreases each epoch until reaching $\text{Final Target Rewards Rate}$.
The maximum amount of Mana distributed as rewards until epoch $n$ is:

$$
\sum_{i=1}^{n} \text{Decay}(\text{Max Reward Rate}(i),n-i)
$$

Since $\text{Max Reward Rate}(i)$ is proportional to the epoch target reward, this is equivalent to

$$
\begin{align*}
&\sum_{i=1}^{n} \text{Decay}(\text{Decay}(\text{Max Reward Rate}(1),i-1),n-i)\\
=&n \text{Decay}(\text{Max Reward Rate}(1),n-1)\\
=&n \text{Decay per Epoch}^{n-1} \text{Max Reward Rate}(1)
\end{align*}
$$

the function above is increasing if $n\leq \frac{-1}{\log(\text{Decay per Epoch})}$ and decreasing otherwise (i.e., it is a concave function). However, since the $\text{Bootstrapping Duration}$ is set such that $\text{Bootstrapping Duration in Years}*\text{Beta per Year}=1$, we have that $\text{Bootstrapping Duration in Years} = \frac{1}{\text{Beta per Year}}=\frac{-1}{\log(\text{Decay per Year})}$. Then, the maximum amount of Mana distributed as rewards in the bootstrapping Phase is achieved at $\text{Bootstrapping Duration}$, i.e., the maximum is

$$
\begin{align*}
&\text{Max Mana Supply Bootstrapping}\\
&=\frac{1}{-\log(\text{Decay per Epoch})} * \text{Max to Target Ratio} * \text{Final Target Rewards Rate}
\end{align*}
$$

By definition, we have that $\text{Final Target Rewards Rate}$ is

$$
\begin{align*}
& \text{Final Target Rewards Rate} = \text{Token Supply} * \text{Reward To Generation Ratio}\\
& * \text{Generation Rate} * 2^{\text{Slots per Epoch Exp}-\text{Generation Rate Exp}}
\end{align*}
$$

Then, the Maximum Mana supply in the bootstrapping phase is

$$
\begin{align*}
&\text{Max Mana Supply Bootstrapping}\\
&=\text{Token Supply} * \text{Generation Rate} * 2^{\text{Slots per Epoch Exp}-\text{Generation Rate Exp}}\\
&\left(\text{Reward To Generation Ratio} * \frac{1}{-\log(\text{Decay per Epoch})} * \text{Max to Target Ratio}\right.\\
+&\left.\frac{1}{1-\text{Decay per Epoch}}\right)\\
&\leq \text{Token Supply} * \text{Generation Rate} * 2^{\text{Slots per Epoch Exp}-\text{Generation Rate Exp}}\\
&\frac{1+\text{Reward To Generation Ratio} * \text{Max to Target Ratio}}{1-\text{Decay per Epoch}}
\end{align*}
$$

### Mana Supply after the bootstrapping Phase

By construction, $\text{Final Target Rewards Rate}$ is such that the target reward per epoch is $\text{Reward To Generation Ratio}$ times the generation by holding tokens in that epoch.

Then, we have that the total Mana in the system will never be larger than $\text{Max Mana Holders} (1 + \text{Max to Target Ratio} * \text{Reward To Generation Ratio})$, i.e. the Mana circulating Supply will be always smaller than :

$$
\begin{align*}
&\text{Max Mana Supply}\\
&=\text{Token Supply} * \text{Generation Rate} * 2^{\text{Slots per Epoch Exp}-\text{Generation Rate Exp}}\\
&\frac{1+\text{Reward To Generation Ratio} * \text{Max to Target Ratio}}{1-\text{Decay per Epoch}}
\end{align*}
$$

which is the same bound found for the bootstrapping Phase.
Thus, the protocol parameters should be set so that the $\text{Max Mana Supply}$ above is at most $2^{\text{Bits Count}}-1$.

### Mana Supply for Random committees

In the case of random commitees, we cap the individual pool reward such that no pool will receive more than $\text{Max Pool Reward}(n) = \text{Max Reward Coeff} * \text{Target Rewards Rate}(n)$ per epoch.
Then, in a single epoch, no more than $\text{Target Committee Size} * \text{Max Reward Coeff} * \text{Target Rewards Rate}(n)$ Mana will be distributed, i.e., in this case, $\text{Max to Target Ratio} = \text{Target Committee Size} * \text{Max Reward Coeff}$.
Since, in general, $\text{Target Committee Size} * \text{Max Reward Coeff}$ might be larger than 1, we must alredy set proper maximim values for $\text{Max to Target Ratio}$ to prevent overflowing in case of a future change in the committee selection.
Here, we set $\text{Max to Target Ratio}=20$.
Note that, for fixed committees, this ratio is naturally respected, without the need to add any type of cap in the rewards.
However, in the case of a future protocol upgrade such that the committee selection becomes random, a cap respecting a maximum of $\text{Max to Target Ratio}=20$ must be introduced.

## Constraints due to fixed point arithmetics

Additionally to the parameter constraints to prevent the Mana supply from overflowing, other parameter constraints must be introduced to that the function defined in TIP 40 do not overflow using 64 bits variables.

In particular, in this TIP we define the following operations:
- `Token Supply << Profit Margin Exponent`: this value must be smaller than <code>2<sup>64</sup></code>,
- `Pool Coefficient = ((Pool Stake(i) << Pool Coefficient Exponent)/Total Stake) + (Validator Stake(i) << Pool Coefficient Exponent) / Total Validator Stake`:
Since both `Pool Stake(i)` and `Validator Stake(i)` are at most `Token Supply`, to not overflow the calculation, `Pool Coefficient Exponent` must be such that <code>(Token Supply << Pool Coefficient Exponent)< 2<sup>64</sup></code>.
`Pool Coefficient` will then use at most `Pool Coefficient Exponent + 1` bits.
- `res = (Pool Coefficient * Target Rewards Rate(n))>>PoolCoefficientExponent`: this implies that `Pool Coefficient * Target Rewards Rate(n))` must always be smaller than <code>2<sup>64</sup></code>, which is guaranteed by the condition <code>Initial Target Rewards Rate <2<sup>63-Pool Coefficient Exponent</sup></code>.
- `Pool Reward = ((res * Epoch Performance Factor)/Validation Blocks Per Slot)>>1`: since `res` is at most two times `Initial Target Rewards Rate`, and `Epoch Performance Factor` is at most `Validation Blocks Per Slot <= 32`, this imples that <code>Initial Target Rewards Rate * Validation Blocks Per Slot < 2<sup>63</sup></code>.

- `Profit Margin Factor = (Profit Margin(n) * (Pool Rewards(n) - Fixed Cost(n))) >> Profit Margin Exponent`: this implies that `Initial Target Rewards Rate<2^(64-Profit Margin Exponent) `

## Constraints due to parameter compatibility

To avoid locally calculating the parameters, some of them are provided in the snapshot file, even thought they not are defined independently in the Whitepaper.
To avoid problems in the parameter setting, we define some sanity checks for these parameters below:

## Lookup Table and Annual Decay

Let `Seconds In An Epoch = Slot Duration In Seconds << Slots Per Epoch Exponent` and `Seconds In A Year = 60 * 60 * 24* 365`.
Then the epoch duration in years is given by `Epoch Duration In Years = Seconds In An Epoch/Seconds In A Year`.
Additionally, let `Annual Decay Factor = Annual Decay Factor Percentage/100`.

The entry `Lookup Table(epochDiff)` in the Lookup table relative to `epochDiff` should be such that

`0 <= delta < 1`, where

`delta = (Annual Decay Factor)^(epochDiff*Epoch Duration In Years)*(2**decay Factor Exp) - Lookup Table(epochDiff)`

## Initial and Final rewards

Let `Seconds In An Epoch = Slot Duration In Seconds << Slots Per Epoch Exponent` and `Seconds In A Year = 60 * 60 * 24* 365`.
Then the epoch duration in years is given by `Epoch Duration In Years = Seconds In An Epoch/Seconds In A Year`.
The bootstrapping duration in years is, then:
`Bootstrapping Duration In Years = Epoch Duration In Years * Bootstrapping Duration`
Additionally, let `Annual Decay Factor = Annual Decay Factor Percentage/100`.

Let `Expected Final Target Rewards Rate = (Total Supply * Reward To Generation Ratio * Generation Rate) >> (Generation Rate Exponent - Slots Per Epoch Exponent)` and `Expected Initial Target Rewards Rate = Final Target Rewards Rate / (Annual Decay Factor ^ Bootstrapping Duration In Years)`.

Then, we need

`0 <= Expected Final Target Rewards Rate - Final Target Rewards Rate < 1`
and
`0 <= Expected Initial Target Rewards Rate - Initial Target Rewards Rate < 1`

## Bootstrapping Duration and Decay

Let `Seconds In An Epoch = Slot Duration In Seconds << Slots Per Epoch Exponent` and `Seconds In A Year = 60 * 60 * 24 * 365`.
Then the number of epochs in a years is given by `Epochs In An Year = Seconds In A Year/Seconds In An Epoch`.
Additionally, let `Annual Decay Factor = Annual Decay Factor Percentage/100`.
Translating this to an exponential decay (as in the Whitepaper), we have that `Beta Per Year = -log(Annual Decay Factor)`.

The bootstrapping duration should be an integer approximation of `Epochs In An Year/Beta Per Year`

## Decay Factor Epoch Sum and Decay

Decay Factor Epoch Sum should be an integer approximation of

`2^Decay Factor Epoch Sum Exponent* Decay per Epoch/(1-Decay per Epoch)`
Loading
Loading