referrerpolicy=no-referrer-when-downgrade

parachains_common/
lib.rs

1// Copyright (C) Parity Technologies (UK) Ltd.
2// SPDX-License-Identifier: Apache-2.0
3
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// 	http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16#![cfg_attr(not(feature = "std"), no_std)]
17
18extern crate alloc;
19
20pub mod impls;
21pub mod message_queue;
22pub mod pay;
23pub mod xcm_config;
24pub use constants::*;
25pub use parachains_common_types::{opaque::*, *};
26
27/// Common constants of parachains.
28mod constants {
29	use frame_support::{
30		weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight},
31		PalletId,
32	};
33	use parachains_common_types::BlockNumber;
34	use sp_runtime::Perbill;
35
36	/// This determines the average expected block time that we are targeting. Blocks will be
37	/// produced at a minimum duration defined by `SLOT_DURATION`. `SLOT_DURATION` is picked up by
38	/// `pallet_timestamp` which is in turn picked up by `pallet_aura` to implement `fn
39	/// slot_duration()`.
40	///
41	/// Change this to adjust the block time.
42	pub const MILLISECS_PER_BLOCK: u64 = 12000;
43	pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;
44
45	// Time is measured by number of blocks.
46	pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
47	pub const HOURS: BlockNumber = MINUTES * 60;
48	pub const DAYS: BlockNumber = HOURS * 24;
49
50	/// We assume that ~5% of the block weight is consumed by `on_initialize` handlers. This is
51	/// used to limit the maximal weight of a single extrinsic.
52	pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5);
53	/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used by
54	/// Operational  extrinsics.
55	pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
56
57	/// We allow for 0.5 seconds of compute with a 6 second average block time.
58	pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(
59		WEIGHT_REF_TIME_PER_SECOND.saturating_div(2),
60		polkadot_primitives::MAX_POV_SIZE as u64,
61	);
62
63	/// We allow for 2 seconds of compute with a 6 second average block.
64	pub const MAXIMUM_BLOCK_WEIGHT_FOR_ASYNC_BACKING: Weight = Weight::from_parts(
65		WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2),
66		polkadot_primitives::MAX_POV_SIZE as u64,
67	);
68
69	/// Treasury pallet id of the local chain, used to convert into AccountId
70	pub const TREASURY_PALLET_ID: PalletId = PalletId(*b"py/trsry");
71}