Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Update polkadot inflation to take into account auctions #5872

Merged
merged 12 commits into from
Nov 8, 2022
Prev Previous commit
Next Next commit
a possible solution -- but needs a rather untrivial data seeding
  • Loading branch information
kianenigma committed Oct 6, 2022
commit 5bd849cc95ca80194bdabf161b4191a3fe29efce
12 changes: 11 additions & 1 deletion runtime/common/src/auctions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ pub mod pallet {
#[pallet::getter(fn auction_counter)]
pub type AuctionCounter<T> = StorageValue<_, AuctionIndex, ValueQuery>;

// TODO: needs a migration to seed the initial data.
// TODO: will this work with how para-ids are swapped/extended?
#[pallet::storage]
#[pallet::getter(fn auctioned_winner_para_ids)]
#[pallet::unbounded]
pub type AuctionedWinnerParaIds<T> = StorageValue<_, Vec<ParaId>, ValueQuery>;

/// Information relating to the current auction, if there is one.
///
/// The first item in the tuple is the lease period index that the first of the four
Expand Down Expand Up @@ -609,7 +616,10 @@ impl<T: Config> Pallet<T> {
});
}
},
Ok(()) => {}, // Nothing to report.
Ok(()) => {
// record the winner para-ids.
AuctionedWinnerParaIds::<T>::mutate(|a| a.push(para));
},
}
}

Expand Down
18 changes: 15 additions & 3 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,9 +511,21 @@ impl pallet_staking::EraPayout<Balance> for EraPayout {
_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();
let auctioned_slots = {
// all para-ids that have been leased out.
let auctioned_winner_para_ids = Auctions::auctioned_winner_para_ids();
// and all para-ids that are not active.
KiChjang marked this conversation as resolved.
Show resolved Hide resolved
let active_para_ids = Paras::parachains();
// the intersection of which is the number of parachain's which we should take into
// account for inflation.
auctioned_winner_para_ids
.into_iter()
.filter(|i| active_para_ids.contains(i))
.count() as u64
// note: we could speed up this block a bit with sorting and binary searching, but it
// does not seem worthwhile for a few hundred parachains at most.
};

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

Expand Down
20 changes: 16 additions & 4 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

use pallet_transaction_payment::CurrencyAdapter;
use runtime_common::{
auctions, claims, crowdloan, impl_runtime_weights, impls::{DealWithFees}, paras_registrar,
auctions, claims, crowdloan, impl_runtime_weights, impls::DealWithFees, paras_registrar,
prod_or_fast, slots, BlockHashCount, BlockLength, CurrencyToVote, SlowAdjustingFeeUpdate,
};

Expand Down Expand Up @@ -543,9 +543,21 @@ impl pallet_staking::EraPayout<Balance> for EraPayout {
_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();
let auctioned_slots = {
// all para-ids that have been leased out.
let auctioned_winner_para_ids = Auctions::auctioned_winner_para_ids();
// and all para-ids that are not active.
KiChjang marked this conversation as resolved.
Show resolved Hide resolved
let active_para_ids = Paras::parachains();
// the intersection of which is the number of parachain's which we should take into
// account for inflation.
auctioned_winner_para_ids
.into_iter()
.filter(|i| active_para_ids.contains(i))
.count() as u64
// note: we could speed up this block a bit with sorting and binary searching, but it
// does not seem worthwhile for a few hundred parachains at most.
};

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

Expand Down