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
43 commits
Select commit Hold shift + click to select a range
616dc1a
first draft of partial unbonding for pools
kianenigma Apr 10, 2022
c045e06
remove option
kianenigma Apr 10, 2022
b333d21
Upstream.into()
kianenigma Apr 12, 2022
ad7f37c
Add some more tests and fix issues
kianenigma Apr 13, 2022
764ae6f
Fix all tests
kianenigma Apr 13, 2022
28844a2
simplify some tests
kianenigma Apr 13, 2022
9a2af20
Update frame/nomination-pools/src/mock.rs
kianenigma Apr 13, 2022
de80c7b
remove clone
kianenigma Apr 14, 2022
580e45d
Merge branch 'kiz-pools-partial-unbonding' of github.com:paritytech/s…
kianenigma Apr 14, 2022
d0f0121
rename to delegator_unbonding_eras
kianenigma Apr 14, 2022
03dafcb
Update frame/nomination-pools/src/tests.rs
kianenigma Apr 14, 2022
257f48b
Update frame/nomination-pools/src/tests.rs
kianenigma Apr 14, 2022
4e04c79
Update frame/nomination-pools/src/tests.rs
kianenigma Apr 14, 2022
26197e3
remove pub
kianenigma Apr 14, 2022
774c28d
Merge branch 'kiz-pools-partial-unbonding' of github.com:paritytech/s…
kianenigma Apr 14, 2022
a469433
Update frame/nomination-pools/src/lib.rs
kianenigma Apr 14, 2022
a1d5e3a
Update frame/nomination-pools/src/lib.rs
kianenigma Apr 14, 2022
b1ee72e
undo
kianenigma Apr 14, 2022
d9ae892
Merge branch 'kiz-pools-partial-unbonding' of github.com:paritytech/s…
kianenigma Apr 14, 2022
ef96a11
Update frame/nomination-pools/src/lib.rs
kianenigma Apr 14, 2022
17296fa
Update frame/nomination-pools/src/lib.rs
kianenigma Apr 14, 2022
5c04916
leftovers
kianenigma Apr 14, 2022
02ff7b6
Merge branch 'kiz-pools-partial-unbonding' of github.com:paritytech/s…
kianenigma Apr 14, 2022
2b52a25
fix invariant
kianenigma Apr 14, 2022
339c7a1
Fix all tests
kianenigma Apr 14, 2022
ac2b5d6
upstream into
kianenigma Apr 15, 2022
b2b5470
Fix the depositor assumption
kianenigma Apr 15, 2022
70f9f8f
round of self-review
kianenigma Apr 15, 2022
4d389f5
little bit more cleanup
kianenigma Apr 15, 2022
31c522d
Update frame/nomination-pools/src/mock.rs
emostov Apr 15, 2022
d7fabb2
Apply suggestions from code review
emostov Apr 16, 2022
40c21f5
Update frame/nomination-pools/src/lib.rs
kianenigma Apr 18, 2022
cb56178
Fix interpretation of MinCreateBond
kianenigma Apr 19, 2022
11a5e91
Merge branch 'kiz-pools-partial-unbonding' of github.com:paritytech/s…
kianenigma Apr 19, 2022
011e8bc
controvesial refactor
kianenigma Apr 19, 2022
49409d7
rename
kianenigma Apr 19, 2022
9e801fc
Merge branch 'zeke-staking-pools' of github.com:paritytech/substrate …
kianenigma Apr 19, 2022
8e8aa5a
make everything build
kianenigma Apr 19, 2022
8985a84
add TODO about killing the reward account
kianenigma Apr 19, 2022
20846ce
Update frame/nomination-pools/src/lib.rs
kianenigma Apr 19, 2022
1e4f7fa
Update frame/nomination-pools/src/lib.rs
emostov Apr 19, 2022
4ef56ae
Upstream.into()
kianenigma Apr 20, 2022
8657efc
last self-review
kianenigma Apr 20, 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
upstream into
  • Loading branch information
