referrerpolicy=no-referrer-when-downgrade

pallet_staking_async_parachain_runtime/governance/
mod.rs

1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: Apache-2.0
5
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// 	http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18//! New governance configurations for the Kusama runtime.
19
20use super::*;
21use crate::xcm_config::Collectives;
22use frame_support::{
23	parameter_types,
24	traits::{
25		fungible::HoldConsideration, tokens::UnityOrOuterConversion, EitherOf, EitherOfDiverse,
26		FromContains, LinearStoragePrice,
27	},
28};
29use frame_system::EnsureRootWithSuccess;
30use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
31use polkadot_runtime_common::impls::{
32	ContainsParts, LocatableAssetConverter, VersionedLocatableAsset, VersionedLocationConverter,
33};
34use sp_runtime::{traits::IdentityLookup, Percent};
35use xcm::latest::{
36	prelude::{InteriorLocation, PalletInstance},
37	BodyId,
38};
39
40mod origins;
41pub use origins::{
42	pallet_custom_origins, AuctionAdmin, FellowshipAdmin, GeneralAdmin, LeaseAdmin,
43	ReferendumCanceller, ReferendumKiller, Spender, StakingAdmin, Treasurer, WhitelistedCaller,
44};
45mod tracks;
46pub use tracks::TracksInfo;
47use xcm_builder::PayOverXcm;
48
49parameter_types! {
50	pub const VoteLockingPeriod: BlockNumber = 7 * DAYS;
51}
52
53impl pallet_conviction_voting::Config for Runtime {
54	type WeightInfo = weights::pallet_conviction_voting::WeightInfo<Self>;
55	type RuntimeEvent = RuntimeEvent;
56	type Currency = Balances;
57	type VoteLockingPeriod = VoteLockingPeriod;
58	type MaxVotes = ConstU32<512>;
59	type MaxTurnout =
60		frame_support::traits::tokens::currency::ActiveIssuanceOf<Balances, Self::AccountId>;
61	type Polls = Referenda;
62	type BlockNumberProvider = RelayChainBlockNumberProvider;
63	type VotingHooks = ();
64}
65
66parameter_types! {
67	pub const AlarmInterval: BlockNumber = 1;
68	pub const SubmissionDeposit: Balance = 1 * 3 * CENTS;
69	pub const UndecidingTimeout: BlockNumber = 14 * DAYS;
70}
71
72impl origins::pallet_custom_origins::Config for Runtime {}
73
74parameter_types! {
75	// Fellows pluralistic body.
76	pub const FellowsBodyId: BodyId = BodyId::Technical;
77}
78
79impl pallet_whitelist::Config for Runtime {
80	type WeightInfo = weights::pallet_whitelist::WeightInfo<Self>;
81	type RuntimeCall = RuntimeCall;
82	type RuntimeEvent = RuntimeEvent;
83	type WhitelistOrigin = EitherOfDiverse<
84		EnsureRoot<Self::AccountId>,
85		EnsureXcm<IsVoiceOfBody<Collectives, FellowsBodyId>>,
86	>;
87	type DispatchWhitelistedOrigin = EitherOf<EnsureRoot<Self::AccountId>, WhitelistedCaller>;
88	type Preimages = Preimage;
89}
90
91impl pallet_referenda::Config for Runtime {
92	type WeightInfo = weights::pallet_referenda::WeightInfo<Self>;
93	type RuntimeCall = RuntimeCall;
94	type RuntimeEvent = RuntimeEvent;
95	type Scheduler = Scheduler;
96	type Currency = Balances;
97	type SubmitOrigin = frame_system::EnsureSigned<AccountId>;
98	type CancelOrigin = EitherOf<EnsureRoot<AccountId>, ReferendumCanceller>;
99	type KillOrigin = EitherOf<EnsureRoot<AccountId>, ReferendumKiller>;
100	type Slash = Treasury;
101	type Votes = pallet_conviction_voting::VotesOf<Runtime>;
102	type Tally = pallet_conviction_voting::TallyOf<Runtime>;
103	type SubmissionDeposit = SubmissionDeposit;
104	type MaxQueued = ConstU32<100>;
105	type UndecidingTimeout = UndecidingTimeout;
106	type AlarmInterval = AlarmInterval;
107	type Tracks = TracksInfo;
108	type Preimages = Preimage;
109	type BlockNumberProvider = RelayChainBlockNumberProvider;
110}
111
112parameter_types! {
113	pub const SpendPeriod: BlockNumber = 6 * DAYS;
114	pub const Burn: Permill = Permill::from_perthousand(2);
115	pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
116	pub const PayoutSpendPeriod: BlockNumber = 30 * DAYS;
117	// The asset's interior location for the paying account. This is the Treasury
118	// pallet instance (which sits at index 37).
119	pub TreasuryInteriorLocation: InteriorLocation = PalletInstance(37).into();
120
121	pub const TipCountdown: BlockNumber = 1 * DAYS;
122	pub const TipFindersFee: Percent = Percent::from_percent(20);
123	pub const TipReportDepositBase: Balance = 100 * CENTS;
124	pub const DataDepositPerByte: Balance = 1 * CENTS;
125	pub const MaxApprovals: u32 = 100;
126	pub const MaxAuthorities: u32 = 100_000;
127	pub const MaxKeys: u32 = 10_000;
128	pub const MaxPeerInHeartbeats: u32 = 10_000;
129	pub const MaxBalance: Balance = Balance::max_value();
130}
131
132pub type TreasurySpender = EitherOf<EnsureRootWithSuccess<AccountId, MaxBalance>, Spender>;
133
134impl pallet_treasury::Config for Runtime {
135	type PalletId = TreasuryPalletId;
136	type Currency = Balances;
137	type RejectOrigin = EitherOfDiverse<EnsureRoot<AccountId>, Treasurer>;
138	type RuntimeEvent = RuntimeEvent;
139	type SpendPeriod = SpendPeriod;
140	type Burn = Burn;
141	type BurnDestination = ();
142	type MaxApprovals = MaxApprovals;
143	type WeightInfo = weights::pallet_treasury::WeightInfo<Runtime>;
144	type SpendFunds = ();
145	type SpendOrigin = TreasurySpender;
146	type AssetKind = VersionedLocatableAsset;
147	type Beneficiary = VersionedLocation;
148	type BeneficiaryLookup = IdentityLookup<Self::Beneficiary>;
149	type Paymaster = PayOverXcm<
150		TreasuryInteriorLocation,
151		crate::xcm_config::XcmRouter,
152		crate::PolkadotXcm,
153		ConstU32<{ 6 * HOURS }>,
154		Self::Beneficiary,
155		Self::AssetKind,
156		LocatableAssetConverter,
157		VersionedLocationConverter,
158	>;
159	type BalanceConverter = UnityOrOuterConversion<
160		ContainsParts<
161			FromContains<
162				xcm_builder::IsChildSystemParachain<ParaId>,
163				xcm_builder::IsParentsOnly<ConstU8<1>>,
164			>,
165		>,
166		AssetRate,
167	>;
168	type PayoutPeriod = PayoutSpendPeriod;
169	type BlockNumberProvider = RelayChainBlockNumberProvider;
170	#[cfg(feature = "runtime-benchmarks")]
171	type BenchmarkHelper = polkadot_runtime_common::impls::benchmarks::TreasuryArguments;
172}
173impl pallet_asset_rate::Config for Runtime {
174	type WeightInfo = weights::pallet_asset_rate::WeightInfo<Runtime>;
175	type RuntimeEvent = RuntimeEvent;
176	type CreateOrigin = EnsureRoot<AccountId>;
177	type RemoveOrigin = EnsureRoot<AccountId>;
178	type UpdateOrigin = EnsureRoot<AccountId>;
179	type Currency = Balances;
180	type AssetKind = <Runtime as pallet_treasury::Config>::AssetKind;
181	#[cfg(feature = "runtime-benchmarks")]
182	type BenchmarkHelper = polkadot_runtime_common::impls::benchmarks::AssetRateArguments;
183}
184
185parameter_types! {
186	pub MaximumSchedulerWeight: frame_support::weights::Weight = Perbill::from_percent(80) *
187		RuntimeBlockWeights::get().max_block;
188	pub const MaxScheduledPerBlock: u32 = 50;
189	pub const NoPreimagePostponement: Option<u32> = Some(10);
190}
191
192impl pallet_scheduler::Config for Runtime {
193	type RuntimeOrigin = RuntimeOrigin;
194	type RuntimeEvent = RuntimeEvent;
195	type PalletsOrigin = OriginCaller;
196	type RuntimeCall = RuntimeCall;
197	type MaximumWeight = MaximumSchedulerWeight;
198	type ScheduleOrigin = EnsureRoot<AccountId>;
199	type MaxScheduledPerBlock = MaxScheduledPerBlock;
200	type WeightInfo = weights::pallet_scheduler::WeightInfo<Runtime>;
201	type OriginPrivilegeCmp = frame_support::traits::EqualPrivilegeOnly;
202	type Preimages = Preimage;
203	type BlockNumberProvider = RelayChainBlockNumberProvider;
204}
205
206parameter_types! {
207	pub const PreimageBaseDeposit: Balance = deposit(2, 64);
208	pub const PreimageByteDeposit: Balance = deposit(0, 1);
209	pub const PreimageHoldReason: RuntimeHoldReason = RuntimeHoldReason::Preimage(pallet_preimage::HoldReason::Preimage);
210}
211
212impl pallet_preimage::Config for Runtime {
213	type WeightInfo = weights::pallet_preimage::WeightInfo<Runtime>;
214	type RuntimeEvent = RuntimeEvent;
215	type Currency = Balances;
216	type ManagerOrigin = EnsureRoot<AccountId>;
217	type Consideration = HoldConsideration<
218		AccountId,
219		Balances,
220		PreimageHoldReason,
221		LinearStoragePrice<PreimageBaseDeposit, PreimageByteDeposit, Balance>,
222	>;
223}