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},
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 MsaMaxProviderNameSize = ConstU32<16>;
90pub type MSAMortalityWindowSize = ConstU32<{ 20 * MINUTES }>;
92pub type MSAMaxSignaturesStored = ConstU32<50_000>;
95parameter_types! {
99 pub const SchemasMaxBytesBoundedVecLimit :u32 = 65_500;
101}
102pub type SchemasMaxRegistrations = ConstU16<65_000>;
104pub type SchemasMinModelSizeBytes = ConstU32<8>;
106pub type MaxSchemaSettingsPerSchema = ConstU32<2>;
108
109impl Encode for SchemasMaxBytesBoundedVecLimit {}
110
111impl MaxEncodedLen for SchemasMaxBytesBoundedVecLimit {
112 fn max_encoded_len() -> usize {
113 u32::max_encoded_len()
114 }
115}
116pub type HandleSuffixMin = ConstU16<10>;
122pub type HandleSuffixMax = ConstU16<99>;
124pub type MinReleaseTransfer = ConstU128<{ currency::EXISTENTIAL_DEPOSIT }>;
128
129pub const MAX_RELEASE_SCHEDULES: u32 = 50;
131pub type MinimumPeriod = ConstU64<0>;
135pub type AuthorshipUncleGenerations = ZERO;
139pub type BalancesMaxLocks = FIFTY;
143pub type BalancesMaxReserves = FIFTY;
144pub type BalancesMaxFreezes = TWO; pub type SchedulerMaxScheduledPerBlock = FIFTY;
149pub type PreimageMaxSize = ConstU32<{ 4096 * 1024 }>;
155
156pub type PreimageBaseDeposit = ConstU128<{ currency::deposit(10, 64) }>;
157pub type PreimageByteDeposit = ConstU128<{ currency::deposit(0, 1) }>;
158pub type CouncilMaxProposals = ConstU32<25>;
163pub type CouncilMaxMembers = ConstU32<10>;
165
166pub type CouncilMotionDuration = ConstU32<{ 5 * DAYS }>;
167pub type TCMaxProposals = ConstU32<25>;
172pub type TCMaxMembers = ConstU32<10>;
174
175pub type TCMotionDuration = ConstU32<{ 5 * DAYS }>;
176pub type LaunchPeriod = ConstU32<{ prod_or_testnet_or_local!(7 * DAYS, 1 * DAYS, 5 * MINUTES) }>;
182pub type VotingPeriod = ConstU32<{ prod_or_testnet_or_local!(7 * DAYS, 1 * DAYS, 5 * MINUTES) }>;
183pub type FastTrackVotingPeriod =
184 ConstU32<{ prod_or_testnet_or_local!(3 * HOURS, 30 * MINUTES, 5 * MINUTES) }>;
185pub type EnactmentPeriod =
186 ConstU32<{ prod_or_testnet_or_local!(8 * DAYS, 30 * HOURS, 10 * MINUTES) }>;
187pub type CooloffPeriod = ConstU32<{ prod_or_testnet_or_local!(7 * DAYS, 1 * DAYS, 5 * MINUTES) }>;
188pub type MinimumDeposit = ConstU128<
189 {
190 prod_or_testnet_or_local!(
191 currency::deposit(5, 0),
192 100 * currency::deposit(5, 0),
193 100 * currency::deposit(5, 0)
194 )
195 },
196>;
197pub type SpendPeriod =
198 ConstU32<{ prod_or_testnet_or_local!(7 * DAYS, 10 * MINUTES, 10 * MINUTES) }>;
199pub type DemocracyMaxVotes = ConstU32<100>;
200pub type DemocracyMaxProposals = HUNDRED;
201pub const TREASURY_PALLET_ID: PalletId = PalletId(*b"py/trsry");
207
208parameter_types! {
212
213 pub const TreasuryPalletId: PalletId = TREASURY_PALLET_ID;
215
216 pub const ProposalBondPercent: Permill = Permill::from_percent(5);
219
220 pub const Burn: Permill = Permill::zero();
223}
224
225pub type MaxApprovals = ConstU32<64>;
228
229pub type ProposalBondMinimum = ConstU128<{ 100 * currency::DOLLARS }>;
231
232pub type ProposalBondMaximum = ConstU128<{ 1_000 * currency::DOLLARS }>;
234
235pub type TransactionPaymentOperationalFeeMultiplier = ConstU8<5>;
240
241pub type TransactionByteFee = ConstU128<{ 10 * currency::MILLICENTS }>;
243pub type MaximumCapacityBatchLength = ConstU8<10>;
247pub type SessionPeriod = ConstU32<{ 6 * HOURS }>;
251pub type SessionOffset = ZERO;
252pub type AuraMaxAuthorities = ConstU32<100_000>;
257pub type CollatorMaxCandidates = ConstU32<50>;
265pub type CollatorMinCandidates = ConstU32<{ prod_or_testnet_or_local!(1, 0, 0) }>;
266pub type CollatorMaxInvulnerables = ConstU32<{ prod_or_testnet_or_local!(16, 5, 5) }>;
267pub type CollatorKickThreshold =
268 ConstU32<{ prod_or_testnet_or_local!(6 * HOURS, 6 * HOURS, 6 * HOURS) }>;
269
270parameter_types! {
272 pub const NeverDepositIntoId: PalletId = PalletId(*b"NeverDep");
273 pub const MessagesMaxPayloadSizeBytes: u32 = 1024 * 3; }
275parameter_types! {
280 pub const ProxyDepositBase: Balance = currency::deposit(1, 8);
282 pub const ProxyDepositFactor: Balance = currency::deposit(0, 33);
284 pub const MaxProxies: u16 = 32;
285 pub const AnnouncementDepositBase: Balance = currency::deposit(1, 8);
286 pub const AnnouncementDepositFactor: Balance = currency::deposit(0, 66);
287 pub const MaxPending: u16 = 32;
288}
289impl Clone for MessagesMaxPayloadSizeBytes {
293 fn clone(&self) -> Self {
294 MessagesMaxPayloadSizeBytes {}
295 }
296}
297
298impl core::fmt::Debug for MessagesMaxPayloadSizeBytes {
299 #[cfg(feature = "std")]
300 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
301 write!(f, "MessagesMaxPayloadSizeBytes<{:?}>", Self::get())
302 }
303
304 #[cfg(not(feature = "std"))]
305 fn fmt(&self, _: &mut core::fmt::Formatter) -> core::fmt::Result {
306 Ok(())
307 }
308}
309
310impl Encode for MessagesMaxPayloadSizeBytes {}
311
312impl MaxEncodedLen for MessagesMaxPayloadSizeBytes {
313 fn max_encoded_len() -> usize {
314 u32::max_encoded_len()
315 }
316}
317parameter_types! {
321 pub const Ss58Prefix: u16 = prod_or_testnet_or_local!(90, 42, 42);
325}
326
327parameter_types! {
330 pub const MaxItemizedBlobSizeBytes: u32 = 1024;
332 pub const MaxItemizedPageSizeBytes: u32 = 10 * (1024 + 2);
335 pub const MaxPaginatedPageSizeBytes: u32 = 1 * 1024;
337}
338pub type MaxPaginatedPageId = ConstU16<32>;
340pub type MaxItemizedActionsCount = ConstU32<5>;
342pub type StatefulMortalityWindowSize = ConstU32<{ 2 * DAYS }>;
344impl Default for MaxItemizedPageSizeBytes {
347 fn default() -> Self {
348 Self
349 }
350}
351
352impl Default for MaxPaginatedPageSizeBytes {
353 fn default() -> Self {
354 Self
355 }
356}
357
358impl Clone for MaxItemizedBlobSizeBytes {
359 fn clone(&self) -> Self {
360 MaxItemizedBlobSizeBytes {}
361 }
362}
363
364impl PartialEq for MaxItemizedBlobSizeBytes {
365 fn eq(&self, _other: &Self) -> bool {
366 true
368 }
369}
370
371impl core::fmt::Debug for MaxItemizedBlobSizeBytes {
372 #[cfg(feature = "std")]
373 fn fmt(&self, _: &mut core::fmt::Formatter) -> core::fmt::Result {
374 Ok(())
375 }
376
377 #[cfg(not(feature = "std"))]
378 fn fmt(&self, _: &mut core::fmt::Formatter) -> core::fmt::Result {
379 Ok(())
380 }
381}
382
383pub type CapacityMinimumStakingAmount = ConstU128<{ currency::EXISTENTIAL_DEPOSIT }>;
385pub type CapacityMinimumTokenBalance = ConstU128<{ currency::DOLLARS }>;
386pub type CapacityMaxUnlockingChunks = ConstU32<4>;
387pub type CapacityMaxEpochLength = ConstU32<{ 2 * DAYS }>; #[cfg(not(any(feature = "frequency-local", feature = "frequency-no-relay")))]
390pub type CapacityUnstakingThawPeriod = ConstU16<30>; #[cfg(any(feature = "frequency-local", feature = "frequency-no-relay"))]
393pub type CapacityUnstakingThawPeriod = ConstU16<2>; parameter_types! {
397 pub const CapacityPerToken: Perbill = Perbill::from_percent(2);
400 pub const CapacityRewardCap: Permill = Permill::from_parts(5_750); }
402pub type CapacityRewardEraLength =
403 ConstU32<{ prod_or_testnet_or_local!(14 * DAYS, 1 * HOURS, 50) }>;
404
405#[cfg(feature = "frequency-bridging")]
409pub mod xcm_version {
410 pub const SAFE_XCM_VERSION: u32 = 4;
414}