Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 7e56e1a

Browse files
committed
track poinst in migration
1 parent a8ccd71 commit 7e56e1a

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

frame/nomination-pools/src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,16 +383,18 @@ impl<T: Config> PoolMember<T> {
383383
current_reward_counter: T::RewardCounter,
384384
) -> Result<BalanceOf<T>, Error<T>> {
385385
// accuracy note: Reward counters are `FixedU128` with base of 10^18. This value is being
386-
// multiplied by a point. The worse case of a point is 10x the granularity of the balance.
386+
// multiplied by a point. The worse case of a point is 10x the granularity of the balance
387+
// (10x is the common configuration of `MaxPointsToBalance`).
388+
//
387389
// Assuming roughly the current issuance of polkadot (12,047,781,394,999,601,455, which is
388-
// 1.2 * 10^9 10^10 = 1.2 * 10^19), the worse case point value is around 10^20.
390+
// 1.2 * 10^9 * 10^10 = 1.2 * 10^19), the worse case point value is around 10^20.
389391
//
390392
// The final multiplication is:
391393
//
392394
// rc * 10^20 / 10^18 = rc * 100
393395
//
394396
// meaning that as long as reward_counter's value is less than 1/100th of its max capacity
395-
// (u128), `checked_mul_int` won't saturate.
397+
// (u128::MAX_VALUE), `checked_mul_int` won't saturate.
396398
//
397399
// given the nature of reward counter being 'pending_rewards / pool_total_point', the only
398400
// (unrealistic) way that super high values can be achieved is for a pool to suddenly

frame/nomination-pools/src/migration.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ pub mod v2 {
191191
let mut members_translated = 0u64;
192192
// just for logging.
193193
let mut total_value_locked = BalanceOf::<T>::zero();
194+
let mut total_points_locked = BalanceOf::<T>::zero();
194195

195196
// store each member of the pool, with their active points. In the process, migrate
196197
// their data as well.
@@ -243,6 +244,7 @@ pub mod v2 {
243244
};
244245

245246
total_value_locked += bonded_pool.points_to_balance(points.clone());
247+
total_points_locked += bonded_pool.points;
246248
let portion = Perbill::from_rational(*points, bonded_pool.points);
247249
let last_claim = portion * accumulated_reward;
248250

@@ -310,10 +312,11 @@ pub mod v2 {
310312

311313
log!(
312314
info,
313-
"Upgraded {} members, {} reward pools, TVL {:?}, storage to version {:?}",
315+
"Upgraded {} members, {} reward pools, TVL {:?} TPL {:?}, storage to version {:?}",
314316
members_translated,
315317
reward_pools_translated,
316318
total_value_locked,
319+
total_points_locked,
317320
current
318321
);
319322
current.put::<Pallet<T>>();

0 commit comments

Comments
 (0)