mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 02:11:07 +00:00
Prevent dust in staking by disallowing cheap bond_extra (#7718)
* prevent bond_extra to cause staking actve lower than ed * prevent bond_extra to cause staking actve lower than ed * Check in post conditions. * check rebond as well. * also change withdraw_unbonded. * Fix build * change check format. * Apply suggestions from code review Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
@@ -579,8 +579,18 @@ fn assert_is_stash(acc: AccountId) {
|
||||
fn assert_ledger_consistent(ctrl: AccountId) {
|
||||
// ensures ledger.total == ledger.active + sum(ledger.unlocking).
|
||||
let ledger = Staking::ledger(ctrl).expect("Not a controller.");
|
||||
let real_total: Balance = ledger.unlocking.iter().fold(ledger.active, |a, c| a + c.value);
|
||||
let real_total: Balance = ledger
|
||||
.unlocking
|
||||
.iter()
|
||||
.fold(ledger.active, |a, c| a + c.value);
|
||||
assert_eq!(real_total, ledger.total);
|
||||
assert!(
|
||||
ledger.active >= Balances::minimum_balance() || ledger.active == 0,
|
||||
"{}: active ledger amount ({}) must be greater than ED {}",
|
||||
ctrl,
|
||||
ledger.active,
|
||||
Balances::minimum_balance()
|
||||
);
|
||||
}
|
||||
|
||||
pub(crate) fn bond_validator(stash: AccountId, ctrl: AccountId, val: Balance) {
|
||||
|
||||
Reference in New Issue
Block a user