kianenigma committed Apr 15, 2022
commit ac2b5d6707045d1ab80ffbb53ef5b09cb535ae22
23 changes: 16 additions & 7 deletions frame/nomination-pools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1393,15 +1393,15 @@ pub mod pallet {
/// `NoMoreChunks` error from the staking system.
#[pallet::weight(T::WeightInfo::unbond())]
#[transactional]
pub fn unbond_other(
pub fn unbond(
origin: OriginFor<T>,
delegator_account: T::AccountId,
mut unbonding_points: BalanceOf<T>,
) -> DispatchResult {
let caller = ensure_signed(origin)?;
let (mut delegator, mut bonded_pool, mut reward_pool) =
Self::get_delegator_with_pools(&delegator_account)?;
bonded_pool.ok_to_unbond_other_with(&caller, &delegator_account, &delegator)?;
bonded_pool.ok_to_unbond_with(&caller, &delegator_account, &delegator)?;

unbonding_points = unbonding_points.min(delegator.active_points());
// Claim the the payout prior to unbonding. Once the user is unbonding their points
Expand Down Expand Up @@ -1520,7 +1520,7 @@ pub mod pallet {
let mut sub_pools = SubPoolsStorage::<T>::get(delegator.pool_id)
.defensive_ok_or_else(|| Error::<T>::SubPoolsNotFound)?;

let should_remove_pool = bonded_pool.ok_to_withdraw_unbonded_other_with(
let should_remove_pool = bonded_pool.ok_to_withdraw_unbonded_with(
&caller,
&delegator_account,
&delegator,
Expand Down Expand Up @@ -1580,9 +1580,9 @@ pub mod pallet {
// delegator being reaped.
Delegators::<T>::remove(&delegator_account);
if should_remove_pool {
let reward_account = bonded_pool.reward_account();
ReversePoolIdLookup::<T>::remove(bonded_pool.bonded_account());
RewardPools::<T>::remove(delegator.pool_id);
Self::deposit_event(Event::<T>::Destroyed { pool_id: delegator.pool_id });
SubPoolsStorage::<T>::remove(delegator.pool_id);
// Kill accounts from storage by making their balance go below ED. We assume
// that the accounts have no references that would prevent destruction once we
Expand All @@ -1592,20 +1592,29 @@ pub mod pallet {
.unwrap_or_default(),
Zero::zero()
);
T::Currency::make_free_balance_be(&bonded_pool.reward_account(), Zero::zero());
let reward_pool_remaining = T::Currency::free_balance(&reward_account);
// This shouldn't fail, but if it does we don't really care
let _ = T::Currency::transfer(
&reward_account,
&delegator_account,
reward_pool_remaining,
ExistenceRequirement::AllowDeath,
);
T::Currency::make_free_balance_be(&reward_account, Zero::zero());
T::Currency::make_free_balance_be(&bonded_pool.bonded_account(), Zero::zero());
Self::deposit_event(Event::<T>::Destroyed { pool_id: delegator.pool_id });
bonded_pool.remove();
None
} else {
bonded_pool.dec_delegators().put();
SubPoolsStorage::<T>::insert(&delegator.pool_id, sub_pools);
Some(T::WeightInfo::withdraw_unbonded_other_update(num_slashing_spans))
Some(T::WeightInfo::withdraw_unbonded_update(num_slashing_spans))
}
} else {
// we certainly don't need to delete any pools, because no one is being removed.
SubPoolsStorage::<T>::insert(&delegator.pool_id, sub_pools);
Delegators::<T>::insert(&delegator_account, delegator);
Some(T::WeightInfo::withdraw_unbonded_other_update(num_slashing_spans))
Some(T::WeightInfo::withdraw_unbonded_update(num_slashing_spans))
};

Ok(post_info_weight.into())
Expand Down
4 changes: 2 additions & 2 deletions frame/nomination-pools/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,9 @@ pub(crate) fn pool_events_since_last_call() -> Vec<super::Event<Runtime>> {
///
/// This is useful for backwards compatibility with the majority of tests that only deal with full
/// unbonding, not partial unbonding.
pub fn fully_unbond_other(origin: Origin, delegator: AccountId) -> DispatchResult {
pub fn fully_unbond(origin: Origin, delegator: AccountId) -> DispatchResult {
let points = Delegators::<Runtime>::get(&delegator).map(|d| d.points).unwrap_or_default();
Pools::unbond_other(origin, delegator, points)
Pools::unbond(origin, delegator, points)
}

#[cfg(test)]
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.