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

Commit

Permalink
contracts: Update deduct block when a contract is excempted (#8418)
Browse files Browse the repository at this point in the history
  • Loading branch information
athei committed Mar 23, 2021
1 parent 067f185 commit 7821936
Showing 1 changed file with 8 additions and 1 deletion.
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

0 comments on commit 7821936

Please sign in to comment.