Skip to main content

platform_version/version/
v13.rs

1use crate::version::consensus_versions::ConsensusVersions;
2use crate::version::dpp_versions::dpp_asset_lock_versions::v1::DPP_ASSET_LOCK_VERSIONS_V1;
3use crate::version::dpp_versions::dpp_contract_versions::v5::CONTRACT_VERSIONS_V5;
4use crate::version::dpp_versions::dpp_costs_versions::v1::DPP_COSTS_VERSIONS_V1;
5use crate::version::dpp_versions::dpp_document_versions::v3::DOCUMENT_VERSIONS_V3;
6use crate::version::dpp_versions::dpp_factory_versions::v1::DPP_FACTORY_VERSIONS_V1;
7use crate::version::dpp_versions::dpp_identity_versions::v1::IDENTITY_VERSIONS_V1;
8use crate::version::dpp_versions::dpp_method_versions::v2::DPP_METHOD_VERSIONS_V2;
9use crate::version::dpp_versions::dpp_state_transition_conversion_versions::v2::STATE_TRANSITION_CONVERSION_VERSIONS_V2;
10use crate::version::dpp_versions::dpp_state_transition_method_versions::v1::STATE_TRANSITION_METHOD_VERSIONS_V1;
11use crate::version::dpp_versions::dpp_state_transition_serialization_versions::v2::STATE_TRANSITION_SERIALIZATION_VERSIONS_V2;
12use crate::version::dpp_versions::dpp_state_transition_versions::v3::STATE_TRANSITION_VERSIONS_V3;
13use crate::version::dpp_versions::dpp_token_versions::v2::TOKEN_VERSIONS_V2;
14use crate::version::dpp_versions::dpp_validation_versions::v4::DPP_VALIDATION_VERSIONS_V4;
15use crate::version::dpp_versions::dpp_voting_versions::v2::VOTING_VERSION_V2;
16use crate::version::dpp_versions::DPPVersion;
17use crate::version::drive_abci_versions::drive_abci_checkpoint_parameters::v1::DRIVE_ABCI_CHECKPOINT_PARAMETERS_V1;
18use crate::version::drive_abci_versions::drive_abci_method_versions::v9::DRIVE_ABCI_METHOD_VERSIONS_V9;
19use crate::version::drive_abci_versions::drive_abci_query_versions::v1::DRIVE_ABCI_QUERY_VERSIONS_V1;
20use crate::version::drive_abci_versions::drive_abci_structure_versions::v1::DRIVE_ABCI_STRUCTURE_VERSIONS_V1;
21use crate::version::drive_abci_versions::drive_abci_validation_versions::v9::DRIVE_ABCI_VALIDATION_VERSIONS_V9;
22use crate::version::drive_abci_versions::drive_abci_withdrawal_constants::v2::DRIVE_ABCI_WITHDRAWAL_CONSTANTS_V2;
23use crate::version::drive_abci_versions::DriveAbciVersion;
24use crate::version::drive_versions::v8::DRIVE_VERSION_V8;
25use crate::version::fee::v2::FEE_VERSION2;
26use crate::version::protocol_version::PlatformVersion;
27use crate::version::system_data_contract_versions::v2::SYSTEM_DATA_CONTRACT_VERSIONS_V2;
28use crate::version::system_limits::v3::SYSTEM_LIMITS_V3;
29use crate::version::ProtocolVersion;
30
31pub const PROTOCOL_VERSION_13: ProtocolVersion = 13;
32
33/// v13 expands the recent per-block address-balance set that incremental client
34/// sync reads: `DRIVE_ABCI_METHOD_VERSIONS_V9` bumps two fields from 0 to 1, both
35/// recording what v0 dropped — (1) `record_added_balance_outputs` folds
36/// shielded-spend transparent credits (Unshield net output, ShieldFromAssetLock
37/// surplus, identity-create fallback), and (2) `process_validation_result`
38/// records the balance effects of paid-invalid / unsuccessful-paid transitions
39/// (charged fees, adjusted outputs), in a real _v1 of the helper so its _v0 stays
40/// byte-identical to old nodes (the outer `process_raw_state_transitions` loop is
41/// unchanged and stays at v0). The storage method
42/// (`store_address_balances_to_recent_block_storage`) is unchanged — only the
43/// recorded set differs. Because that set changes the committed state root, both
44/// bumps activate only once the network votes in v13.
45///
46/// v13 also enables DPNS username transfers and sales:
47/// * `DRIVE_ABCI_VALIDATION_VERSIONS_V9` bumps data trigger bindings to v1,
48///   dropping the reject bindings for Transfer, Purchase and UpdatePrice on
49///   DPNS `domain` documents. It also revises the shielded identity-create
50///   exit-denomination set: 0.03 and 0.25 DASH are added and 0.3 DASH is
51///   retired, giving 0.03 / 0.1 / 0.25 / 0.5 / 1 DASH.
52/// * `DRIVE_VERSION_V8` bumps the document transfer/purchase high-level
53///   operation conversions to v1, which rewrite a transferred or purchased
54///   domain's `records.identity` to the new owner so the username resolves
55///   to the buyer.
56/// * `DRIVE_VERSION_V8` also switches the compacted address-balance-changes
57///   proof to the two-proof `CompactedAddressBalanceProof` bincode envelope
58///   (`prove_compacted_address_balance_changes` 1 via
59///   `DRIVE_VERIFY_METHOD_VERSIONS_V2`'s matching decoder bump): the
60///   independently verified predecessor proof binds the forward-query start
61///   key. Nodes and clients on v12 and below keep the legacy single GroveDB
62///   proof, so mixed-version networks interoperate until v13 activates.
63pub const PLATFORM_V13: PlatformVersion = PlatformVersion {
64    protocol_version: PROTOCOL_VERSION_13,
65    drive: DRIVE_VERSION_V8,
66    drive_abci: DriveAbciVersion {
67        structs: DRIVE_ABCI_STRUCTURE_VERSIONS_V1,
68        methods: DRIVE_ABCI_METHOD_VERSIONS_V9, // changed: records shielded-spend transparent credits (Unshield net output, ShieldFromAssetLock surplus, identity-create fallback) into the recent per-block address-balance set
69        validation_and_processing: DRIVE_ABCI_VALIDATION_VERSIONS_V9, // changed: allow DPNS domain transfer/purchase/update-price
70        withdrawal_constants: DRIVE_ABCI_WITHDRAWAL_CONSTANTS_V2,
71        query: DRIVE_ABCI_QUERY_VERSIONS_V1,
72        checkpoints: DRIVE_ABCI_CHECKPOINT_PARAMETERS_V1,
73    },
74    dpp: DPPVersion {
75        costs: DPP_COSTS_VERSIONS_V1,
76        validation: DPP_VALIDATION_VERSIONS_V4,
77        state_transition_serialization_versions: STATE_TRANSITION_SERIALIZATION_VERSIONS_V2,
78        state_transition_conversion_versions: STATE_TRANSITION_CONVERSION_VERSIONS_V2,
79        state_transition_method_versions: STATE_TRANSITION_METHOD_VERSIONS_V1,
80        state_transitions: STATE_TRANSITION_VERSIONS_V3,
81        contract_versions: CONTRACT_VERSIONS_V5, // changed: v2 document meta-schema accepts the keeps*History flags
82        document_versions: DOCUMENT_VERSIONS_V3,
83        identity_versions: IDENTITY_VERSIONS_V1,
84        voting_versions: VOTING_VERSION_V2,
85        token_versions: TOKEN_VERSIONS_V2,
86        asset_lock_versions: DPP_ASSET_LOCK_VERSIONS_V1,
87        methods: DPP_METHOD_VERSIONS_V2,
88        factory_versions: DPP_FACTORY_VERSIONS_V1,
89    },
90    system_data_contracts: SYSTEM_DATA_CONTRACT_VERSIONS_V2, // changed: DPNS v2 subscribes domain to document history
91    fee_version: FEE_VERSION2,
92    system_limits: SYSTEM_LIMITS_V3,
93    consensus: ConsensusVersions {
94        tenderdash_consensus_version: 1,
95    },
96};
97
98#[cfg(test)]
99mod tests {
100    use super::*;
101    use crate::version::v12::PLATFORM_V12;
102
103    #[test]
104    fn token_authorization_hardening_activates_only_at_v13() {
105        let v12_batch = &PLATFORM_V12
106            .drive_abci
107            .validation_and_processing
108            .state_transitions
109            .batch_state_transition;
110        let v13_batch = &PLATFORM_V13
111            .drive_abci
112            .validation_and_processing
113            .state_transitions
114            .batch_state_transition;
115
116        assert_eq!(v12_batch.token_base_transition_state_validation, 0);
117        assert_eq!(v13_batch.token_base_transition_state_validation, 1);
118        assert_eq!(v12_batch.token_base_transition_group_action_validation, 0);
119        assert_eq!(v13_batch.token_base_transition_group_action_validation, 1);
120        assert_eq!(v12_batch.token_config_update_transition_state_validation, 0);
121        assert_eq!(v13_batch.token_config_update_transition_state_validation, 1);
122        assert_eq!(
123            PLATFORM_V12
124                .dpp
125                .validation
126                .data_contract
127                .validate_token_config_groups_exist,
128            0
129        );
130        assert_eq!(
131            PLATFORM_V13
132                .dpp
133                .validation
134                .data_contract
135                .validate_token_config_groups_exist,
136            1
137        );
138    }
139}