Ensure data size of identity pallet is bounded (#9168)

* Ensure data size of identity pallet is bounded

* Fix unit tests for identity pallet

* Move identity pallet custom types into its own module

* Make use of NoBound family traits

* Fix identity pallet benchmarks

* Enumerate type imports

* Properly convert to BoundedVec in benchmarks

* Re-export types

* Use BoundedVec when storing sub identities

* Add generate_storage_info

* Manually implement MaxEncodedLen on select types

* Use ConstU32 instead of parameter_type

* Leverage DefaultNoBound and add some comments

* Use max_encoded_len() instead of hardcoded constant

* Use MaxEncodedLen in parity-scal-codec

* Add get_mut method for WeakBoundedVec

* Use expect on an infallible operation

* Rewrite as for loop
This commit is contained in:
Keith Yeung
2021-07-07 19:57:26 -07:00
committed by GitHub
parent b42b8fc5fb
commit 721a3b9e9c
7 changed files with 406 additions and 325 deletions
@@ -122,6 +122,14 @@ impl<T, S> BoundedVec<T, S> {
pub fn retain<F: FnMut(&T) -> bool>(&mut self, f: F) {
self.0.retain(f)
}
/// Exactly the same semantics as [`Vec::get_mut`].
pub fn get_mut<I: SliceIndex<[T]>>(
&mut self,
index: I,
) -> Option<&mut <I as SliceIndex<[T]>>::Output> {
self.0.get_mut(index)
}
}
impl<T, S: Get<u32>> From<BoundedVec<T, S>> for Vec<T> {