This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
nomination-pools: prevent bonded_balance
to go below MinJoinBond
#11664
Labels
I3-bug
The node fails to follow expected behavior.
U2-some_time_soon
Issue is worth doing soon.
Z1-easy
Can be fixed primarily by duplicating and adapting code by an intermediate coder
Z6-mentor
An easy task where a mentor is available. Please indicate in the issue who the mentor could be.
Currently, once a member wants to join a pool, we enforce them to put at least
MinJoinBond
into the pool.substrate/frame/nomination-pools/src/lib.rs
Line 1422 in abb80e5
But we allow them to immediately unbond and go below this value, without any checks. To fix this, the
unbond
transaction should ensure that the bonded balance is still more thanMinJoinBond
, or it is0
.Note that bonded balance of the member needs to be computed and is not currently know at the scope of
fn unbond
. Nonetheless, the conversion is possible. All points are always convertible to balance via thepoints_to_balance
function.Lastly, since all transactions are now transactional by default, it is easiest to check this condition at the end of the function, after
member
has been updated, potentially usingmember.active_balance
(which is correct but slightly inefficient).Once done, the documentation of
MinJoinBond
should be updated, and proper tests should be added.The text was updated successfully, but these errors were encountered: