This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Update polkadot inflation to take into account auctions #5872
Merged
Merged
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e9f8178
Update polkadot inflation to take into account auctions
kianenigma a7526dd
Master.into()
kianenigma 3794aa8
Merge branch 'master' of github.com:paritytech/polkadot into kiz-fix-…
kianenigma 5bd849c
a possible solution -- but needs a rather untrivial data seeding
kianenigma 10d3984
some additional comments
kianenigma e1a3dee
Use LOWEST_PUBLIC_ID as a guide to filter out system/common good para…
KiChjang b522abe
Fixes
KiChjang 383d1c0
Merge remote-tracking branch 'origin/master' into kiz-fix-polkadot-in…
KiChjang ea26e4c
Merge branch 'master' into kiz-fix-polkadot-inflation
shawntabrizi 5de49f5
move tests
shawntabrizi 8469476
Merge branch 'master' of github.com:paritytech/polkadot into kiz-fix-…
kianenigma 14f3abc
fix
kianenigma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
|
@@ -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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this true? what about parathreads which did not secure an auction slot? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the |
||
.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, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this hardcoded amount problematic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No - it just sets an effective upper limit to how much of the inflation can be accounted for by the slot auctions.