Skip to content
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

Closed
kianenigma opened this issue Jun 14, 2022 · 0 comments · Fixed by #11746
Closed

nomination-pools: prevent bonded_balance to go below MinJoinBond #11664

kianenigma opened this issue Jun 14, 2022 · 0 comments · Fixed by #11746
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.

Comments

@kianenigma
Copy link
Contributor

Currently, once a member wants to join a pool, we enforce them to put at least MinJoinBond into the pool.

ensure!(amount >= MinJoinBond::<T>::get(), Error::<T>::MinimumBondNotMet);

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 than MinJoinBond, or it is 0.

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 the points_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 using member.active_balance (which is correct but slightly inefficient).

Once done, the documentation of MinJoinBond should be updated, and proper tests should be added.

@kianenigma kianenigma added I3-bug The node fails to follow expected behavior. U1-asap No need to stop dead in your tracks, however issue should be addressed as soon as possible. Z6-mentor An easy task where a mentor is available. Please indicate in the issue who the mentor could be. Z1-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder labels Jun 14, 2022
@kianenigma kianenigma added U2-some_time_soon Issue is worth doing soon. and removed U1-asap No need to stop dead in your tracks, however issue should be addressed as soon as possible. labels Jun 14, 2022
@wirednkod wirednkod removed their assignment Jul 20, 2022
@kianenigma kianenigma moved this from Backlog to Done in (Nominated) Proof of Stake Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants