referrerpolicy=no-referrer-when-downgrade

cumulus_test_runtime/
flavors.rs

1// Copyright (C) Parity Technologies (UK) Ltd.
2// This file is part of Cumulus.
3
4// Cumulus 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// Cumulus 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 Cumulus.  If not, see <http://www.gnu.org/licenses/>.
16
17pub mod spec_version_incremented {
18	#[cfg(feature = "std")]
19	include!(concat!(env!("OUT_DIR"), "/wasm_binary_spec_version_incremented.rs"));
20}
21
22pub mod relay_parent_offset {
23	#[cfg(feature = "std")]
24	include!(concat!(env!("OUT_DIR"), "/wasm_binary_relay_parent_offset.rs"));
25}
26
27pub mod elastic_scaling_500ms {
28	#[cfg(feature = "std")]
29	include!(concat!(env!("OUT_DIR"), "/wasm_binary_elastic_scaling_500ms.rs"));
30}
31
32pub mod elastic_scaling {
33	#[cfg(feature = "std")]
34	include!(concat!(env!("OUT_DIR"), "/wasm_binary_elastic_scaling.rs"));
35}
36
37pub mod elastic_scaling_12s_slot {
38	#[cfg(feature = "std")]
39	include!(concat!(env!("OUT_DIR"), "/wasm_binary_elastic_scaling_12s_slot.rs"));
40}
41
42pub mod block_bundling {
43	#[cfg(feature = "std")]
44	include!(concat!(env!("OUT_DIR"), "/wasm_binary_block_bundling.rs"));
45}
46
47pub mod sync_backing {
48	#[cfg(feature = "std")]
49	include!(concat!(env!("OUT_DIR"), "/wasm_binary_sync_backing.rs"));
50}
51
52pub mod async_backing {
53	#[cfg(feature = "std")]
54	include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
55}
56
57pub mod async_backing_v3 {
58	#[cfg(feature = "std")]
59	include!(concat!(env!("OUT_DIR"), "/wasm_binary_async_backing_v3.rs"));
60}
61
62pub mod async_backing_v3_rpo {
63	#[cfg(feature = "std")]
64	include!(concat!(env!("OUT_DIR"), "/wasm_binary_async_backing_v3_rpo.rs"));
65}
66
67pub mod elastic_scaling_v3 {
68	#[cfg(feature = "std")]
69	include!(concat!(env!("OUT_DIR"), "/wasm_binary_elastic_scaling_v3.rs"));
70}
71
72pub mod slot_duration_18s {
73	#[cfg(feature = "std")]
74	include!(concat!(env!("OUT_DIR"), "/wasm_binary_slot_duration_18s.rs"));
75}
76
77pub mod with_authority_discovery {
78	#[cfg(feature = "std")]
79	include!(concat!(env!("OUT_DIR"), "/wasm_binary_with_authority_discovery.rs"));
80}
81
82pub(crate) const SCHEDULING_V3_ENABLED: bool = cfg!(feature = "v3-descriptor");
83
84pub(crate) const fn relay_parent_offset() -> u32 {
85	if cfg!(feature = "relay-parent-offset-2") {
86		return 2;
87	}
88
89	if cfg!(feature = "with-authority-discovery") {
90		return 2;
91	}
92
93	0
94}
95
96pub(crate) const fn slot_duration() -> u64 {
97	if cfg!(feature = "18s-slot") {
98		return 18000;
99	}
100
101	if cfg!(feature = "12s-slot") {
102		return 12000;
103	}
104
105	6000
106}
107
108pub(crate) const fn block_processing_velocity() -> u32 {
109	if cfg!(feature = "velocity-12") {
110		return 12;
111	}
112
113	if cfg!(feature = "velocity-6") {
114		return 6;
115	}
116
117	if cfg!(feature = "velocity-3") {
118		return 3;
119	}
120
121	1
122}
123
124pub(crate) const fn unincluded_segment_capacity() -> u32 {
125	if cfg!(feature = "sync-backing") {
126		return 1;
127	}
128
129	// Without sync backing, the block flow is the following:
130	//
131	// - Collator produces the block(s) on relay chain block `X`
132	// - In the meantime the relay chain is building block `X + 1`
133	// - The collator sends the collation to the relay chain, and it gets backed on chain in relay
134	//   block `X + 2`
135	// - The collation then gets included on chain in relay block `X + 3`
136	//
137	// With `relay_parent_offset() = N`, the collator builds on relay tip `R - N` while the
138	// chain is at `R`, so the buffer must additionally absorb `N * velocity` parablocks worth
139	// of in-flight blocks between the relay parent and the relay tip.
140	block_processing_velocity() * (3 + relay_parent_offset())
141}