seal: Fail instantiate if new contract is below subsistence threshold (#6719)

* seal: Fail instantiate if new contract is below subsistence threshold

We need each contract that exists to be above the subsistence threshold
in order to keep up the guarantuee that we always leave a tombstone behind
with the exception of a contract that called `ext_terminate`.

* Fixup executor test

* Bump runtime
This commit is contained in:
Alexander Theißen
2020-07-27 11:45:00 +02:00
committed by GitHub
parent 63bd1d8346
commit bead1becf0
6 changed files with 23 additions and 15 deletions
+2 -2
View File
@@ -743,7 +743,7 @@ impl<T: Trait> Config<T> {
/// than the subsistence threshold in order to guarantee that a tombstone is created.
///
/// The only way to completely kill a contract without a tombstone is calling `ext_terminate`.
fn subsistence_threshold(&self) -> BalanceOf<T> {
pub fn subsistence_threshold(&self) -> BalanceOf<T> {
self.existential_deposit.saturating_add(self.tombstone_deposit)
}
@@ -751,7 +751,7 @@ impl<T: Trait> Config<T> {
///
/// This is for cases where this value is needed in rent calculation rather than
/// during contract execution.
fn subsistence_threshold_uncached() -> BalanceOf<T> {
pub fn subsistence_threshold_uncached() -> BalanceOf<T> {
T::Currency::minimum_balance().saturating_add(T::TombstoneDeposit::get())
}
}