You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Experiencing problems? Have you tried our Stack Exchange first?
This is not a support question.
Description of bug
We are building a new layer 1 using Frontier EVM alongside pallet_staking. We are using a custom Substrate token as its native token. We have set our existential deposit to zero to prevent dusting. However, we've identified an issue related to storage writes in the staking process, specifically with the Self::bonded entry. According to the documentation, this entry is not cleared unless the balance falls below the existential deposit and is removed as dust. With an existential deposit of zero, these entries are never cleaned, which leads to a situation where stakers remain indefinitely bonded with a stake of zero after they chill and unbond. This results in unnecessary storage overhead and potential unknown issues.
Expected behavior:
After an account is fully unbonded, it should not remain in a bonded state if it has a zero stake.
Actual behavior:
Accounts remain bonded with zero stake due to the non-removal of Self::bonded because the existential deposit is zero.
Potential impact:
This could lead to increased storage overhead and might cause other unknown issues in network behavior or staking mechanics.
Yes, seems staking pallet has not been written with expectation that ED can be zero.
Fix is to do a <= check with ED or an explicit zero check (safer as it is noop for runtimes with ed > 0).
When a staker unbonds and withdraws, it is possible that their stash
will contain less currency than the existential deposit. If that
happens, their stash is reaped. But if the existential deposit is zero,
the reap is not triggered. This PR adjusts `pallet_staking` to reap a
stash in the special case that the stash value is zero and the
existential deposit is zero.
This change is important for blockchains built on substrate that require
an existential deposit of zero, becuase it conserves valued storage
space.
There are two places in which ledgers are checked to determine if their
value is less than the existential deposit and they should be reaped: in
the methods `do_withdraw_unbonded` and `reap_stash`. When the check is
made, the condition `ledger_total == 0` is also checked. If
`ledger_total` is zero, then it must be below any existential deposit
greater than zero and equal to an existential deposit of 0.
I added a new test for each method to confirm the change behaves as
expected.
Closes#4340
---------
Co-authored-by: command-bot <>
Is there an existing issue?
Experiencing problems? Have you tried our Stack Exchange first?
Description of bug
We are building a new layer 1 using Frontier EVM alongside pallet_staking. We are using a custom Substrate token as its native token. We have set our existential deposit to zero to prevent dusting. However, we've identified an issue related to storage writes in the staking process, specifically with the
Self::bonded
entry. According to the documentation, this entry is not cleared unless the balance falls below the existential deposit and is removed as dust. With an existential deposit of zero, these entries are never cleaned, which leads to a situation where stakers remain indefinitely bonded with a stake of zero after they chill and unbond. This results in unnecessary storage overhead and potential unknown issues.Expected behavior:
After an account is fully unbonded, it should not remain in a bonded state if it has a zero stake.
Actual behavior:
Accounts remain bonded with zero stake due to the non-removal of
Self::bonded
because the existential deposit is zero.Potential impact:
This could lead to increased storage overhead and might cause other unknown issues in network behavior or staking mechanics.
Steps to reproduce
pallet_staking
.The text was updated successfully, but these errors were encountered: