rococo_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 / 30_000;
30 pub const GRAND: Balance = CENTS * 100_000;
31 pub const MILLICENTS: Balance = CENTS / 1_000;
32
33 pub const fn deposit(items: u32, bytes: u32) -> Balance {
34 items as Balance * 2_000 * CENTS + (bytes as Balance) * 100 * MILLICENTS
35 }
36}
37
38pub mod time {
40 use polkadot_runtime_common::prod_or_fast;
41
42 use polkadot_primitives::{BlockNumber, Moment};
43 pub const MILLISECS_PER_BLOCK: Moment = 6000;
44 pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK;
45
46 frame_support::parameter_types! {
47 pub EpochDurationInBlocks: BlockNumber =
48 prod_or_fast!(1 * HOURS, 1 * MINUTES, "ROCOCO_EPOCH_DURATION");
49 }
50
51 pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
53 pub const HOURS: BlockNumber = MINUTES * 60;
54 pub const DAYS: BlockNumber = HOURS * 24;
55 pub const WEEKS: BlockNumber = DAYS * 7;
56
57 pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
62}
63
64pub mod fee {
66 use crate::weights::ExtrinsicBaseWeight;
67 use frame_support::weights::{
68 WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial,
69 };
70 use polkadot_primitives::Balance;
71 use smallvec::smallvec;
72 pub use sp_runtime::Perbill;
73
74 pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25);
76
77 pub struct WeightToFee;
88 impl WeightToFeePolynomial for WeightToFee {
89 type Balance = Balance;
90 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
91 let p = super::currency::CENTS;
93 let q = 10 * Balance::from(ExtrinsicBaseWeight::get().ref_time());
94 smallvec![WeightToFeeCoefficient {
95 degree: 1,
96 negative: false,
97 coeff_frac: Perbill::from_rational(p % q, q),
98 coeff_integer: p / q,
99 }]
100 }
101 }
102}
103
104pub mod system_parachain {
106 use frame_support::parameter_types;
107 use polkadot_primitives::Id as ParaId;
108 use xcm_builder::IsChildSystemParachain;
109
110 parameter_types! {
111 pub AssetHubParaId: ParaId = ASSET_HUB_ID.into();
112 pub PeopleParaId: ParaId = PEOPLE_ID.into();
113 }
114
115 pub const ASSET_HUB_ID: u32 = 1000;
117 pub const CONTRACTS_ID: u32 = 1002;
119 pub const ENCOINTER_ID: u32 = 1003;
121 pub const PEOPLE_ID: u32 = 1004;
123 pub const BRIDGE_HUB_ID: u32 = 1013;
125 pub const BROKER_ID: u32 = 1005;
127
128 pub type SystemParachains = IsChildSystemParachain<ParaId>;
130
131 pub mod coretime {
133 #[cfg(feature = "fast-runtime")]
137 pub const TIMESLICE_PERIOD: u32 = 20;
138 #[cfg(not(feature = "fast-runtime"))]
139 pub const TIMESLICE_PERIOD: u32 = 80;
140 }
141}
142
143pub const TREASURY_PALLET_ID: u8 = 18;
145
146#[cfg(test)]
147mod tests {
148 use super::{
149 currency::{CENTS, MILLICENTS},
150 fee::WeightToFee,
151 };
152 use crate::weights::ExtrinsicBaseWeight;
153 use frame_support::weights::WeightToFee as WeightToFeeT;
154 use polkadot_runtime_common::MAXIMUM_BLOCK_WEIGHT;
155
156 #[test]
157 fn full_block_fee_is_correct() {
159 let full_block = WeightToFee::weight_to_fee(&MAXIMUM_BLOCK_WEIGHT);
161 assert!(full_block >= 1_000 * CENTS);
162 assert!(full_block <= 10_000 * CENTS);
163 }
164
165 #[test]
166 fn extrinsic_base_fee_is_correct() {
168 println!("Base: {}", ExtrinsicBaseWeight::get());
170 let x = WeightToFee::weight_to_fee(&ExtrinsicBaseWeight::get());
171 let y = CENTS / 10;
172 assert!(x.max(y) - x.min(y) < MILLICENTS);
173 }
174}