Skip to content

Commit

Permalink
Polkadot: Make the current inflation formula adjustable (#443)
Browse files Browse the repository at this point in the history
Counterpart of #364.

Similarly, it has no impact on the inflation as-is, and just exposes the
params to the Root track.

## UI Consideration

Similarly, it adds `Inflation_experimental_inflation_info` Runtime API,
which can be used by UIs to fetch information about the inflation,
without needing to rely on storage items.

## Example

- With current parameters: 

```
Inflation ==> staking = 402244.054 DOT (4,022,440,540,915,948) / leftover = 4178.285 DOT (41,782,856,835,356)
```

- With `UseLegacyAuctions = false`, which means we no longer set aside
around 15% of tokens for auctions. This makes the difference between
actual staked and ideal staking rate (staking inefficiency) grow, and
therefore reduce the staking reward and increase the treasury income.

```
Inflation ==> staking = 340780.189 DOT (3,407,801,892,871,273) / leftover = 65642.150 DOT (656,421,504,843,446)
```

---------

Co-authored-by: Oliver Tale-Yazdi <[email protected]>
Co-authored-by: Gonçalo Pestana <[email protected]>
Co-authored-by: Ankan <[email protected]>
  • Loading branch information
4 people authored Oct 1, 2024
1 parent 6df0558 commit 646031d
Show file tree
Hide file tree
Showing 7 changed files with 312 additions and 108 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- Chain-spec generator: propagate the `on_chain_release_build` feature to the chain-spec generator. Without this the live/genesis chain-specs contain a wrongly-configured WASM blob ([polkadot-fellows/runtimes#450](https://github.com/polkadot-fellows/runtimes/pull/450)).

### Added

- Polkadot: Make the current inflation formula adjustable ([polkadot-fellows/runtimes#443](https://github.com/polkadot-fellows/runtimes/pull/443))

## [1.3.2] 27.08.2024

### Fixed
Expand Down
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 16 additions & 13 deletions relay/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ use kusama_runtime_constants::{
currency::*, fee::*, system_parachain, time::*, TREASURY_PALLET_ID,
};

/// Default logging target.
pub const LOG_TARGET: &str = "runtime::kusama";

// Genesis preset configurations.
pub mod genesis_config_presets;

Expand Down Expand Up @@ -1919,11 +1922,11 @@ impl Runtime {
};

// We assume un-delayed 6h eras.
let era_duration = 6 * HOURS;
let era_duration = 6 * (HOURS as Moment) * MILLISECS_PER_BLOCK;
let next_mint = <Self as pallet_staking::Config>::EraPayout::era_payout(
staked,
stake_able_issuance,
era_duration.into(),
era_duration,
);

InflationInfo { inflation, next_mint }
Expand Down Expand Up @@ -3044,17 +3047,17 @@ mod remote_tests {
use ss58_registry::TokenRegistry;
let token: ss58_registry::Token = TokenRegistry::Ksm.into();

log::info!(target: "runtime::kusama", "total-staked = {:?}", token.amount(total_staked));
log::info!(target: "runtime::kusama", "total-issuance = {:?}", token.amount(total_issuance));
log::info!(target: "runtime::kusama", "staking-rate = {:?}", Perquintill::from_rational(total_staked, total_issuance));
log::info!(target: "runtime::kusama", "era-duration = {:?}", average_era_duration_millis);
log::info!(target: "runtime::kusama", "min-inflation = {:?}", dynamic_params::inflation::MinInflation::get());
log::info!(target: "runtime::kusama", "max-inflation = {:?}", dynamic_params::inflation::MaxInflation::get());
log::info!(target: "runtime::kusama", "falloff = {:?}", dynamic_params::inflation::Falloff::get());
log::info!(target: "runtime::kusama", "useAuctionSlots = {:?}", dynamic_params::inflation::UseAuctionSlots::get());
log::info!(target: "runtime::kusama", "idealStake = {:?}", dynamic_params::inflation::IdealStake::get());
log::info!(target: "runtime::kusama", "maxStakingRewards = {:?}", pallet_staking::MaxStakedRewards::<Runtime>::get());
log::info!(target: "runtime::kusama", "💰 Inflation ==> staking = {:?} / leftover = {:?}", token.amount(staking), token.amount(leftover));
log::info!(target: LOG_TARGET, "total-staked = {:?}", token.amount(total_staked));
log::info!(target: LOG_TARGET, "total-issuance = {:?}", token.amount(total_issuance));
log::info!(target: LOG_TARGET, "staking-rate = {:?}", Perquintill::from_rational(total_staked, total_issuance));
log::info!(target: LOG_TARGET, "era-duration = {:?}", average_era_duration_millis);
log::info!(target: LOG_TARGET, "min-inflation = {:?}", dynamic_params::inflation::MinInflation::get());
log::info!(target: LOG_TARGET, "max-inflation = {:?}", dynamic_params::inflation::MaxInflation::get());
log::info!(target: LOG_TARGET, "falloff = {:?}", dynamic_params::inflation::Falloff::get());
log::info!(target: LOG_TARGET, "useAuctionSlots = {:?}", dynamic_params::inflation::UseAuctionSlots::get());
log::info!(target: LOG_TARGET, "idealStake = {:?}", dynamic_params::inflation::IdealStake::get());
log::info!(target: LOG_TARGET, "maxStakingRewards = {:?}", pallet_staking::MaxStakedRewards::<Runtime>::get());
log::info!(target: LOG_TARGET, "💰 Inflation ==> staking = {:?} / leftover = {:?}", token.amount(staking), token.amount(leftover));
});
}

Expand Down
8 changes: 8 additions & 0 deletions relay/polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ pallet-multisig = { workspace = true }
pallet-nomination-pools = { workspace = true }
pallet-nomination-pools-runtime-api = { workspace = true }
pallet-offences = { workspace = true }
pallet-parameters = { workspace = true }
pallet-preimage = { workspace = true }
pallet-proxy = { workspace = true }
pallet-referenda = { workspace = true }
Expand Down Expand Up @@ -96,6 +97,7 @@ pallet-nomination-pools-benchmarking = { optional = true, workspace = true }
polkadot-runtime-common = { workspace = true }
runtime-parachains = { workspace = true }
polkadot-primitives = { workspace = true }
relay-common = { workspace = true }

xcm = { workspace = true }
xcm-executor = { workspace = true }
Expand All @@ -114,6 +116,8 @@ separator = { workspace = true }
remote-externalities = { workspace = true }
tokio = { features = ["macros"], workspace = true }
sp-tracing = { workspace = true }
hex-literal = { workspace = true }
ss58-registry = { workspace = true }

[build-dependencies]
substrate-wasm-builder = { workspace = true, optional = true }
Expand Down Expand Up @@ -164,6 +168,7 @@ std = [
"pallet-nomination-pools/std",
"pallet-offences-benchmarking?/std",
"pallet-offences/std",
"pallet-parameters/std",
"pallet-preimage/std",
"pallet-proxy/std",
"pallet-referenda/std",
Expand All @@ -187,6 +192,7 @@ std = [
"polkadot-primitives/std",
"polkadot-runtime-common/std",
"polkadot-runtime-constants/std",
"relay-common/std",
"runtime-parachains/std",
"scale-info/std",
"serde_json/std",
Expand Down Expand Up @@ -242,6 +248,7 @@ runtime-benchmarks = [
"pallet-nomination-pools/runtime-benchmarks",
"pallet-offences-benchmarking/runtime-benchmarks",
"pallet-offences/runtime-benchmarks",
"pallet-parameters/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
"pallet-proxy/runtime-benchmarks",
"pallet-referenda/runtime-benchmarks",
Expand Down Expand Up @@ -295,6 +302,7 @@ try-runtime = [
"pallet-multisig/try-runtime",
"pallet-nomination-pools/try-runtime",
"pallet-offences/try-runtime",
"pallet-parameters/try-runtime",
"pallet-preimage/try-runtime",
"pallet-proxy/try-runtime",
"pallet-referenda/try-runtime",
Expand Down
Loading

0 comments on commit 646031d

Please sign in to comment.