@@ -115,7 +115,7 @@ use sp_runtime::{
115
115
traits:: {
116
116
Hash , StaticLookup , Zero , MaybeSerializeDeserialize , Member , Convert , Saturating ,
117
117
} ,
118
- RuntimeDebug ,
118
+ RuntimeDebug , Perbill ,
119
119
} ;
120
120
use frame_support:: {
121
121
decl_module, decl_event, decl_storage, decl_error, ensure,
@@ -205,11 +205,8 @@ pub struct RawAliveContractInfo<CodeHash, Balance, BlockNumber> {
205
205
///
206
206
/// It is a sum of each key-value pair stored by this contract.
207
207
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 ,
211
208
/// The total number of key-value pairs in storage of this contract.
212
- pub total_pair_count : u32 ,
209
+ pub pair_count : u32 ,
213
210
/// The code associated with a given account.
214
211
pub code_hash : CodeHash ,
215
212
/// Pay rent at most up to this value.
@@ -286,24 +283,35 @@ pub trait Config: frame_system::Config {
286
283
/// The minimum amount required to generate a tombstone.
287
284
type TombstoneDeposit : Get < BalanceOf < Self > > ;
288
285
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.
291
291
///
292
292
/// This is a simple way to ensure that contracts with empty storage eventually get deleted by
293
293
/// 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 > > ;
298
295
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.
301
297
///
302
298
/// Let's suppose the deposit is 1,000 BU (balance units)/byte and the rent is 1 BU/byte/day,
303
299
/// then a contract with 1,000,000 BU that uses 1,000 bytes of storage would pay no rent.
304
300
/// But if the balance reduced to 500,000 BU and the storage stayed the same at 1,000,
305
301
/// 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 > ;
307
315
308
316
/// Reward that is received by the party whose touch has led
309
317
/// to removal of a contract.
@@ -435,25 +443,35 @@ decl_module! {
435
443
/// The minimum amount required to generate a tombstone.
436
444
const TombstoneDeposit : BalanceOf <T > = T :: TombstoneDeposit :: get( ) ;
437
445
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.
440
447
///
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( ) ;
448
455
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.
451
457
///
452
458
/// Let's suppose the deposit is 1,000 BU (balance units)/byte and the rent is 1 BU/byte/day,
453
459
/// then a contract with 1,000,000 BU that uses 1,000 bytes of storage would pay no rent.
454
460
/// But if the balance reduced to 500,000 BU and the storage stayed the same at 1,000,
455
461
/// 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( ) ;
457
475
458
476
/// Reward that is received by the party whose touch has led
459
477
/// to removal of a contract.
0 commit comments