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

Commit 8870351

Browse files
committed
Unbond & Rebond: do_rebag
1 parent 724c17e commit 8870351

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

frame/staking/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,6 +1781,7 @@ pub mod pallet {
17811781
let era = Self::current_era().unwrap_or(0) + T::BondingDuration::get();
17821782
ledger.unlocking.push(UnlockChunk { value, era });
17831783
Self::update_ledger(&controller, &ledger);
1784+
Self::do_rebag(&ledger.stash);
17841785
Self::deposit_event(Event::<T>::Unbonded(ledger.stash, value));
17851786
}
17861787
Ok(())
@@ -2273,6 +2274,7 @@ pub mod pallet {
22732274

22742275
Self::deposit_event(Event::<T>::Bonded(ledger.stash.clone(), value));
22752276
Self::update_ledger(&controller, &ledger);
2277+
Self::do_rebag(&ledger.stash);
22762278
Ok(Some(
22772279
35 * WEIGHT_PER_MICROS +
22782280
50 * WEIGHT_PER_NANOS * (ledger.unlocking.len() as Weight) +

frame/staking/src/tests.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3885,7 +3885,6 @@ mod voter_bags {
38853885

38863886
// decrease stake within the range of the current bag
38873887
assert_ok!(Staking::unbond(Origin::signed(43), 999)); // 2000 - 999 = 1001
3888-
assert_ok!(Staking::rebag(Origin::signed(43), 42));
38893888
// does not change bags
38903889
assert_eq!(
38913890
get_bags(),
@@ -3894,7 +3893,6 @@ mod voter_bags {
38943893

38953894
// reduce stake to the level of a non-existent bag
38963895
assert_ok!(Staking::unbond(Origin::signed(43), 971)); // 1001 - 971 = 30
3897-
assert_ok!(Staking::rebag(Origin::signed(43), 42));
38983896
// creates the bag and moves the voter into it
38993897
assert_eq!(
39003898
get_bags(),
@@ -3903,7 +3901,6 @@ mod voter_bags {
39033901

39043902
// increase stake by `rebond`-ing to the level of a pre-existing bag
39053903
assert_ok!(Staking::rebond(Origin::signed(43), 31)); // 30 + 41 = 61
3906-
assert_ok!(Staking::rebag(Origin::signed(43), 42));
39073904
// moves the voter to that bag
39083905
assert_eq!(get_bags(), vec![(10, vec![31]), (1000, vec![11, 21, 101, 42]),]);
39093906
});

0 commit comments

Comments
 (0)