19
19
//!
20
20
//! The Staking module is used to manage funds at stake by network maintainers.
21
21
//!
22
- //! - [`staking::Trait `](./trait.Trait .html)
22
+ //! - [`staking::Config `](./trait.Config .html)
23
23
//! - [`Call`](./enum.Call.html)
24
24
//! - [`Module`](./struct.Module.html)
25
25
//!
107
107
//!
108
108
//! Rewards must be claimed for each era before it gets too old by `$HISTORY_DEPTH` using the
109
109
//! `payout_stakers` call. Any account can call `payout_stakers`, which pays the reward to the
110
- //! validator as well as its nominators. Only the [`Trait ::MaxNominatorRewardedPerValidator`]
110
+ //! validator as well as its nominators. Only the [`Config ::MaxNominatorRewardedPerValidator`]
111
111
//! biggest stakers can claim their reward. This is to limit the i/o cost to mutate storage for each
112
112
//! nominator's account.
113
113
//!
154
154
//! use frame_system::ensure_signed;
155
155
//! use pallet_staking::{self as staking};
156
156
//!
157
- //! pub trait Trait : staking::Trait {}
157
+ //! pub trait Config : staking::Config {}
158
158
//!
159
159
//! decl_module! {
160
- //! pub struct Module<T: Trait > for enum Call where origin: T::Origin {
160
+ //! pub struct Module<T: Config > for enum Call where origin: T::Origin {
161
161
//! /// Reward a validator.
162
162
//! #[weight = 0]
163
163
//! pub fn reward_myself(origin) -> dispatch::DispatchResult {
175
175
//! ### Era payout
176
176
//!
177
177
//! The era payout is computed using yearly inflation curve defined at
178
- //! [`T::RewardCurve`](./trait.Trait .html#associatedtype.RewardCurve) as such:
178
+ //! [`T::RewardCurve`](./trait.Config .html#associatedtype.RewardCurve) as such:
179
179
//!
180
180
//! ```nocompile
181
181
//! staker_payout = yearly_inflation(npos_token_staked / total_tokens) * total_tokens / era_per_year
186
186
//! remaining_payout = max_yearly_inflation * total_tokens / era_per_year - staker_payout
187
187
//! ```
188
188
//! The remaining reward is send to the configurable end-point
189
- //! [`T::RewardRemainder`](./trait.Trait .html#associatedtype.RewardRemainder).
189
+ //! [`T::RewardRemainder`](./trait.Config .html#associatedtype.RewardRemainder).
190
190
//!
191
191
//! ### Reward Calculation
192
192
//!
232
232
//!
233
233
//! The controller account can free a portion (or all) of the funds using the
234
234
//! [`unbond`](enum.Call.html#variant.unbond) call. Note that the funds are not immediately
235
- //! accessible. Instead, a duration denoted by [`BondingDuration`](./trait.Trait .html#associatedtype.BondingDuration)
235
+ //! accessible. Instead, a duration denoted by [`BondingDuration`](./trait.Config .html#associatedtype.BondingDuration)
236
236
//! (in number of eras) must pass until the funds can actually be removed. Once the
237
237
//! `BondingDuration` is over, the [`withdraw_unbonded`](./enum.Call.html#variant.withdraw_unbonded)
238
238
//! call can be used to actually withdraw the funds.
@@ -385,12 +385,12 @@ pub type OffchainAccuracy = PerU16;
385
385
386
386
/// The balance type of this module.
387
387
pub type BalanceOf < T > =
388
- <<T as Trait >:: Currency as Currency < <T as frame_system:: Trait >:: AccountId > >:: Balance ;
388
+ <<T as Config >:: Currency as Currency < <T as frame_system:: Config >:: AccountId > >:: Balance ;
389
389
390
390
type PositiveImbalanceOf < T > =
391
- <<T as Trait >:: Currency as Currency < <T as frame_system:: Trait >:: AccountId > >:: PositiveImbalance ;
391
+ <<T as Config >:: Currency as Currency < <T as frame_system:: Config >:: AccountId > >:: PositiveImbalance ;
392
392
type NegativeImbalanceOf < T > =
393
- <<T as Trait >:: Currency as Currency < <T as frame_system:: Trait >:: AccountId > >:: NegativeImbalance ;
393
+ <<T as Config >:: Currency as Currency < <T as frame_system:: Config >:: AccountId > >:: NegativeImbalance ;
394
394
395
395
/// Information regarding the active era (era in used in session).
396
396
#[ derive( Encode , Decode , RuntimeDebug ) ]
@@ -732,8 +732,8 @@ impl<BlockNumber> Default for ElectionStatus<BlockNumber> {
732
732
733
733
/// Means for interacting with a specialized version of the `session` trait.
734
734
///
735
- /// This is needed because `Staking` sets the `ValidatorIdOf` of the `pallet_session::Trait `
736
- pub trait SessionInterface < AccountId > : frame_system:: Trait {
735
+ /// This is needed because `Staking` sets the `ValidatorIdOf` of the `pallet_session::Config `
736
+ pub trait SessionInterface < AccountId > : frame_system:: Config {
737
737
/// Disable a given validator by stash ID.
738
738
///
739
739
/// Returns `true` if new era should be forced at the end of this session.
@@ -746,22 +746,22 @@ pub trait SessionInterface<AccountId>: frame_system::Trait {
746
746
fn prune_historical_up_to ( up_to : SessionIndex ) ;
747
747
}
748
748
749
- impl < T : Trait > SessionInterface < <T as frame_system:: Trait >:: AccountId > for T where
750
- T : pallet_session:: Trait < ValidatorId = <T as frame_system:: Trait >:: AccountId > ,
751
- T : pallet_session:: historical:: Trait <
752
- FullIdentification = Exposure < <T as frame_system:: Trait >:: AccountId , BalanceOf < T > > ,
749
+ impl < T : Config > SessionInterface < <T as frame_system:: Config >:: AccountId > for T where
750
+ T : pallet_session:: Config < ValidatorId = <T as frame_system:: Config >:: AccountId > ,
751
+ T : pallet_session:: historical:: Config <
752
+ FullIdentification = Exposure < <T as frame_system:: Config >:: AccountId , BalanceOf < T > > ,
753
753
FullIdentificationOf = ExposureOf < T > ,
754
754
> ,
755
- T :: SessionHandler : pallet_session:: SessionHandler < <T as frame_system:: Trait >:: AccountId > ,
756
- T :: SessionManager : pallet_session:: SessionManager < <T as frame_system:: Trait >:: AccountId > ,
755
+ T :: SessionHandler : pallet_session:: SessionHandler < <T as frame_system:: Config >:: AccountId > ,
756
+ T :: SessionManager : pallet_session:: SessionManager < <T as frame_system:: Config >:: AccountId > ,
757
757
T :: ValidatorIdOf :
758
- Convert < <T as frame_system:: Trait >:: AccountId , Option < <T as frame_system:: Trait >:: AccountId > > ,
758
+ Convert < <T as frame_system:: Config >:: AccountId , Option < <T as frame_system:: Config >:: AccountId > > ,
759
759
{
760
- fn disable_validator ( validator : & <T as frame_system:: Trait >:: AccountId ) -> Result < bool , ( ) > {
760
+ fn disable_validator ( validator : & <T as frame_system:: Config >:: AccountId ) -> Result < bool , ( ) > {
761
761
<pallet_session:: Module < T > >:: disable ( validator)
762
762
}
763
763
764
- fn validators ( ) -> Vec < <T as frame_system:: Trait >:: AccountId > {
764
+ fn validators ( ) -> Vec < <T as frame_system:: Config >:: AccountId > {
765
765
<pallet_session:: Module < T > >:: validators ( )
766
766
}
767
767
@@ -770,7 +770,7 @@ impl<T: Trait> SessionInterface<<T as frame_system::Trait>::AccountId> for T whe
770
770
}
771
771
}
772
772
773
- pub trait Trait : frame_system:: Trait + SendTransactionTypes < Call < Self > > {
773
+ pub trait Config : frame_system:: Config + SendTransactionTypes < Call < Self > > {
774
774
/// The staking balance.
775
775
type Currency : LockableCurrency < Self :: AccountId , Moment =Self :: BlockNumber > ;
776
776
@@ -792,7 +792,7 @@ pub trait Trait: frame_system::Trait + SendTransactionTypes<Call<Self>> {
792
792
type RewardRemainder : OnUnbalanced < NegativeImbalanceOf < Self > > ;
793
793
794
794
/// The overarching event type.
795
- type Event : From < Event < Self > > + Into < <Self as frame_system:: Trait >:: Event > ;
795
+ type Event : From < Event < Self > > + Into < <Self as frame_system:: Config >:: Event > ;
796
796
797
797
/// Handler for the unbalanced reduction when slashing a staker.
798
798
type Slash : OnUnbalanced < NegativeImbalanceOf < Self > > ;
@@ -904,7 +904,7 @@ impl Default for Releases {
904
904
}
905
905
906
906
decl_storage ! {
907
- trait Store for Module <T : Trait > as Staking {
907
+ trait Store for Module <T : Config > as Staking {
908
908
/// Number of eras to keep in history.
909
909
///
910
910
/// Information is kept for eras in `[current_era - history_depth; current_era]`.
@@ -1121,7 +1121,7 @@ decl_storage! {
1121
1121
}
1122
1122
1123
1123
decl_event ! (
1124
- pub enum Event <T > where Balance = BalanceOf <T >, <T as frame_system:: Trait >:: AccountId {
1124
+ pub enum Event <T > where Balance = BalanceOf <T >, <T as frame_system:: Config >:: AccountId {
1125
1125
/// The era payout has been set; the first balance is the validator-payout; the second is
1126
1126
/// the remainder from the maximum amount of reward.
1127
1127
/// \[era_index, validator_payout, remainder\]
@@ -1153,7 +1153,7 @@ decl_event!(
1153
1153
1154
1154
decl_error ! {
1155
1155
/// Error for the staking module.
1156
- pub enum Error for Module <T : Trait > {
1156
+ pub enum Error for Module <T : Config > {
1157
1157
/// Not a controller account.
1158
1158
NotController ,
1159
1159
/// Not a stash account.
@@ -1223,7 +1223,7 @@ decl_error! {
1223
1223
}
1224
1224
1225
1225
decl_module ! {
1226
- pub struct Module <T : Trait > for enum Call where origin: T :: Origin {
1226
+ pub struct Module <T : Config > for enum Call where origin: T :: Origin {
1227
1227
/// Number of sessions per era.
1228
1228
const SessionsPerEra : SessionIndex = T :: SessionsPerEra :: get( ) ;
1229
1229
@@ -2159,7 +2159,7 @@ decl_module! {
2159
2159
}
2160
2160
}
2161
2161
2162
- impl < T : Trait > Module < T > {
2162
+ impl < T : Config > Module < T > {
2163
2163
/// The total balance that can be slashed from a stash account as of right now.
2164
2164
pub fn slashable_balance_of ( stash : & T :: AccountId ) -> BalanceOf < T > {
2165
2165
// Weight note: consider making the stake accessible through stash.
@@ -3083,7 +3083,7 @@ impl<T: Trait> Module<T> {
3083
3083
///
3084
3084
/// Once the first new_session is planned, all session must start and then end in order, though
3085
3085
/// some session can lag in between the newest session planned and the latest session started.
3086
- impl < T : Trait > pallet_session:: SessionManager < T :: AccountId > for Module < T > {
3086
+ impl < T : Config > pallet_session:: SessionManager < T :: AccountId > for Module < T > {
3087
3087
fn new_session ( new_index : SessionIndex ) -> Option < Vec < T :: AccountId > > {
3088
3088
Self :: new_session ( new_index)
3089
3089
}
@@ -3095,7 +3095,7 @@ impl<T: Trait> pallet_session::SessionManager<T::AccountId> for Module<T> {
3095
3095
}
3096
3096
}
3097
3097
3098
- impl < T : Trait > historical:: SessionManager < T :: AccountId , Exposure < T :: AccountId , BalanceOf < T > > > for Module < T > {
3098
+ impl < T : Config > historical:: SessionManager < T :: AccountId , Exposure < T :: AccountId , BalanceOf < T > > > for Module < T > {
3099
3099
fn new_session ( new_index : SessionIndex )
3100
3100
-> Option < Vec < ( T :: AccountId , Exposure < T :: AccountId , BalanceOf < T > > ) > >
3101
3101
{
@@ -3124,7 +3124,7 @@ impl<T: Trait> historical::SessionManager<T::AccountId, Exposure<T::AccountId, B
3124
3124
/// * 1 point to the producer of each referenced uncle block.
3125
3125
impl < T > pallet_authorship:: EventHandler < T :: AccountId , T :: BlockNumber > for Module < T >
3126
3126
where
3127
- T : Trait + pallet_authorship:: Trait + pallet_session:: Trait
3127
+ T : Config + pallet_authorship:: Config + pallet_session:: Config
3128
3128
{
3129
3129
fn note_author ( author : T :: AccountId ) {
3130
3130
Self :: reward_by_ids ( vec ! [ ( author, 20 ) ] )
@@ -3141,7 +3141,7 @@ impl<T> pallet_authorship::EventHandler<T::AccountId, T::BlockNumber> for Module
3141
3141
/// if any.
3142
3142
pub struct StashOf < T > ( sp_std:: marker:: PhantomData < T > ) ;
3143
3143
3144
- impl < T : Trait > Convert < T :: AccountId , Option < T :: AccountId > > for StashOf < T > {
3144
+ impl < T : Config > Convert < T :: AccountId , Option < T :: AccountId > > for StashOf < T > {
3145
3145
fn convert ( controller : T :: AccountId ) -> Option < T :: AccountId > {
3146
3146
<Module < T > >:: ledger ( & controller) . map ( |l| l. stash )
3147
3147
}
@@ -3154,7 +3154,7 @@ impl<T: Trait> Convert<T::AccountId, Option<T::AccountId>> for StashOf<T> {
3154
3154
/// `active_era`. It can differ from the latest planned exposure in `current_era`.
3155
3155
pub struct ExposureOf < T > ( sp_std:: marker:: PhantomData < T > ) ;
3156
3156
3157
- impl < T : Trait > Convert < T :: AccountId , Option < Exposure < T :: AccountId , BalanceOf < T > > > >
3157
+ impl < T : Config > Convert < T :: AccountId , Option < Exposure < T :: AccountId , BalanceOf < T > > > >
3158
3158
for ExposureOf < T >
3159
3159
{
3160
3160
fn convert ( validator : T :: AccountId ) -> Option < Exposure < T :: AccountId , BalanceOf < T > > > {
@@ -3167,19 +3167,19 @@ impl<T: Trait> Convert<T::AccountId, Option<Exposure<T::AccountId, BalanceOf<T>>
3167
3167
}
3168
3168
3169
3169
/// This is intended to be used with `FilterHistoricalOffences`.
3170
- impl < T : Trait >
3170
+ impl < T : Config >
3171
3171
OnOffenceHandler < T :: AccountId , pallet_session:: historical:: IdentificationTuple < T > , Weight >
3172
3172
for Module < T > where
3173
- T : pallet_session:: Trait < ValidatorId = <T as frame_system:: Trait >:: AccountId > ,
3174
- T : pallet_session:: historical:: Trait <
3175
- FullIdentification = Exposure < <T as frame_system:: Trait >:: AccountId , BalanceOf < T > > ,
3173
+ T : pallet_session:: Config < ValidatorId = <T as frame_system:: Config >:: AccountId > ,
3174
+ T : pallet_session:: historical:: Config <
3175
+ FullIdentification = Exposure < <T as frame_system:: Config >:: AccountId , BalanceOf < T > > ,
3176
3176
FullIdentificationOf = ExposureOf < T > ,
3177
3177
> ,
3178
- T :: SessionHandler : pallet_session:: SessionHandler < <T as frame_system:: Trait >:: AccountId > ,
3179
- T :: SessionManager : pallet_session:: SessionManager < <T as frame_system:: Trait >:: AccountId > ,
3178
+ T :: SessionHandler : pallet_session:: SessionHandler < <T as frame_system:: Config >:: AccountId > ,
3179
+ T :: SessionManager : pallet_session:: SessionManager < <T as frame_system:: Config >:: AccountId > ,
3180
3180
T :: ValidatorIdOf : Convert <
3181
- <T as frame_system:: Trait >:: AccountId ,
3182
- Option < <T as frame_system:: Trait >:: AccountId > ,
3181
+ <T as frame_system:: Config >:: AccountId ,
3182
+ Option < <T as frame_system:: Config >:: AccountId > ,
3183
3183
> ,
3184
3184
{
3185
3185
fn on_offence (
@@ -3310,7 +3310,7 @@ pub struct FilterHistoricalOffences<T, R> {
3310
3310
3311
3311
impl < T , Reporter , Offender , R , O > ReportOffence < Reporter , Offender , O >
3312
3312
for FilterHistoricalOffences < Module < T > , R > where
3313
- T : Trait ,
3313
+ T : Config ,
3314
3314
R : ReportOffence < Reporter , Offender , O > ,
3315
3315
O : Offence < Offender > ,
3316
3316
{
@@ -3335,7 +3335,7 @@ impl<T, Reporter, Offender, R, O> ReportOffence<Reporter, Offender, O>
3335
3335
}
3336
3336
3337
3337
#[ allow( deprecated) ]
3338
- impl < T : Trait > frame_support:: unsigned:: ValidateUnsigned for Module < T > {
3338
+ impl < T : Config > frame_support:: unsigned:: ValidateUnsigned for Module < T > {
3339
3339
type Call = Call < T > ;
3340
3340
fn validate_unsigned ( source : TransactionSource , call : & Self :: Call ) -> TransactionValidity {
3341
3341
if let Call :: submit_election_solution_unsigned(
0 commit comments