contracts: Remove OnKilledAccount implementation (#5397)

* contracts: Remove OnKilledAccount implementation

Contracts now longer rely on this callback to tell them when they
are removed. Instead, they can only self destruct  using `ext_terminate`.

* Fix account removal test

* Fix account storage removal
This commit is contained in:
Alexander Theißen
2020-03-26 11:16:24 +01:00
committed by GitHub
parent b0d2f4b173
commit 7cbadd73be
3 changed files with 16 additions and 28 deletions
+1 -13
View File
@@ -125,7 +125,7 @@ use frame_support::{
parameter_types, IsSubType,
weights::DispatchInfo,
};
use frame_support::traits::{OnKilledAccount, OnUnbalanced, Currency, Get, Time, Randomness};
use frame_support::traits::{OnUnbalanced, Currency, Get, Time, Randomness};
use frame_system::{self as system, ensure_signed, RawOrigin, ensure_root};
use sp_core::storage::well_known_keys::CHILD_STORAGE_KEY_PREFIX;
use pallet_contracts_primitives::{RentProjection, ContractAccessError};
@@ -941,18 +941,6 @@ decl_storage! {
}
}
// TODO: this should be removed in favour of a self-destruct contract host function allowing the
// contract to delete all storage and the `ContractInfoOf` key and transfer remaining balance to
// some other account. As it stands, it's an economic insecurity on any smart-contract chain.
// https://github.com/paritytech/substrate/issues/4952
impl<T: Trait> OnKilledAccount<T::AccountId> for Module<T> {
fn on_killed_account(who: &T::AccountId) {
if let Some(ContractInfo::Alive(info)) = <ContractInfoOf<T>>::take(who) {
child::kill_storage(&info.trie_id, info.child_trie_unique_id());
}
}
}
/// In-memory cache of configuration values.
///
/// We assume that these values can't be changed in the