Skip to content

Commit

Permalink
recalibrate inflation (#132)
Browse files Browse the repository at this point in the history
# Summary

This proposal changes inflation calculation to be based on the during of
the epoch in seconds instead of relying on number of blocks that are
expected to be produced in a year.

# Motivation

Currently on mainnet blocks are produced usually at between 1.2 and 1.3
per second, which is great. However, when we calculate inflation per
epoch, we use the following formula (note: this excludes the tokens
burnt in transaction fees):
```
inflation = total_supply * yearly_inflate_rate * epoch_length / expected_num_blocks_per_year
```
where `expected_num_blocks_per_year` is a genesis parameter currently
set to 31536000, i.e, a block every second. Since blocks are produced
faster that, expected_num_blocks_per_year is smaller than the actual
value, which means that, at the current rate, we will have ~20% more
inflation than expected.

# Guide-level explanation

Calculating the inflation based on blocks isn’t the most reliably way to
begin with. Even though currently epochs are shorter than expected, they
could, in some cases, be longer than expected if there are a few
validators offline for the entire duration of the epoch. To address
this, I propose that we change the inflation calculation based on time
elapsed instead of number of blocks. More specifically, this proposal
only requires changing the inflation calculation to
```
inflation = total_supply * yearly_inflation_rate * duration_of_epoch_in_seconds / num_seconds_in_a_year
```
This is essentially still a first-order Taylor approximation of the
target inflation rate, in the similar vein as the original calculation.
However, it is more accurate and is less subject to the perturbation of
the epoch time.

# Reference-level explanation

* Duration of an epoch can be easily calculated when we finalize the
epoch by subtracting the timestamp of the first block of the epoch from
that of the last block.
* Upgrade process is relatively straightforward. We simply switch to the
new way of calculating inflation when the protocol version changes.
* For simplicity, we set `num_seconds_in_a_year` as a constant
`31536000`. For leap year this will be not entirely accurate but the
difference is negligibly small.
  • Loading branch information
bowenwang1996 authored Oct 5, 2022
1 parent 666bc95 commit c6b29a4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions specs/Economics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ The protocol sets a ceiling for the maximum issuance of tokens, and dynamically

| Name | Description |
| - | - |
| `reward[t]` | `totalSupply[t]` * ((`1 + REWARD_PCT_PER_YEAR`) ** (`1/EPOCHS_A_YEAR`) - `1`) |
| `reward[t]` | `totalSupply[t]` * `REWARD_PCT_PER_YEAR` * `epochTime[t]` / `NUM_SECONDS_IN_A_YEAR` |
| `epochFee[t]` | `sum([(1 - DEVELOPER_PCT_PER_YEAR) * block.txFee + block.stateFee for block in epoch[t]])` |
| `issuance[t]` | The amount of token issued at a certain epoch[t], `issuance[t] = reward[t] - epochFee[t]` |

Where `totalSupply[t]` is the total number of tokens in the system at a given time *t*.
Where `totalSupply[t]` is the total number of tokens in the system at a given time *t* and `epochTime[t]` is the
duration of the epoch in seconds.
If `epochFee[t] > reward[t]` the issuance is negative, thus the `totalSupply[t]` decreases in given epoch.

## Transaction Fees
Expand Down

0 comments on commit c6b29a4

Please sign in to comment.