Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frame/babe/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use sp_runtime::{
use frame_system::InitKind;
use frame_support::{
parameter_types,
traits::{KeyOwnerProofSystem, OnInitialize},
traits::{KeyOwnerProofSystem, OnInitialize, GenesisBuild},
};
use sp_io;
use sp_core::{H256, U256, crypto::{IsWrappedBy, KeyTypeId, Pair}};
Expand Down
2 changes: 1 addition & 1 deletion frame/grandpa/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use ::grandpa as finality_grandpa;
use codec::Encode;
use frame_support::{
parameter_types,
traits::{KeyOwnerProofSystem, OnFinalize, OnInitialize},
traits::{KeyOwnerProofSystem, OnFinalize, OnInitialize, GenesisBuild},
};
use pallet_staking::EraIndex;
use sp_core::{crypto::KeyTypeId, H256};
Expand Down
2 changes: 1 addition & 1 deletion frame/offences/benchmarking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use pallet_offences::{Config as OffencesConfig, Pallet as Offences};
use pallet_session::historical::{Config as HistoricalConfig, IdentificationTuple};
use pallet_session::{Config as SessionConfig, SessionManager};
use pallet_staking::{
Module as Staking, Config as StakingConfig, RewardDestination, ValidatorPrefs, Exposure,
Pallet as Staking, Config as StakingConfig, RewardDestination, ValidatorPrefs, Exposure,
IndividualExposure, Event as StakingEvent,
};

Expand Down
9 changes: 4 additions & 5 deletions frame/session/benchmarking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ use sp_std::vec;
use frame_benchmarking::{benchmarks, impl_benchmark_test_suite};
use frame_support::{
codec::Decode,
storage::StorageValue,
traits::{KeyOwnerProofSystem, OnInitialize},
};
use frame_system::RawOrigin;
Expand Down Expand Up @@ -59,7 +58,7 @@ benchmarks! {
false,
RewardDestination::Staked,
)?;
let v_controller = pallet_staking::Module::<T>::bonded(&v_stash).ok_or("not stash")?;
let v_controller = pallet_staking::Pallet::<T>::bonded(&v_stash).ok_or("not stash")?;
let keys = T::Keys::default();
let proof: Vec<u8> = vec![0,1,2,3];
// Whitelist controller account from further DB operations.
Expand All @@ -75,7 +74,7 @@ benchmarks! {
false,
RewardDestination::Staked
)?;
let v_controller = pallet_staking::Module::<T>::bonded(&v_stash).ok_or("not stash")?;
let v_controller = pallet_staking::Pallet::<T>::bonded(&v_stash).ok_or("not stash")?;
let keys = T::Keys::default();
let proof: Vec<u8> = vec![0,1,2,3];
Session::<T>::set_keys(RawOrigin::Signed(v_controller.clone()).into(), keys, proof)?;
Expand Down Expand Up @@ -125,7 +124,7 @@ fn check_membership_proof_setup<T: Config>(
(sp_runtime::KeyTypeId, &'static [u8; 32]),
sp_session::MembershipProof,
) {
pallet_staking::ValidatorCount::put(n);
pallet_staking::ValidatorCount::<T>::put(n);

// create validators and set random session keys
for (n, who) in create_validators::<T>(n, 1000)
Expand All @@ -137,7 +136,7 @@ fn check_membership_proof_setup<T: Config>(
use rand::SeedableRng;

let validator = T::Lookup::lookup(who).unwrap();
let controller = pallet_staking::Module::<T>::bonded(validator).unwrap();
let controller = pallet_staking::Pallet::<T>::bonded(validator).unwrap();

let keys = {
let mut keys = [0u8; 128];
Expand Down
34 changes: 17 additions & 17 deletions frame/staking/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//! Staking pallet benchmarking.

use super::*;
use crate::Module as Staking;
use crate::Pallet as Staking;
use testing_utils::*;

use sp_runtime::traits::One;
Expand Down Expand Up @@ -88,7 +88,7 @@ pub fn create_validator_with_nominators<T: Config>(
}
}

ValidatorCount::put(1);
ValidatorCount::<T>::put(1);

// Start a new Era
let new_validators = Staking::<T>::new_era(SessionIndex::one()).unwrap();
Expand All @@ -102,7 +102,7 @@ pub fn create_validator_with_nominators<T: Config>(
individual: points_individual.into_iter().collect(),
};

let current_era = CurrentEra::get().unwrap();
let current_era = CurrentEra::<T>::get().unwrap();
ErasRewardPoints::<T>::insert(current_era, reward);

// Create reward pool
Expand Down Expand Up @@ -164,7 +164,7 @@ benchmarks! {
add_slashing_spans::<T>(&stash, s);
let amount = T::Currency::minimum_balance() * 5u32.into(); // Half of total
Staking::<T>::unbond(RawOrigin::Signed(controller.clone()).into(), amount)?;
CurrentEra::put(EraIndex::max_value());
CurrentEra::<T>::put(EraIndex::max_value());
let ledger = Ledger::<T>::get(&controller).ok_or("ledger not created before")?;
let original_total: BalanceOf<T> = ledger.total;
whitelist_account!(controller);
Expand All @@ -183,7 +183,7 @@ benchmarks! {
add_slashing_spans::<T>(&stash, s);
let amount = T::Currency::minimum_balance() * 10u32.into();
Staking::<T>::unbond(RawOrigin::Signed(controller.clone()).into(), amount)?;
CurrentEra::put(EraIndex::max_value());
CurrentEra::<T>::put(EraIndex::max_value());
let ledger = Ledger::<T>::get(&controller).ok_or("ledger not created before")?;
let original_total: BalanceOf<T> = ledger.total;
whitelist_account!(controller);
Expand Down Expand Up @@ -303,17 +303,17 @@ benchmarks! {
let validator_count = MAX_VALIDATORS;
}: _(RawOrigin::Root, validator_count)
verify {
assert_eq!(ValidatorCount::get(), validator_count);
assert_eq!(ValidatorCount::<T>::get(), validator_count);
}

force_no_eras {}: _(RawOrigin::Root)
verify { assert_eq!(ForceEra::get(), Forcing::ForceNone); }
verify { assert_eq!(ForceEra::<T>::get(), Forcing::ForceNone); }

force_new_era {}: _(RawOrigin::Root)
verify { assert_eq!(ForceEra::get(), Forcing::ForceNew); }
verify { assert_eq!(ForceEra::<T>::get(), Forcing::ForceNew); }

force_new_era_always {}: _(RawOrigin::Root)
verify { assert_eq!(ForceEra::get(), Forcing::ForceAlways); }
verify { assert_eq!(ForceEra::<T>::get(), Forcing::ForceAlways); }

// Worst case scenario, the list of invulnerables is very long.
set_invulnerables {
Expand Down Expand Up @@ -361,7 +361,7 @@ benchmarks! {
RewardDestination::Controller,
)?;

let current_era = CurrentEra::get().unwrap();
let current_era = CurrentEra::<T>::get().unwrap();
// set the commission for this particular era as well.
<ErasValidatorPrefs<T>>::insert(current_era, validator.clone(), <Staking<T>>::validators(&validator));

Expand Down Expand Up @@ -394,7 +394,7 @@ benchmarks! {
RewardDestination::Staked,
)?;

let current_era = CurrentEra::get().unwrap();
let current_era = CurrentEra::<T>::get().unwrap();
// set the commission for this particular era as well.
<ErasValidatorPrefs<T>>::insert(current_era, validator.clone(), <Staking<T>>::validators(&validator));

Expand Down Expand Up @@ -444,20 +444,20 @@ benchmarks! {

set_history_depth {
let e in 1 .. 100;
HistoryDepth::put(e);
CurrentEra::put(e);
HistoryDepth::<T>::put(e);
CurrentEra::<T>::put(e);
for i in 0 .. e {
<ErasStakers<T>>::insert(i, T::AccountId::default(), Exposure::<T::AccountId, BalanceOf<T>>::default());
<ErasStakersClipped<T>>::insert(i, T::AccountId::default(), Exposure::<T::AccountId, BalanceOf<T>>::default());
<ErasValidatorPrefs<T>>::insert(i, T::AccountId::default(), ValidatorPrefs::default());
<ErasValidatorReward<T>>::insert(i, BalanceOf::<T>::one());
<ErasRewardPoints<T>>::insert(i, EraRewardPoints::<T::AccountId>::default());
<ErasTotalStake<T>>::insert(i, BalanceOf::<T>::one());
ErasStartSessionIndex::insert(i, i);
ErasStartSessionIndex::<T>::insert(i, i);
}
}: _(RawOrigin::Root, EraIndex::zero(), u32::max_value())
verify {
assert_eq!(HistoryDepth::get(), 0);
assert_eq!(HistoryDepth::<T>::get(), 0);
}

reap_stash {
Expand Down Expand Up @@ -503,7 +503,7 @@ benchmarks! {
let new_validators = Staking::<T>::new_era(SessionIndex::one()).unwrap();
assert!(new_validators.len() == v as usize);

let current_era = CurrentEra::get().unwrap();
let current_era = CurrentEra::<T>::get().unwrap();
let mut points_total = 0;
let mut points_individual = Vec::new();
let mut payout_calls_arg = Vec::new();
Expand Down Expand Up @@ -636,7 +636,7 @@ mod tests {

assert_eq!(nominators.len() as u32, n);

let current_era = CurrentEra::get().unwrap();
let current_era = CurrentEra::<Test>::get().unwrap();

let original_free_balance = Balances::free_balance(&validator_stash);
assert_ok!(Staking::payout_stakers(Origin::signed(1337), validator_stash, current_era));
Expand Down
Loading