mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-03 21:37:23 +00:00
pallet-contracts: State rent fixes (#6147)
* Don't store the storage size offset in the contract itself. * Clean the AccountDb code a bit * Use `storage_size: 0` when creating AliveContractInfo * Count empty storage items. * Update frame/contracts/src/account_db.rs Co-authored-by: Nikolay Volf <nikvolf@gmail.com> * Use more clear wording. Co-authored-by: Alexander Theißen <athei@users.noreply.github.com> * Change the order of decrement and increment for storage size Co-authored-by: Nikolay Volf <nikvolf@gmail.com> Co-authored-by: Alexander Theißen <athei@users.noreply.github.com>
This commit is contained in:
@@ -92,8 +92,13 @@ fn compute_fee_per_block<T: Trait>(
|
||||
.checked_div(&T::RentDepositOffset::get())
|
||||
.unwrap_or_else(Zero::zero);
|
||||
|
||||
let effective_storage_size =
|
||||
<BalanceOf<T>>::from(contract.storage_size).saturating_sub(free_storage);
|
||||
// For now, we treat every empty KV pair as if it was one byte long.
|
||||
let empty_pairs_equivalent = contract.empty_pair_count;
|
||||
|
||||
let effective_storage_size = <BalanceOf<T>>::from(
|
||||
contract.storage_size + T::StorageSizeOffset::get() + empty_pairs_equivalent,
|
||||
)
|
||||
.saturating_sub(free_storage);
|
||||
|
||||
effective_storage_size
|
||||
.checked_mul(&T::RentByteFee::get())
|
||||
|
||||
Reference in New Issue
Block a user