style: Migrate to stable-only rustfmt configuration
- Remove nightly-only features from .rustfmt.toml and vendor/ss58-registry/rustfmt.toml - Removed features: imports_granularity, wrap_comments, comment_width, reorder_impl_items, spaces_around_ranges, binop_separator, match_arm_blocks, trailing_semicolon, trailing_comma - Format all 898 affected files with stable rustfmt - Ensures long-term reliability without nightly toolchain dependency
This commit is contained in:
@@ -136,10 +136,10 @@ struct Bounds {
|
||||
|
||||
impl Bounds {
|
||||
fn check(&self, value: u32) -> bool {
|
||||
let wrong = (self.min_strict && value <= self.min) ||
|
||||
(!self.min_strict && value < self.min) ||
|
||||
(self.max_strict && value >= self.max) ||
|
||||
(!self.max_strict && value > self.max);
|
||||
let wrong = (self.min_strict && value <= self.min)
|
||||
|| (!self.min_strict && value < self.min)
|
||||
|| (self.max_strict && value >= self.max)
|
||||
|| (!self.max_strict && value > self.max);
|
||||
|
||||
!wrong
|
||||
}
|
||||
@@ -291,8 +291,8 @@ fn compute_points(input: &INposInput) -> Vec<(u32, u32)> {
|
||||
|
||||
// For each point p: (next_p.0 - p.0) < segment_length && (next_p.1 - p.1) < segment_length.
|
||||
// This ensures that the total number of segments doesn't overflow max_piece_count.
|
||||
let max_length = (input.max_inflation - input.min_inflation + 1_000_000 - inpos.x_ideal) /
|
||||
(input.max_piece_count - 1);
|
||||
let max_length = (input.max_inflation - input.min_inflation + 1_000_000 - inpos.x_ideal)
|
||||
/ (input.max_piece_count - 1);
|
||||
|
||||
let mut delta_y = max_length;
|
||||
let mut y = input.max_inflation;
|
||||
@@ -319,8 +319,8 @@ fn compute_points(input: &INposInput) -> Vec<(u32, u32)> {
|
||||
// Compute the y corresponding to x=1_000_000 using the current point and the previous
|
||||
// one.
|
||||
|
||||
let delta_y: u32 = ((next_x - 1_000_000) as u64 * (prev.1 - next_y) as u64 /
|
||||
(next_x - prev.0) as u64)
|
||||
let delta_y: u32 = ((next_x - 1_000_000) as u64 * (prev.1 - next_y) as u64
|
||||
/ (next_x - prev.0) as u64)
|
||||
.try_into()
|
||||
.unwrap();
|
||||
|
||||
|
||||
@@ -42,8 +42,8 @@ where
|
||||
const MILLISECONDS_PER_YEAR: u64 = 1000 * 3600 * 24 * 36525 / 100;
|
||||
|
||||
let portion = Perbill::from_rational(era_duration as u64, MILLISECONDS_PER_YEAR);
|
||||
let payout = portion *
|
||||
yearly_inflation
|
||||
let payout = portion
|
||||
* yearly_inflation
|
||||
.calculate_for_fraction_times_denominator(npos_token_staked, total_tokens.clone());
|
||||
let maximum = portion * (yearly_inflation.maximum * total_tokens);
|
||||
(payout, maximum)
|
||||
|
||||
@@ -86,8 +86,9 @@ impl<T: Config> StakingLedger<T> {
|
||||
pub(crate) fn paired_account(account: StakingAccount<T::AccountId>) -> Option<T::AccountId> {
|
||||
match account {
|
||||
StakingAccount::Stash(stash) => <Bonded<T>>::get(stash),
|
||||
StakingAccount::Controller(controller) =>
|
||||
<Ledger<T>>::get(&controller).map(|ledger| ledger.stash),
|
||||
StakingAccount::Controller(controller) => {
|
||||
<Ledger<T>>::get(&controller).map(|ledger| ledger.stash)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,8 +110,9 @@ impl<T: Config> StakingLedger<T> {
|
||||
/// stash has a controller which is bonding a ledger associated with another stash.
|
||||
pub(crate) fn get(account: StakingAccount<T::AccountId>) -> Result<StakingLedger<T>, Error<T>> {
|
||||
let (stash, controller) = match account.clone() {
|
||||
StakingAccount::Stash(stash) =>
|
||||
(stash.clone(), <Bonded<T>>::get(&stash).ok_or(Error::<T>::NotStash)?),
|
||||
StakingAccount::Stash(stash) => {
|
||||
(stash.clone(), <Bonded<T>>::get(&stash).ok_or(Error::<T>::NotStash)?)
|
||||
},
|
||||
StakingAccount::Controller(controller) => (
|
||||
Ledger::<T>::get(&controller)
|
||||
.map(|l| l.stash)
|
||||
@@ -148,8 +150,9 @@ impl<T: Config> StakingLedger<T> {
|
||||
) -> Option<RewardDestination<T::AccountId>> {
|
||||
let stash = match account {
|
||||
StakingAccount::Stash(stash) => Some(stash),
|
||||
StakingAccount::Controller(controller) =>
|
||||
Self::paired_account(StakingAccount::Controller(controller)),
|
||||
StakingAccount::Controller(controller) => {
|
||||
Self::paired_account(StakingAccount::Controller(controller))
|
||||
},
|
||||
};
|
||||
|
||||
if let Some(stash) = stash {
|
||||
@@ -296,11 +299,11 @@ pub struct StakingLedgerInspect<T: Config> {
|
||||
#[cfg(test)]
|
||||
impl<T: Config> PartialEq<StakingLedgerInspect<T>> for StakingLedger<T> {
|
||||
fn eq(&self, other: &StakingLedgerInspect<T>) -> bool {
|
||||
self.stash == other.stash &&
|
||||
self.total == other.total &&
|
||||
self.active == other.active &&
|
||||
self.unlocking == other.unlocking &&
|
||||
self.legacy_claimed_rewards == other.legacy_claimed_rewards
|
||||
self.stash == other.stash
|
||||
&& self.total == other.total
|
||||
&& self.active == other.active
|
||||
&& self.unlocking == other.unlocking
|
||||
&& self.legacy_claimed_rewards == other.legacy_claimed_rewards
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1220,8 +1220,8 @@ impl<T: Config> EraInfo<T> {
|
||||
validator: &T::AccountId,
|
||||
page: Page,
|
||||
) -> bool {
|
||||
ledger.legacy_claimed_rewards.binary_search(&era).is_ok() ||
|
||||
Self::is_rewards_claimed(era, validator, page)
|
||||
ledger.legacy_claimed_rewards.binary_search(&era).is_ok()
|
||||
|| Self::is_rewards_claimed(era, validator, page)
|
||||
}
|
||||
|
||||
/// Check if the rewards for the given era and page index have been claimed.
|
||||
|
||||
@@ -393,7 +393,9 @@ pub mod v11 {
|
||||
warn,
|
||||
"new bags-list name is equal to the old one, only bumping the version"
|
||||
);
|
||||
return T::DbWeight::get().reads(1).saturating_add(T::DbWeight::get().writes(1));
|
||||
return T::DbWeight::get()
|
||||
.reads(1)
|
||||
.saturating_add(T::DbWeight::get().writes(1));
|
||||
}
|
||||
|
||||
move_pallet(old_pallet_name.as_bytes(), new_pallet_name.as_bytes());
|
||||
|
||||
@@ -113,7 +113,7 @@ impl<T: Config> Pezpallet<T> {
|
||||
})?;
|
||||
|
||||
match Ledger::<T>::get(controller) {
|
||||
Some(ledger) =>
|
||||
Some(ledger) => {
|
||||
if ledger.stash != *stash {
|
||||
Ok(LedgerIntegrityState::Corrupted)
|
||||
} else {
|
||||
@@ -122,7 +122,8 @@ impl<T: Config> Pezpallet<T> {
|
||||
} else {
|
||||
Ok(LedgerIntegrityState::Ok)
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
None => Ok(LedgerIntegrityState::CorruptedKilled),
|
||||
}
|
||||
}
|
||||
@@ -480,8 +481,8 @@ impl<T: Config> Pezpallet<T> {
|
||||
|
||||
// New era.
|
||||
let maybe_new_era_validators = Self::try_trigger_new_era(session_index, is_genesis);
|
||||
if maybe_new_era_validators.is_some() &&
|
||||
matches!(ForceEra::<T>::get(), Forcing::ForceNew)
|
||||
if maybe_new_era_validators.is_some()
|
||||
&& matches!(ForceEra::<T>::get(), Forcing::ForceNew)
|
||||
{
|
||||
Self::set_force_era(Forcing::NotForcing);
|
||||
}
|
||||
@@ -906,8 +907,8 @@ impl<T: Config> Pezpallet<T> {
|
||||
let mut min_active_stake = u64::MAX;
|
||||
|
||||
let mut sorted_voters = T::VoterList::iter();
|
||||
while all_voters.len() < final_predicted_len as usize &&
|
||||
voters_seen < (NPOS_MAX_ITERATIONS_COEFFICIENT * final_predicted_len as u32)
|
||||
while all_voters.len() < final_predicted_len as usize
|
||||
&& voters_seen < (NPOS_MAX_ITERATIONS_COEFFICIENT * final_predicted_len as u32)
|
||||
{
|
||||
let voter = match sorted_voters.next() {
|
||||
Some(voter) => {
|
||||
@@ -1014,8 +1015,8 @@ impl<T: Config> Pezpallet<T> {
|
||||
let mut targets_seen = 0;
|
||||
|
||||
let mut targets_iter = T::TargetList::iter();
|
||||
while all_targets.len() < final_predicted_len as usize &&
|
||||
targets_seen < (NPOS_MAX_ITERATIONS_COEFFICIENT * final_predicted_len as u32)
|
||||
while all_targets.len() < final_predicted_len as usize
|
||||
&& targets_seen < (NPOS_MAX_ITERATIONS_COEFFICIENT * final_predicted_len as u32)
|
||||
{
|
||||
let target = match targets_iter.next() {
|
||||
Some(target) => {
|
||||
@@ -2120,8 +2121,8 @@ impl<T: Config> StakingInterface for Pezpallet<T> {
|
||||
/// There is an assumption that, this account is keyless and managed by another pezpallet in the
|
||||
/// runtime. Hence, it can never sign its own transactions.
|
||||
fn is_virtual_staker(who: &T::AccountId) -> bool {
|
||||
pezframe_system::Pezpallet::<T>::account_nonce(who).is_zero() &&
|
||||
VirtualStakers::<T>::contains_key(who)
|
||||
pezframe_system::Pezpallet::<T>::account_nonce(who).is_zero()
|
||||
&& VirtualStakers::<T>::contains_key(who)
|
||||
}
|
||||
|
||||
fn slash_reward_fraction() -> Perbill {
|
||||
@@ -2258,9 +2259,11 @@ impl<T: Config> Pezpallet<T> {
|
||||
// if stash == controller, it means that the ledger has migrated to
|
||||
// post-controller. If no migration happened, we expect that the (stash,
|
||||
// controller) pair has only one associated ledger.
|
||||
{
|
||||
if stash != controller {
|
||||
count_double += 1;
|
||||
},
|
||||
}
|
||||
},
|
||||
(None, None) => {
|
||||
count_none += 1;
|
||||
},
|
||||
@@ -2297,8 +2300,8 @@ impl<T: Config> Pezpallet<T> {
|
||||
}
|
||||
|
||||
ensure!(
|
||||
(Ledger::<T>::iter().count() == Payee::<T>::iter().count()) &&
|
||||
(Ledger::<T>::iter().count() == Bonded::<T>::iter().count()),
|
||||
(Ledger::<T>::iter().count() == Payee::<T>::iter().count())
|
||||
&& (Ledger::<T>::iter().count() == Bonded::<T>::iter().count()),
|
||||
"number of entries in payee storage items does not match the number of bonded ledgers",
|
||||
);
|
||||
|
||||
@@ -2312,8 +2315,8 @@ impl<T: Config> Pezpallet<T> {
|
||||
/// * Current validator count is bounded by the election provider's max winners.
|
||||
fn check_count() -> Result<(), TryRuntimeError> {
|
||||
ensure!(
|
||||
<T as Config>::VoterList::count() ==
|
||||
Nominators::<T>::count() + Validators::<T>::count(),
|
||||
<T as Config>::VoterList::count()
|
||||
== Nominators::<T>::count() + Validators::<T>::count(),
|
||||
"wrong external count"
|
||||
);
|
||||
ensure!(
|
||||
@@ -2394,9 +2397,10 @@ impl<T: Config> Pezpallet<T> {
|
||||
ErasStakers::<T>::iter_prefix_values(era)
|
||||
.map(|expo| {
|
||||
ensure!(
|
||||
expo.total ==
|
||||
expo.own +
|
||||
expo.others
|
||||
expo.total
|
||||
== expo.own
|
||||
+ expo
|
||||
.others
|
||||
.iter()
|
||||
.map(|e| e.value)
|
||||
.fold(Zero::zero(), |acc, x| acc + x),
|
||||
@@ -2429,8 +2433,8 @@ impl<T: Config> Pezpallet<T> {
|
||||
ErasStakersPaged::<T>::iter_prefix((era,))
|
||||
.map(|((validator, _page), expo)| {
|
||||
ensure!(
|
||||
expo.page_total ==
|
||||
expo.others.iter().map(|e| e.value).fold(Zero::zero(), |acc, x| acc + x),
|
||||
expo.page_total
|
||||
== expo.others.iter().map(|e| e.value).fold(Zero::zero(), |acc, x| acc + x),
|
||||
"wrong total exposure for the page.",
|
||||
);
|
||||
|
||||
@@ -2511,10 +2515,11 @@ impl<T: Config> Pezpallet<T> {
|
||||
match len {
|
||||
0 => { /* not supporting this validator at all. */ },
|
||||
1 => sum_exposed += individual[0].value,
|
||||
_ =>
|
||||
_ => {
|
||||
return Err(
|
||||
"nominator cannot back a validator more than once.".into()
|
||||
),
|
||||
)
|
||||
},
|
||||
};
|
||||
Ok(())
|
||||
})
|
||||
|
||||
@@ -808,9 +808,9 @@ pub mod pezpallet {
|
||||
_ => Ok(()),
|
||||
});
|
||||
assert!(
|
||||
ValidatorCount::<T>::get() <=
|
||||
<T::ElectionProvider as ElectionProvider>::MaxWinnersPerPage::get() *
|
||||
<T::ElectionProvider as ElectionProvider>::Pages::get()
|
||||
ValidatorCount::<T>::get()
|
||||
<= <T::ElectionProvider as ElectionProvider>::MaxWinnersPerPage::get()
|
||||
* <T::ElectionProvider as ElectionProvider>::Pages::get()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -993,8 +993,8 @@ pub mod pezpallet {
|
||||
|
||||
// ensure election results are always bounded with the same value
|
||||
assert!(
|
||||
<T::ElectionProvider as ElectionProvider>::MaxWinnersPerPage::get() ==
|
||||
<T::GenesisElectionProvider as ElectionProvider>::MaxWinnersPerPage::get()
|
||||
<T::ElectionProvider as ElectionProvider>::MaxWinnersPerPage::get()
|
||||
== <T::GenesisElectionProvider as ElectionProvider>::MaxWinnersPerPage::get()
|
||||
);
|
||||
|
||||
assert!(
|
||||
@@ -1822,10 +1822,10 @@ pub mod pezpallet {
|
||||
let origin_balance = asset::total_balance::<T>(&stash);
|
||||
let ledger_total =
|
||||
Self::ledger(Stash(stash.clone())).map(|l| l.total).unwrap_or_default();
|
||||
let reapable = origin_balance < ed ||
|
||||
origin_balance.is_zero() ||
|
||||
ledger_total < ed ||
|
||||
ledger_total.is_zero();
|
||||
let reapable = origin_balance < ed
|
||||
|| origin_balance.is_zero()
|
||||
|| ledger_total < ed
|
||||
|| ledger_total.is_zero();
|
||||
ensure!(reapable, Error::<T>::FundedTarget);
|
||||
|
||||
// Remove all staking-related information and lock.
|
||||
|
||||
@@ -387,9 +387,9 @@ fn rewards_should_work() {
|
||||
);
|
||||
assert_eq_error_rate!(
|
||||
asset::total_balance::<Test>(&101),
|
||||
init_balance_101 +
|
||||
part_for_101_from_11 * total_payout_0 * 2 / 3 +
|
||||
part_for_101_from_21 * total_payout_0 * 1 / 3,
|
||||
init_balance_101
|
||||
+ part_for_101_from_11 * total_payout_0 * 2 / 3
|
||||
+ part_for_101_from_21 * total_payout_0 * 1 / 3,
|
||||
2
|
||||
);
|
||||
|
||||
@@ -427,9 +427,9 @@ fn rewards_should_work() {
|
||||
);
|
||||
assert_eq_error_rate!(
|
||||
asset::total_balance::<Test>(&101),
|
||||
init_balance_101 +
|
||||
part_for_101_from_11 * (total_payout_0 * 2 / 3 + total_payout_1) +
|
||||
part_for_101_from_21 * total_payout_0 * 1 / 3,
|
||||
init_balance_101
|
||||
+ part_for_101_from_11 * (total_payout_0 * 2 / 3 + total_payout_1)
|
||||
+ part_for_101_from_21 * total_payout_0 * 1 / 3,
|
||||
2
|
||||
);
|
||||
});
|
||||
@@ -6540,8 +6540,8 @@ fn test_validator_exposure_is_backward_compatible_with_non_paged_rewards_payout(
|
||||
let actual_exposure_page_1 = ErasStakersPaged::<Test>::get((1, 11, 1)).unwrap();
|
||||
expected_individual_exposures.iter().for_each(|exposure| {
|
||||
assert!(
|
||||
actual_exposure_page_0.others.contains(exposure) ||
|
||||
actual_exposure_page_1.others.contains(exposure)
|
||||
actual_exposure_page_0.others.contains(exposure)
|
||||
|| actual_exposure_page_1.others.contains(exposure)
|
||||
);
|
||||
});
|
||||
assert_eq!(
|
||||
@@ -9289,8 +9289,8 @@ fn manual_slashing_works() {
|
||||
let expected_balance_1 = initial_balance - (initial_balance / 4); // 25% slash
|
||||
|
||||
assert!(
|
||||
balance_after_first_slash <= expected_balance_1 &&
|
||||
balance_after_first_slash >= expected_balance_1 - 5,
|
||||
balance_after_first_slash <= expected_balance_1
|
||||
&& balance_after_first_slash >= expected_balance_1 - 5,
|
||||
"First slash was not applied correctly. Expected around {}, got {}",
|
||||
expected_balance_1,
|
||||
balance_after_first_slash
|
||||
@@ -9342,8 +9342,8 @@ fn manual_slashing_works() {
|
||||
let expected_balance_3 = initial_balance / 2; // 50% of original
|
||||
|
||||
assert!(
|
||||
balance_after_third_slash <= expected_balance_3 &&
|
||||
balance_after_third_slash >= expected_balance_3 - 5,
|
||||
balance_after_third_slash <= expected_balance_3
|
||||
&& balance_after_third_slash >= expected_balance_3 - 5,
|
||||
"Third slash was not applied correctly. Expected around {}, got {}",
|
||||
expected_balance_3,
|
||||
balance_after_third_slash
|
||||
@@ -9385,8 +9385,8 @@ fn manual_slashing_works() {
|
||||
let expected_balance_5 = initial_balance / 4; // 25% of original (75% slashed)
|
||||
|
||||
assert!(
|
||||
balance_after_fifth_slash <= expected_balance_5 &&
|
||||
balance_after_fifth_slash >= expected_balance_5 - 5,
|
||||
balance_after_fifth_slash <= expected_balance_5
|
||||
&& balance_after_fifth_slash >= expected_balance_5 - 5,
|
||||
"Fifth slash was not applied correctly. Expected around {}, got {}",
|
||||
expected_balance_5,
|
||||
balance_after_fifth_slash
|
||||
|
||||
Reference in New Issue
Block a user