referrerpolicy=no-referrer-when-downgrade

penpal_runtime/weights/
rocksdb_weights.rs

1// This file is part of Cumulus.
2// SPDX-License-Identifier: Unlicense
3
4// This is free and unencumbered software released into the public domain.
5
6// Anyone is free to copy, modify, publish, use, compile, sell, or
7// distribute this software, either in source code form or as a compiled
8// binary, for any purpose, commercial or non-commercial, and by any
9// means.
10
11// In jurisdictions that recognize copyright laws, the author or authors
12// of this software dedicate any and all copyright interest in the
13// software to the public domain. We make this dedication for the benefit
14// of the public at large and to the detriment of our heirs and
15// successors. We intend this dedication to be an overt act of
16// relinquishment in perpetuity of all present and future rights to this
17// software under copyright law.
18
19// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25// OTHER DEALINGS IN THE SOFTWARE.
26
27// For more information, please refer to <http://unlicense.org/>
28
29pub mod constants {
30	use frame_support::{
31		parameter_types,
32		weights::{constants, RuntimeDbWeight},
33	};
34
35	parameter_types! {
36		/// By default, Substrate uses `RocksDB`, so this will be the weight used throughout
37		/// the runtime.
38		pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight {
39			read: 25_000 * constants::WEIGHT_REF_TIME_PER_NANOS,
40			write: 100_000 * constants::WEIGHT_REF_TIME_PER_NANOS,
41		};
42	}
43
44	#[cfg(test)]
45	mod test_db_weights {
46		use super::constants::RocksDbWeight as W;
47		use frame_support::weights::constants;
48
49		/// Checks that all weights exist and have sane values.
50		// NOTE: If this test fails but you are sure that the generated values are fine,
51		// you can delete it.
52		#[test]
53		fn sane() {
54			// At least 1 µs.
55			assert!(
56				W::get().reads(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
57				"Read weight should be at least 1 µs."
58			);
59			assert!(
60				W::get().writes(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
61				"Write weight should be at least 1 µs."
62			);
63			// At most 1 ms.
64			assert!(
65				W::get().reads(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
66				"Read weight should be at most 1 ms."
67			);
68			assert!(
69				W::get().writes(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
70				"Write weight should be at most 1 ms."
71			);
72		}
73	}
74}