Skip to content

Commit

Permalink
contracts: Add reserved field to ContractInfoOf for future proofing
Browse files Browse the repository at this point in the history
  • Loading branch information
athei committed Feb 23, 2021
1 parent 2224f8d commit 9de3f3c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions frame/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,8 @@ pub struct RawAliveContractInfo<CodeHash, Balance, BlockNumber> {
pub deduct_block: BlockNumber,
/// Last block child storage has been written.
pub last_write: Option<BlockNumber>,
/// This field is reserved for future evolution of format.
pub _reserved: Option<()>,
}

impl<CodeHash, Balance, BlockNumber> RawAliveContractInfo<CodeHash, Balance, BlockNumber> {
Expand Down
4 changes: 1 addition & 3 deletions frame/contracts/src/rent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,14 +514,12 @@ where
<ContractInfoOf<T>>::remove(&origin);
let tombstone_code_len = E::remove_user(origin_contract.code_hash);
<ContractInfoOf<T>>::insert(&dest, ContractInfo::Alive(AliveContractInfo::<T> {
trie_id: origin_contract.trie_id,
storage_size: origin_contract.storage_size,
pair_count: origin_contract.pair_count,
code_hash,
rent_allowance,
rent_payed: <BalanceOf<T>>::zero(),
deduct_block: current_block,
last_write,
.. origin_contract
}));

let origin_free_balance = T::Currency::free_balance(&origin);
Expand Down
1 change: 1 addition & 0 deletions frame/contracts/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ where
rent_payed: <BalanceOf<T>>::zero(),
pair_count: 0,
last_write: None,
_reserved: None,
};

*existing = Some(contract.into());
Expand Down
2 changes: 2 additions & 0 deletions frame/contracts/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ fn account_removal_does_not_remove_storage() {
rent_allowance: 40,
rent_payed: 0,
last_write: None,
_reserved: None,
});
let _ = Balances::deposit_creating(&ALICE, 110);
ContractInfoOf::<Test>::insert(ALICE, &alice_contract_info);
Expand All @@ -407,6 +408,7 @@ fn account_removal_does_not_remove_storage() {
rent_allowance: 40,
rent_payed: 0,
last_write: None,
_reserved: None,
});
let _ = Balances::deposit_creating(&BOB, 110);
ContractInfoOf::<Test>::insert(BOB, &bob_contract_info);
Expand Down

0 comments on commit 9de3f3c

Please sign in to comment.