use crate::version::system_limits::SystemLimits; /// System limits for protocol version 14 and above. Relative to the last /// released table (V3) this changes the withdrawal limit, adds the /// time-range overlap-factor cap and adds the time-range TTL pair (the TTL /// fields joined this table in place while protocol version 14 was /// unreleased, rather than spawning a new version). The table stays editable /// in place until 4.2 (protocol version 14) is live on mainnet, and is frozen /// after: /// /// * `max_time_range_ttl_seconds` is set to one week: the ceiling on the /// `ttl` a `timeRange` index transform may declare. The cap is what makes /// the ephemeral-bytes fee model safe — a flat processing rate is only an /// honest price for transitional storage while the lifetime it covers is /// bounded. See `book/src/drive/time-range-ttl.md`. /// * `min_time_range_ttl_drop_operations_per_write` is set to 32. Drive /// raises this floor according to the merged grid's tree structure and /// overlap, so cleanup can retire trees faster than writes create them. /// /// The withdrawal and overlap-factor changes: /// /// * The daily withdrawal limit becomes relative: `daily_withdrawal_limit_percent` is set to 15, /// so Platform pools at most 15% of the total credits it held a day ago into asset unlock /// transactions per 24 hours, never below one maximal withdrawal, instead of the flat 2000 /// Dash that applied from v8 (matching Core v22's `LimitAmountV22`). v13 is already live on /// networks with the flat limit, so the change gates here. The limit has no fixed cap. /// * Withdrawals also fit a Core-anchored limit, a stricter copy of Core v24's relative net /// unlock rule read from Core's own credit pool balances: the pool may drop by at most /// `core_credit_pool_unlock_limit_percent` (15, Core allows 20) of its highest balance at a /// window start Core may use for the unlock (Core's window, `core_credit_pool_window_blocks` /// 576 or `regtest_core_credit_pool_window_blocks` 100, back from the chain locked height, /// up to Core's asset unlock validity, `withdrawal_constants.core_expiration_blocks` 48, /// later), at least /// `core_credit_pool_unlock_limit_floor` (1500 Dash, Core's floor is 2000), less what is /// queued or broadcast and not completed yet. /// * `max_time_range_overlap_factor` is set: a `timeRange` index transform may declare at most /// 24 overlapping windows per timestamp (a day-long window sliding hourly). The rule cannot /// exist before v14 because the `timeRange` keyword itself is only admitted by the v14 /// document meta-schema. /// * `core_dust_relay_fee_per_kb` is set to Core's default 3000 duffs/kB: an expired /// withdrawal whose whole amount is below the dust threshold of its output script (546 /// duffs for P2PKH) is marked FAILED by `rebroadcast_expired_withdrawal_documents` v2 /// instead of being re-signed every 48 Core blocks forever. Withdrawals admitted before /// v12's 1000-duff floor can carry such amounts on live networks. /// * Core withdrawal fee rates are capped at 6,765 duffs per byte. /// * Contract groups (protocol version 14): a data contract create transition may declare at /// most 16 contract group memberships, a contract group may name at most 16 admins besides /// its owner, and a group's name and description are capped at 64 and 256 characters. The /// `max_contract_group_size` limit was renamed `max_group_member_count` at the same time; it /// bounds the members of a change-control `Group` inside a contract, not a contract group. /// * Contract moderation (protocol version 14): a moderated data contract may name at most 16 /// moderator identities, its owner counted when named. A suspension runs until at most /// 2^53 - 1 milliseconds of block time, the largest value JSON clients read exactly. The /// text of the reason a ban or a suspension carries is at most 1024 bytes. /// * Elected moderation teams (protocol version 14): a contract that declares an elected /// moderation team sets its join window and vote window at most four weeks, and at least /// one day on mainnet (0 is allowed on every other network), and its challenge cool-down /// between two weeks and three years, all in seconds. /// * Typed array document properties (protocol version 14): a typed array property declares /// `maxItems`, at most 1024 elements (`max_typed_array_items`, backfilled into the /// earlier tables, whose parsers never read it). /// * Typed array element indexes (protocol version 14): an index keying documents by the /// elements of a typed array holds the array to at most 16 elements /// (`max_indexed_array_items`), or 4 when the index also has a `timeRange` or `integerRange` /// window (`max_windowed_indexed_array_items`), and one document of such a type writes at /// most 256 index entries across its indexes (`max_index_entries_per_document`). They joined /// this table in place while protocol version 14 was unreleased. `None` in the earlier /// tables, whose parsers refuse an index on a typed array. /// * References (protocol version 14): one document of a document type carries at most 256 /// references, counted at registration as one per property with `refersTo`, one for the /// type's `ownerRefersTo` and `maxItems` per typed array whose elements declare one /// (`max_references_per_document`, /// backfilled into the earlier tables, whose parsers never read it). Each reference is a /// billed state read when the document is written. /// * Reference expressions (protocol version 14): a `refersTo` `anyOf` or `allOf` list holds at /// most 4 operands (`max_reference_operands`) and they nest at most 4 combinators deep /// (`max_reference_expression_depth`), both backfilled into the earlier tables, whose parsers /// never read them; every leaf counts against `max_references_per_document`. /// * Property constraints (protocol version 14): a document type declares at most 16 /// `propertyConstraints` rules (`max_property_constraints`) of at most 32 nodes each /// (`max_property_constraint_nodes`), reading at most 4 distinct `countOf` and `sumOf` /// totals (`max_property_constraint_aggregates`), all backfilled into the earlier tables, /// whose parsers never read them. The first two bound the arithmetic one document write /// causes, the third the count and sum trees it reads. /// * Document expiry (protocol version 14): a document type may declare a `ttl` of at least /// one hour (`min_document_ttl_seconds`) and at most one year (`max_document_ttl_seconds`), /// and the platform deletes at most 128 expired documents per block /// (`max_document_expirations_per_block`), weighing at most 1,024 in documents plus their /// index levels (`max_document_expiration_weight_per_block`), all joined this table in /// place while protocol version 14 was unreleased. `None` or 0 in the earlier tables, /// whose parsers never read the keyword and whose blocks never run the cleanup. /// * Moderation charters (protocol version 14): an elected moderation declaration lets a /// seated team's leader add at most 15 members (`max_contract_moderation_added_moderators`), /// which joined this table in place while protocol version 14 was unreleased. A charter's /// description cap is the charter schema's own `maxBytes`, not a limit here. /// * Settled-document deletions (protocol version 14): a document type's /// `moderatorAbilities.deleteSettled` requires at most as many approvals as the declared team /// holds, its leader, the 15 members a charter elects (`max_moderation_charter_elected_members`, /// the charters contract's `electedCharter.members` `maxItems`) and the declaration's /// `maxAddedModerators`. It joined this table in place while protocol version 14 was /// unreleased, and was backfilled into the earlier tables, whose parsers never read it. /// * Contested documents (protocol version 14): a contest accepts at most 1,000 contenders /// (`max_contenders_per_contest`, backfilled into the earlier tables, whose validation never /// reads it). The end of a poll within the cap tallies and cleans up every contender in one /// block; the end of one that grew past 10,000 before version 14, its first 10,000 /// (`maximum_contenders_to_consider`). /// * Contested summed types (protocol version 14): a document type with a contested index /// and a summed property may only be registered when that property's values lie within /// ±2^27 (`max_contested_summed_value_magnitude`), so awarding a contest cannot take a sum /// out of `i64`. It joined this table in place while protocol version 14 was unreleased. /// `None` in the earlier tables, whose parsers never read it. /// * Expiring summed types (protocol version 14): a document type with a `ttl` and a summed /// property whose values may be negative may only be registered when they lie within /// ±2^27 (`max_expiring_signed_summed_value_magnitude`), so deleting expired documents /// cannot take a sum out of `i64`. It joined this table in place while protocol version /// 14 was unreleased. `None` in the earlier tables, whose parsers never read it. /// * Token pool notes threshold (protocol version 14): a token configuration's /// `minimumPoolNotesForOutgoing` is at most 250 (`max_token_pool_notes_for_outgoing`), the /// credit pool's own threshold, backfilled into the earlier tables, which admit no token /// configuration able to carry it. /// * Choosing the first commitment (protocol version 14): a create whose `refersTo` declares /// `chooseFirst` reads at most 1,000 competitors of the commitment it found /// (`max_choose_first_candidates`, backfilled into the earlier tables, whose validation never /// reads it). /// * Unsigned index value keys (protocol version 14): the first block of the version rewrites /// the keys of unsigned integer index values, applying its moves in batches of 10,000 moves /// (`max_rekey_batch_moves`). `None` in the earlier tables, which never run the rewrite. pub const SYSTEM_LIMITS_V4: SystemLimits = SystemLimits { max_document_revisions_erased_per_transition: None, max_enum_violation_listed_values: None, max_enum_violation_listed_bytes: None, // The page matches one notes-tree chunk (2^11). A batch holds at most that // page's missing rhos; GroveDB accepts a Vec of operations with no smaller API cap. credit_pool_nullifier_backfill_page_size: 2048, credit_pool_nullifier_backfill_batch_size: 2048, estimated_contract_max_serialized_size: 16384, max_field_value_size: 5120, //5 KiB // Use the protocol's existing data-contract schema-depth ceiling as the conservative // instance budget, bounding pre-schema work well above known document requirements. max_document_value_depth: Some(256), max_typed_array_items: 1024, // typed array properties (new in v14): contract registration caps their maxItems here max_index_property_name_bytes: 255, // native registration checks (new in v15): an index property name holds at most the 255 bytes of a GroveDB key max_contract_schema_patterns: 32, // schema pattern bounds (consensus from v15, mempool policy before): a contract holds at most 32 patterns max_schema_pattern_compiled_size: 131_072, // and each compiles within 128 KiB max_schema_pattern_bytes: 256, // each takes at most 256 bytes as written max_contract_schema_pattern_bytes: 4096, // and all of them at most 4 KiB together, one in `$defs` once for each document type max_schema_pattern_case_folded_code_points: 4096, // and each is estimated to case-fold at most 4096 code points when it is translated max_compiled_contract_size: None, // no contract is stored compiled before protocol version 15 max_private_document_entry_size: None, // no private document type before protocol version 15 private_document_store_target_chunk_bytes: None, private_document_store_min_chunk_power: None, private_document_store_max_chunk_power: None, max_private_document_entries_per_transition: None, max_references_per_document: 256, // refersTo (new in v14): contract registration caps the references one document carries, a typed array of references counting its maxItems max_reference_operands: 4, // refersTo anyOf / allOf (new in v14): contract registration caps the operands one list holds max_reference_expression_depth: 4, // refersTo anyOf / allOf (new in v14): contract registration caps how deep they nest max_document_type_requirement_slots: 4, // backfilled: dynamic references parse from protocol version 15 max_document_type_requirement_condition_nodes: 16, // backfilled: a slot `when` parses from protocol version 15 max_document_type_requirement_condition_text_length: 256, // backfilled: a slot `when` parses from protocol version 15 max_property_constraints: 16, // propertyConstraints (new in v14): contract registration caps the rules one document type declares max_property_constraint_nodes: 32, // propertyConstraints (new in v14): contract registration caps the nodes (comparison, operators, properties, values) of one rule max_property_constraint_aggregates: 4, // propertyConstraints countOf / sumOf (new in v14): contract registration caps the distinct totals one document type's rules read max_state_transition_size: 20480, //20 KiB // Load-bearing for state correctness, not just for throughput — see // SystemLimits::max_transitions_in_documents_batch and SYSTEM_LIMITS_V1. max_transitions_in_documents_batch: 1, withdrawal_transactions_per_block_limit: 4, retry_signing_expired_withdrawal_documents_per_block_limit: 1, max_withdrawal_amount: 50_000_000_000_000, //500 Dash daily_withdrawal_limit_percent: Some(15), // 15% of the total credits a day ago (replaces the flat 2000 Dash in v14) core_credit_pool_unlock_limit_percent: Some(15), // Core v24 allows 20% of the pool a window ago core_credit_pool_unlock_limit_floor: Some(150_000_000_000_000), // 1500 Dash; Core v24's floor is 2000 Dash core_credit_pool_window_blocks: Some(576), // Core's credit pool window (CreditPoolPeriodBlocks), mainnet, testnet and devnets regtest_core_credit_pool_window_blocks: Some(100), // Core's credit pool window on regtest min_withdrawal_amount: 1_000_000, //1000 duffs (raised from 190 in v12) core_dust_relay_fee_per_kb: Some(3000), // Core's default dust relay fee: 546-duff P2PKH threshold; expired withdrawals below it fail instead of re-signing max_core_fee_per_byte: Some(6_765), max_group_member_count: 256, max_contract_group_memberships_per_contract: 16, max_contract_group_admins: 16, max_contract_group_name_length: 64, max_contract_group_description_length: 256, max_contract_moderators: 16, max_contract_suspension_until: 9_007_199_254_740_991, max_contract_moderation_reason_length: 1024, max_yes_no_vote_poll_minimum_voting_power: 2000, max_yes_no_vote_poll_minimum_voting_power_percent_of_total: 50, max_yes_no_vote_poll_duration_ms: 2_419_200_000, // four weeks min_yes_no_vote_poll_duration_ms: 604_800_000, // one week min_yes_no_vote_poll_supermajority_percent: 50, // a simple majority yes_no_vote_poll_masternode_vote_strength: 1, yes_no_vote_poll_evonode_vote_strength: 4, max_contract_warnings_per_identity: 16, max_contract_moderation_reason_documents: 16, min_mainnet_contract_moderation_election_window_seconds: 86_400, // one day max_contract_moderation_election_window_seconds: 2_419_200, // four weeks min_contract_moderation_challenge_cool_down_seconds: 1_209_600, // two weeks max_contract_moderation_challenge_cool_down_seconds: 94_608_000, // three years of 365 days contract_document_restore_window_ms: 604_800_000, // 7 days max_contract_moderation_added_moderators: 15, max_moderation_charter_elected_members: 15, max_contenders_per_contest: 1_000, max_token_redemption_cycles: 128, max_evonode_reward_claim_epochs: 100, // NOTE: the Halo 2 proof grows with the action count (~2,273 B/action on // top of the 408 B serialized action), so a transition's on-wire size is // ~2,681 B per action + ~2,930 B fixed (measured: 2 actions → 8,294 B, // 6 → 19,018 B). The effective per-transition action bound under the // 20 KiB `max_state_transition_size` is therefore 6, NOT this cap — 16 // only becomes reachable if the size limit is raised. Pinned by dpp's // `seed_pool_batch_fits_max_state_transition_size` signing test. max_shielded_transition_actions: 16, max_token_pool_notes_for_outgoing: 250, max_time_range_overlap_factor: Some(24), max_time_range_ttl_seconds: Some(604_800), // one week min_time_range_ttl_drop_operations_per_write: Some(32), min_document_ttl_seconds: Some(3_600), // document ttl (new in v14): one hour max_document_ttl_seconds: Some(31_536_000), // document ttl (new in v14): one year of 365 days max_document_expirations_per_block: 128, // document ttl (new in v14): expired documents deleted per block max_document_expiration_weight_per_block: 1_024, // document ttl (new in v14): deleted documents plus their index levels per block max_contested_summed_value_magnitude: Some(1 << 27), // contested summed types (new in v14): values within ±2^27 max_expiring_signed_summed_value_magnitude: Some(1 << 27), // expiring summed types (new in v14): values within ±2^27 unless never negative max_summed_value_magnitude_without_type_total: None, // read from protocol version 15 max_summed_value_magnitude_in_64_bit_sums: None, // read from protocol version 15 max_indexed_array_items: Some(16), // typed array element indexes (new in v14): an indexed typed array holds at most 16 elements max_windowed_indexed_array_items: Some(4), // typed array element indexes (new in v14): at most 4 when the index also has a timeRange or integerRange window max_index_entries_per_document: Some(256), // typed array element indexes (new in v14): one document of a type with an indexed array writes at most 256 index entries max_choose_first_candidates: 1_000, // refersTo chooseFirst (new in v14): competitors a create reads, oldest first max_rekey_batch_moves: Some(10_000), // the protocol version 14 rewrite of unsigned index value keys applies its moves in batches of this many moves max_history_migration_batch_operations: None, // read only by the protocol version 15 upgrade };