diff --git a/custom-pallets/department-funding/src/benchmarking.rs b/custom-pallets/department-funding/src/benchmarking.rs index dafbdde..dff7ccd 100644 --- a/custom-pallets/department-funding/src/benchmarking.rs +++ b/custom-pallets/department-funding/src/benchmarking.rs @@ -164,5 +164,85 @@ mod benchmarks { apply_jurors(RawOrigin::Signed(account2.clone()), department_id, stake) } + #[benchmark] + fn pass_period() { + 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); + + let mut accounts = vec![]; + + for j in 4..50 { + let account_number = account::("apply-juror-account", j, SEED); + let _ = ::Currency::deposit_creating(&account_number, balance); + accounts.push(account_number); + } + + for j in 4..30 { + let stake = DepartmentFunding::::u64_to_balance_saturated(j * 100); + assert_ok!(DepartmentFunding::::apply_jurors( + RawOrigin::Signed(accounts[(j) as usize].clone()).into(), + department_id.clone(), + stake + )); + } + + let phase_data = DepartmentFunding::::get_phase_data(); + + >::set_block_number(start_block_number + phase_data.staking_length); + + #[extrinsic_call] + pass_period(RawOrigin::Signed(accounts[0].clone()), department_id) + } + 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 773c414..03816e6 100644 --- a/custom-pallets/department-funding/src/weights.rs +++ b/custom-pallets/department-funding/src/weights.rs @@ -2,7 +2,7 @@ //! Autogenerated weights for `pallet_department_funding` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-10-10, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-10-11, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `amiya`, CPU: `12th Gen Intel(R) Core(TM) i7-12650H` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` @@ -40,6 +40,7 @@ pub trait WeightInfo { fn create_department_required_fund() -> Weight; fn apply_staking_period() -> Weight; fn apply_jurors() -> Weight; + fn pass_period() -> Weight; } /// Weights for `pallet_department_funding` using the Substrate node and recommended hardware. @@ -59,8 +60,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `345` // Estimated: `3810` - // Minimum execution time: 27_469_000 picoseconds. - Weight::from_parts(28_838_000, 3810) + // Minimum execution time: 24_830_000 picoseconds. + Weight::from_parts(25_919_000, 3810) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -80,8 +81,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `306` // Estimated: `3771` - // Minimum execution time: 26_581_000 picoseconds. - Weight::from_parts(27_526_000, 3771) + // Minimum execution time: 24_280_000 picoseconds. + Weight::from_parts(24_973_000, 3771) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -97,11 +98,26 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `443` // Estimated: `3908` - // Minimum execution time: 38_811_000 picoseconds. - Weight::from_parts(40_559_000, 3908) + // Minimum execution time: 34_852_000 picoseconds. + Weight::from_parts(36_814_000, 3908) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_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:1) + /// Proof: `SchellingGameShared::PeriodName` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `SchellingGameShared::StakingStartTime` (r:1 w:0) + /// Proof: `SchellingGameShared::StakingStartTime` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn pass_period() -> Weight { + // Proof Size summary in bytes: + // Measured: `282` + // Estimated: `3747` + // Minimum execution time: 18_865_000 picoseconds. + Weight::from_parts(19_787_000, 3747) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } } // For backwards compatibility and tests. @@ -120,8 +136,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `345` // Estimated: `3810` - // Minimum execution time: 27_469_000 picoseconds. - Weight::from_parts(28_838_000, 3810) + // Minimum execution time: 24_830_000 picoseconds. + Weight::from_parts(25_919_000, 3810) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -141,8 +157,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `306` // Estimated: `3771` - // Minimum execution time: 26_581_000 picoseconds. - Weight::from_parts(27_526_000, 3771) + // Minimum execution time: 24_280_000 picoseconds. + Weight::from_parts(24_973_000, 3771) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -158,9 +174,24 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `443` // Estimated: `3908` - // Minimum execution time: 38_811_000 picoseconds. - Weight::from_parts(40_559_000, 3908) + // Minimum execution time: 34_852_000 picoseconds. + Weight::from_parts(36_814_000, 3908) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(2_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:1) + /// Proof: `SchellingGameShared::PeriodName` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `SchellingGameShared::StakingStartTime` (r:1 w:0) + /// Proof: `SchellingGameShared::StakingStartTime` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn pass_period() -> Weight { + // Proof Size summary in bytes: + // Measured: `282` + // Estimated: `3747` + // Minimum execution time: 18_865_000 picoseconds. + Weight::from_parts(19_787_000, 3747) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } }