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

Mangata dev v0.9.36 #20

Merged
merged 127 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
e090658
Companion for EPM duplicate submissions (#6115)
kianenigma Oct 19, 2022
906d911
try and fix build (#6170)
kianenigma Oct 20, 2022
0fd106c
sync versions with current release (0.9.31) (#6176)
coderobe Oct 22, 2022
a060975
Use a more typesafe approach for managing indexed data (#6150)
tifecool Oct 22, 2022
f610ffc
Add missing prerequisite in README for implementers guide (#6181)
mrcnski Oct 24, 2022
37d2b0f
Companion for #12457 (Bounded Multisig) (#6172)
shawntabrizi Oct 25, 2022
29bf467
Make some fixes to logging in PVF subsystem (#6180)
mrcnski Oct 26, 2022
11221b5
Co #12558: Update `pallet-multisig` benches (#6188)
ggwpez Oct 26, 2022
ef8d1a7
Update impl guide README (#6197)
nuke-web3 Oct 27, 2022
d17ee12
[Companion] StakingInterface adjustments (#6199)
ruseinov Oct 29, 2022
b77710b
Companion for update `wasm-opt` (#6209)
athei Oct 30, 2022
e3f6731
Make ValidateUnsigned available on all chains for paras. (#6214)
eskimor Oct 30, 2022
5d05f2a
fix upgrade node test, use latest as base image (#6215)
pepoviola Oct 31, 2022
0bc8fdd
Check if approval voting db is empty on startup (#6219)
sandreim Oct 31, 2022
9081d71
PVF timeouts follow-up (#6151)
mrcnski Nov 1, 2022
9804140
BlockId removal: refactor: BlockBackend::block_body (#6223)
michalkucharczyk Nov 1, 2022
7176670
Replace parachain/parathread boolean by enum (#6198)
Nov 1, 2022
d6fad72
BlockId removal: refactor: Backend::justifications (#6229)
michalkucharczyk Nov 2, 2022
183e25a
BlockId removal: refactor: Backend::block_indexed_body (#6233)
michalkucharczyk Nov 3, 2022
d803489
Xcm-Simulator Docs (#6178)
Szegoo Nov 3, 2022
0f0807a
Add stake.plus bootnodes for westend, kusama, polkadot (#6224)
senseless Nov 4, 2022
c7dd266
clean up executed runtime migrations (#6206)
coderobe Nov 4, 2022
40aefb4
Co #12085: Update `k256` (#6238)
ggwpez Nov 5, 2022
2223fcb
cleanup deps (#6242)
xlc Nov 7, 2022
f015678
Pipeline with ci image with rust 1.65 (#6243)
alvicsam Nov 7, 2022
c661a22
BlockId removal: &Hash to Hash (#6246)
michalkucharczyk Nov 7, 2022
9309ac6
Increase max rewardable nominators (#6230)
kianenigma Nov 8, 2022
ba6643f
Update polkadot inflation to take into account auctions (#5872)
kianenigma Nov 8, 2022
26c31a0
Add a `last change` footer to the implementers guide (#6216)
mrcnski Nov 8, 2022
b19973c
Retry failed PVF prepare jobs (#6213)
mrcnski Nov 8, 2022
ee1a034
staking miner: remove needless queue check (#6221)
niklasad1 Nov 8, 2022
23044be
companion for fast unstake batching (#6253)
kianenigma Nov 8, 2022
1eb107d
Make rolling session more resilient in case of long finality stalls (…
sandreim Nov 8, 2022
a70d12a
Retry failed PVF execution (AmbiguousWorkerDeath) (#6235)
mrcnski Nov 8, 2022
18faf1c
[Companion] Bound Election and Staking by MaxActiveValidators (#6157)
Ank4n Nov 9, 2022
6e5aa28
Companion for substrate#12560 (#6226)
koushiro Nov 9, 2022
3711c6f
Companion for substrate#12530: Consolidate and deduplicate MMR API me…
Lederstrumpf Nov 9, 2022
597b1d2
Add a few staking params to fast-runtime build (#5424)
moh-eulith Nov 10, 2022
0f9244b
State trie migration rococo runtime changes. (#6127)
cheme Nov 11, 2022
a59c120
Brad implementers guide revisions 2 (#6239)
BradleyOlson64 Nov 11, 2022
133d405
Update disputes prioritisation in `dispute-coordinator` (#6130)
tdimitrov Nov 11, 2022
659297f
approval-voting: remove redundant validation check (#6266)
ordian Nov 12, 2022
9a99426
remove fill_block (#6200)
Szegoo Nov 12, 2022
1d46275
fix a compilation warning (#6279)
ordian Nov 13, 2022
89dc70f
Only report concluded if there is an actual dispute. (#6270)
eskimor Nov 14, 2022
624ae57
[ci] fix buildah image (#6281)
alvicsam Nov 14, 2022
353c57b
Revert special casing of Kusama for grandpa rounds. (#6217)
eskimor Nov 15, 2022
b984c40
Fixes "for loop over an `Option`" warnings (#6291)
mrcnski Nov 15, 2022
756ccc3
companion for #12599 (#6290)
niklasad1 Nov 15, 2022
a3d25c7
[ci] Improve pipeline stopper (#6300)
alvicsam Nov 16, 2022
c289ace
Provisioner should ignore unconfirmed disputes (#6294)
tdimitrov Nov 16, 2022
ce9a3e3
Add Helikon boot nodes for Polkadot, Kusama and Westend. (#6240)
kukabi Nov 17, 2022
98df65b
Dedup subsystem name (#6305)
sandreim Nov 17, 2022
eed7f40
Change best effort queue behaviour in `dispute-coordinator` (#6275)
tdimitrov Nov 17, 2022
9546890
[ci] fix build implementers guide (#6306)
alvicsam Nov 17, 2022
8065159
Remove the `wasmtime` feature flag (companion for substrate#12684) (#…
koute Nov 18, 2022
8b9f580
Add `starts_with` to v0 and v1 MultiLocation (#6311)
joepetrowski Nov 20, 2022
c7e43d6
Extend lower bound of `manage_lease_period_start` from `runtime_commo…
koute Nov 21, 2022
3cf644a
Update async-trait version to v0.1.58 (#6319)
altonen Nov 22, 2022
cfb10d4
Add PVF module documentation (#6293)
mrcnski Nov 23, 2022
b5e498c
Rate limit improvements (#6315)
eskimor Nov 23, 2022
e1cd7ce
[ci] fix build-implementers-guide (#6335)
alvicsam Nov 24, 2022
ba5dd20
Added Amforc bootnodes for Polkadot and Kusama (#6077)
tugytur Nov 24, 2022
795b20c
ig: Fix description of execution retry delay (#6342)
mrcnski Nov 24, 2022
b4b3fa5
Add support for outbound only configs on request/response protocols (…
skunert Nov 26, 2022
8549b37
cargo update -p sp-io (#6351)
ordian Nov 27, 2022
728acfb
Add more granularity to prometheus histogram buckets (#6348)
bredamatt Nov 28, 2022
e5602d4
Provide some more granular metrics for polkadot_pvf_execution_time (#…
mrcnski Nov 28, 2022
7538b76
[ci] fix implementer guide job (#6357)
alvicsam Nov 28, 2022
1b1bc62
dispute-coordinator: fix earliest session checks for pruning and impo…
sandreim Nov 28, 2022
98d2350
remove executed migrations (0.9.33) (#6364)
coderobe Nov 29, 2022
3f288d3
Companion for: pallet-mmr: move offchain logic to client-side gadget …
serban300 Nov 29, 2022
d8ae624
Remove `parity-util-mem` from `runtime-api` cache (#6367)
mrcnski Nov 29, 2022
7cd860e
Add Collectives as Trusted Teleporter (#6326)
joepetrowski Nov 29, 2022
7821614
sync versions with current release (0.9.33) (#6363)
coderobe Nov 30, 2022
71a0fad
Clippyfy (#6341)
Nov 30, 2022
36a2c89
Companion for: MMR: move RPC code from frame/ to client/ (#6369)
acatangiu Nov 30, 2022
90effe7
support opengov calls in proxy definitions (#6366)
joepetrowski Nov 30, 2022
ce003d6
Use CPU clock timeout for PVF jobs (#6282)
mrcnski Nov 30, 2022
6343ae7
guide: remove refences to outdated secondary checkers (#6309)
ordian Nov 30, 2022
bc65cf2
Kusama: approve/reject treasury prop by treasurer (#6354)
muharem Dec 1, 2022
3a918d4
Add buckets on lower end of distribution to network bridge latency me…
bredamatt Dec 2, 2022
acd9176
Reduce provisioner work (#6328)
Dec 2, 2022
d28b09e
update deprecated alias `--all` (#6383)
amab8901 Dec 3, 2022
2821cc0
Upgrade tokio to 1.22.0 (#6262)
dmitry-markin Dec 5, 2022
d96d68d
Set polkadot version in one place (#6095)
gilescope Dec 5, 2022
f39dbaf
Introduce NIS functionality into Kusama/Rococo (#6352)
gavofyork Dec 5, 2022
48de7a2
OpenGov improvements for Kusama (#6372)
gavofyork Dec 5, 2022
a9d5309
Tweak some NIS params (#6393)
gavofyork Dec 5, 2022
c81edbf
allow root with gov2 origins (#6390)
joepetrowski Dec 5, 2022
7e0fcfa
Bump Substrate (#6394)
gavofyork Dec 5, 2022
75979e4
crowdloan: Fix migration. (#6397)
bkchr Dec 6, 2022
09f2d1a
Companion of Substrate PR 12837 (#6385)
joao-paulo-parity Dec 6, 2022
eaa5b3a
Make submission deposit reasonable (#6402)
gavofyork Dec 6, 2022
5f881f5
kusama whitelist pallet preimage dep upgrade (#6392)
muharem Dec 6, 2022
1c8c54b
Bump (#6404)
gavofyork Dec 6, 2022
9cf336a
Companion for paritytech/substrate#12795 (#6374)
mrcnski Dec 6, 2022
d57049f
Let the PVF host kill the worker on timeout (#6381)
mrcnski Dec 6, 2022
ef17d4f
Companion for paritytech/substrate#12788 (#6360)
muharem Dec 7, 2022
b097577
Make sure to preserve backing votes (#6382)
eskimor Dec 7, 2022
6e82eb5
Refactoring to condense disputes tests (#6395)
BradleyOlson64 Dec 7, 2022
f3b7642
[ci] Adjust check-runtime-migration job (#6107)
alvicsam Dec 8, 2022
f4b8c91
update weights (sync with 0.9.33) (#6362)
coderobe Dec 8, 2022
b6ccb9e
Feature gate test `benchmark_storage_works` (#6376)
ggwpez Dec 8, 2022
6d612ab
Companion for paritytech/substrate#12868 (#6406)
KiChjang Dec 8, 2022
81d24de
OpenGov: Tweak parameters further (#6416)
gavofyork Dec 11, 2022
441106e
companion for #12663 jsonrpsee v0.16 (#6339)
niklasad1 Dec 12, 2022
4a7032c
CI: Remove the excessive variable declaration (#6426)
rcny Dec 12, 2022
c732a8d
companion slash chilling update (#6424)
kianenigma Dec 12, 2022
c98a782
swap error responses (#6421)
joepetrowski Dec 13, 2022
64a8b43
[ci] fix check-transaction-versions (#6425)
alvicsam Dec 13, 2022
de0839b
approval-distribution: batched approval/assignment sending (#6401)
sandreim Dec 13, 2022
cbbc24f
add westend bootnode (#6434)
tugytur Dec 14, 2022
be42a9c
[ci] add job switcher (#6433)
alvicsam Dec 14, 2022
b235eef
companion for try-runtime revamp (#6187)
kianenigma Dec 15, 2022
6e3f2c5
Fix wrong rate limit + add a few logs. (#6440)
eskimor Dec 15, 2022
fb24fcc
Bump workspace unified version
coderobe Dec 15, 2022
6b95256
Bump spec_version to 9360
coderobe Dec 15, 2022
f302fec
fix diener output
coderobe Dec 15, 2022
8f4fcdf
bump substrate
coderobe Dec 15, 2022
0ff4c93
clean up migrations
coderobe Dec 15, 2022
d99a456
bump version (0.9.36)
coderobe Dec 15, 2022
c5ca60d
sync transaction_version with 0.9.35 (compatible)
coderobe Dec 15, 2022
75c0184
sync transaction_version with 0.9.35 (compatible)
coderobe Dec 16, 2022
dc25abc
update weights (0.9.36) (#6450)
coderobe Dec 19, 2022
e84cb86
resolve conflicts
devdanco Jan 4, 2023
0000dbf
delete unnecessary files
devdanco Jan 24, 2023
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
Prev Previous commit
Next Next commit
Update polkadot inflation to take into account auctions (paritytech#5872
)

* Update polkadot inflation to take into account auctions

* a possible solution -- but needs a rather untrivial data seeding

* some additional comments

* Use LOWEST_PUBLIC_ID as a guide to filter out system/common good para ids

* Fixes

* move tests

* fix

Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
  • Loading branch information
3 people authored Nov 8, 2022
commit ba6643fe2223848b4652fef00f82a830e2d62d29
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 2 additions & 0 deletions runtime/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "m
pallet-session = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-staking-reward-fn = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-vesting = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
Expand Down Expand Up @@ -84,6 +85,7 @@ std = [
"pallet-beefy-mmr/std",
"pallet-session/std",
"pallet-staking/std",
"pallet-staking-reward-fn/std",
"pallet-timestamp/std",
"pallet-vesting/std",
"pallet-transaction-payment/std",
Expand Down
81 changes: 81 additions & 0 deletions runtime/common/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

use crate::NegativeImbalance;
use frame_support::traits::{Currency, Imbalance, OnUnbalanced};
use primitives::v2::Balance;
use sp_runtime::Perquintill;

/// Logic for the author to get a portion of fees.
pub struct ToAuthor<R>(sp_std::marker::PhantomData<R>);
Expand Down Expand Up @@ -57,6 +59,45 @@ where
}
}

pub fn era_payout(
total_staked: Balance,
non_gilt_issuance: Balance,
max_annual_inflation: Perquintill,
period_fraction: Perquintill,
auctioned_slots: u64,
) -> (Balance, Balance) {
use pallet_staking_reward_fn::compute_inflation;
use sp_runtime::traits::Saturating;

let min_annual_inflation = Perquintill::from_rational(25u64, 1000u64);
let delta_annual_inflation = max_annual_inflation.saturating_sub(min_annual_inflation);

// 30% reserved for up to 60 slots.
let auction_proportion = Perquintill::from_rational(auctioned_slots.min(60), 200u64);

// Therefore the ideal amount at stake (as a percentage of total issuance) is 75% less the
// amount that we expect to be taken up with auctions.
let ideal_stake = Perquintill::from_percent(75).saturating_sub(auction_proportion);

let stake = Perquintill::from_rational(total_staked, non_gilt_issuance);
let falloff = Perquintill::from_percent(5);
let adjustment = compute_inflation(stake, ideal_stake, falloff);
let staking_inflation =
min_annual_inflation.saturating_add(delta_annual_inflation * adjustment);

let max_payout = period_fraction * max_annual_inflation * non_gilt_issuance;
let staking_payout = (period_fraction * staking_inflation) * non_gilt_issuance;
let rest = max_payout.saturating_sub(staking_payout);

let other_issuance = non_gilt_issuance.saturating_sub(total_staked);
if total_staked > other_issuance {
let _cap_rest = Perquintill::from_rational(other_issuance, total_staked) * staking_payout;
// We don't do anything with this, but if we wanted to, we could introduce a cap on the
// treasury amount with: `rest = rest.min(cap_rest);`
}
(staking_payout, rest)
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down Expand Up @@ -209,4 +250,44 @@ mod tests {
assert_eq!(Balances::free_balance(Treasury::account_id()), 8);
});
}

#[test]
fn compute_inflation_should_give_sensible_results() {
assert_eq!(
pallet_staking_reward_fn::compute_inflation(
Perquintill::from_percent(75),
Perquintill::from_percent(75),
Perquintill::from_percent(5),
),
Perquintill::one()
);
assert_eq!(
pallet_staking_reward_fn::compute_inflation(
Perquintill::from_percent(50),
Perquintill::from_percent(75),
Perquintill::from_percent(5),
),
Perquintill::from_rational(2u64, 3u64)
);
assert_eq!(
pallet_staking_reward_fn::compute_inflation(
Perquintill::from_percent(80),
Perquintill::from_percent(75),
Perquintill::from_percent(5),
),
Perquintill::from_rational(1u64, 2u64)
);
}

#[test]
fn era_payout_should_give_sensible_results() {
assert_eq!(
era_payout(75, 100, Perquintill::from_percent(10), Perquintill::one(), 0,),
(10, 0)
);
assert_eq!(
era_payout(80, 100, Perquintill::from_percent(10), Perquintill::one(), 0,),
(6, 4)
);
}
}
2 changes: 0 additions & 2 deletions runtime/kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ pallet-session = { git = "https://github.com/paritytech/substrate", branch = "ma
pallet-society = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-staking-reward-fn = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-system = {git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
Expand Down Expand Up @@ -170,7 +169,6 @@ std = [
"pallet-session/std",
"pallet-society/std",
"pallet-staking/std",
"pallet-staking-reward-fn/std",
"pallet-timestamp/std",
"pallet-tips/std",
"pallet-treasury/std",
Expand Down
53 changes: 10 additions & 43 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use primitives::v2::{
CoreState, GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage,
Moment, Nonce, OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes,
SessionInfo, Signature, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex,
LOWEST_PUBLIC_ID,
};
use runtime_common::{
auctions, claims, crowdloan, impl_runtime_weights, impls::DealWithFees, paras_registrar,
Expand Down Expand Up @@ -504,59 +505,25 @@ impl pallet_bags_list::Config<VoterBagsListInstance> for Runtime {
type Score = sp_npos_elections::VoteWeight;
}

fn era_payout(
total_staked: Balance,
non_gilt_issuance: Balance,
max_annual_inflation: Perquintill,
period_fraction: Perquintill,
auctioned_slots: u64,
) -> (Balance, Balance) {
use pallet_staking_reward_fn::compute_inflation;
use sp_arithmetic::traits::Saturating;

let min_annual_inflation = Perquintill::from_rational(25u64, 1000u64);
let delta_annual_inflation = max_annual_inflation.saturating_sub(min_annual_inflation);

// 30% reserved for up to 60 slots.
let auction_proportion = Perquintill::from_rational(auctioned_slots.min(60), 200u64);

// Therefore the ideal amount at stake (as a percentage of total issuance) is 75% less the amount that we expect
// to be taken up with auctions.
let ideal_stake = Perquintill::from_percent(75).saturating_sub(auction_proportion);

let stake = Perquintill::from_rational(total_staked, non_gilt_issuance);
let falloff = Perquintill::from_percent(5);
let adjustment = compute_inflation(stake, ideal_stake, falloff);
let staking_inflation =
min_annual_inflation.saturating_add(delta_annual_inflation * adjustment);

let max_payout = period_fraction * max_annual_inflation * non_gilt_issuance;
let staking_payout = (period_fraction * staking_inflation) * non_gilt_issuance;
let rest = max_payout.saturating_sub(staking_payout);

let other_issuance = non_gilt_issuance.saturating_sub(total_staked);
if total_staked > other_issuance {
let _cap_rest = Perquintill::from_rational(other_issuance, total_staked) * staking_payout;
// We don't do anything with this, but if we wanted to, we could introduce a cap on the treasury amount
// with: `rest = rest.min(cap_rest);`
}
(staking_payout, rest)
}

pub struct EraPayout;
impl pallet_staking::EraPayout<Balance> for EraPayout {
fn era_payout(
total_staked: Balance,
_total_issuance: Balance,
era_duration_millis: u64,
) -> (Balance, Balance) {
// TODO: #3011 Update with proper auctioned slots tracking.
// This should be fine for the first year of parachains.
let auctioned_slots: u64 = auctions::Pallet::<Runtime>::auction_counter().into();
// all para-ids that are currently active.
let auctioned_slots = Paras::parachains()
.into_iter()
// all active para-ids that do not belong to a system or common good chain is the number
// of parachains that we should take into account for inflation.
.filter(|i| *i >= LOWEST_PUBLIC_ID)
.count() as u64;

const MAX_ANNUAL_INFLATION: Perquintill = Perquintill::from_percent(10);
const MILLISECONDS_PER_YEAR: u64 = 1000 * 3600 * 24 * 36525 / 100;

era_payout(
runtime_common::impls::era_payout(
total_staked,
Gilt::issuance().non_gilt,
MAX_ANNUAL_INFLATION,
Expand Down
34 changes: 0 additions & 34 deletions runtime/kusama/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,40 +137,6 @@ fn nominator_limit() {
println!("can support {} nominators to yield a weight of {}", active, weight_with(active));
}

#[test]
fn compute_inflation_should_give_sensible_results() {
assert_eq!(
pallet_staking_reward_fn::compute_inflation(
Perquintill::from_percent(75),
Perquintill::from_percent(75),
Perquintill::from_percent(5),
),
Perquintill::one()
);
assert_eq!(
pallet_staking_reward_fn::compute_inflation(
Perquintill::from_percent(50),
Perquintill::from_percent(75),
Perquintill::from_percent(5),
),
Perquintill::from_rational(2u64, 3u64)
);
assert_eq!(
pallet_staking_reward_fn::compute_inflation(
Perquintill::from_percent(80),
Perquintill::from_percent(75),
Perquintill::from_percent(5),
),
Perquintill::from_rational(1u64, 2u64)
);
}

#[test]
fn era_payout_should_give_sensible_results() {
assert_eq!(era_payout(75, 100, Perquintill::from_percent(10), Perquintill::one(), 0,), (10, 0));
assert_eq!(era_payout(80, 100, Perquintill::from_percent(10), Perquintill::one(), 0,), (6, 4));
}

#[test]
fn call_size() {
RuntimeCall::assert_size_under(230);
Expand Down
32 changes: 31 additions & 1 deletion runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ use primitives::v2::{
CoreState, GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage,
Moment, Nonce, OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes,
SessionInfo, Signature, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex,
LOWEST_PUBLIC_ID,
};
use sp_core::OpaqueMetadata;
use sp_mmr_primitives as mmr;
Expand Down Expand Up @@ -536,6 +537,35 @@ type SlashCancelOrigin = EitherOfDiverse<
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 3, 4>,
>;

pub struct EraPayout;
impl pallet_staking::EraPayout<Balance> for EraPayout {
fn era_payout(
total_staked: Balance,
total_issuance: Balance,
era_duration_millis: u64,
) -> (Balance, Balance) {
// all para-ids that are not active.
let auctioned_slots = Paras::parachains()
.into_iter()
// all active para-ids that do not belong to a system or common good chain is the number
// of parachains that we should take into account for inflation.
.filter(|i| *i >= LOWEST_PUBLIC_ID)
.count() as u64;

const MAX_ANNUAL_INFLATION: Perquintill = Perquintill::from_percent(10);
const MILLISECONDS_PER_YEAR: u64 = 1000 * 3600 * 24 * 36525 / 100;

runtime_common::impls::era_payout(
total_staked,
// Polkadot has no notion of gilts, the entire issuance is non-guilt.
total_issuance,
MAX_ANNUAL_INFLATION,
Perquintill::from_rational(era_duration_millis, MILLISECONDS_PER_YEAR),
auctioned_slots,
)
}
}

impl pallet_staking::Config for Runtime {
type MaxNominations = MaxNominations;
type Currency = Balances;
Expand All @@ -552,7 +582,7 @@ impl pallet_staking::Config for Runtime {
// A super-majority of the council can cancel the slash.
type SlashCancelOrigin = SlashCancelOrigin;
type SessionInterface = Self;
type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
type EraPayout = EraPayout;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
type NextNewSession = Session;
Expand Down