From 0c91f60e133004d2887d06d2f3c65ae3f5b5333c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= <alex.theissen@me.com> Date: Tue, 23 Mar 2021 11:15:40 +0100 Subject: [PATCH] contracts: Update deduct block when a contract is excempted (#8418) --- substrate/frame/contracts/src/rent.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/substrate/frame/contracts/src/rent.rs b/substrate/frame/contracts/src/rent.rs index 9b3a3f731a2..8605451ad1e 100644 --- a/substrate/frame/contracts/src/rent.rs +++ b/substrate/frame/contracts/src/rent.rs @@ -245,7 +245,6 @@ where evictable_code: Option<PrefabWasmModule<T>>, ) -> Result<Option<AliveContractInfo<T>>, DispatchError> { match (verdict, evictable_code) { - (Verdict::Exempt, _) => return Ok(Some(alive_contract_info)), (Verdict::Evict { amount }, Some(code)) => { // We need to remove the trie first because it is the only operation // that can fail and this function is called without a storage @@ -274,6 +273,14 @@ where (Verdict::Evict { amount: _ }, None) => { Ok(None) } + (Verdict::Exempt, _) => { + let contract = ContractInfo::Alive(AliveContractInfo::<T> { + deduct_block: current_block_number, + ..alive_contract_info + }); + <ContractInfoOf<T>>::insert(account, &contract); + Ok(Some(contract.get_alive().expect("We just constructed it as alive. qed"))) + }, (Verdict::Charge { amount }, _) => { let contract = ContractInfo::Alive(AliveContractInfo::<T> { rent_allowance: alive_contract_info.rent_allowance - amount.peek(), -- GitLab