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

Implements partial inflation minting to treasury #1483

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions polkadot/runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,7 @@ impl pallet_staking::Config for Runtime {
type AdminOrigin = EitherOf<EnsureRoot<Self::AccountId>, StakingAdmin>;
type SessionInterface = Self;
type EraPayout = EraPayout;
type InflationLevyDestination = Treasury;
type NextNewSession = Session;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
Expand Down
11 changes: 11 additions & 0 deletions polkadot/runtime/kusama/src/weights/pallet_staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,4 +793,15 @@ impl<T: frame_system::Config> pallet_staking::WeightInfo for WeightInfo<T> {
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: Staking TreasuryInflationTreasury (r:0 w:1)
/// Proof: Staking TreasuryInflationTreasury (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
fn set_treasury_fraction() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 3_415_000 picoseconds.
Weight::from_parts(3_315_000, 0)
.saturating_add(T::DbWeight::get().writes(1_u64))
}

}
1 change: 1 addition & 0 deletions polkadot/runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ impl pallet_staking::Config for Runtime {
type AdminOrigin = EitherOf<EnsureRoot<Self::AccountId>, StakingAdmin>;
type SessionInterface = Self;
type EraPayout = EraPayout;
type InflationLevyDestination = Treasury;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
type NextNewSession = Session;
Expand Down
10 changes: 10 additions & 0 deletions polkadot/runtime/polkadot/src/weights/pallet_staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,4 +793,14 @@ impl<T: frame_system::Config> pallet_staking::WeightInfo for WeightInfo<T> {
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: Staking TreasuryInflationTreasury (r:0 w:1)
/// Proof: Staking TreasuryInflationTreasury (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
fn set_treasury_fraction() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 3_415_000 picoseconds.
Weight::from_parts(3_175_000, 0)
.saturating_add(T::DbWeight::get().writes(1_u64))
}
}
14 changes: 12 additions & 2 deletions polkadot/runtime/test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ use frame_election_provider_support::{
use frame_support::{
construct_runtime, parameter_types,
traits::{Everything, KeyOwnerProofSystem, WithdrawReasons},
PalletId,
};
use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId};
use pallet_session::historical as session_historical;
Expand All @@ -68,8 +69,8 @@ use sp_runtime::{
curve::PiecewiseLinear,
generic, impl_opaque_keys,
traits::{
BlakeTwo256, Block as BlockT, ConvertInto, Extrinsic as ExtrinsicT, OpaqueKeys,
SaturatedConversion, StaticLookup, Verify,
AccountIdConversion, BlakeTwo256, Block as BlockT, ConvertInto, Extrinsic as ExtrinsicT,
OpaqueKeys, SaturatedConversion, StaticLookup, Verify,
},
transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity},
ApplyExtrinsicResult, KeyTypeId, Perbill,
Expand Down Expand Up @@ -321,6 +322,7 @@ parameter_types! {
pub const OnChainMaxWinners: u32 = u32::MAX;
// Unbounded number of election targets and voters.
pub ElectionBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::default().build();
pub const BurnAccountId: PalletId = PalletId(*b"burnburn");
}

