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

contracts: Update deduct_block when a contract is exempted from paying rent #8418

Merged
1 commit merged into from
Mar 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion frame/contracts/src/rent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(),
Expand Down