polkadot-fellows / runtimes

The various runtimes which make up the core subsystems of networks for which the Fellowship is represented.
GNU General Public License v3.0
135 stars 85 forks source link

Kusama: Make the current inflation formula adjustable. #364

Closed kianenigma closed 1 month ago

kianenigma commented 3 months ago

This PR does not alter the inflation of Kusama, but instead make the current parameters of the system fully configurable.

Parameters

The parameters are as follows:

/// Minimum inflation rate used to calculate era payouts.
pub static MinInflation: Perquintill = Perquintill::from_rational(25u64, 1000);

/// Maximum inflation rate used to calculate era payouts.
pub static MaxInflation: Perquintill = Perquintill::from_percent(10);

/// Ideal stake ratio used to calculate era payouts.
pub static IdealStake: Perquintill = Perquintill::from_percent(75);

/// Falloff used to calculate era payouts.
pub static Falloff: Perquintill = Perquintill::from_percent(5);

/// Whether to use auction slots or not in the calculation of era payouts, then we subtract
/// `num_auctioned_slots.min(60) / 200` from `ideal_stake`.
///
/// That is, we assume up to 60 parachains that are leased can reduce the ideal stake by a
/// maximum of 30%.
///
/// With the move to agile-coretime, this parameter does not make much sense and should
/// generally be set to false.
pub static UseAuctionSlots: bool = true;

All of the above are exactly the current values in Kusama, and leave everything unchanged, leading to roughly 1kKSM minted for validators, and around 90KSM for treasury.

All of the above can be changed via the Root track only.

Given that it is hard to come to consensus, I highly advise this PR (and a similar PR to Polkadot) to NOT alter any parameter and leave that to the token holders.

Just to provide one example, if we set UseAuctionSlots = false and leave everything else un-changed, the amount minted per era would be:

This, in my opinion, is the most non-controversial change as the incorporation of auctions in the inflation rate is already meaningless with agile-coretime.

Consideration for UIs

This PR is shipped with a new runtime API that is only added to the Kusama runtime: Inflation_experimental_inflation_info. I hope this API is used by the UIs to show the inflation parameters of the network, rather than re-creating the Rust logic in the front-end.

kianenigma commented 2 months ago

Some updates:

  1. Depends on https://github.com/polkadot-fellows/runtimes/pull/381
  2. Would also preferably depend on sdk 1.15 to get the new relay_inflation helper fn.
  3. Based on the last fellowship call, for now we will only add this to Kusama https://www.youtube.com/live/oWppBMrgU7M?si=b4O-G_mIEBp1tnV4&t=2137
kianenigma commented 2 months ago

Once https://github.com/polkadot-fellows/runtimes/pull/381 is merged, I shall merge https://github.com/kianenigma/runtimes/tree/kiz-inflation-with-update here.

kianenigma commented 2 months ago

I ran some experiments on this in Kusama, and I thought these parameters are the ones that map 1-1 to the current system, but the numbers differ quite a lot with the current daily inflation of Kusama (around 1kKSM):

Jul 19 09:15:35.490 DEBUG runtime::kusama: params: EraPayoutParams { total_staked: 8062597276340684331, total_stakable: 15224588856636910147, ideal_stake: 75%, max_annual_inflation: 10%, min_annual_inflation: 2.5%, falloff: 5%, period_fraction: 0.0317894896950338%, legacy_auction_proportion: Some(17.5%) }    
Jul 19 09:15:35.490  INFO runtime::kusama: total-staked = 8062597.276 KSM (8,062,597,276,340,684,331)    
Jul 19 09:15:35.490  INFO runtime::kusama: total-issuance = 15224588.856 KSM (15,224,588,856,636,910,147)    
Jul 19 09:15:35.490  INFO runtime::kusama: staking-rate = 52.9577340463018619%    
Jul 19 09:15:35.490  INFO runtime::kusama: era-duration = 10032000    
Jul 19 09:15:35.490  INFO runtime::kusama: min-inflation = 2.5%    
Jul 19 09:15:35.490  INFO runtime::kusama: max-inflation = 10%    
Jul 19 09:15:35.490  INFO runtime::kusama: falloff = 5%    
Jul 19 09:15:35.490  INFO runtime::kusama: useAuctionSlots = true    
Jul 19 09:15:35.490  INFO runtime::kusama: idealStake = 75%    
Jul 19 09:15:35.490  INFO runtime::kusama: maxStakingRewards = None    
Jul 19 09:15:35.490  INFO runtime::kusama: 💰 Inflation ==> staking = 455.307 KSM (455,307,459,857,217) / leftover = 28.674 KSM (28,674,450,711,956)   

Need to double check and ensure the code is fully backwards compatible.

kianenigma commented 2 months ago

Well, I called this simulation more or less in the middle of an era, so the era duration is assumed to be half :)) So the code adds up.

joepetrowski commented 1 month ago

/merge

fellowship-merge-bot[bot] commented 1 month ago

Enabled auto-merge in Pull Request

Available commands - `/merge`: Enables auto-merge for Pull Request - `/merge cancel`: Cancels auto-merge for Pull Request - `/merge help`: Shows this menu For more information see the [documentation](https://github.com/paritytech/auto-merge-bot)