platform_version/version/fee/document_ttl/v1.rs
1use crate::version::fee::document_ttl::{DocumentTtlFeeTier, FeeDocumentTtlVersion};
2
3/// Introduced with protocol version 14 (4.2), the first version that parses the document
4/// type `ttl` keyword; every fee schedule references it, and none before 14 reads it.
5///
6/// The per-byte prices are pro rata of the first year of perpetual storage: 27,000 credits
7/// per byte (`storage_disk_usage_credit_per_byte`), of which the distribution table pays 5%
8/// out in the first year (40 mainnet epochs of 9.125 days), so about 3.7 credits per byte per
9/// day and 33.75 per byte per 9.125 day period, rounded up. A document of a one-year `ttl`
10/// therefore pays about what a permanent document deleted after a year keeps paying net of
11/// its refund. The period is mainnet's epoch length, fixed here so a network configured
12/// with shorter epochs does not multiply the price.
13pub const FEE_DOCUMENT_TTL_VERSION1: FeeDocumentTtlVersion = FeeDocumentTtlVersion {
14 tiers: [
15 DocumentTtlFeeTier {
16 max_ttl_seconds: 3_600, // up to one hour
17 credit_per_byte: 1,
18 },
19 DocumentTtlFeeTier {
20 max_ttl_seconds: 86_400, // up to one day
21 credit_per_byte: 4,
22 },
23 DocumentTtlFeeTier {
24 max_ttl_seconds: 172_800, // up to two days
25 credit_per_byte: 8,
26 },
27 DocumentTtlFeeTier {
28 max_ttl_seconds: 345_600, // up to four days
29 credit_per_byte: 15,
30 },
31 DocumentTtlFeeTier {
32 max_ttl_seconds: 604_800, // up to seven days
33 credit_per_byte: 26,
34 },
35 ],
36 credit_per_byte_per_period: 34,
37 pricing_period_seconds: 788_400, // 9.125 days, mainnet's epoch length
38 // Measured on protocol version 14 (drive `delete_document_for_contract` of a document of
39 // a type with a `ttl`, averaged over ten documents): about 1.53M credits of processing with
40 // one index level, 1.94M with two and 2.39M with four. Base plus per level covers each.
41 cleanup_base_processing_cost: 1_200_000,
42 cleanup_processing_cost_per_index_level: 400_000,
43 // What the deletion pays per byte of the document it removes: the removal
44 // (`storage_processing_credit_per_byte`, 400) and the read of the document
45 // (`storage_load_credit_per_byte`, 20). The measured documents above were small, so the
46 // base and per level costs stand for everything but the document's own bytes.
47 cleanup_processing_cost_per_document_byte: 420,
48};