mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 20:31:13 +00:00
Renames of Trait to Config in README.md, weight templates and few minor ones (#7636)
* manual rename * renamse in README.md * fix template
This commit is contained in:
committed by
GitHub
parent
35efc8e4b0
commit
15b0dece54
@@ -24,22 +24,22 @@ mod mock;
|
||||
use sp_std::prelude::*;
|
||||
use sp_std::vec;
|
||||
|
||||
use frame_system::{RawOrigin, Module as System, Config as SystemTrait};
|
||||
use frame_system::{RawOrigin, Module as System, Config as SystemConfig};
|
||||
use frame_benchmarking::{benchmarks, account};
|
||||
use frame_support::traits::{Currency, OnInitialize};
|
||||
|
||||
use sp_runtime::{Perbill, traits::{Convert, StaticLookup, Saturating, UniqueSaturatedInto}};
|
||||
use sp_staking::offence::{ReportOffence, Offence, OffenceDetails};
|
||||
|
||||
use pallet_balances::{Config as BalancesTrait};
|
||||
use pallet_balances::{Config as BalancesConfig};
|
||||
use pallet_babe::BabeEquivocationOffence;
|
||||
use pallet_grandpa::{GrandpaEquivocationOffence, GrandpaTimeSlot};
|
||||
use pallet_im_online::{Config as ImOnlineTrait, Module as ImOnline, UnresponsivenessOffence};
|
||||
use pallet_offences::{Config as OffencesTrait, Module as Offences};
|
||||
use pallet_session::historical::{Config as HistoricalTrait, IdentificationTuple};
|
||||
use pallet_session::{Config as SessionTrait, SessionManager};
|
||||
use pallet_im_online::{Config as ImOnlineConfig, Module as ImOnline, UnresponsivenessOffence};
|
||||
use pallet_offences::{Config as OffencesConfig, Module 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 StakingTrait, RewardDestination, ValidatorPrefs,
|
||||
Module as Staking, Config as StakingConfig, RewardDestination, ValidatorPrefs,
|
||||
Exposure, IndividualExposure, ElectionStatus, MAX_NOMINATIONS, Event as StakingEvent
|
||||
};
|
||||
|
||||
@@ -53,32 +53,32 @@ const MAX_DEFERRED_OFFENCES: u32 = 100;
|
||||
pub struct Module<T: Config>(Offences<T>);
|
||||
|
||||
pub trait Config:
|
||||
SessionTrait
|
||||
+ StakingTrait
|
||||
+ OffencesTrait
|
||||
+ ImOnlineTrait
|
||||
+ HistoricalTrait
|
||||
+ BalancesTrait
|
||||
SessionConfig
|
||||
+ StakingConfig
|
||||
+ OffencesConfig
|
||||
+ ImOnlineConfig
|
||||
+ HistoricalConfig
|
||||
+ BalancesConfig
|
||||
+ IdTupleConvert<Self>
|
||||
{}
|
||||
|
||||
/// A helper trait to make sure we can convert `IdentificationTuple` coming from historical
|
||||
/// and the one required by offences.
|
||||
pub trait IdTupleConvert<T: HistoricalTrait + OffencesTrait> {
|
||||
pub trait IdTupleConvert<T: HistoricalConfig + OffencesConfig> {
|
||||
/// Convert identification tuple from `historical` trait to the one expected by `offences`.
|
||||
fn convert(id: IdentificationTuple<T>) -> <T as OffencesTrait>::IdentificationTuple;
|
||||
fn convert(id: IdentificationTuple<T>) -> <T as OffencesConfig>::IdentificationTuple;
|
||||
}
|
||||
|
||||
impl<T: HistoricalTrait + OffencesTrait> IdTupleConvert<T> for T where
|
||||
<T as OffencesTrait>::IdentificationTuple: From<IdentificationTuple<T>>
|
||||
impl<T: HistoricalConfig + OffencesConfig> IdTupleConvert<T> for T where
|
||||
<T as OffencesConfig>::IdentificationTuple: From<IdentificationTuple<T>>
|
||||
{
|
||||
fn convert(id: IdentificationTuple<T>) -> <T as OffencesTrait>::IdentificationTuple {
|
||||
fn convert(id: IdentificationTuple<T>) -> <T as OffencesConfig>::IdentificationTuple {
|
||||
id.into()
|
||||
}
|
||||
}
|
||||
|
||||
type LookupSourceOf<T> = <<T as SystemTrait>::Lookup as StaticLookup>::Source;
|
||||
type BalanceOf<T> = <<T as StakingTrait>::Currency as Currency<<T as SystemTrait>::AccountId>>::Balance;
|
||||
type LookupSourceOf<T> = <<T as SystemConfig>::Lookup as StaticLookup>::Source;
|
||||
type BalanceOf<T> = <<T as StakingConfig>::Currency as Currency<<T as SystemConfig>::AccountId>>::Balance;
|
||||
|
||||
struct Offender<T: Config> {
|
||||
pub controller: T::AccountId,
|
||||
@@ -165,10 +165,10 @@ fn make_offenders<T: Config>(num_offenders: u32, num_nominators: u32) -> Result<
|
||||
|
||||
let id_tuples = offenders.iter()
|
||||
.map(|offender|
|
||||
<T as SessionTrait>::ValidatorIdOf::convert(offender.controller.clone())
|
||||
<T as SessionConfig>::ValidatorIdOf::convert(offender.controller.clone())
|
||||
.expect("failed to get validator id from account id"))
|
||||
.map(|validator_id|
|
||||
<T as HistoricalTrait>::FullIdentificationOf::convert(validator_id.clone())
|
||||
<T as HistoricalConfig>::FullIdentificationOf::convert(validator_id.clone())
|
||||
.map(|full_id| (validator_id, full_id))
|
||||
.expect("failed to convert validator id to full identification"))
|
||||
.collect::<Vec<IdentificationTuple<T>>>();
|
||||
@@ -176,7 +176,7 @@ fn make_offenders<T: Config>(num_offenders: u32, num_nominators: u32) -> Result<
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn check_events<T: Config, I: Iterator<Item = <T as SystemTrait>::Event>>(expected: I) {
|
||||
fn check_events<T: Config, I: Iterator<Item = <T as SystemConfig>::Event>>(expected: I) {
|
||||
let events = System::<T>::events() .into_iter()
|
||||
.map(|frame_system::EventRecord { event, .. }| event).collect::<Vec<_>>();
|
||||
let expected = expected.collect::<Vec<_>>();
|
||||
@@ -235,7 +235,7 @@ benchmarks! {
|
||||
};
|
||||
assert_eq!(System::<T>::event_count(), 0);
|
||||
}: {
|
||||
let _ = <T as ImOnlineTrait>::ReportUnresponsiveness::report_offence(
|
||||
let _ = <T as ImOnlineConfig>::ReportUnresponsiveness::report_offence(
|
||||
reporters.clone(),
|
||||
offence
|
||||
);
|
||||
@@ -250,14 +250,14 @@ benchmarks! {
|
||||
.flat_map(|offender| {
|
||||
core::iter::once(offender.stash).chain(offender.nominator_stashes.into_iter())
|
||||
})
|
||||
.map(|stash| <T as StakingTrait>::Event::from(
|
||||
.map(|stash| <T as StakingConfig>::Event::from(
|
||||
StakingEvent::<T>::Slash(stash, BalanceOf::<T>::from(slash_amount))
|
||||
))
|
||||
.collect::<Vec<_>>();
|
||||
let reward_events = reporters.into_iter()
|
||||
.flat_map(|reporter| vec![
|
||||
frame_system::Event::<T>::NewAccount(reporter.clone()).into(),
|
||||
<T as BalancesTrait>::Event::from(
|
||||
<T as BalancesConfig>::Event::from(
|
||||
pallet_balances::Event::<T>::Endowed(reporter, (reward_amount / r).into())
|
||||
).into()
|
||||
]);
|
||||
@@ -272,7 +272,7 @@ benchmarks! {
|
||||
.chain(slash_events.into_iter().map(Into::into))
|
||||
.chain(reward_events)
|
||||
.chain(slash_rest.into_iter().map(Into::into))
|
||||
.chain(std::iter::once(<T as OffencesTrait>::Event::from(
|
||||
.chain(std::iter::once(<T as OffencesConfig>::Event::from(
|
||||
pallet_offences::Event::Offence(
|
||||
UnresponsivenessOffence::<T>::ID,
|
||||
0_u32.to_le_bytes().to_vec(),
|
||||
|
||||
Reference in New Issue
Block a user