Skip to content
Snippets Groups Projects
Commit 7bd95f9a authored by Bernardo Cardoso's avatar Bernardo Cardoso
Browse files

Staking benchmarks fixes

parent 61ed82b4
No related branches found
No related tags found
No related merge requests found
Pipeline #258083 failed
......@@ -873,6 +873,58 @@ benchmarks! {
assert_eq!(MinCommission::<T>::get(), Perbill::from_percent(100));
}
set_cmix_id {
let stash = create_funded_user::<T>("stash", USER_SEED, 100);
let controller = create_funded_user::<T>("controller", USER_SEED, 100);
let controller_lookup = T::Lookup::unlookup(controller.clone());
let amount = T::Currency::minimum_balance() * 10u32.into();
let cmix_id = T::Hashing::hash(&mut USER_SEED.to_be_bytes());
Staking::<T>::bond(
RawOrigin::Signed(stash.clone()).into(),
controller_lookup,
amount,
None,
)?;
whitelist_account!(stash);
}: _(RawOrigin::Signed(stash), cmix_id)
verify {
assert!(CmixIds::<T>::contains_key(&cmix_id));
assert_eq!(Ledger::<T>::get(&controller).unwrap().cmix_id, Some(cmix_id));
}
transfer_cmix_id {
// Create first stash/controller pair
let stash = create_funded_user::<T>("stash", USER_SEED, 100);
let controller = create_funded_user::<T>("controller", USER_SEED, 100);
let controller_lookup = T::Lookup::unlookup(controller.clone());
let amount = T::Currency::minimum_balance() * 10u32.into();
let cmix_id = T::Hashing::hash(&mut USER_SEED.to_be_bytes());
Staking::<T>::bond(
RawOrigin::Signed(stash.clone()).into(),
controller_lookup,
amount.clone(),
Some(cmix_id),
)?;
assert!(CmixIds::<T>::contains_key(&cmix_id));
assert_eq!(Ledger::<T>::get(&controller).unwrap().cmix_id, Some(cmix_id));
// Create second stash/controller pair
let stash2 = create_funded_user::<T>("stash2", USER_SEED, 100);
let controller2 = create_funded_user::<T>("controller2", USER_SEED, 100);
let controller_lookup2 = T::Lookup::unlookup(controller2.clone());
Staking::<T>::bond(
RawOrigin::Signed(stash2.clone()).into(),
controller_lookup2,
amount,
None,
)?;
whitelist_account!(stash);
}: _(RawOrigin::Signed(stash), stash2)
verify {
assert!(CmixIds::<T>::contains_key(&cmix_id));
assert!(Ledger::<T>::get(&controller).unwrap().cmix_id.is_none());
assert_eq!(Ledger::<T>::get(&controller2).unwrap().cmix_id, Some(cmix_id));
}
impl_benchmark_test_suite!(
Staking,
crate::mock::ExtBuilder::default().has_stakers(true),
......
......@@ -1771,7 +1771,7 @@ pub mod pallet {
/// ## Complexity
/// - Independent of the arguments. Moderate complexity.
/// - O(1)
/// - Two Reads
/// - Three Reads
/// - Two writes
#[pallet::call_index(24)]
#[pallet::weight(T::WeightInfo::set_cmix_id())]
......
......@@ -57,7 +57,6 @@ pub trait WeightInfo {
fn kick(k: u32, ) -> Weight;
fn nominate(n: u32, ) -> Weight;
fn chill() -> Weight;
fn set_payee() -> Weight;
fn set_controller() -> Weight;
fn set_validator_count() -> Weight;
fn force_no_eras() -> Weight;
......@@ -66,7 +65,6 @@ pub trait WeightInfo {
fn set_invulnerables(v: u32, ) -> Weight;
fn force_unstake(s: u32, ) -> Weight;
fn cancel_deferred_slash(s: u32, ) -> Weight;
fn payout_stakers_dead_controller(n: u32, ) -> Weight;
fn payout_stakers_alive_staked(n: u32, ) -> Weight;
fn rebond(l: u32, ) -> Weight;
fn reap_stash(s: u32, ) -> Weight;
......@@ -320,19 +318,6 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
.saturating_add(T::DbWeight::get().reads(8_u64))
.saturating_add(T::DbWeight::get().writes(6_u64))
}
/// Storage: Staking Ledger (r:1 w:0)
/// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen)
/// Storage: Staking Payee (r:0 w:1)
/// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen)
fn set_payee() -> Weight {
// Proof Size summary in bytes:
// Measured: `840`
// Estimated: `3566`
// Minimum execution time: 13_399 nanoseconds.
Weight::from_parts(13_567_000, 3566)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// Storage: Staking Bonded (r:1 w:1)
/// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen)
/// Storage: Staking Ledger (r:2 w:2)
......@@ -459,39 +444,6 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// Proof: Staking ErasValidatorReward (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)
/// Storage: Staking Bonded (r:257 w:0)
/// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen)
/// Storage: Staking Ledger (r:1 w:1)
/// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen)
/// Storage: Staking ErasStakersClipped (r:1 w:0)
/// Proof Skipped: Staking ErasStakersClipped (max_values: None, max_size: None, mode: Measured)
/// Storage: Staking ErasRewardPoints (r:1 w:0)
/// Proof Skipped: Staking ErasRewardPoints (max_values: None, max_size: None, mode: Measured)
/// Storage: Staking ErasValidatorPrefs (r:1 w:0)
/// Proof: Staking ErasValidatorPrefs (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
/// Storage: Staking Payee (r:257 w:0)
/// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen)
/// Storage: System Account (r:257 w:257)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
/// The range of component `n` is `[0, 256]`.
fn payout_stakers_dead_controller(n: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `20345 + n * (143 ±0)`
// Estimated: `54756 + n * (8024 ±1)`
// Minimum execution time: 73_652 nanoseconds.
Weight::from_parts(127_839_483, 54756)
// Standard Error: 14_195
.saturating_add(Weight::from_parts(21_932_079, 0).saturating_mul(n.into()))
.saturating_add(T::DbWeight::get().reads(9_u64))
.saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(n.into())))
.saturating_add(T::DbWeight::get().writes(2_u64))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into())))
.saturating_add(Weight::from_parts(0, 8024).saturating_mul(n.into()))
}
/// Storage: Staking CurrentEra (r:1 w:0)
/// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
/// Storage: Staking ErasValidatorReward (r:1 w:0)
/// Proof: Staking ErasValidatorReward (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)
/// Storage: Staking Bonded (r:257 w:0)
/// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen)
/// Storage: Staking Ledger (r:257 w:257)
/// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen)
/// Storage: Staking ErasStakersClipped (r:1 w:0)
......@@ -1032,19 +984,6 @@ impl WeightInfo for () {
.saturating_add(RocksDbWeight::get().reads(8_u64))
.saturating_add(RocksDbWeight::get().writes(6_u64))
}
/// Storage: Staking Ledger (r:1 w:0)
/// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen)
/// Storage: Staking Payee (r:0 w:1)
/// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen)
fn set_payee() -> Weight {
// Proof Size summary in bytes:
// Measured: `840`
// Estimated: `3566`
// Minimum execution time: 13_399 nanoseconds.
Weight::from_parts(13_567_000, 3566)
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
/// Storage: Staking Bonded (r:1 w:1)
/// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen)
/// Storage: Staking Ledger (r:2 w:2)
......@@ -1171,39 +1110,6 @@ impl WeightInfo for () {
/// Proof: Staking ErasValidatorReward (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)
/// Storage: Staking Bonded (r:257 w:0)
/// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen)
/// Storage: Staking Ledger (r:1 w:1)
/// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen)
/// Storage: Staking ErasStakersClipped (r:1 w:0)
/// Proof Skipped: Staking ErasStakersClipped (max_values: None, max_size: None, mode: Measured)
/// Storage: Staking ErasRewardPoints (r:1 w:0)
/// Proof Skipped: Staking ErasRewardPoints (max_values: None, max_size: None, mode: Measured)
/// Storage: Staking ErasValidatorPrefs (r:1 w:0)
/// Proof: Staking ErasValidatorPrefs (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
/// Storage: Staking Payee (r:257 w:0)
/// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen)
/// Storage: System Account (r:257 w:257)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
/// The range of component `n` is `[0, 256]`.
fn payout_stakers_dead_controller(n: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `20345 + n * (143 ±0)`
// Estimated: `54756 + n * (8024 ±1)`
// Minimum execution time: 73_652 nanoseconds.
Weight::from_parts(127_839_483, 54756)
// Standard Error: 14_195
.saturating_add(Weight::from_parts(21_932_079, 0).saturating_mul(n.into()))
.saturating_add(RocksDbWeight::get().reads(9_u64))
.saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(n.into())))
.saturating_add(RocksDbWeight::get().writes(2_u64))
.saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(n.into())))
.saturating_add(Weight::from_parts(0, 8024).saturating_mul(n.into()))
}
/// Storage: Staking CurrentEra (r:1 w:0)
/// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
/// Storage: Staking ErasValidatorReward (r:1 w:0)
/// Proof: Staking ErasValidatorReward (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)
/// Storage: Staking Bonded (r:257 w:0)
/// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen)
/// Storage: Staking Ledger (r:257 w:257)
/// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen)
/// Storage: Staking ErasStakersClipped (r:1 w:0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment