substrate_benchmark_machine/hardware.rs
1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: Apache-2.0
5
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18//! Contains types to define hardware requirements.
19
20use lazy_static::lazy_static;
21use sc_sysinfo::Requirements;
22
23lazy_static! {
24 /// The hardware requirements as measured on reference hardware.
25 ///
26 /// These values are provided by Parity, however it is possible
27 /// to use your own requirements if you are running a custom chain.
28 ///
29 /// The reference hardware is describe here:
30 /// <https://wiki.polkadot.network/docs/maintain-guides-how-to-validate-polkadot>
31 pub static ref SUBSTRATE_REFERENCE_HARDWARE: Requirements = {
32 let raw = include_bytes!("reference_hardware.json").as_slice();
33 serde_json::from_slice(raw).expect("Hardcoded data is known good; qed")
34 };
35}
36
37#[cfg(test)]
38mod tests {
39 use super::*;
40
41 /// `SUBSTRATE_REFERENCE_HARDWARE` can be en- and decoded.
42 #[test]
43 fn json_static_data() {
44 let raw = serde_json::to_string(&*SUBSTRATE_REFERENCE_HARDWARE).unwrap();
45 let decoded: Requirements = serde_json::from_str(&raw).unwrap();
46
47 assert_eq!(decoded, SUBSTRATE_REFERENCE_HARDWARE.clone());
48 }
49}