11//! A set of constant values used in substrate runtime.
22
3+ /// Time.
4+ pub mod time {
5+ use jupiter_primitives:: { BlockNumber , Moment } ;
6+
7+ pub const MILLISECS_PER_BLOCK : Moment = 6000 ;
8+ pub const SECS_PER_BLOCK : Moment = MILLISECS_PER_BLOCK / 1000 ;
9+
10+ pub const SLOT_DURATION : Moment = MILLISECS_PER_BLOCK ;
11+ pub const EPOCH_DURATION_IN_BLOCKS : BlockNumber = 1 * HOURS ;
12+
13+ // These time units are defined in number of blocks.
14+ pub const MINUTES : BlockNumber = 60 / ( SECS_PER_BLOCK as BlockNumber ) ;
15+ pub const HOURS : BlockNumber = MINUTES * 60 ;
16+ pub const DAYS : BlockNumber = HOURS * 24 ;
17+
18+ // 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks.
19+ pub const PRIMARY_PROBABILITY : ( u64 , u64 ) = ( 1 , 4 ) ;
20+ }
21+
322/// Money matters.
423pub mod jupiter_currency {
524 use super :: jupiter_fee:: { Weight2FeeNumerator , WeightToFee } ;
@@ -25,58 +44,6 @@ pub mod jupiter_currency {
2544 pub type JupiterWeight2Fee = WeightToFee < JupiterNumerator > ;
2645}
2746
28- pub mod currency {
29- use jupiter_primitives:: Balance ;
30-
31- /// The existential deposit. Set to 1/10 of its parent Relay Chain.
32- pub const EXISTENTIAL_DEPOSIT : Balance = 100 * MILLICENTS ;
33-
34- pub const UNITS : Balance = 1_000_000_000_000 ;
35- pub const CENTS : Balance = UNITS / 100 ;
36- pub const MILLICENTS : Balance = CENTS / 1_000 ;
37- pub const GRAND : Balance = CENTS * 100_000 ;
38-
39- pub const fn deposit ( items : u32 , bytes : u32 ) -> Balance {
40- // 1/10 of Westend testnet
41- ( items as Balance * 100 * CENTS + ( bytes as Balance ) * 5 * MILLICENTS ) / 10
42- }
43- }
44-
45- /// Time.
46- pub mod time {
47- use jupiter_primitives:: { BlockNumber , Moment } ;
48-
49- pub const MILLISECS_PER_BLOCK : Moment = 6000 ;
50- pub const SECS_PER_BLOCK : Moment = MILLISECS_PER_BLOCK / 1000 ;
51-
52- pub const SLOT_DURATION : Moment = MILLISECS_PER_BLOCK ;
53- pub const EPOCH_DURATION_IN_BLOCKS : BlockNumber = 1 * HOURS ;
54-
55- // These time units are defined in number of blocks.
56- pub const MINUTES : BlockNumber = 60 / ( SECS_PER_BLOCK as BlockNumber ) ;
57- pub const HOURS : BlockNumber = MINUTES * 60 ;
58- pub const DAYS : BlockNumber = HOURS * 24 ;
59-
60- // 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks.
61- pub const PRIMARY_PROBABILITY : ( u64 , u64 ) = ( 1 , 4 ) ;
62- }
63-
64- /// Common constants
65- pub mod constants {
66- use frame_support:: weights:: { constants:: WEIGHT_PER_SECOND , Weight } ;
67- use sp_runtime:: Perbill ;
68-
69- /// We assume that ~5% of the block weight is consumed by `on_initialize` handlers. This is
70- /// used to limit the maximal weight of a single extrinsic.
71- pub const AVERAGE_ON_INITIALIZE_RATIO : Perbill = Perbill :: from_percent ( 5 ) ;
72- /// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used by
73- /// Operational extrinsics.
74- pub const NORMAL_DISPATCH_RATIO : Perbill = Perbill :: from_percent ( 75 ) ;
75-
76- /// We allow for 0.5 seconds of compute with a 6 second average block time.
77- pub const MAXIMUM_BLOCK_WEIGHT : Weight = WEIGHT_PER_SECOND / 2 ;
78- }
79-
8047/// Fee-related.
8148pub mod jupiter_fee {
8249 use frame_support:: weights:: {
@@ -120,30 +87,3 @@ pub mod jupiter_fee {
12087 }
12188 }
12289}
123-
124- pub mod fee {
125- use frame_support:: weights:: {
126- constants:: ExtrinsicBaseWeight , WeightToFeeCoefficient , WeightToFeeCoefficients ,
127- WeightToFeePolynomial ,
128- } ;
129- use jupiter_primitives:: Balance ;
130- use smallvec:: smallvec;
131- pub use sp_runtime:: Perbill ;
132-
133- pub const TARGET_BLOCK_FULLNESS : Perbill = Perbill :: from_percent ( 25 ) ;
134-
135- pub struct WeightToFee ;
136- impl WeightToFeePolynomial for WeightToFee {
137- type Balance = Balance ;
138- fn polynomial ( ) -> WeightToFeeCoefficients < Self :: Balance > {
139- let p = super :: currency:: CENTS ;
140- let q = 100 * Balance :: from ( ExtrinsicBaseWeight :: get ( ) ) ;
141- smallvec ! [ WeightToFeeCoefficient {
142- degree: 1 ,
143- negative: false ,
144- coeff_frac: Perbill :: from_rational( p % q, q) ,
145- coeff_integer: p / q,
146- } ]
147- }
148- }
149- }
0 commit comments