Skip to main content

platform_version/version/fee/document_reference/
mod.rs

1use bincode::{Decode, Encode};
2
3pub mod v1;
4
5/// Fees of the reads a document reference (`refersTo`) makes when a document is written
6/// (protocol version 14).
7///
8/// A create whose `refersTo` declares `chooseFirst` reads the competitors of the commitment it
9/// found, at most `SystemLimits::max_choose_first_candidates` documents in one query, and hashes
10/// the `findBy` function once for each. Both are billed as they run, but never more than
11/// `choose_first_credits_per_candidate` times that limit, the scan's budget. Check tx, which
12/// does not validate such a create's state, holds its signer to the whole budget on top of the
13/// create's estimated fee, so a block never charges the scan more than the signer was admitted
14/// with: a signer who could not pay for a full scan is kept out of the mempool rather than
15/// refused unpaid in a block, with its nonce left to replay.
16///
17/// A `where` entry comparing typed arrays (an equality between two of them, `contains` or
18/// `containsAll`) is billed by the list elements it reads, before it compares them.
19///
20/// Every earlier schedule carries the same group; it is unread there because neither
21/// `chooseFirst` nor a `where` entry parses before protocol version 14.
22#[derive(Clone, Debug, Encode, Decode, Default, PartialEq, Eq)]
23pub struct FeeDocumentReferenceVersion {
24    /// The credits per competitor a `chooseFirst` may read that bound what its scan bills, and
25    /// what check tx reserves for it.
26    pub choose_first_credits_per_candidate: u64,
27    /// The credits per list element a `where` entry comparing typed arrays reads, on both
28    /// sides, against a document in state or a moderated document's removal record.
29    pub where_list_credits_per_element: u64,
30}