From bcda9a7a8cfe52e01a466f4b6d04f43bcc71fcbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Tue, 28 May 2024 11:12:56 +0200 Subject: [PATCH] nits --- .../src/migrations/v13_stake_tracker/mod.rs | 7 +++---- substrate/frame/staking/src/pallet/impls.rs | 16 ++-------------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/substrate/frame/staking/src/migrations/v13_stake_tracker/mod.rs b/substrate/frame/staking/src/migrations/v13_stake_tracker/mod.rs index db96eac60c84..e40b96975ba5 100644 --- a/substrate/frame/staking/src/migrations/v13_stake_tracker/mod.rs +++ b/substrate/frame/staking/src/migrations/v13_stake_tracker/mod.rs @@ -88,7 +88,6 @@ impl, 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; @@ -96,15 +95,15 @@ impl, W: weights::WeightInfo> SteppedMigration // 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::::weight_of(&nominator); + let nominator_vote = Pallet::::weight_of(&nominator); // iter over up to `MaxNominationsOf` targets of `nominator` and insert or // update the target's approval's score. for target in nominations.into_iter() { if ::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)?; } } diff --git a/substrate/frame/staking/src/pallet/impls.rs b/substrate/frame/staking/src/pallet/impls.rs index 282ed1c4c921..a3fff07e05b0 100644 --- a/substrate/frame/staking/src/pallet/impls.rs +++ b/substrate/frame/staking/src/pallet/impls.rs @@ -2110,7 +2110,6 @@ impl Pallet { "VoterList contains non-staker" ); - /* Self::check_ledgers()?; Self::check_bonded_consistency()?; Self::check_payees()?; @@ -2119,7 +2118,6 @@ impl Pallet { Self::check_paged_exposures()?; Self::check_count()?; Self::ensure_disabled_validators_sorted()?; - */ Self::do_try_state_approvals()?; Self::do_try_state_target_sorting() } @@ -2514,12 +2512,6 @@ impl Pallet { if let Some(approvals) = approvals_map.get_mut(&target) { *approvals += vote.into(); } else { - // TODO: simplify - let self_stake = Pallet::::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) => { @@ -2528,12 +2520,10 @@ impl Pallet { }, _ => approvals_map.insert(target, vote.into()), }; - */ } } } - let mut a = 0; // add active validators without any nominations. for (validator, _) in Validators::::iter() { // do not add validator if it is not in a good state. @@ -2553,7 +2543,6 @@ impl Pallet { ); }, _ => { - a += 1; let self_stake = Pallet::::weight_of(&validator); approvals_map.insert(validator, self_stake.into()); }, @@ -2572,11 +2561,11 @@ impl Pallet { 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::::weight_of(&target), ); } } @@ -2588,7 +2577,6 @@ impl Pallet { if !mismatch_approvals.is_zero() { log!(error, "{} targets with unexpected score in list", mismatch_approvals); - return Err("final calculated approvals != target list scores".into()); }