pallet_staking_async_rc_runtime_constants/
lib.rs1#![cfg_attr(not(feature = "std"), no_std)]
18
19pub mod weights;
20
21pub mod currency {
23 use polkadot_primitives::Balance;
24
25 pub const EXISTENTIAL_DEPOSIT: Balance = 1 * CENTS;
27
28 pub const UNITS: Balance = 1_000_000_000_000;
29 pub const CENTS: Balance = UNITS / 100;
30 pub const MILLICENTS: Balance = CENTS / 1_000;
31 pub const GRAND: Balance = CENTS * 100_000;
32
33 pub const fn deposit(items: u32, bytes: u32) -> Balance {
34 items as Balance * 100 * CENTS + (bytes as Balance) * 5 * MILLICENTS
35 }
36}
37
38pub mod time {
40 use polkadot_primitives::{BlockNumber, Moment};
41 use polkadot_runtime_common::prod_or_fast;
42
43 pub const MILLISECS_PER_BLOCK: Moment = 6000;
44 pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK;
45 pub const EPOCH_DURATION_IN_SLOTS: BlockNumber = prod_or_fast!(1 * HOURS, 1 * MINUTES);
46
47 pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
49 pub const HOURS: BlockNumber = MINUTES * 60;
50 pub const DAYS: BlockNumber = HOURS * 24;
51
52 pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
57}
58
59pub mod fee {
61 use crate::weights::ExtrinsicBaseWeight;
62 use frame_support::weights::{
63 WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial,
64 };
65 use polkadot_primitives::Balance;
66 use smallvec::smallvec;
67 pub use sp_runtime::Perbill;
68
69 pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25);
71
72 pub struct WeightToFee;
83 impl WeightToFeePolynomial for WeightToFee {
84 type Balance = Balance;
85 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
86 let p = super::currency::CENTS;
88 let q = 10 * Balance::from(ExtrinsicBaseWeight::get().ref_time());
89 smallvec![WeightToFeeCoefficient {
90 degree: 1,
91 negative: false,
92 coeff_frac: Perbill::from_rational(p % q, q),
93 coeff_integer: p / q,
94 }]
95 }
96 }
97}
98
99pub mod system_parachain {
101 use polkadot_primitives::Id;
102 use xcm_builder::IsChildSystemParachain;
103
104 pub const ASSET_HUB_ID: u32 = 1000;
106 pub const COLLECTIVES_ID: u32 = 1001;
108 pub const BRIDGE_HUB_ID: u32 = 1002;
110 pub const ENCOINTER_ID: u32 = 1003;
112 pub const PEOPLE_ID: u32 = 1004;
114 pub const BROKER_ID: u32 = 1005;
116
117 pub type SystemParachains = IsChildSystemParachain<Id>;
119
120 pub mod coretime {
122 #[cfg(feature = "fast-runtime")]
126 pub const TIMESLICE_PERIOD: u32 = 20;
127 #[cfg(not(feature = "fast-runtime"))]
128 pub const TIMESLICE_PERIOD: u32 = 80;
129 }
130}
131
132pub const TREASURY_PALLET_ID: u8 = 37;
134
135pub mod xcm {
137 pub mod body {
139 #[allow(dead_code)]
141 const ROOT_INDEX: u32 = 0;
142 pub const FELLOWSHIP_ADMIN_INDEX: u32 = 1;
144 #[deprecated = "Will be removed after August 2024; Use `xcm::latest::BodyId::Treasury` \
145 instead"]
146 pub const TREASURER_INDEX: u32 = 2;
147 }
148}
149
150#[cfg(test)]
151mod tests {
152 use super::{
153 currency::{CENTS, MILLICENTS, UNITS},
154 fee::WeightToFee,
155 };
156 use crate::weights::ExtrinsicBaseWeight;
157 use frame_support::weights::WeightToFee as WeightToFeeT;
158 use polkadot_runtime_common::MAXIMUM_BLOCK_WEIGHT;
159
160 #[test]
161 fn full_block_fee_is_correct() {
163 let full_block = WeightToFee::weight_to_fee(&MAXIMUM_BLOCK_WEIGHT);
165 assert!(full_block >= 10 * UNITS);
166 assert!(full_block <= 100 * UNITS);
167 }
168
169 #[test]
170 fn extrinsic_base_fee_is_correct() {
172 println!("Base: {}", ExtrinsicBaseWeight::get());
174 let x = WeightToFee::weight_to_fee(&ExtrinsicBaseWeight::get());
175 let y = CENTS / 10;
176 assert!(x.max(y) - x.min(y) < MILLICENTS);
177 }
178}