Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
ea30833
make pool roles optional
kianenigma May 13, 2022
00e8c87
undo lock file changes?
kianenigma May 13, 2022
fa5e95a
add migration
kianenigma May 13, 2022
f2df79e
add the ability for pools to chill themselves
kianenigma May 14, 2022
56cf997
boilerplate of tests
kianenigma May 14, 2022
508bc0a
new system works, tests need fixing
kianenigma May 15, 2022
f83944a
somewhat stable, but I think I found another bug as well
kianenigma May 15, 2022
ac48c37
Fix it all
kianenigma May 16, 2022
cbeb9fb
Master.into()
kianenigma May 16, 2022
031040f
Add more more sophisticated test + capture one more bug.
kianenigma May 16, 2022
efc7b4f
Update frame/staking/src/lib.rs
kianenigma May 16, 2022
60d42f1
reduce the diff a little bit
kianenigma May 17, 2022
02aa7d4
add some test for the slashing bug
kianenigma May 19, 2022
90db26e
cleanup
kianenigma May 19, 2022
5bf6d9c
Merge branch 'kiz-pool-chill' of github.com:paritytech/substrate into…
kianenigma May 19, 2022
1d8c940
Master.into()
kianenigma May 19, 2022
2ec4857
Merge branch 'master' of github.com:paritytech/substrate into kiz-poo…
kianenigma May 20, 2022
a51e408
fix lock file?
kianenigma May 20, 2022
28c8852
Fix
kianenigma May 20, 2022
c9413a2
fmt
kianenigma May 20, 2022
433476d
Merge branch 'master' of github.com:paritytech/substrate into kiz-poo…
kianenigma May 23, 2022
c34b655
Update frame/nomination-pools/src/lib.rs
kianenigma May 23, 2022
d0d75a1
Update frame/nomination-pools/src/lib.rs
kianenigma May 23, 2022
a6afb06
Update frame/nomination-pools/src/lib.rs
kianenigma May 23, 2022
a3a43e7
Update frame/nomination-pools/src/mock.rs
kianenigma May 23, 2022
4b7b0c7
Fix build
kianenigma May 23, 2022
3f66688
Merge branch 'kiz-pool-chill' of github.com:paritytech/substrate into…
kianenigma May 23, 2022
640ec31
fix some fishy tests..
kianenigma May 23, 2022
398ddfe
add one last integrity check for MinCreateBond
kianenigma May 24, 2022
d5dc697
remove bad assertion -- needs to be dealt with later
kianenigma May 24, 2022
05fb517
Merge branch 'master' of github.com:paritytech/substrate into kiz-poo…
kianenigma May 24, 2022
f4dbd0a
nits
shawntabrizi May 25, 2022
0a79c80
Master.into()
kianenigma Jun 8, 2022
78c0310
Merge branch 'kiz-pool-chill' of github.com:paritytech/substrate into…
kianenigma Jun 9, 2022
0fb1125
fix tests and add benchmarks for chill
kianenigma Jun 9, 2022
12773bb
remove stuff
kianenigma Jun 9, 2022
ca475df
fix benchmarks
kianenigma Jun 10, 2022
44a2722
Merge branch 'master' of https://github.com/paritytech/substrate into…
Jun 10, 2022
f027faf
cargo run --quiet --profile=production --features=runtime-benchmarks…
Jun 10, 2022
33b581c
Master.into()
kianenigma Jun 11, 2022
c77613f
Merge branch 'kiz-pool-chill' of github.com:paritytech/substrate into…
kianenigma Jun 11, 2022
d69af2c
remove defensive
kianenigma Jun 11, 2022
d318197
Merge branch 'master' of github.com:paritytech/substrate into kiz-poo…
kianenigma Jun 13, 2022
486a0e9
first working version
kianenigma Jun 13, 2022
9b2113f
Master.into()
kianenigma Jun 14, 2022
36cb484
bring back all tests
kianenigma Jun 14, 2022
723574b
ALL new tests work now
kianenigma Jun 14, 2022
624abe9
Merge branch 'master' of github.com:paritytech/substrate into kiz-fix…
kianenigma Jun 14, 2022
82287b0
cleanup
kianenigma Jun 14, 2022
e403fb1
make sure benchmarks and all work
kianenigma Jun 15, 2022
4cad93a
Merge branch 'master' of https://github.com/paritytech/substrate into…
Jun 15, 2022
221369b
cargo run --quiet --profile=production --features=runtime-benchmarks…
Jun 15, 2022
696a55e
round of self-review, make arithmetic safe
kianenigma Jun 15, 2022
0689b58
Merge branch 'kiz-fix-reward-pools-2' of github.com:paritytech/substr…
kianenigma Jun 15, 2022
bcb413c
fix warn
kianenigma Jun 15, 2022
bce40f7
add migration code
kianenigma Jun 16, 2022
8fc25ac
Merge branch 'master' of github.com:paritytech/substrate into kiz-fix…
kianenigma Jun 16, 2022
fc3ad18
Fix doc
kianenigma Jun 17, 2022
03107f3
Merge branches 'kiz-fix-reward-pools-2' and 'master' of github.com:pa…
kianenigma Jun 21, 2022
9f875a9
add precision notes
kianenigma Jun 21, 2022
0513284
make arithmetic fallible
kianenigma Jun 21, 2022
1c43f09
fix node runtime
kianenigma Jun 21, 2022
ef56db6
a lot of precision tests and notes and stuff
kianenigma Jun 22, 2022
3da2364
document MaxPOintsToBalance better
kianenigma Jun 22, 2022
ed5083f
Merge branch 'master' of github.com:paritytech/substrate into kiz-fix…
kianenigma Jun 23, 2022
3690489
:round of self-review
kianenigma Jun 23, 2022
62d35c8
fmt
kianenigma Jun 23, 2022
1c840b2
fix some comments
kianenigma Jun 23, 2022
7d9d403
Merge branch 'master' of github.com:paritytech/substrate into kiz-fix…
kianenigma Jun 26, 2022
78b79f2
Master.into()
kianenigma Jul 1, 2022
a8ccd71
Fix proportional slashing logic
kianenigma Jul 5, 2022
60b7641
Update frame/nomination-pools/src/tests.rs
kianenigma Jul 6, 2022
a2082cd
Update frame/nomination-pools/src/tests.rs
kianenigma Jul 6, 2022
ecb7890
Update frame/nomination-pools/src/lib.rs
kianenigma Jul 6, 2022
7e56e1a
track poinst in migration
kianenigma Jul 6, 2022
80b31c0
Merge branch 'kiz-fix-reward-pools-2' of github.com:paritytech/substr…
kianenigma Jul 6, 2022
579da37
fix
kianenigma Jul 6, 2022
51c1608
fmt
kianenigma Jul 6, 2022
3779081
fix migration
kianenigma Jul 6, 2022
9171a13
remove event read
kianenigma Jul 6, 2022
b9ab747
Apply suggestions from code review
kianenigma Jul 7, 2022
d4f45e7
Update frame/staking/src/lib.rs
kianenigma Jul 9, 2022
ca47b05
Update frame/nomination-pools/src/lib.rs
kianenigma Jul 9, 2022
f3e10a9
Update frame/nomination-pools/src/lib.rs
kianenigma Jul 9, 2022
463ddfd
Merge branch 'master' of github.com:paritytech/substrate into kiz-fix…
kianenigma Jul 10, 2022
51873c7
Merge branch 'kiz-fix-reward-pools-2' of github.com:paritytech/substr…
kianenigma Jul 10, 2022
c205ac3
update
kianenigma Jul 10, 2022
69d1f9c
fmt
kianenigma Jul 10, 2022
3efe9f5
fmt
kianenigma Jul 10, 2022
84a2639
add one last test
kianenigma Jul 10, 2022
e7673f8
fmt
kianenigma Jul 12, 2022
ed2c225
Merge branch 'master' of github.com:paritytech/substrate into kiz-fix…
kianenigma Jul 12, 2022
de9886d
merged
kianenigma Jul 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
cleanup
  • Loading branch information
