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

Do not allow zero Existential Deposit when using Balances #4894

Merged
merged 14 commits into from
Feb 12, 2020

Conversation

shawntabrizi
Copy link
Member

@shawntabrizi shawntabrizi commented Feb 11, 2020

Fixes #3798

The balances module uses comparison operators within it's logic which assume that the existential deposit is some non-zero value.

However, many of our tests use ED of 0 which may result in unexpected behaviors when actually deploying to a real environment.

Here we add a check that the ED of the balances module is non-zero in the construction of the genesis to prevent potential issues on live chains where they may try to set the value to 0.

Additionally, we update all Pallets to have an ED > 0 for their tests.

@shawntabrizi shawntabrizi changed the title Do not allow non-zero Existential Deposit when using Balances Do not allow zero Existential Deposit when using Balances Feb 11, 2020
@shawntabrizi shawntabrizi added the A0-please_review Pull request needs code review. label Feb 11, 2020
@shawntabrizi shawntabrizi marked this pull request as ready for review February 11, 2020 18:16
@@ -788,7 +788,7 @@ decl_module! {
let mut payouts = <Payouts<T, I>>::get(&who);
if let Some((when, amount)) = payouts.first() {
if when <= &<system::Module<T>>::block_number() {
T::Currency::transfer(&Self::payouts(), &who, *amount, KeepAlive)?;
T::Currency::transfer(&Self::payouts(), &who, *amount, AllowDeath)?;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gavofyork: ping on this change

The payouts transfer allow death in all the other parts of the code. I assume this was just missed.

A user should be able to get paid out using the full funds of the payouts account.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes a test which was failing now that ED is non-zero, and we weren't allowing a full payout.

frame/balances/src/lib.rs Outdated Show resolved Hide resolved
@gavofyork gavofyork merged commit 2723b9c into paritytech:master Feb 12, 2020
@shawntabrizi shawntabrizi deleted the shawntabrizi-nonzero-ed branch February 12, 2020 10:51
@kianenigma kianenigma mentioned this pull request May 29, 2020
1 task
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve test suite for runtime modules. should be tested with non null ExistentialDeposit
4 participants