kusama_runtime_constants/
lib.rs1#![cfg_attr(not(feature = "std"), no_std)]
18
19pub mod weights;
20
21pub mod currency {
23 use 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 QUID: Balance = UNITS / 30;
30 pub const CENTS: Balance = QUID / 100;
31 pub const GRAND: Balance = QUID * 1_000;
32 pub const MILLICENTS: Balance = CENTS / 1_000;
33
34 pub const fn deposit(items: u32, bytes: u32) -> Balance {
35 items as Balance * 2_000 * CENTS + (bytes as Balance) * 100 * MILLICENTS
36 }
37}
38
39pub mod time {
41 use primitives::{BlockNumber, Moment};
42 use runtime_common::prod_or_fast;
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 pub const WEEKS: BlockNumber = DAYS * 7;
52
53 pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
58}
59
60pub mod fee {
62 use crate::weights::ExtrinsicBaseWeight;
63 use frame_support::weights::{
64 WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial,
65 };
66 use primitives::Balance;
67 use smallvec::smallvec;
68 pub use sp_runtime::Perbill;
69
70 pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25);
72
73 pub struct WeightToFee;
84 impl WeightToFeePolynomial for WeightToFee {
85 type Balance = Balance;
86 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
87 let p = super::currency::CENTS;
89 let q = 10 * Balance::from(ExtrinsicBaseWeight::get().ref_time());
90 smallvec![WeightToFeeCoefficient {
91 degree: 1,
92 negative: false,
93 coeff_frac: Perbill::from_rational(p % q, q),
94 coeff_integer: p / q,
95 }]
96 }
97 }
98}
99
100#[cfg(test)]
101mod tests {
102 use super::{
103 currency::{CENTS, MILLICENTS},
104 fee::WeightToFee,
105 };
106 use crate::weights::ExtrinsicBaseWeight;
107 use frame_support::weights::WeightToFee as WeightToFeeT;
108 use runtime_common::MAXIMUM_BLOCK_WEIGHT;
109
110 #[test]
111 fn full_block_fee_is_correct() {
113 let full_block = WeightToFee::weight_to_fee(&MAXIMUM_BLOCK_WEIGHT);
115 assert!(full_block >= 1_000 * CENTS);
116 assert!(full_block <= 10_000 * CENTS);
117 }
118
119 #[test]
120 fn extrinsic_base_fee_is_correct() {
122 println!("Base: {}", ExtrinsicBaseWeight::get());
124 let x = WeightToFee::weight_to_fee(&ExtrinsicBaseWeight::get());
125 let y = CENTS / 10;
126 assert!(x.max(y) - x.min(y) < MILLICENTS);
127 }
128}