diff --git a/pallets/universal-dividend/src/benchmarking.rs b/pallets/universal-dividend/src/benchmarking.rs
index 311d0db97c0db5eb5bd28062f965f928c35536ac..99a3929377c4397289c291d295f0e52e75076e77 100644
--- a/pallets/universal-dividend/src/benchmarking.rs
+++ b/pallets/universal-dividend/src/benchmarking.rs
@@ -98,6 +98,22 @@ benchmarks! {
assert!(!Balances::<T>::free_balance(&caller).is_zero());
assert_eq!(Balances::<T>::free_balance(&recipient), transfer_amount);
}
+ on_removed_member {
+ let i in 0..T::MaxPastReeval::get();
+ let caller: T::AccountId = T::AccountIdOf::convert(1).unwrap();
+ CurrentUdIndex::<T>::put(2054u16);
+ T::MembersStorage::insert(&caller, FirstEligibleUd(Some(NonZeroU16::new(CurrentUdIndex::<T>::get() - i as u16).unwrap())))?;
+ let (_, uds_total) = compute_claim_uds::compute_claim_uds(
+ CurrentUdIndex::<T>::get(),
+ CurrentUdIndex::<T>::get() - i as u16,
+ PastReevals::<T>::get().into_iter(),
+ );
+ }: {Pallet::<T>::on_removed_member(CurrentUdIndex::<T>::get() - i as u16, &caller);}
+ verify {
+ if i != 0 {
+ assert_has_event::<T>(Event::<T>::UdsAutoPaidAtRemoval {count: i as u16, total: uds_total, who: caller}.into());
+ }
+ }
impl_benchmark_test_suite!(
Pallet,
diff --git a/pallets/universal-dividend/src/lib.rs b/pallets/universal-dividend/src/lib.rs
index e751f34dad9ccb786de6cb84cd9017d865aea377..09ba8511dc786cd3f8e534fbec2dc622c144dce1 100644
--- a/pallets/universal-dividend/src/lib.rs
+++ b/pallets/universal-dividend/src/lib.rs
@@ -447,9 +447,9 @@ pub mod pallet {
total: uds_total,
who: who.clone(),
});
- T::DbWeight::get().reads_writes(2, 1)
+ <T as pallet::Config>::WeightInfo::on_removed_member(first_ud_index as u32)
} else {
- T::DbWeight::get().reads(1)
+ <T as pallet::Config>::WeightInfo::on_removed_member(0)
}
}
}
diff --git a/pallets/universal-dividend/src/weights.rs b/pallets/universal-dividend/src/weights.rs
index f4f7ccdc11fe5dd60ca55acb90dec86b43a057f7..75eb80a58898d4252a480c1b6e3a77d7a8cd0629 100644
--- a/pallets/universal-dividend/src/weights.rs
+++ b/pallets/universal-dividend/src/weights.rs
@@ -23,6 +23,7 @@ pub trait WeightInfo {
fn claim_uds(i: u32) -> Weight;
fn transfer_ud() -> Weight;
fn transfer_ud_keep_alive() -> Weight;
+ fn on_removed_member(i: u32) -> Weight;
}
// Insecure weights implementation, use it for tests only!
@@ -50,4 +51,11 @@ impl WeightInfo for () {
.saturating_add(RocksDbWeight::get().reads(2))
.saturating_add(RocksDbWeight::get().writes(2))
}
+ fn on_removed_member(i: u32) -> Weight {
+ Weight::from_parts(32_514_000, 0)
+ // Standard Error: 32_000
+ .saturating_add(Weight::from_parts(8_000, 0).saturating_mul(i as u64))
+ .saturating_add(RocksDbWeight::get().reads(4))
+ .saturating_add(RocksDbWeight::get().writes(1))
+ }
}
diff --git a/runtime/common/src/weights/pallet_universal_dividend.rs b/runtime/common/src/weights/pallet_universal_dividend.rs
index d7eb897eb77dc8910e0d8ea69926484916e83f4e..8ba14ff1407ff88a4cc4747e0f206afc31cea824 100644
--- a/runtime/common/src/weights/pallet_universal_dividend.rs
+++ b/runtime/common/src/weights/pallet_universal_dividend.rs
@@ -50,8 +50,8 @@ impl<T: frame_system::Config> pallet_universal_dividend::WeightInfo for WeightIn
// Proof Size summary in bytes:
// Measured: `644`
// Estimated: `4109`
- // Minimum execution time: 16_554_000 picoseconds.
- Weight::from_parts(18_469_192, 0)
+ // Minimum execution time: 16_776_000 picoseconds.
+ Weight::from_parts(18_197_968, 0)
.saturating_add(Weight::from_parts(0, 4109))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
@@ -66,8 +66,8 @@ impl<T: frame_system::Config> pallet_universal_dividend::WeightInfo for WeightIn
// Proof Size summary in bytes:
// Measured: `93`
// Estimated: `3591`
- // Minimum execution time: 23_431_000 picoseconds.
- Weight::from_parts(23_871_000, 0)
+ // Minimum execution time: 22_683_000 picoseconds.
+ Weight::from_parts(23_755_000, 0)
.saturating_add(Weight::from_parts(0, 3591))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
@@ -82,10 +82,29 @@ impl<T: frame_system::Config> pallet_universal_dividend::WeightInfo for WeightIn
// Proof Size summary in bytes:
// Measured: `93`
// Estimated: `3591`
- // Minimum execution time: 16_815_000 picoseconds.
- Weight::from_parts(17_432_000, 0)
+ // Minimum execution time: 16_789_000 picoseconds.
+ Weight::from_parts(17_565_000, 0)
.saturating_add(Weight::from_parts(0, 3591))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
+ /// Storage: UniversalDividend CurrentUdIndex (r:1 w:0)
+ /// Proof: UniversalDividend CurrentUdIndex (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen)
+ /// Storage: UniversalDividend PastReevals (r:1 w:0)
+ /// Proof: UniversalDividend PastReevals (max_values: Some(1), max_size: Some(1602), added: 2097, mode: MaxEncodedLen)
+ /// Storage: System Account (r:1 w:1)
+ /// Proof: System Account (max_values: None, max_size: Some(126), added: 2601, mode: MaxEncodedLen)
+ /// The range of component `i` is `[0, 160]`.
+ fn on_removed_member(i: u32, ) -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `215`
+ // Estimated: `3591`
+ // Minimum execution time: 2_717_000 picoseconds.
+ Weight::from_parts(9_608_158, 0)
+ .saturating_add(Weight::from_parts(0, 3591))
+ // Standard Error: 975
+ .saturating_add(Weight::from_parts(4_370, 0).saturating_mul(i.into()))
+ .saturating_add(T::DbWeight::get().reads(3))
+ .saturating_add(T::DbWeight::get().writes(1))
+ }
}