frame_benchmarking_pallet_pov/
lib.rs1#![cfg_attr(not(feature = "std"), no_std)]
21
22mod benchmarking;
23mod tests;
24mod weights;
25
26extern crate alloc;
27
28pub use pallet::*;
29
30#[frame_support::pallet]
31pub mod pallet {
32 use alloc::vec::Vec;
33 use frame_support::pallet_prelude::*;
34 use frame_system::pallet_prelude::*;
35
36 #[pallet::pallet]
37 pub struct Pallet<T>(_);
38
39 #[pallet::config]
40 pub trait Config: frame_system::Config {
41 #[allow(deprecated)]
42 type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
43 }
44
45 #[pallet::storage]
46 pub(crate) type Value<T: Config> = StorageValue<Value = u32, QueryKind = OptionQuery>;
47
48 #[pallet::storage]
49 pub(crate) type Value2<T: Config> = StorageValue<Value = u32, QueryKind = OptionQuery>;
50
51 #[pallet::storage]
53 #[pallet::unbounded]
54 pub(crate) type UnboundedValue<T: Config> =
55 StorageValue<Value = Vec<u8>, QueryKind = OptionQuery>;
56
57 #[pallet::storage]
59 pub(crate) type BoundedValue<T: Config> =
60 StorageValue<Value = BoundedVec<u8, ConstU32<32>>, QueryKind = OptionQuery>;
61
62 #[pallet::storage]
64 pub(crate) type LargeValue<T: Config> =
65 StorageValue<Value = BoundedVec<u8, ConstU32<{ 1 << 22 }>>, QueryKind = OptionQuery>;
66
67 #[pallet::storage]
68 pub(crate) type LargeValue2<T: Config> =
69 StorageValue<Value = BoundedVec<u8, ConstU32<{ 1 << 22 }>>, QueryKind = OptionQuery>;
70
71 #[pallet::storage]
73 pub(crate) type Map1M<T: Config> = StorageMap<
74 Hasher = Blake2_256,
75 Key = u32,
76 Value = u32,
77 QueryKind = OptionQuery,
78 MaxValues = ConstU32<1_000_000>,
79 >;
80
81 #[pallet::storage]
83 pub(crate) type Map16M<T: Config> = StorageMap<
84 Hasher = Blake2_256,
85 Key = u32,
86 Value = u32,
87 QueryKind = OptionQuery,
88 MaxValues = ConstU32<16_000_000>,
89 >;
90
91 #[pallet::storage]
92 pub(crate) type DoubleMap1M<T: Config> = StorageDoubleMap<
93 Hasher1 = Blake2_256,
94 Hasher2 = Blake2_256,
95 Key1 = u32,
96 Key2 = u32,
97 Value = u32,
98 QueryKind = OptionQuery,
99 MaxValues = ConstU32<1_000_000>,
100 >;
101
102 #[pallet::storage]
103 #[pallet::unbounded]
104 pub(crate) type UnboundedMap<T: Config> =
105 StorageMap<Hasher = Blake2_256, Key = u32, Value = Vec<u32>, QueryKind = OptionQuery>;
106
107 #[pallet::storage]
108 #[pallet::unbounded]
109 pub(crate) type UnboundedMap2<T: Config> =
110 StorageMap<Hasher = Blake2_256, Key = u32, Value = Vec<u32>, QueryKind = OptionQuery>;
111
112 #[pallet::storage]
113 #[pallet::unbounded]
114 pub(crate) type UnboundedMapTwox<T: Config> =
115 StorageMap<Hasher = Twox64Concat, Key = u32, Value = Vec<u32>, QueryKind = OptionQuery>;
116
117 #[pallet::event]
118 #[pallet::generate_deposit(pub(super) fn deposit_event)]
119 pub enum Event<T: Config> {
120 TestEvent,
121 }
122
123 #[pallet::call]
124 impl<T: Config> Pallet<T> {
125 #[pallet::call_index(0)]
126 #[pallet::weight({0})]
127 pub fn emit_event(_origin: OriginFor<T>) -> DispatchResult {
128 Self::deposit_event(Event::TestEvent);
129 Ok(())
130 }
131
132 #[pallet::call_index(1)]
133 #[pallet::weight({0})]
134 pub fn noop(_origin: OriginFor<T>) -> DispatchResult {
135 Ok(())
136 }
137 }
138}