pub struct OnChainSeqPhragmen;
Expand Down Expand Up @@ -351,6 +353,7 @@ impl pallet_staking::Config for Runtime {
type AdminOrigin = frame_system::EnsureNever<()>;
type SessionInterface = Self;
type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
type InflationLevyDestination = BurnPot; // burn inflation if treasury fraction > 0.
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
type NextNewSession = Session;
Expand All @@ -368,6 +371,13 @@ impl pallet_staking::Config for Runtime {
type WeightInfo = ();
}

pub struct BurnPot;
impl sp_runtime::traits::Get<AccountId> for BurnPot {
fn get() -> AccountId {
BurnAccountId::get().into_account_truncating()
}
}

parameter_types! {
pub MaxSetIdSessionEntries: u32 = BondingDuration::get() * SessionsPerEra::get();
}
Expand Down
11 changes: 10 additions & 1 deletion polkadot/runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub use pallet_election_provider_multi_phase::{Call as EPMCall, GeometricDeposit
pub use pallet_staking::StakerStatus;
use pallet_staking::UseValidatorsMap;
pub use pallet_timestamp::Call as TimestampCall;
use sp_runtime::traits::Get;
use sp_runtime::traits::{AccountIdConversion, Get};
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;

Expand Down Expand Up @@ -625,6 +625,7 @@ parameter_types! {
pub const MaxNominatorRewardedPerValidator: u32 = 64;
pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17);
pub const MaxNominations: u32 = <NposCompactSolution16 as frame_election_provider_support::NposSolution>::LIMIT as u32;
pub const BurnAccountId: PalletId = PalletId(*b"burnburn");
}

impl pallet_staking::Config for Runtime {
Expand All @@ -642,6 +643,7 @@ impl pallet_staking::Config for Runtime {
type AdminOrigin = EnsureRoot<AccountId>;
type SessionInterface = Self;
type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
type InflationLevyDestination = BurnPot; // burn inflation if treasury fraction > 0.
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
type NextNewSession = Session;
Expand All @@ -657,6 +659,13 @@ impl pallet_staking::Config for Runtime {
type WeightInfo = weights::pallet_staking::WeightInfo<Runtime>;
}

pub struct BurnPot;
impl Get<AccountId> for BurnPot {
fn get() -> AccountId {
BurnAccountId::get().into_account_truncating()
}
}

impl pallet_fast_unstake::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
Expand Down
10 changes: 10 additions & 0 deletions polkadot/runtime/westend/src/weights/pallet_staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,4 +793,14 @@ impl<T: frame_system::Config> pallet_staking::WeightInfo for WeightInfo<T> {
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: Staking TreasuryInflationTreasury (r:0 w:1)
/// Proof: Staking TreasuryInflationTreasury (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
fn set_treasury_fraction() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 3_415_000 picoseconds.
Weight::from_parts(3_488_000, 0)
.saturating_add(T::DbWeight::get().writes(1_u64))
}
}
1 change: 1 addition & 0 deletions substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,7 @@ impl pallet_staking::Config for Runtime {
>;
type SessionInterface = Self;
type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
type InflationLevyDestination = Treasury;
type NextNewSession = Session;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
Expand Down
11 changes: 10 additions & 1 deletion substrate/frame/babe/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use sp_runtime::{
curve::PiecewiseLinear,
impl_opaque_keys,
testing::{Digest, DigestItem, Header, TestXt},
traits::{Header as _, IdentityLookup, OpaqueKeys},
traits::{AccountIdConversion, Header as _, IdentityLookup, OpaqueKeys},
BuildStorage, Perbill,
};
use sp_staking::{EraIndex, SessionIndex};
Expand Down Expand Up @@ -166,6 +166,7 @@ parameter_types! {
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(16);
pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::default().build();
pub const BurnAccountId: frame_support::PalletId = frame_support::PalletId(*b"burnburn");
}

pub struct OnChainSeqPhragmen;
Expand Down Expand Up @@ -193,6 +194,7 @@ impl pallet_staking::Config for Test {
type SessionInterface = Self;
type UnixTime = pallet_timestamp::Pallet<Test>;
type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
type InflationLevyDestination = BurnPot; // burn inflation if treasury fraction > 0.
type MaxNominatorRewardedPerValidator = ConstU32<64>;
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
type NextNewSession = Session;
Expand All @@ -208,6 +210,13 @@ impl pallet_staking::Config for Test {
type WeightInfo = ();
}

pub struct BurnPot;
impl sp_runtime::traits::Get<DummyValidatorId> for BurnPot {
fn get() -> DummyValidatorId {
BurnAccountId::get().into_account_truncating()
}
}

impl pallet_offences::Config for Test {
type RuntimeEvent = RuntimeEvent;
type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
Expand Down
11 changes: 10 additions & 1 deletion substrate/frame/beefy/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use sp_runtime::{
curve::PiecewiseLinear,
impl_opaque_keys,
testing::TestXt,
traits::{BlakeTwo256, IdentityLookup, OpaqueKeys},
traits::{AccountIdConversion, BlakeTwo256, IdentityLookup, OpaqueKeys},
BuildStorage, Perbill,
};
use sp_staking::{EraIndex, SessionIndex};
Expand Down Expand Up @@ -188,6 +188,7 @@ parameter_types! {
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17);
pub static ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::default().build();
pub const BurnAccountId: frame_support::PalletId = frame_support::PalletId(*b"burnburn");
}

pub struct OnChainSeqPhragmen;
Expand Down Expand Up @@ -215,6 +216,7 @@ impl pallet_staking::Config for Test {
type SessionInterface = Self;
type UnixTime = pallet_timestamp::Pallet<Test>;
type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
type InflationLevyDestination = BurnPot; // burn inflation if treasury fraction > 0.
type MaxNominatorRewardedPerValidator = ConstU32<64>;
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
type NextNewSession = Session;
Expand All @@ -230,6 +232,13 @@ impl pallet_staking::Config for Test {
type WeightInfo = ();
}

pub struct BurnPot;
impl sp_runtime::traits::Get<u64> for BurnPot {
fn get() -> u64 {
BurnAccountId::get().into_account_truncating()
}
}

impl pallet_offences::Config for Test {
type RuntimeEvent = RuntimeEvent;
type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use sp_runtime::{
OffchainDbExt, OffchainWorkerExt, TransactionPoolExt,
},
testing,
traits::Zero,
traits::{AccountIdConversion, Zero},
transaction_validity, BuildStorage, PerU16, Perbill, Percent,
};
use sp_staking::{
Expand Down Expand Up @@ -247,6 +247,7 @@ parameter_types! {
pub const MaxNominatorRewardedPerValidator: u32 = 256;
pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(40);
pub HistoryDepth: u32 = 84;
pub const BurnAccountId: frame_support::PalletId = frame_support::PalletId(*b"burnburn");
}

impl pallet_bags_list::Config for Runtime {
Expand Down Expand Up @@ -275,6 +276,7 @@ impl pallet_staking::Config for Runtime {
type AdminOrigin = EnsureRoot<AccountId>; // root can cancel slashes
type SessionInterface = Self;
type EraPayout = ();
type InflationLevyDestination = BurnPot; // burn inflation if treasury fraction > 0.
type NextNewSession = Session;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
Expand All @@ -290,6 +292,13 @@ impl pallet_staking::Config for Runtime {
type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig;
}

pub struct BurnPot;
impl sp_runtime::traits::Get<AccountId> for BurnPot {
fn get() -> AccountId {
BurnAccountId::get().into_account_truncating()
}
}

impl<LocalCall> frame_system::offchain::SendTransactionTypes<LocalCall> for Runtime
where
RuntimeCall: From<LocalCall>,
Expand Down
11 changes: 10 additions & 1 deletion substrate/frame/fast-unstake/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use frame_support::{
weights::constants::WEIGHT_REF_TIME_PER_SECOND,
};
use sp_runtime::{
traits::{Convert, IdentityLookup},
traits::{AccountIdConversion, Convert, IdentityLookup},
BuildStorage,
};

Expand Down Expand Up @@ -114,6 +114,7 @@ parameter_types! {
pub static CurrentEra: u32 = 0;
pub static Ongoing: bool = false;
pub static MaxWinners: u32 = 100;
pub const BurnAccountId: frame_support::PalletId = frame_support::PalletId(*b"burnburn");
}

pub struct MockElection;
Expand Down Expand Up @@ -149,6 +150,7 @@ impl pallet_staking::Config for Runtime {
type BondingDuration = BondingDuration;
type SessionInterface = ();
type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
type InflationLevyDestination = BurnPot; // burn inflation if treasury fraction > 0.
type NextNewSession = ();
type HistoryDepth = ConstU32<84>;
type MaxNominatorRewardedPerValidator = ConstU32<64>;
Expand All @@ -164,6 +166,13 @@ impl pallet_staking::Config for Runtime {
type WeightInfo = ();
}

pub struct BurnPot;
impl sp_runtime::traits::Get<AccountId> for BurnPot {
fn get() -> AccountId {
BurnAccountId::get().into_account_truncating()
}
}

pub struct BalanceToU256;
impl Convert<Balance, sp_core::U256> for BalanceToU256 {
fn convert(n: Balance) -> sp_core::U256 {
Expand Down
11 changes: 10 additions & 1 deletion substrate/frame/grandpa/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use sp_runtime::{
curve::PiecewiseLinear,
impl_opaque_keys,
testing::{TestXt, UintAuthorityId},
traits::{IdentityLookup, OpaqueKeys},
traits::{AccountIdConversion, IdentityLookup, OpaqueKeys},
BuildStorage, DigestItem, Perbill,
};
use sp_staking::{EraIndex, SessionIndex};
Expand Down Expand Up @@ -168,6 +168,7 @@ parameter_types! {
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17);
pub static ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::default().build();
pub const BurnAccountId: frame_support::PalletId = frame_support::PalletId(*b"burnburn");
}

pub struct OnChainSeqPhragmen;
Expand Down Expand Up @@ -195,6 +196,7 @@ impl pallet_staking::Config for Test {
type SessionInterface = Self;
type UnixTime = pallet_timestamp::Pallet<Test>;
type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
type InflationLevyDestination = BurnPot; // burn inflation if treasury fraction > 0.
type MaxNominatorRewardedPerValidator = ConstU32<64>;
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
type NextNewSession = Session;
Expand All @@ -210,6 +212,13 @@ impl pallet_staking::Config for Test {
type WeightInfo = ();
}

pub struct BurnPot;
impl sp_runtime::traits::Get<u64> for BurnPot {
fn get() -> u64 {
BurnAccountId::get().into_account_truncating()
}
}

impl pallet_offences::Config for Test {
type RuntimeEvent = RuntimeEvent;
type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
Expand Down
11 changes: 10 additions & 1 deletion substrate/frame/nomination-pools/benchmarking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::VoterBagsListInstance;
use frame_election_provider_support::VoteWeight;
use frame_support::{pallet_prelude::*, parameter_types, traits::ConstU64, PalletId};
use sp_runtime::{
traits::{Convert, IdentityLookup},
traits::{AccountIdConversion, Convert, IdentityLookup},
BuildStorage, FixedU128, Perbill,
};

Expand Down Expand Up @@ -92,6 +92,7 @@ pallet_staking_reward_curve::build! {
}
parameter_types! {
pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS;
pub const BurnAccountId: frame_support::PalletId = frame_support::PalletId(*b"burnburn");
}
impl pallet_staking::Config for Runtime {
type Currency = Balances;
Expand All @@ -108,6 +109,7 @@ impl pallet_staking::Config for Runtime {
type BondingDuration = ConstU32<3>;
type SessionInterface = ();
type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
type InflationLevyDestination = BurnPot; // burn inflation if treasury fraction > 0.
type NextNewSession = ();
type MaxNominatorRewardedPerValidator = ConstU32<64>;
type OffendingValidatorsThreshold = ();
Expand All @@ -124,6 +126,13 @@ impl pallet_staking::Config for Runtime {
type WeightInfo = ();
}

pub struct BurnPot;
impl sp_runtime::traits::Get<AccountId> for BurnPot {
fn get() -> AccountId {
BurnAccountId::get().into_account_truncating()
}
}

parameter_types! {
pub static BagThresholds: &'static [VoteWeight] = &[10, 20, 30, 40, 50, 60, 1_000, 2_000, 10_000];
}
Expand Down
Loading