referrerpolicy=no-referrer-when-downgrade

polkadot_primitives/vstaging/
mod.rs

1// Copyright (C) Parity Technologies (UK) Ltd.
2// This file is part of Polkadot.
3
4// Polkadot is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// Polkadot is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with Polkadot.  If not, see <http://www.gnu.org/licenses/>.
16
17//! Staging Primitives.
18
19use codec::{Decode, DecodeWithMemTracking, Encode};
20use polkadot_core_primitives::Balance;
21use scale_info::TypeInfo;
22use sp_arithmetic::Perbill;
23
24use crate::v9::ON_DEMAND_DEFAULT_QUEUE_MAX_SIZE;
25
26/// Information about a relay parent.
27#[derive(
28	Debug,
29	Default,
30	Clone,
31	PartialEq,
32	Encode,
33	Decode,
34	DecodeWithMemTracking,
35	TypeInfo,
36	serde::Serialize,
37	serde::Deserialize,
38)]
39pub struct RelayParentInfo<Hash, BlockNumber> {
40	/// The block number of the relay parent.
41	pub number: BlockNumber,
42	/// The state root of the relay parent.
43	pub state_root: Hash,
44}
45
46/// Scheduler configuration parameters. All coretime/ondemand parameters are here.
47///
48/// Vstaging: removed `ttl` and `max_availability_timeouts` fields.
49#[derive(
50	Debug,
51	Copy,
52	Clone,
53	PartialEq,
54	Encode,
55	Decode,
56	DecodeWithMemTracking,
57	TypeInfo,
58	serde::Serialize,
59	serde::Deserialize,
60)]
61pub struct SchedulerParams<BlockNumber> {
62	/// How often parachain groups should be rotated across parachains.
63	///
64	/// Must be non-zero.
65	pub group_rotation_frequency: BlockNumber,
66	/// Availability timeout for a block on a core, measured in blocks.
67	///
68	/// This is the maximum amount of blocks after a core became occupied that validators have time
69	/// to make the block available.
70	///
71	/// This value only has effect on group rotations. If backers backed something at the end of
72	/// their rotation, the occupied core affects the backing group that comes afterwards. We limit
73	/// the effect one backing group can have on the next to `paras_availability_period` blocks.
74	///
75	/// Within a group rotation there is no timeout as backers are only affecting themselves.
76	///
77	/// Must be at least 1. With a value of 1, the previous group will not be able to negatively
78	/// affect the following group at the expense of a tight availability timeline at group
79	/// rotation boundaries.
80	pub paras_availability_period: BlockNumber,
81	/// The maximum number of validators to have per core.
82	///
83	/// `None` means no maximum.
84	pub max_validators_per_core: Option<u32>,
85	/// The amount of blocks ahead to schedule paras.
86	pub lookahead: u32,
87	/// How many cores are managed by the coretime chain.
88	pub num_cores: u32,
89	/// The maximum queue size of the pay as you go module.
90	pub on_demand_queue_max_size: u32,
91	/// The target utilization of the spot price queue in percentages.
92	pub on_demand_target_queue_utilization: Perbill,
93	/// How quickly the fee rises in reaction to increased utilization.
94	/// The lower the number the slower the increase.
95	pub on_demand_fee_variability: Perbill,
96	/// The minimum amount needed to claim a slot in the spot pricing queue.
97	pub on_demand_base_fee: Balance,
98}
99
100impl<BlockNumber: Default + From<u32>> Default for SchedulerParams<BlockNumber> {
101	#[allow(deprecated)]
102	fn default() -> Self {
103		Self {
104			group_rotation_frequency: 1u32.into(),
105			paras_availability_period: 1u32.into(),
106			max_validators_per_core: Default::default(),
107			lookahead: 1,
108			num_cores: Default::default(),
109			on_demand_queue_max_size: ON_DEMAND_DEFAULT_QUEUE_MAX_SIZE,
110			on_demand_target_queue_utilization: Perbill::from_percent(25),
111			on_demand_fee_variability: Perbill::from_percent(3),
112			on_demand_base_fee: 10_000_000u128,
113		}
114	}
115}