common_runtime/
constants.rs1use crate::prod_or_testnet_or_local;
2use common_primitives::node::{Balance, BlockNumber};
3use parity_scale_codec::{Encode, MaxEncodedLen};
4
5use frame_support::{
6 parameter_types,
7 sp_runtime::{Perbill, Permill},
8 traits::{ConstU128, ConstU16, ConstU32, ConstU64, ConstU8, Get},
9 weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight},
10 PalletId,
11};
12
13pub const FREQUENCY_TESTNET_TOKEN: &str = "XRQCY";
15pub const FREQUENCY_LOCAL_TOKEN: &str = "UNIT";
16pub const FREQUENCY_TOKEN: &str = "FRQCY";
17pub const TOKEN_DECIMALS: u8 = 8;
18
19pub const CHAIN_ID: u32 = prod_or_testnet_or_local!(2091u32, 420420420u32, 420420420u32);
21
22pub type MaxSchemaGrants = ConstU32<30>;
24
25pub const MILLISECS_PER_BLOCK: u64 = 6_000;
32
33pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;
36
37pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
39pub const HOURS: BlockNumber = MINUTES * 60;
40pub const DAYS: BlockNumber = HOURS * 24;
41
42pub mod currency {
44 use common_primitives::node::Balance;
45
46 pub const EXISTENTIAL_DEPOSIT: Balance = CENTS;
48
49 pub const UNITS: Balance = 10u128.saturating_pow(super::TOKEN_DECIMALS as u32);
50 pub const DOLLARS: Balance = UNITS; pub const CENTS: Balance = DOLLARS / 100; pub const MILLICENTS: Balance = CENTS / 1_000; pub const fn deposit(items: u32, bytes: u32) -> Balance {
58 items as Balance * 20 * DOLLARS + (bytes as Balance) * 100 * MILLICENTS
59 }
60}
61
62pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5);
65
66pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
69
70pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(
72 WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2),
73 cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64,
74);
75
76pub type ZERO = ConstU32<0>;
77pub type TWO = ConstU32<2>;
78pub type FIFTY = ConstU32<50>;
79pub type HUNDRED = ConstU32<100>;
80
81pub type FrameSystemMaxConsumers = ConstU32<16>;
83pub type MsaMaxPublicKeysPerMsa = ConstU8<25>;
88pub type MSAMortalityWindowSize = ConstU32<{ 20 * MINUTES }>;
90pub type MSAMaxSignaturesStored = ConstU32<50_000>;
93#[derive(Clone, Copy, Debug, Eq, PartialEq)]
95pub struct MsaMaxProviderNameSize;
96impl Get<u32> for MsaMaxProviderNameSize {
97 fn get() -> u32 {
98 256
99 }
100}
101#[derive(Clone, Copy, Debug, Eq, PartialEq)]
103pub struct MsaMaxLanguageCodeSize;
104impl Get<u32> for MsaMaxLanguageCodeSize {
105 fn get() -> u32 {
106 8
107 }
108}
109#[derive(Clone, Copy, Debug, Eq, PartialEq)]
111pub struct MsaMaxLogoCidSize;
112impl Get<u32> for MsaMaxLogoCidSize {
113 fn get() -> u32 {
114 64
115 }
116}
117#[derive(Clone, Copy, Debug, Eq, PartialEq)]
119pub struct MsaMaxLocaleCount;
120impl Get<u32> for MsaMaxLocaleCount {
121 fn get() -> u32 {
122 10
123 }
124}
125#[derive(Clone, Copy, Debug, Eq, PartialEq)]
127pub struct MsaMaxLogoSize;
128impl Get<u32> for MsaMaxLogoSize {
129 fn get() -> u32 {
130 1024 * 128
131 }
132}
133parameter_types! {
137 pub const SchemasMaxBytesBoundedVecLimit :u32 = 65_500;
139}
140pub type SchemasMaxRegistrations = ConstU16<65_000>;
142pub type SchemasMinModelSizeBytes = ConstU32<8>;
144pub type MaxSchemaSettingsPerSchema = ConstU32<2>;
146
147impl Encode for SchemasMaxBytesBoundedVecLimit {}
148
149impl MaxEncodedLen for SchemasMaxBytesBoundedVecLimit {
150 fn max_encoded_len() -> usize {
151 u32::max_encoded_len()
152 }
153}
154pub type HandleSuffixMin = ConstU16<10>;
160pub type HandleSuffixMax = ConstU16<99>;
162pub type MinReleaseTransfer = ConstU128<{ currency::EXISTENTIAL_DEPOSIT }>;
166
167pub const MAX_RELEASE_SCHEDULES: u32 = 50;
169pub type MinimumPeriod = ConstU64<0>;
173pub type AuthorshipUncleGenerations = ZERO;
177pub type BalancesMaxLocks = FIFTY;
181pub type BalancesMaxReserves = FIFTY;
182pub type BalancesMaxFreezes = TWO; pub type SchedulerMaxScheduledPerBlock = FIFTY;
187pub type PreimageMaxSize = ConstU32<{ 4096 * 1024 }>;
193
194pub type PreimageBaseDeposit = ConstU128<{ currency::deposit(10, 64) }>;
195pub type PreimageByteDeposit = ConstU128<{ currency::deposit(0, 1) }>;
196pub type CouncilMaxProposals = ConstU32<25>;
201pub type CouncilMaxMembers = ConstU32<10>;
203
204pub type CouncilMotionDuration = ConstU32<{ 5 * DAYS }>;
205pub type TCMaxProposals = ConstU32<25>;
210pub type TCMaxMembers = ConstU32<10>;
212
213pub type TCMotionDuration = ConstU32<{ 5 * DAYS }>;
214pub type LaunchPeriod = ConstU32<{ prod_or_testnet_or_local!(7 * DAYS, 1 * DAYS, 5 * MINUTES) }>;
220pub type VotingPeriod = ConstU32<{ prod_or_testnet_or_local!(7 * DAYS, 1 * DAYS, 5 * MINUTES) }>;
221pub type FastTrackVotingPeriod =
222 ConstU32<{ prod_or_testnet_or_local!(3 * HOURS, 30 * MINUTES, 5 * MINUTES) }>;
223pub type EnactmentPeriod =
224 ConstU32<{ prod_or_testnet_or_local!(8 * DAYS, 30 * HOURS, 10 * MINUTES) }>;
225pub type CooloffPeriod = ConstU32<{ prod_or_testnet_or_local!(7 * DAYS, 1 * DAYS, 5 * MINUTES) }>;
226pub type MinimumDeposit = ConstU128<
227 {
228 prod_or_testnet_or_local!(
229 currency::deposit(5, 0),
230 100 * currency::deposit(5, 0),
231 100 * currency::deposit(5, 0)
232 )
233 },
234>;
235pub type SpendPeriod =
236 ConstU32<{ prod_or_testnet_or_local!(7 * DAYS, 10 * MINUTES, 10 * MINUTES) }>;
237pub type DemocracyMaxVotes = ConstU32<100>;
238pub type DemocracyMaxProposals = HUNDRED;
239pub const TREASURY_PALLET_ID: PalletId = PalletId(*b"py/trsry");
245
246parameter_types! {
250
251 pub const TreasuryPalletId: PalletId = TREASURY_PALLET_ID;
253
254 pub const ProposalBondPercent: Permill = Permill::from_percent(5);
257
258 pub const Burn: Permill = Permill::zero();
261}
262
263pub type MaxApprovals = ConstU32<64>;
266
267pub type ProposalBondMinimum = ConstU128<{ 100 * currency::DOLLARS }>;
269
270pub type ProposalBondMaximum = ConstU128<{ 1_000 * currency::DOLLARS }>;
272
273pub type TransactionPaymentOperationalFeeMultiplier = ConstU8<5>;
278
279pub type TransactionByteFee = ConstU128<{ 10 * currency::MILLICENTS }>;
281pub type MaximumCapacityBatchLength = ConstU8<10>;
285pub type SessionPeriod = ConstU32<{ 6 * HOURS }>;
289pub type SessionOffset = ZERO;
290pub type AuraMaxAuthorities = ConstU32<100_000>;
295pub type CollatorMaxCandidates = ConstU32<50>;
303pub type CollatorMinCandidates = ConstU32<{ prod_or_testnet_or_local!(1, 0, 0) }>;
304pub type CollatorMaxInvulnerables = ConstU32<{ prod_or_testnet_or_local!(16, 5, 5) }>;
305pub type CollatorKickThreshold =
306 ConstU32<{ prod_or_testnet_or_local!(6 * HOURS, 6 * HOURS, 6 * HOURS) }>;
307
308parameter_types! {
310 pub const NeverDepositIntoId: PalletId = PalletId(*b"NeverDep");
311 pub const MessagesMaxPayloadSizeBytes: u32 = 1024 * 3; }
313parameter_types! {
318 pub const ProxyDepositBase: Balance = currency::deposit(1, 8);
320 pub const ProxyDepositFactor: Balance = currency::deposit(0, 33);
322 pub const MaxProxies: u16 = 32;
323 pub const AnnouncementDepositBase: Balance = currency::deposit(1, 8);
324 pub const AnnouncementDepositFactor: Balance = currency::deposit(0, 66);
325 pub const MaxPending: u16 = 32;
326}
327impl Clone for MessagesMaxPayloadSizeBytes {
331 fn clone(&self) -> Self {
332 MessagesMaxPayloadSizeBytes {}
333 }
334}
335
336impl core::fmt::Debug for MessagesMaxPayloadSizeBytes {
337 #[cfg(feature = "std")]
338 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
339 write!(f, "MessagesMaxPayloadSizeBytes<{:?}>", Self::get())
340 }
341
342 #[cfg(not(feature = "std"))]
343 fn fmt(&self, _: &mut core::fmt::Formatter) -> core::fmt::Result {
344 Ok(())
345 }
346}
347
348impl Encode for MessagesMaxPayloadSizeBytes {}
349
350impl MaxEncodedLen for MessagesMaxPayloadSizeBytes {
351 fn max_encoded_len() -> usize {
352 u32::max_encoded_len()
353 }
354}
355parameter_types! {
359 pub const Ss58Prefix: u16 = prod_or_testnet_or_local!(90, 42, 42);
363}
364
365parameter_types! {
368 pub const MaxItemizedBlobSizeBytes: u32 = 1024;
370 pub const MaxItemizedPageSizeBytes: u32 = 10 * (1024 + 2);
373 pub const MaxPaginatedPageSizeBytes: u32 = 1 * 1024;
375}
376pub type MaxPaginatedPageId = ConstU16<32>;
378pub type MaxItemizedActionsCount = ConstU32<5>;
380pub type StatefulMortalityWindowSize = ConstU32<{ 2 * DAYS }>;
382impl Default for MaxItemizedPageSizeBytes {
385 fn default() -> Self {
386 Self
387 }
388}
389
390impl Default for MaxPaginatedPageSizeBytes {
391 fn default() -> Self {
392 Self
393 }
394}
395
396impl Clone for MaxItemizedBlobSizeBytes {
397 fn clone(&self) -> Self {
398 MaxItemizedBlobSizeBytes {}
399 }
400}
401
402impl PartialEq for MaxItemizedBlobSizeBytes {
403 fn eq(&self, _other: &Self) -> bool {
404 true
406 }
407}
408
409impl core::fmt::Debug for MaxItemizedBlobSizeBytes {
410 #[cfg(feature = "std")]
411 fn fmt(&self, _: &mut core::fmt::Formatter) -> core::fmt::Result {
412 Ok(())
413 }
414
415 #[cfg(not(feature = "std"))]
416 fn fmt(&self, _: &mut core::fmt::Formatter) -> core::fmt::Result {
417 Ok(())
418 }
419}
420
421pub type CapacityMinimumStakingAmount = ConstU128<{ currency::EXISTENTIAL_DEPOSIT }>;
423pub type CapacityMinimumTokenBalance = ConstU128<{ currency::DOLLARS }>;
424pub type CapacityMaxUnlockingChunks = ConstU32<4>;
425pub type CapacityMaxEpochLength = ConstU32<{ 2 * DAYS }>; #[cfg(not(any(feature = "frequency-local", feature = "frequency-no-relay")))]
428pub type CapacityUnstakingThawPeriod = ConstU16<30>; #[cfg(any(feature = "frequency-local", feature = "frequency-no-relay"))]
431pub type CapacityUnstakingThawPeriod = ConstU16<2>; parameter_types! {
435 pub const CapacityPerToken: Perbill = Perbill::from_percent(2);
438 pub const CapacityRewardCap: Permill = Permill::from_parts(5_750); }
440pub type CapacityRewardEraLength =
441 ConstU32<{ prod_or_testnet_or_local!(14 * DAYS, 1 * HOURS, 50) }>;
442
443#[cfg(feature = "frequency-bridging")]
447pub mod xcm_version {
448 pub const SAFE_XCM_VERSION: u32 = 4;
452}