diff --git a/pallets/communities-manager/src/benchmarking.rs b/pallets/communities-manager/src/benchmarking.rs index 62f8185a..a0388afc 100644 --- a/pallets/communities-manager/src/benchmarking.rs +++ b/pallets/communities-manager/src/benchmarking.rs @@ -5,6 +5,7 @@ use frame_benchmarking::v2::*; use frame_support::traits::fungible::Mutate; use frame_system::RawOrigin; +use sp_runtime::SaturatedConversion; type RuntimeEventFor = ::RuntimeEvent; @@ -58,7 +59,7 @@ mod benchmarks { } #[benchmark] - fn create_memberships() -> Result<(), BenchmarkError> { + fn create_memberships(q: Linear<1, 1024>) -> Result<(), BenchmarkError> { // setup code T::CreateCollection::create_collection_with_id( T::MembershipsManagerCollectionId::get(), @@ -74,7 +75,7 @@ mod benchmarks { #[extrinsic_call] _( RawOrigin::Root, - u16::MAX.into(), + q.saturated_into(), 100u32.into(), 300_000_000_000u128.into(), ); @@ -83,7 +84,7 @@ mod benchmarks { assert_has_event::( Event::::MembershipsCreated { starting_at: 100u32.into(), - amount: u16::MAX.into(), + amount: q.saturated_into(), } .into(), ); diff --git a/pallets/communities-manager/src/lib.rs b/pallets/communities-manager/src/lib.rs index 90ae1f8e..f4a09836 100644 --- a/pallets/communities-manager/src/lib.rs +++ b/pallets/communities-manager/src/lib.rs @@ -176,11 +176,12 @@ pub mod pallet { Ok(()) } + #[pallet::weight(::WeightInfo::create_memberships(*amount))] #[pallet::call_index(1)] pub fn create_memberships( origin: OriginFor, - #[pallet::compact] amount: u32, - #[pallet::compact] starting_at: ::MembershipId, + amount: u16, + starting_at: ::MembershipId, #[pallet::compact] price: NativeBalanceOf, ) -> DispatchResult { T::CreateMembershipsOrigin::ensure_origin(origin)?; diff --git a/pallets/communities-manager/src/weights.rs b/pallets/communities-manager/src/weights.rs index 913d95e4..e8746ca3 100644 --- a/pallets/communities-manager/src/weights.rs +++ b/pallets/communities-manager/src/weights.rs @@ -8,7 +8,7 @@ use core::marker::PhantomData; /// Weight functions needed for pallet_communities. pub trait WeightInfo { fn register() -> Weight; - fn create_memberships() -> Weight; + fn create_memberships(q: u16, ) -> Weight; } /// Weights for pallet_communities using the Substrate node and recommended hardware. @@ -53,7 +53,7 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().writes(14)) } - fn create_memberships() -> Weight { + fn create_memberships(_: u16, ) -> Weight { // Proof Size summary in bytes: // Measured: `278` // Estimated: `132561` @@ -105,7 +105,7 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().writes(14)) } - fn create_memberships() -> Weight { + fn create_memberships(_: u16, ) -> Weight { // Proof Size summary in bytes: // Measured: `278` // Estimated: `132561` diff --git a/runtime/kreivo/src/weights/pallet_communities_manager.rs b/runtime/kreivo/src/weights/pallet_communities_manager.rs index 060a7b04..4eb47b12 100644 --- a/runtime/kreivo/src/weights/pallet_communities_manager.rs +++ b/runtime/kreivo/src/weights/pallet_communities_manager.rs @@ -74,7 +74,7 @@ impl pallet_communities_manager::WeightInfo for WeightI .saturating_add(T::DbWeight::get().writes(14)) } - fn create_memberships() -> Weight { + fn create_memberships(_: u16, ) -> Weight { // Proof Size summary in bytes: // Measured: `278` // Estimated: `132561`