Skip to content

Commit

Permalink
nits
Browse files Browse the repository at this point in the history
  • Loading branch information
gpestana committed May 28, 2024
1 parent 0139b15 commit bcda9a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,23 +88,22 @@ impl<T: Config<CurrencyBalance = u128>, W: weights::WeightInfo> SteppedMigration
// nominations (see below). Thus it is better to just chill the nominator and move
// on.
if Self::try_chill_nominator(&nominator) {
//log!(info, "nominator {:?} chilled, skip it.", nominator);
chilled += 1;
cursor = Some(nominator);
continue;
}
// clean the nominations before migrating. This will ensure that the voter is not
// nominating duplicate and/or dangling targets.
let nominations = Self::clean_nominations(&nominator)?;
let nominator_stake = Pallet::<T>::weight_of(&nominator);
let nominator_vote = Pallet::<T>::weight_of(&nominator);

// iter over up to `MaxNominationsOf<T>` targets of `nominator` and insert or
// update the target's approval's score.
for target in nominations.into_iter() {
if <T as Config>::TargetList::contains(&target) {
Self::update_target(&target, nominator_stake)?;
Self::update_target(&target, nominator_vote)?;
} else {
Self::insert_target(&target, nominator_stake)?;
Self::insert_target(&target, nominator_vote)?;
}
}

Expand Down
16 changes: 2 additions & 14 deletions substrate/frame/staking/src/pallet/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2110,7 +2110,6 @@ impl<T: Config> Pallet<T> {
"VoterList contains non-staker"
);

/*
Self::check_ledgers()?;
Self::check_bonded_consistency()?;
Self::check_payees()?;
Expand All @@ -2119,7 +2118,6 @@ impl<T: Config> Pallet<T> {
Self::check_paged_exposures()?;
Self::check_count()?;
Self::ensure_disabled_validators_sorted()?;
*/
Self::do_try_state_approvals()?;
Self::do_try_state_target_sorting()
}
Expand Down Expand Up @@ -2514,12 +2512,6 @@ impl<T: Config> Pallet<T> {
if let Some(approvals) = approvals_map.get_mut(&target) {
*approvals += vote.into();
} else {
// TODO: simplify
let self_stake = Pallet::<T>::weight_of(&target);
let init_stake = self_stake.saturating_add(vote);
approvals_map.insert(target, init_stake.into());

/*
// new addition to the map. add self-stake if validator is active.
let _ = match Self::status(&target) {
Ok(StakerStatus::Validator) => {
Expand All @@ -2528,12 +2520,10 @@ impl<T: Config> Pallet<T> {
},
_ => approvals_map.insert(target, vote.into()),
};
*/
}
}
}

let mut a = 0;
// add active validators without any nominations.
for (validator, _) in Validators::<T>::iter() {
// do not add validator if it is not in a good state.
Expand All @@ -2553,7 +2543,6 @@ impl<T: Config> Pallet<T> {
);
},
_ => {
a += 1;
let self_stake = Pallet::<T>::weight_of(&validator);
approvals_map.insert(validator, self_stake.into());
},
Expand All @@ -2572,11 +2561,11 @@ impl<T: Config> Pallet<T> {

log!(
error,
"try-runtime: score of {:?} in `TargetList` list: {:?}, calculated sum of all stake: {:?} -- status: {:?}",
"try-runtime: score of {:?} in `TargetList` list: {:?}, calculated sum of all stake: {:?} -- weight self-stake: {:?}",
target,
stake_in_list,
calculated_stake,
Self::status(&target),
Pallet::<T>::weight_of(&target),
);
}
}
Expand All @@ -2588,7 +2577,6 @@ impl<T: Config> Pallet<T> {

if !mismatch_approvals.is_zero() {
log!(error, "{} targets with unexpected score in list", mismatch_approvals);

return Err("final calculated approvals != target list scores".into());
}

Expand Down

0 comments on commit bcda9a7

Please sign in to comment.