@@ -115,7 +115,7 @@ use sp_runtime::{
115115 traits:: {
116116 Hash , StaticLookup , Zero , MaybeSerializeDeserialize , Member , Convert , Saturating ,
117117 } ,
118- RuntimeDebug ,
118+ RuntimeDebug , Perbill ,
119119} ;
120120use frame_support:: {
121121 decl_module, decl_event, decl_storage, decl_error, ensure,
@@ -205,11 +205,8 @@ pub struct RawAliveContractInfo<CodeHash, Balance, BlockNumber> {
205205 ///
206206 /// It is a sum of each key-value pair stored by this contract.
207207 pub storage_size : u32 ,
208- /// The number of key-value pairs that have values of zero length.
209- /// The condition `empty_pair_count ≤ total_pair_count` always holds.
210- pub empty_pair_count : u32 ,
211208 /// The total number of key-value pairs in storage of this contract.
212- pub total_pair_count : u32 ,
209+ pub pair_count : u32 ,
213210 /// The code associated with a given account.
214211 pub code_hash : CodeHash ,
215212 /// Pay rent at most up to this value.
@@ -286,24 +283,35 @@ pub trait Config: frame_system::Config {
286283 /// The minimum amount required to generate a tombstone.
287284 type TombstoneDeposit : Get < BalanceOf < Self > > ;
288285
289- /// A size offset for an contract. A just created account with untouched storage will have that
290- /// much of storage from the perspective of the state rent.
286+ /// The balance every contract needs to deposit to stay alive indefinitely.
287+ ///
288+ /// This is different from the [`Self::TombstoneDeposit`] because this only needs to be
289+ /// deposited while the contract is alive. Costs for additional storage are added to
290+ /// this base cost.
291291 ///
292292 /// This is a simple way to ensure that contracts with empty storage eventually get deleted by
293293 /// making them pay rent. This creates an incentive to remove them early in order to save rent.
294- type StorageSizeOffset : Get < u32 > ;
295-
296- /// Price of a byte of storage per one block interval. Should be greater than 0.
297- type RentByteFee : Get < BalanceOf < Self > > ;
294+ type DepositPerContract : Get < BalanceOf < Self > > ;
298295
299- /// The amount of funds a contract should deposit in order to offset
300- /// the cost of one byte.
296+ /// The balance a contract needs to deposit per storage byte to stay alive indefinitely.
301297 ///
302298 /// Let's suppose the deposit is 1,000 BU (balance units)/byte and the rent is 1 BU/byte/day,
303299 /// then a contract with 1,000,000 BU that uses 1,000 bytes of storage would pay no rent.
304300 /// But if the balance reduced to 500,000 BU and the storage stayed the same at 1,000,
305301 /// then it would pay 500 BU/day.
306- type RentDepositOffset : Get < BalanceOf < Self > > ;
302+ type DepositPerStorageByte : Get < BalanceOf < Self > > ;
303+
304+ /// The balance a contract needs to deposit per storage item to stay alive indefinitely.
305+ ///
306+ /// It works the same as [`Self::DepositPerStorageByte`] but for storage items.
307+ type DepositPerStorageItem : Get < BalanceOf < Self > > ;
308+
309+ /// The fraction of the deposit that should be used as rent per block.
310+ ///
311+ /// When a contract hasn't enough balance deposited to stay alive indefinitely it needs
312+ /// to pay per block for the storage it consumes that is not covered by the deposit.
313+ /// This determines how high this rent payment is per block as a fraction of the deposit.
314+ type RentFraction : Get < Perbill > ;
307315
308316 /// Reward that is received by the party whose touch has led
309317 /// to removal of a contract.
@@ -435,25 +443,35 @@ decl_module! {
435443 /// The minimum amount required to generate a tombstone.
436444 const TombstoneDeposit : BalanceOf <T > = T :: TombstoneDeposit :: get( ) ;
437445
438- /// A size offset for an contract. A just created account with untouched storage will have that
439- /// much of storage from the perspective of the state rent.
446+ /// The balance every contract needs to deposit to stay alive indefinitely.
440447 ///
441- /// This is a simple way to ensure that contracts with empty storage eventually get deleted
442- /// by making them pay rent. This creates an incentive to remove them early in order to save
443- /// rent .
444- const StorageSizeOffset : u32 = T :: StorageSizeOffset :: get ( ) ;
445-
446- /// Price of a byte of storage per one block interval. Should be greater than 0 .
447- const RentByteFee : BalanceOf <T > = T :: RentByteFee :: get( ) ;
448+ /// This is different from the [`Self::TombstoneDeposit`] because this only needs to be
449+ /// deposited while the contract is alive. Costs for additional storage are added to
450+ /// this base cost .
451+ ///
452+ /// This is a simple way to ensure that contracts with empty storage eventually get deleted by
453+ /// making them pay rent. This creates an incentive to remove them early in order to save rent .
454+ const DepositPerContract : BalanceOf <T > = T :: DepositPerContract :: get( ) ;
448455
449- /// The amount of funds a contract should deposit in order to offset
450- /// the cost of one byte.
456+ /// The balance a contract needs to deposit per storage byte to stay alive indefinitely.
451457 ///
452458 /// Let's suppose the deposit is 1,000 BU (balance units)/byte and the rent is 1 BU/byte/day,
453459 /// then a contract with 1,000,000 BU that uses 1,000 bytes of storage would pay no rent.
454460 /// But if the balance reduced to 500,000 BU and the storage stayed the same at 1,000,
455461 /// then it would pay 500 BU/day.
456- const RentDepositOffset : BalanceOf <T > = T :: RentDepositOffset :: get( ) ;
462+ const DepositPerStorageByte : BalanceOf <T > = T :: DepositPerStorageByte :: get( ) ;
463+
464+ /// The balance a contract needs to deposit per storage item to stay alive indefinitely.
465+ ///
466+ /// It works the same as [`Self::DepositPerStorageByte`] but for storage items.
467+ const DepositPerStorageItem : BalanceOf <T > = T :: DepositPerStorageItem :: get( ) ;
468+
469+ /// The fraction of the deposit that should be used as rent per block.
470+ ///
471+ /// When a contract hasn't enough balance deposited to stay alive indefinitely it needs
472+ /// to pay per block for the storage it consumes that is not covered by the deposit.
473+ /// This determines how high this rent payment is per block as a fraction of the deposit.
474+ const RentFraction : Perbill = T :: RentFraction :: get( ) ;
457475
458476 /// Reward that is received by the party whose touch has led
459477 /// to removal of a contract.
0 commit comments