diff --git a/pallets/sponsorship/src/lib.rs b/pallets/sponsorship/src/lib.rs index 1232a6cfb02..80f38210901 100644 --- a/pallets/sponsorship/src/lib.rs +++ b/pallets/sponsorship/src/lib.rs @@ -157,19 +157,42 @@ pub mod pallet { #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { /// Event emitted when a new pot is created. - PotCreated { pot: T::PotId }, + PotCreated { + pot: T::PotId, + sponsor: T::AccountId, + sponsorship_type: T::SponsorshipType, + fee_quota: BalanceOf, + reserve_quota: BalanceOf, + }, /// Event emitted when a pot is removed. PotRemoved { pot: T::PotId }, /// Event emitted when a pot is updated. - PotUpdated { pot: T::PotId }, + PotUpdated { + pot: T::PotId, + fee_quota: BalanceOf, + reserve_quota: BalanceOf, + }, /// Event emitted when a pot is updated. - PotSponsorshipTypeUpdated { pot: T::PotId }, + PotSponsorshipTypeUpdated { + pot: T::PotId, + sponsorship_type: T::SponsorshipType, + }, /// Event emitted when user/users are registered indicating the list of them - UsersRegistered { pot: T::PotId, users: Vec }, + UsersRegistered { + pot: T::PotId, + users: Vec, + fee_quota: BalanceOf, + reserve_quota: BalanceOf, + }, /// Event emitted when user/users are removed indicating the list of them UsersRemoved { pot: T::PotId, users: Vec }, /// Event emitted when fee_quota or reserve_quota or both are updated for the given list - UsersLimitsUpdated { pot: T::PotId, users: Vec }, + UsersLimitsUpdated { + pot: T::PotId, + users: Vec, + fee_quota: BalanceOf, + reserve_quota: BalanceOf, + }, /// Event emitted when a sponsor_me call has been successful indicating the reserved amount Sponsored { paid: BalanceOf, repaid: BalanceOf }, /// Event emitted when the transaction fee is paid showing the payer and the amount @@ -222,14 +245,20 @@ pub mod pallet { >::insert( pot, PotDetailsOf:: { - sponsor: who, - sponsorship_type, + sponsor: who.clone(), + sponsorship_type: sponsorship_type.clone(), fee_quota: LimitedBalance::with_limit(fee_quota), reserve_quota: LimitedBalance::with_limit(reserve_quota), }, ); - Self::deposit_event(Event::PotCreated { pot }); + Self::deposit_event(Event::PotCreated { + pot, + sponsor: who, + sponsorship_type, + fee_quota, + reserve_quota, + }); Ok(()) } @@ -287,7 +316,12 @@ pub mod pallet { }, ); } - Self::deposit_event(Event::UsersRegistered { pot, users }); + Self::deposit_event(Event::UsersRegistered { + pot, + users, + fee_quota: common_fee_quota, + reserve_quota: common_reserve_quota, + }); Ok(()) } @@ -403,7 +437,11 @@ pub mod pallet { .map_err(|_| Error::::CannotUpdateReserveLimit)?; >::insert(pot, pot_details); - Self::deposit_event(Event::PotUpdated { pot }); + Self::deposit_event(Event::PotUpdated { + pot, + fee_quota: new_fee_quota, + reserve_quota: new_reserve_quota, + }); Ok(()) } @@ -437,7 +475,12 @@ pub mod pallet { } >::insert(pot, pot_details); - Self::deposit_event(Event::UsersLimitsUpdated { pot, users }); + Self::deposit_event(Event::UsersLimitsUpdated { + pot, + users, + fee_quota: new_fee_quota, + reserve_quota: new_reserve_quota, + }); Ok(()) } @@ -455,11 +498,11 @@ pub mod pallet { Pot::::try_mutate(pot, |maybe_pot_details| -> DispatchResult { let pot_details = maybe_pot_details.as_mut().ok_or(Error::::PotNotExist)?; ensure!(pot_details.sponsor == who, Error::::NoPermission); - pot_details.sponsorship_type = sponsorship_type; + pot_details.sponsorship_type = sponsorship_type.clone(); Ok(()) })?; - Self::deposit_event(Event::PotSponsorshipTypeUpdated { pot }); + Self::deposit_event(Event::PotSponsorshipTypeUpdated { pot, sponsorship_type }); Ok(()) } } diff --git a/pallets/sponsorship/src/tests.rs b/pallets/sponsorship/src/tests.rs index 15047a2214d..ee6a71e11c7 100644 --- a/pallets/sponsorship/src/tests.rs +++ b/pallets/sponsorship/src/tests.rs @@ -53,7 +53,16 @@ fn creator_of_pot_becomes_sponsor() { pot_details.reserve_quota.limit() )); assert_eq!(Pot::::get(pot), Some(pot_details)); - System::assert_last_event(Event::PotCreated { pot }.into()); + System::assert_last_event( + Event::PotCreated { + pot, + sponsor: 1, + sponsorship_type: SponsorshipType::Uniques, + fee_quota: 5, + reserve_quota: 7, + } + .into(), + ); }); } @@ -239,7 +248,14 @@ fn sponsors_can_always_increase_pot_limits() { unused_pot_details.fee_quota.limit() + 1, unused_pot_details.reserve_quota.limit() + 1 )); - System::assert_last_event(Event::PotUpdated { pot: unused_pot }.into()); + System::assert_last_event( + Event::PotUpdated { + pot: unused_pot, + fee_quota: 6, + reserve_quota: 8, + } + .into(), + ); let updated_pot = Pot::::get(unused_pot).unwrap(); assert_eq!(updated_pot.fee_quota.limit(), unused_pot_details.fee_quota.limit() + 1); assert_eq!( @@ -264,7 +280,14 @@ fn sponsors_can_always_increase_pot_limits() { fully_used_pot_details.fee_quota.limit() + 1, fully_used_pot_details.reserve_quota.limit() + 1 )); - System::assert_last_event(Event::PotUpdated { pot: fully_used_pot }.into()); + System::assert_last_event( + Event::PotUpdated { + pot: fully_used_pot, + fee_quota: 6, + reserve_quota: 8, + } + .into(), + ); let updated_pot = Pot::::get(fully_used_pot).unwrap(); assert_eq!( updated_pot.fee_quota.limit(), @@ -353,6 +376,8 @@ fn sponsors_can_decrease_pot_limits_only_when_available_margin_allows() { System::assert_last_event( Event::PotUpdated { pot: partially_used_pot, + fee_quota: 4, + reserve_quota: 3, } .into(), ); @@ -446,6 +471,8 @@ fn sponsors_can_register_new_users() { Event::UsersRegistered { pot, users: vec![user_1, user_2], + fee_quota: common_fee_quota, + reserve_quota: common_reserve_quota, } .into(), ); @@ -474,6 +501,8 @@ fn sponsors_can_register_new_users() { Event::UsersRegistered { pot, users: vec![user_3], + fee_quota: user_3_fee_quota, + reserve_quota: user_3_reserve_quota, } .into(), ); @@ -684,6 +713,8 @@ fn only_sponsors_have_permission_to_update_users_limits() { Event::UsersLimitsUpdated { pot, users: vec![user_1, user_2], + fee_quota: common_fee_quota + 1, + reserve_quota: common_reserve_quota + 1, } .into(), ); @@ -836,6 +867,8 @@ fn sponsors_can_always_set_user_limits_to_an_amount_equal_or_greater_than_before Event::UsersLimitsUpdated { pot, users: vec![user_1, user_2], + fee_quota: common_fee_quota + 1, + reserve_quota: common_reserve_quota + 1, } .into(), ); @@ -933,6 +966,8 @@ fn sponsors_can_reduce_user_limits_when_available_margin_allows() { Event::UsersLimitsUpdated { pot, users: vec![user_1], + fee_quota: lowest_fee_limit, + reserve_quota: lowest_reserve_limit, } .into(), ); @@ -949,6 +984,8 @@ fn sponsors_can_reduce_user_limits_when_available_margin_allows() { Event::UsersLimitsUpdated { pot, users: vec![user_2], + fee_quota: lowest_fee_limit - 1, + reserve_quota: lowest_reserve_limit - 1, } .into(), ); diff --git a/pallets/sponsorship/src/weights.rs b/pallets/sponsorship/src/weights.rs index 5cf7e1e9d7a..6fd80d5ef56 100644 --- a/pallets/sponsorship/src/weights.rs +++ b/pallets/sponsorship/src/weights.rs @@ -19,12 +19,12 @@ //! Autogenerated weights for pallet_sponsorship //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-09-14, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-11-14, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `chain-bench-66242306`, CPU: `AMD EPYC 7B13` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// /home/fredrik_nodle_com/bin/nodle-parachain +// ./target/release/nodle-parachain // benchmark // pallet // --chain=dev @@ -71,8 +71,8 @@ impl WeightInfo for SubstrateWeight { // Storage: System Events (r:1 w:1) // Proof Skipped: System Events (max_values: Some(1), max_size: None, mode: Measured) fn create_pot() -> Weight { - // Minimum execution time: 21_080 nanoseconds. - Weight::from_parts(21_990_000_u64, 0) + // Minimum execution time: 20_580 nanoseconds. + Weight::from_parts(21_770_000_u64, 0) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -89,8 +89,8 @@ impl WeightInfo for SubstrateWeight { // Storage: System Events (r:1 w:1) // Proof Skipped: System Events (max_values: Some(1), max_size: None, mode: Measured) fn remove_pot() -> Weight { - // Minimum execution time: 27_670 nanoseconds. - Weight::from_parts(28_730_000_u64, 0) + // Minimum execution time: 27_709 nanoseconds. + Weight::from_parts(28_509_000_u64, 0) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -105,8 +105,8 @@ impl WeightInfo for SubstrateWeight { // Storage: System Events (r:1 w:1) // Proof Skipped: System Events (max_values: Some(1), max_size: None, mode: Measured) fn update_pot_limits() -> Weight { - // Minimum execution time: 23_030 nanoseconds. - Weight::from_parts(24_060_000_u64, 0) + // Minimum execution time: 22_820 nanoseconds. + Weight::from_parts(23_650_000_u64, 0) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -121,8 +121,8 @@ impl WeightInfo for SubstrateWeight { // Storage: System Events (r:1 w:1) // Proof Skipped: System Events (max_values: Some(1), max_size: None, mode: Measured) fn update_sponsorship_type() -> Weight { - // Minimum execution time: 21_620 nanoseconds. - Weight::from_parts(22_440_000_u64, 0) + // Minimum execution time: 21_300 nanoseconds. + Weight::from_parts(22_020_000_u64, 0) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -142,10 +142,10 @@ impl WeightInfo for SubstrateWeight { // Proof Skipped: System Events (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `l` is `[1, 1000]`. fn register_users(l: u32, ) -> Weight { - // Minimum execution time: 61_130 nanoseconds. - Weight::from_parts(62_070_000_u64, 0) - // Standard Error: 9_134 - .saturating_add(Weight::from_parts(36_248_627_u64, 0).saturating_mul(l as u64)) + // Minimum execution time: 60_910 nanoseconds. + Weight::from_parts(61_600_000_u64, 0) + // Standard Error: 6_651 + .saturating_add(Weight::from_parts(36_156_400_u64, 0).saturating_mul(l as u64)) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(l as u64))) .saturating_add(T::DbWeight::get().writes(2_u64)) @@ -169,10 +169,10 @@ impl WeightInfo for SubstrateWeight { // Proof Skipped: System Events (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `l` is `[1, 1000]`. fn remove_users(l: u32, ) -> Weight { - // Minimum execution time: 136_150 nanoseconds. - Weight::from_parts(137_760_000_u64, 0) - // Standard Error: 43_995 - .saturating_add(Weight::from_parts(113_547_601_u64, 0).saturating_mul(l as u64)) + // Minimum execution time: 135_290 nanoseconds. + Weight::from_parts(136_720_000_u64, 0) + // Standard Error: 48_135 + .saturating_add(Weight::from_parts(112_231_748_u64, 0).saturating_mul(l as u64)) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(l as u64))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -192,10 +192,10 @@ impl WeightInfo for SubstrateWeight { // Proof Skipped: System Events (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `l` is `[1, 1000]`. fn update_users_limits(l: u32, ) -> Weight { - // Minimum execution time: 32_780 nanoseconds. - Weight::from_parts(33_600_000_u64, 0) - // Standard Error: 9_144 - .saturating_add(Weight::from_parts(9_738_582_u64, 0).saturating_mul(l as u64)) + // Minimum execution time: 32_940 nanoseconds. + Weight::from_parts(33_730_000_u64, 0) + // Standard Error: 9_718 + .saturating_add(Weight::from_parts(9_643_418_u64, 0).saturating_mul(l as u64)) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(l as u64))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -218,8 +218,8 @@ impl WeightInfo for SubstrateWeight { // Storage: System Events (r:1 w:1) // Proof Skipped: System Events (max_values: Some(1), max_size: None, mode: Measured) fn pre_sponsor() -> Weight { - // Minimum execution time: 89_820 nanoseconds. - Weight::from_parts(91_600_000_u64, 0) + // Minimum execution time: 88_970 nanoseconds. + Weight::from_parts(90_430_000_u64, 0) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -240,8 +240,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Sponsorship Pot (r:0 w:1) // Proof: Sponsorship Pot (max_values: None, max_size: Some(117), added: 2592, mode: MaxEncodedLen) fn post_sponsor() -> Weight { - // Minimum execution time: 82_000 nanoseconds. - Weight::from_parts(83_070_000_u64, 0) + // Minimum execution time: 80_690 nanoseconds. + Weight::from_parts(82_260_000_u64, 0) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -259,8 +259,8 @@ impl WeightInfo for () { // Storage: System Events (r:1 w:1) // Proof Skipped: System Events (max_values: Some(1), max_size: None, mode: Measured) fn create_pot() -> Weight { - // Minimum execution time: 21_080 nanoseconds. - Weight::from_parts(21_990_000_u64, 0) + // Minimum execution time: 20_580 nanoseconds. + Weight::from_parts(21_770_000_u64, 0) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -277,8 +277,8 @@ impl WeightInfo for () { // Storage: System Events (r:1 w:1) // Proof Skipped: System Events (max_values: Some(1), max_size: None, mode: Measured) fn remove_pot() -> Weight { - // Minimum execution time: 27_670 nanoseconds. - Weight::from_parts(28_730_000_u64, 0) + // Minimum execution time: 27_709 nanoseconds. + Weight::from_parts(28_509_000_u64, 0) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -293,8 +293,8 @@ impl WeightInfo for () { // Storage: System Events (r:1 w:1) // Proof Skipped: System Events (max_values: Some(1), max_size: None, mode: Measured) fn update_pot_limits() -> Weight { - // Minimum execution time: 23_030 nanoseconds. - Weight::from_parts(24_060_000_u64, 0) + // Minimum execution time: 22_820 nanoseconds. + Weight::from_parts(23_650_000_u64, 0) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -309,8 +309,8 @@ impl WeightInfo for () { // Storage: System Events (r:1 w:1) // Proof Skipped: System Events (max_values: Some(1), max_size: None, mode: Measured) fn update_sponsorship_type() -> Weight { - // Minimum execution time: 21_620 nanoseconds. - Weight::from_parts(22_440_000_u64, 0) + // Minimum execution time: 21_300 nanoseconds. + Weight::from_parts(22_020_000_u64, 0) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -330,10 +330,10 @@ impl WeightInfo for () { // Proof Skipped: System Events (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `l` is `[1, 1000]`. fn register_users(l: u32, ) -> Weight { - // Minimum execution time: 61_130 nanoseconds. - Weight::from_parts(62_070_000_u64, 0) - // Standard Error: 9_134 - .saturating_add(Weight::from_parts(36_248_627_u64, 0).saturating_mul(l as u64)) + // Minimum execution time: 60_910 nanoseconds. + Weight::from_parts(61_600_000_u64, 0) + // Standard Error: 6_651 + .saturating_add(Weight::from_parts(36_156_400_u64, 0).saturating_mul(l as u64)) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(l as u64))) .saturating_add(RocksDbWeight::get().writes(2_u64)) @@ -357,10 +357,10 @@ impl WeightInfo for () { // Proof Skipped: System Events (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `l` is `[1, 1000]`. fn remove_users(l: u32, ) -> Weight { - // Minimum execution time: 136_150 nanoseconds. - Weight::from_parts(137_760_000_u64, 0) - // Standard Error: 43_995 - .saturating_add(Weight::from_parts(113_547_601_u64, 0).saturating_mul(l as u64)) + // Minimum execution time: 135_290 nanoseconds. + Weight::from_parts(136_720_000_u64, 0) + // Standard Error: 48_135 + .saturating_add(Weight::from_parts(112_231_748_u64, 0).saturating_mul(l as u64)) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(l as u64))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -380,10 +380,10 @@ impl WeightInfo for () { // Proof Skipped: System Events (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `l` is `[1, 1000]`. fn update_users_limits(l: u32, ) -> Weight { - // Minimum execution time: 32_780 nanoseconds. - Weight::from_parts(33_600_000_u64, 0) - // Standard Error: 9_144 - .saturating_add(Weight::from_parts(9_738_582_u64, 0).saturating_mul(l as u64)) + // Minimum execution time: 32_940 nanoseconds. + Weight::from_parts(33_730_000_u64, 0) + // Standard Error: 9_718 + .saturating_add(Weight::from_parts(9_643_418_u64, 0).saturating_mul(l as u64)) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(l as u64))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -406,8 +406,8 @@ impl WeightInfo for () { // Storage: System Events (r:1 w:1) // Proof Skipped: System Events (max_values: Some(1), max_size: None, mode: Measured) fn pre_sponsor() -> Weight { - // Minimum execution time: 89_820 nanoseconds. - Weight::from_parts(91_600_000_u64, 0) + // Minimum execution time: 88_970 nanoseconds. + Weight::from_parts(90_430_000_u64, 0) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -428,8 +428,8 @@ impl WeightInfo for () { // Storage: Sponsorship Pot (r:0 w:1) // Proof: Sponsorship Pot (max_values: None, max_size: Some(117), added: 2592, mode: MaxEncodedLen) fn post_sponsor() -> Weight { - // Minimum execution time: 82_000 nanoseconds. - Weight::from_parts(83_070_000_u64, 0) + // Minimum execution time: 80_690 nanoseconds. + Weight::from_parts(82_260_000_u64, 0) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) }