kianenigma committed May 19, 2022
commit 90db26e6318a8980e5c7f471e71679c8c4a602b5
37 changes: 13 additions & 24 deletions frame/nomination-pools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ impl<T: Config> PoolMember<T> {
}

/// Try and unbond `points_dissolved` from self, and in return mint `points_issued` into the
/// corresponding `era`.
/// corresponding `era`'s unlock schedule.
///
/// In the absence of slashing, these two points are always the same. In the presence of
/// slashing, the value of points in different pools varies.
Expand Down Expand Up @@ -988,7 +988,7 @@ impl<T: Config> UnbondPool<T> {
Pallet::<T>::point_to_balance(self.balance, self.points, points)
}

/// Issue points and update the balance given `new_balance`.
/// Issue the equivalent points of `new_funds` into self.
///
/// Returns the actual amounts of points issued.
fn issue(&mut self, new_funds: BalanceOf<T>) -> BalanceOf<T> {
Expand Down Expand Up @@ -1153,12 +1153,6 @@ pub mod pallet {
///
/// This is the value that will always exist in the staking ledger of the pool bonded account
/// while all other accounts leave.
///
/// A sane configuration should thus ensure that this value is large enough such that it is more
/// than `MinimumNominatorBond` and `ExistentialDeposit`. The pool's bonded account's stash
/// falling behind `MinimumNominatorBond` it cannot call unbond, and the pool bonded account's
/// stash falling below `ExistentialDeposit` means the ledger can be killed prematurely in a
/// call to `T::StakingInterface::withdraw_unbonded`.
#[pallet::storage]
pub type MinCreateBond<T: Config> = StorageValue<_, BalanceOf<T>, ValueQuery>;

Expand Down Expand Up @@ -1266,11 +1260,10 @@ pub mod pallet {
PaidOut { member: T::AccountId, pool_id: PoolId, payout: BalanceOf<T> },
/// A member has unbonded from their pool.
///
/// - `balance` is the corresponding balance of the number of points that have been
/// requested to be unbonded (the argument of the `unbond` transaction) from the bonded
/// pool.
/// - `points` is the number of points that are issued as a result of
/// `balance` into the corresponding unbonding pool.
/// - `balance` is the corresponding balance of the number of points that has been requested
/// to be unbonded (the argument of the `unbond` transaction) from the bonded pool.
/// - `points` is the number of points that are issued as a result of `balance` being
/// dissolved into the corresponding unbonding pool.
///
/// In the absence of slashing, these values will match. In the presence of slashing, the
/// number of points that are issued in the unbonding pool will be less than the amount
Expand All @@ -1285,7 +1278,8 @@ pub mod pallet {
///
/// The given number of `points` have been dissolved in return of `balance`.
///
/// Similar to `Unbonded` event, in the absence of slashing, these values will match.
/// Similar to `Unbonded` event, in the absence of slashing, the ratio of point to balance
/// will be 1.
Withdrawn {
member: T::AccountId,
pool_id: PoolId,
Expand Down Expand Up @@ -1313,8 +1307,6 @@ pub mod pallet {
UnbondingPoolSlashed { pool_id: PoolId, era: EraIndex, balance: BalanceOf<T> },
}

#[cfg_attr(test, derive(PartialEq))]
pub enum InnerError {}
#[pallet::error]
#[cfg_attr(test, derive(PartialEq))]
pub enum Error<T> {
Expand All @@ -1329,8 +1321,6 @@ pub mod pallet {
/// An account is already delegating in another pool. An account may only belong to one
/// pool at a time.
AccountBelongsToOtherPool,
/// The member is already unbonding in this era.
AlreadyUnbonding,
/// The member is fully unbonded (and thus cannot access the bonded and reward pool
/// anymore to, for example, collect rewards).
FullyUnbonding,
Expand Down Expand Up @@ -1499,7 +1489,7 @@ pub mod pallet {

/// Unbond up to `unbonding_points` of the `member_account`'s funds from the pool. It
/// implicitly collects the rewards one last time, since not doing so would mean some
/// rewards would go forfeited.
/// rewards would be forfeited.
///
/// Under certain conditions, this call can be dispatched permissionlessly (i.e. by any
/// account).
Expand Down Expand Up @@ -1568,24 +1558,24 @@ pub mod pallet {
.try_insert(unbond_era, UnbondPool::default())
// The above call to `maybe_merge_pools` should ensure there is
// always enough space to insert.
// TODO: make this visible and transparent #11439
// TODO: make this error type transparent #11439
.defensive_map_err(|_| Error::<T>::DefensiveError)?;
}

let actual_unbonding_points = sub_pools
let points_unbonded = sub_pools
.with_era
.get_mut(&unbond_era)
// The above check ensures the pool exists.
.defensive_ok_or_else(|| Error::<T>::DefensiveError)?
.issue(unbonding_balance);

// Try and unbond in the member map.
member.try_unbond(unbonding_points, actual_unbonding_points, unbond_era)?;
member.try_unbond(unbonding_points, points_unbonded, unbond_era)?;

Self::deposit_event(Event::<T>::Unbonded {
member: member_account.clone(),
pool_id: member.pool_id,
points: actual_unbonding_points,
points: points_unbonded,
balance: unbonding_balance,
});

Expand Down Expand Up @@ -2329,7 +2319,6 @@ impl<T: Config> Pallet<T> {
if level.is_zero() {
return Ok(())
}

// note: while a bit wacky, since they have the same key, even collecting to vec should
// result in the same set of keys, in the same order.
let bonded_pools = BondedPools::<T>::iter_keys().collect::<Vec<_>>();
Expand Down
6 changes: 1 addition & 5 deletions frame/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,13 +618,9 @@ impl<T: Config> StakingLedger<T> {
}
}

// clear leftover chunks..
self.unlocking.retain(|c| !c.value.is_zero());
// report this slash..
T::OnStakerSlash::on_slash(&self.stash, self.active, &slashed_unlocking);
// and report the final grand total slash amount.
let final_effective_slash = pre_slash_total.saturating_sub(self.total);
final_effective_slash
pre_slash_total.saturating_sub(self.total)
}
}

Expand Down
4 changes: 2 additions & 2 deletions primitives/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub trait StakingInterface {
/// non-staking locks on the bonded pair's balance this may not be accurate.
fn total_stake(stash: &Self::AccountId) -> Option<Self::Balance>;

/// Bond (lock) `value` of `stash`'s balance. `stash` will be set as the account
/// Bond (lock) `value` of `stash`'s balance. `controller` will be set as the account
/// controlling `stash`. This creates what is referred to as "bonded pair".
fn bond(
stash: Self::AccountId,
Expand All @@ -102,7 +102,7 @@ pub trait StakingInterface {
payee: Self::AccountId,
) -> DispatchResult;

/// Have `stash` nominate `validators`.
/// Have `controller` nominate `validators`.
fn nominate(
controller: Self::AccountId,
validators: sp_std::vec::Vec<Self::AccountId>,
Expand Down