You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Part of KILTprotocol/ticket#3650, built on top
of #787.
What started as a simple fix for the web3name pallet benchmarks, turned
out to be a bigger changeset due to a couple of bugs found in the
Substrate code, which are mentioned in the self-review I gave myself
[below](#790 (review)).
In a gist, what I did is:
1. Update the benchmarking logic for the web3name pallet to delegate the
name creation to a `BenchmarkHelper` type.
2. Implement the trait above for both web3names (which uses the old
implementation) and the dotnames
3. Work around the Substrate bug for our pallets as well as the
`pallet_collective` and `pallet_membership` pallets which we deploy
multiple times
4. Add the benchmarking of the `pallet_membership` deployments of the
`TipsMembership` pallet
let n in (T::MinNameLength::get()) .. (T::MaxNameLength::get());
80
+
let n in (<TasConfig<I>>::MinNameLength::get()) .. (<TasConfig<I>>::MaxNameLength::get());
75
81
let caller:AccountIdOf<T> = account("caller",0,CALLER_SEED);
76
82
let owner:Web3NameOwnerOf<T,I> = account("owner",0,OWNER_SEED);
77
-
let web3_name_input:BoundedVec<u8,T::MaxNameLength> = BoundedVec::try_from(generate_web3_name_input(n.saturated_into())).expect("BoundedVec creation should not fail.");
83
+
let web3_name_input:BoundedVec<u8,<TasConfig<I>>::MaxNameLength> = BoundedVec::try_from(<TasConfig<I>>::BenchmarkHelper::generate_name_input_with_length(n.saturated_into())).expect("BoundedVec creation should not fail.");
78
84
let web3_name_input_clone = web3_name_input.clone();
79
-
let origin = T::OwnerOrigin::generate_origin(caller.clone(), owner.clone());
85
+
let origin = <TasConfig<I>>::OwnerOrigin::generate_origin(caller.clone(), owner.clone());
let caller:AccountIdOf<T> = account("caller",0,CALLER_SEED);
93
99
let owner:Web3NameOwnerOf<T,I> = account("owner",0,OWNER_SEED);
94
-
let web3_name_input:BoundedVec<u8,T::MaxNameLength> = BoundedVec::try_from(generate_web3_name_input(T::MaxNameLength::get().saturated_into())).expect("BoundedVec creation should not fail.");
95
-
let origin = T::OwnerOrigin::generate_origin(caller.clone(), owner.clone());
100
+
let web3_name_input:BoundedVec<u8,<TasConfig<I>>::MaxNameLength> = BoundedVec::try_from(<TasConfig<I>>::BenchmarkHelper::generate_name_input_with_length(<TasConfig<I>>::MaxNameLength::get().saturated_into())).expect("BoundedVec creation should not fail.");
101
+
let origin = <TasConfig<I>>::OwnerOrigin::generate_origin(caller.clone(), owner.clone());
96
102
97
103
make_free_for_did::<T,I>(&caller);
98
104
Pallet::<T,I>::claim(origin.clone(), web3_name_input.clone()).expect("Should register the claimed web3 name.");
let n in (T::MinNameLength::get()) .. (T::MaxNameLength::get());
115
+
let n in (<TasConfig<I>>::MinNameLength::get()) .. (<TasConfig<I>>::MaxNameLength::get());
110
116
let caller:AccountIdOf<T> = account("caller",0,CALLER_SEED);
111
117
let owner:Web3NameOwnerOf<T,I> = account("owner",0,OWNER_SEED);
112
-
let web3_name_input:BoundedVec<u8,T::MaxNameLength> = BoundedVec::try_from(generate_web3_name_input(n.saturated_into())).expect("BoundedVec creation should not fail.");
118
+
let web3_name_input:BoundedVec<u8,<TasConfig<I>>::MaxNameLength> = BoundedVec::try_from(<TasConfig<I>>::BenchmarkHelper::generate_name_input_with_length(n.saturated_into())).expect("BoundedVec creation should not fail.");
113
119
let web3_name_input_clone = web3_name_input.clone();
114
-
let did_origin = T::OwnerOrigin::generate_origin(caller.clone(), owner.clone());
120
+
let did_origin = <TasConfig<I>>::OwnerOrigin::generate_origin(caller.clone(), owner.clone());
115
121
let signed_origin = RawOrigin::Signed(caller.clone());
let n in (T::MinNameLength::get()) .. (T::MaxNameLength::get());
135
+
let n in (<TasConfig<I>>::MinNameLength::get()) .. (<TasConfig<I>>::MaxNameLength::get());
130
136
let caller:AccountIdOf<T> = account("caller",0,CALLER_SEED);
131
137
let owner:Web3NameOwnerOf<T,I> = account("owner",0,OWNER_SEED);
132
-
let web3_name_input:BoundedVec<u8,T::MaxNameLength> = BoundedVec::try_from(generate_web3_name_input(n.saturated_into())).expect("BoundedVec creation should not fail.");
138
+
let web3_name_input:BoundedVec<u8,<TasConfig<I>>::MaxNameLength> = BoundedVec::try_from(<TasConfig<I>>::BenchmarkHelper::generate_name_input_with_length(n.saturated_into())).expect("BoundedVec creation should not fail.");
133
139
let web3_name_input_clone = web3_name_input.clone();
134
-
let did_origin = T::OwnerOrigin::generate_origin(caller.clone(), owner.clone());
140
+
let did_origin = <TasConfig<I>>::OwnerOrigin::generate_origin(caller.clone(), owner.clone());
let n in (T::MinNameLength::get()) .. (T::MaxNameLength::get());
156
+
let n in (<TasConfig<I>>::MinNameLength::get()) .. (<TasConfig<I>>::MaxNameLength::get());
151
157
let caller:AccountIdOf<T> = account("caller",0,CALLER_SEED);
152
158
let owner:Web3NameOwnerOf<T,I> = account("owner",0,OWNER_SEED);
153
-
let web3_name_input:BoundedVec<u8,T::MaxNameLength> = BoundedVec::try_from(generate_web3_name_input(n.saturated_into())).expect("BoundedVec creation should not fail.");
159
+
let web3_name_input:BoundedVec<u8,<TasConfig<I>>::MaxNameLength> = BoundedVec::try_from(<TasConfig<I>>::BenchmarkHelper::generate_name_input_with_length(n.saturated_into())).expect("BoundedVec creation should not fail.");
154
160
let web3_name_input_clone = web3_name_input.clone();
// Char validation logic taken from https://github.com/paritytech/polkadot-sdk/blob/657b5503a04e97737696fa7344641019350fb521/substrate/frame/identity/src/lib.rs#L1435
0 commit comments