@@ -47,10 +47,10 @@ use sp_staking::{
47
47
48
48
use crate :: {
49
49
asset, election_size_tracker:: StaticTracker , log, slashing, weights:: WeightInfo , ActiveEraInfo ,
50
- BalanceOf , BoundedExposuresOf , EraInfo , EraPayout , Exposure , Forcing , IndividualExposure ,
51
- LedgerIntegrityState , MaxNominationsOf , MaxWinnersOf , MaxWinnersPerPageOf , Nominations ,
52
- NominationsQuota , PositiveImbalanceOf , RewardDestination , SessionInterface , SnapshotStatus ,
53
- StakingLedger , ValidatorPrefs , STAKING_ID ,
50
+ BalanceOf , BoundedExposuresOf , EraInfo , EraPayout , ExistenceOrLegacyExposure , Exposure ,
51
+ Forcing , IndividualExposure , LedgerIntegrityState , MaxNominationsOf , MaxWinnersOf ,
52
+ MaxWinnersPerPageOf , Nominations , NominationsQuota , PositiveImbalanceOf , RewardDestination ,
53
+ SessionInterface , SnapshotStatus , StakingLedger , ValidatorPrefs , STAKING_ID ,
54
54
} ;
55
55
use alloc:: { boxed:: Box , vec, vec:: Vec } ;
56
56
@@ -306,7 +306,7 @@ impl<T: Config> Pallet<T> {
306
306
307
307
if EraInfo :: < T > :: is_rewards_claimed ( era, & stash, page) {
308
308
return Err ( Error :: < T > :: AlreadyClaimed
309
- . with_weight ( T :: WeightInfo :: payout_stakers_alive_staked ( 0 ) ) )
309
+ . with_weight ( T :: WeightInfo :: payout_stakers_alive_staked ( 0 ) ) ) ;
310
310
}
311
311
312
312
EraInfo :: < T > :: set_rewards_as_claimed ( era, & stash, page) ;
@@ -332,7 +332,7 @@ impl<T: Config> Pallet<T> {
332
332
333
333
// Nothing to do if they have no reward points.
334
334
if validator_reward_points. is_zero ( ) {
335
- return Ok ( Some ( T :: WeightInfo :: payout_stakers_alive_staked ( 0 ) ) . into ( ) )
335
+ return Ok ( Some ( T :: WeightInfo :: payout_stakers_alive_staked ( 0 ) ) . into ( ) ) ;
336
336
}
337
337
338
338
// This is the fraction of the total reward that the validator and the
@@ -421,7 +421,7 @@ impl<T: Config> Pallet<T> {
421
421
) -> Option < ( PositiveImbalanceOf < T > , RewardDestination < T :: AccountId > ) > {
422
422
// noop if amount is zero
423
423
if amount. is_zero ( ) {
424
- return None
424
+ return None ;
425
425
}
426
426
let dest = Self :: payee ( StakingAccount :: Stash ( stash. clone ( ) ) ) ?;
427
427
@@ -484,7 +484,7 @@ impl<T: Config> Pallet<T> {
484
484
_ => {
485
485
// Either `Forcing::ForceNone`,
486
486
// or `Forcing::NotForcing if era_length >= T::SessionsPerEra::get()`.
487
- return None
487
+ return None ;
488
488
} ,
489
489
}
490
490
@@ -1098,7 +1098,7 @@ impl<T: Config> Pallet<T> {
1098
1098
// if voter weight is zero, do not consider this voter for the snapshot.
1099
1099
if voter_weight. is_zero ( ) {
1100
1100
log ! ( debug, "voter's active balance is 0. skip this voter." ) ;
1101
- continue
1101
+ continue ;
1102
1102
}
1103
1103
1104
1104
if let Some ( Nominations { targets, .. } ) = <Nominators < T > >:: get ( & voter) {
@@ -1113,7 +1113,7 @@ impl<T: Config> Pallet<T> {
1113
1113
Self :: deposit_event ( Event :: < T > :: SnapshotVotersSizeExceeded {
1114
1114
size : voters_size_tracker. size as u32 ,
1115
1115
} ) ;
1116
- break
1116
+ break ;
1117
1117
}
1118
1118
1119
1119
all_voters. push ( voter) ;
@@ -1139,7 +1139,7 @@ impl<T: Config> Pallet<T> {
1139
1139
Self :: deposit_event ( Event :: < T > :: SnapshotVotersSizeExceeded {
1140
1140
size : voters_size_tracker. size as u32 ,
1141
1141
} ) ;
1142
- break
1142
+ break ;
1143
1143
}
1144
1144
all_voters. push ( self_vote) ;
1145
1145
validators_taken. saturating_inc ( ) ;
@@ -1205,7 +1205,7 @@ impl<T: Config> Pallet<T> {
1205
1205
Self :: deposit_event ( Event :: < T > :: SnapshotTargetsSizeExceeded {
1206
1206
size : targets_size_tracker. size as u32 ,
1207
1207
} ) ;
1208
- break
1208
+ break ;
1209
1209
}
1210
1210
1211
1211
if Validators :: < T > :: contains_key ( & target) {
@@ -1536,7 +1536,7 @@ impl<T: Config> ElectionDataProvider for Pallet<T> {
1536
1536
// We can't handle this case yet -- return an error. WIP to improve handling this case in
1537
1537
// <https://github.com/paritytech/substrate/pull/13195>.
1538
1538
if bounds. exhausted ( None , CountBound ( targets. len ( ) as u32 ) . into ( ) ) {
1539
- return Err ( "Target snapshot too big" )
1539
+ return Err ( "Target snapshot too big" ) ;
1540
1540
}
1541
1541
1542
1542
debug_assert ! ( !bounds. slice_exhausted( & targets) ) ;
@@ -1546,7 +1546,7 @@ impl<T: Config> ElectionDataProvider for Pallet<T> {
1546
1546
1547
1547
fn next_election_prediction ( now : BlockNumberFor < T > ) -> BlockNumberFor < T > {
1548
1548
if let Some ( override_value) = BenchmarkNextElection :: get ( ) {
1549
- return override_value. into ( )
1549
+ return override_value. into ( ) ;
1550
1550
}
1551
1551
1552
1552
let current_era = CurrentEra :: < T > :: get ( ) . unwrap_or ( 0 ) ;
@@ -1587,7 +1587,7 @@ impl<T: Config> ElectionDataProvider for Pallet<T> {
1587
1587
log ! ( debug, "we are mid-election, pointing to next era as election prediction." ) ;
1588
1588
return now. saturating_add (
1589
1589
BlockNumberFor :: < T > :: from ( T :: SessionsPerEra :: get ( ) ) * session_length,
1590
- )
1590
+ ) ;
1591
1591
}
1592
1592
1593
1593
now. saturating_add (
@@ -1775,14 +1775,25 @@ impl<T: Config> historical::SessionManager<T::AccountId, Exposure<T::AccountId,
1775
1775
}
1776
1776
}
1777
1777
1778
- impl < T : Config > historical:: SessionManager < T :: AccountId , ( ) > for Pallet < T > {
1779
- fn new_session ( new_index : SessionIndex ) -> Option < Vec < ( T :: AccountId , ( ) ) > > {
1780
- <Self as pallet_session:: SessionManager < _ > >:: new_session ( new_index)
1781
- . map ( |validators| validators. into_iter ( ) . map ( |v| ( v, ( ) ) ) . collect ( ) )
1778
+ impl < T : Config >
1779
+ historical:: SessionManager < T :: AccountId , ExistenceOrLegacyExposure < T :: AccountId , BalanceOf < T > > >
1780
+ for Pallet < T >
1781
+ {
1782
+ fn new_session (
1783
+ new_index : SessionIndex ,
1784
+ ) -> Option < Vec < ( T :: AccountId , ExistenceOrLegacyExposure < T :: AccountId , BalanceOf < T > > ) > > {
1785
+ <Self as pallet_session:: SessionManager < _ > >:: new_session ( new_index) . map ( |validators| {
1786
+ validators. into_iter ( ) . map ( |v| ( v, ExistenceOrLegacyExposure :: Exists ) ) . collect ( )
1787
+ } )
1782
1788
}
1783
- fn new_session_genesis ( new_index : SessionIndex ) -> Option < Vec < ( T :: AccountId , ( ) ) > > {
1784
- <Self as pallet_session:: SessionManager < _ > >:: new_session_genesis ( new_index)
1785
- . map ( |validators| validators. into_iter ( ) . map ( |v| ( v, ( ) ) ) . collect ( ) )
1789
+ fn new_session_genesis (
1790
+ new_index : SessionIndex ,
1791
+ ) -> Option < Vec < ( T :: AccountId , ExistenceOrLegacyExposure < T :: AccountId , BalanceOf < T > > ) > > {
1792
+ <Self as pallet_session:: SessionManager < _ > >:: new_session_genesis ( new_index) . map (
1793
+ |validators| {
1794
+ validators. into_iter ( ) . map ( |v| ( v, ExistenceOrLegacyExposure :: Exists ) ) . collect ( )
1795
+ } ,
1796
+ )
1786
1797
}
1787
1798
fn start_session ( start_index : SessionIndex ) {
1788
1799
<Self as pallet_session:: SessionManager < _ > >:: start_session ( start_index)
@@ -1861,7 +1872,7 @@ impl<T: Config> Pallet<T> {
1861
1872
add_db_reads_writes ( 1 , 0 ) ;
1862
1873
let Some ( active_era) = ActiveEra :: < T > :: get ( ) else {
1863
1874
log ! ( warn, "🦹 on_offence: no active era; ignoring offence" ) ;
1864
- return consumed_weight
1875
+ return consumed_weight;
1865
1876
} ;
1866
1877
1867
1878
add_db_reads_writes ( 1 , 0 ) ;
@@ -1886,7 +1897,7 @@ impl<T: Config> Pallet<T> {
1886
1897
// defensive: this implies offence is for a discarded era, and should already be
1887
1898
// filtered out.
1888
1899
log ! ( warn, "🦹 on_offence: no era found for slash_session; ignoring offence" ) ;
1889
- return Weight :: default ( )
1900
+ return Weight :: default ( ) ;
1890
1901
} ,
1891
1902
}
1892
1903
} ;
@@ -1899,7 +1910,7 @@ impl<T: Config> Pallet<T> {
1899
1910
// Skip if the validator is invulnerable.
1900
1911
if invulnerables. contains ( & validator) {
1901
1912
log ! ( debug, "🦹 on_offence: {:?} is invulnerable; ignoring offence" , validator) ;
1902
- continue
1913
+ continue ;
1903
1914
}
1904
1915
1905
1916
add_db_reads_writes ( 1 , 0 ) ;
@@ -2328,7 +2339,7 @@ impl<T: Config> StakingInterface for Pallet<T> {
2328
2339
who : & Self :: AccountId ,
2329
2340
) -> Result < sp_staking:: StakerStatus < Self :: AccountId > , DispatchError > {
2330
2341
if !StakingLedger :: < T > :: is_bonded ( StakingAccount :: Stash ( who. clone ( ) ) ) {
2331
- return Err ( Error :: < T > :: NotStash . into ( ) )
2342
+ return Err ( Error :: < T > :: NotStash . into ( ) ) ;
2332
2343
}
2333
2344
2334
2345
let is_validator = Validators :: < T > :: contains_key ( & who) ;
@@ -2405,7 +2416,7 @@ impl<T: Config> sp_staking::StakingUnchecked for Pallet<T> {
2405
2416
payee : & Self :: AccountId ,
2406
2417
) -> DispatchResult {
2407
2418
if StakingLedger :: < T > :: is_bonded ( StakingAccount :: Stash ( keyless_who. clone ( ) ) ) {
2408
- return Err ( Error :: < T > :: AlreadyBonded . into ( ) )
2419
+ return Err ( Error :: < T > :: AlreadyBonded . into ( ) ) ;
2409
2420
}
2410
2421
2411
2422
// check if payee not same as who.
0 commit comments