From 86fb12f7fda45d9abaef5dfe535dc56c355706bb Mon Sep 17 00:00:00 2001 From: Amiya Behera Date: Thu, 10 Oct 2024 21:43:45 +0530 Subject: [PATCH] apply jurors benchmark department-funding --- .../department-funding/src/benchmarking.rs | 59 +++++++++++++++++++ .../department-funding/src/weights.rs | 51 +++++++++++++--- 2 files changed, 102 insertions(+), 8 deletions(-) diff --git a/custom-pallets/department-funding/src/benchmarking.rs b/custom-pallets/department-funding/src/benchmarking.rs index 0e12f35..dafbdde 100644 --- a/custom-pallets/department-funding/src/benchmarking.rs +++ b/custom-pallets/department-funding/src/benchmarking.rs @@ -105,5 +105,64 @@ mod benchmarks { apply_staking_period(RawOrigin::Signed(account1), department_id) } + #[benchmark] + fn apply_jurors() { + let department_id = 1; + let tipping_name = TippingName::SmallTipper; + + let account1 = account::("account1", 1, SEED); + + let balance = DepartmentFunding::::u64_to_balance_saturated(100000000000000); + + let _ = ::Currency::deposit_creating(&account1, balance); + + let funding_needed = DepartmentFunding::::u64_to_balance_saturated(10_000u64); + // Dispatch a signed extrinsic. + let department_account_id = 5; + let content_department: Content = Content::IPFS( + "bafkreiaiq24be2iioasr6ftyaum3icmj7amtjkom2jeokov5k5ojwzhvqy" + .as_bytes() + .to_vec(), + ); + + assert_ok!(>::create_department( + RawOrigin::Signed(account1.clone()).into(), + content_department + )); + + let content: Content = Content::IPFS( + "bafkreiaiq24be2iioasr6ftyaum3icmj7amtjkom2jeokov5k5ojwzhvqy" + .as_bytes() + .to_vec(), + ); + + assert_ok!(DepartmentFunding::::create_department_required_fund( + RawOrigin::Signed(account1.clone()).into(), + department_id, + content.clone(), + tipping_name, + funding_needed, + )); + + let start_block_number = DepartmentFunding::::u64_to_block_saturated(50); + + >::set_block_number(start_block_number); + assert_ok!(DepartmentFunding::::apply_staking_period( + RawOrigin::Signed(account1.clone()).into(), + department_id + )); + + let account2 = account::("stake-account", 2, SEED); + + let balance = DepartmentFunding::::u64_to_balance_saturated(100000000000000); + + let _ = ::Currency::deposit_creating(&account2, balance); + + let stake = DepartmentFunding::::u64_to_balance_saturated(100); + + #[extrinsic_call] + apply_jurors(RawOrigin::Signed(account2.clone()), department_id, stake) + } + impl_benchmark_test_suite!(Template, crate::mock::new_test_ext(), crate::mock::Test); } diff --git a/custom-pallets/department-funding/src/weights.rs b/custom-pallets/department-funding/src/weights.rs index 9c7a4a1..773c414 100644 --- a/custom-pallets/department-funding/src/weights.rs +++ b/custom-pallets/department-funding/src/weights.rs @@ -39,6 +39,7 @@ use core::marker::PhantomData; pub trait WeightInfo { fn create_department_required_fund() -> Weight; fn apply_staking_period() -> Weight; + fn apply_jurors() -> Weight; } /// Weights for `pallet_department_funding` using the Substrate node and recommended hardware. @@ -58,8 +59,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `345` // Estimated: `3810` - // Minimum execution time: 28_476_000 picoseconds. - Weight::from_parts(29_780_000, 3810) + // Minimum execution time: 27_469_000 picoseconds. + Weight::from_parts(28_838_000, 3810) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -79,11 +80,28 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `306` // Estimated: `3771` - // Minimum execution time: 26_841_000 picoseconds. - Weight::from_parts(28_235_000, 3771) + // Minimum execution time: 26_581_000 picoseconds. + Weight::from_parts(27_526_000, 3771) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } + /// Storage: `DepartmentFunding::ValidationBlock` (r:1 w:0) + /// Proof: `DepartmentFunding::ValidationBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `SchellingGameShared::PeriodName` (r:1 w:0) + /// Proof: `SchellingGameShared::PeriodName` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `SortitionSumGame::SortitionSumTrees` (r:1 w:1) + /// Proof: `SortitionSumGame::SortitionSumTrees` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn apply_jurors() -> Weight { + // Proof Size summary in bytes: + // Measured: `443` + // Estimated: `3908` + // Minimum execution time: 38_811_000 picoseconds. + Weight::from_parts(40_559_000, 3908) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } } // For backwards compatibility and tests. @@ -102,8 +120,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `345` // Estimated: `3810` - // Minimum execution time: 28_476_000 picoseconds. - Weight::from_parts(29_780_000, 3810) + // Minimum execution time: 27_469_000 picoseconds. + Weight::from_parts(28_838_000, 3810) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -123,9 +141,26 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `306` // Estimated: `3771` - // Minimum execution time: 26_841_000 picoseconds. - Weight::from_parts(28_235_000, 3771) + // Minimum execution time: 26_581_000 picoseconds. + Weight::from_parts(27_526_000, 3771) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } + /// Storage: `DepartmentFunding::ValidationBlock` (r:1 w:0) + /// Proof: `DepartmentFunding::ValidationBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `SchellingGameShared::PeriodName` (r:1 w:0) + /// Proof: `SchellingGameShared::PeriodName` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `SortitionSumGame::SortitionSumTrees` (r:1 w:1) + /// Proof: `SortitionSumGame::SortitionSumTrees` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn apply_jurors() -> Weight { + // Proof Size summary in bytes: + // Measured: `443` + // Estimated: `3908` + // Minimum execution time: 38_811_000 picoseconds. + Weight::from_parts(40_559_000, 3908) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } }