Skip to main content

platform_version/version/drive_versions/
v9.rs

1use crate::version::drive_versions::drive_address_funds_method_versions::v2::DRIVE_ADDRESS_FUNDS_METHOD_VERSIONS_V2;
2use crate::version::drive_versions::drive_contract_method_versions::v3::DRIVE_CONTRACT_METHOD_VERSIONS_V3;
3use crate::version::drive_versions::drive_credit_pool_method_versions::v1::CREDIT_POOL_METHOD_VERSIONS_V1;
4use crate::version::drive_versions::drive_document_method_versions::v4::DRIVE_DOCUMENT_METHOD_VERSIONS_V4;
5use crate::version::drive_versions::drive_group_method_versions::v1::DRIVE_GROUP_METHOD_VERSIONS_V1;
6use crate::version::drive_versions::drive_group_method_versions::DriveShieldedMethodVersions;
7use crate::version::drive_versions::drive_grove_method_versions::v1::DRIVE_GROVE_METHOD_VERSIONS_V1;
8use crate::version::drive_versions::drive_identity_method_versions::v2::DRIVE_IDENTITY_METHOD_VERSIONS_V2;
9use crate::version::drive_versions::drive_state_transition_method_versions::v4::DRIVE_STATE_TRANSITION_METHOD_VERSIONS_V4;
10use crate::version::drive_versions::drive_structure_version::v1::DRIVE_STRUCTURE_V1;
11use crate::version::drive_versions::drive_token_method_versions::v1::DRIVE_TOKEN_METHOD_VERSIONS_V1;
12use crate::version::drive_versions::drive_verify_method_versions::v2::DRIVE_VERIFY_METHOD_VERSIONS_V2;
13use crate::version::drive_versions::drive_vote_method_versions::v2::DRIVE_VOTE_METHOD_VERSIONS_V2;
14use crate::version::drive_versions::{
15    DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion,
16    DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveFetchMethodVersions,
17    DriveInitializationMethodVersions, DriveMethodVersions, DriveOperationsMethodVersion,
18    DrivePlatformStateMethodVersions, DrivePlatformSystemMethodVersions,
19    DrivePrefundedSpecializedMethodVersions, DriveProtocolUpgradeVersions,
20    DriveProveMethodVersions, DriveSavedBlockTransactionsMethodVersions,
21    DriveSystemEstimationCostsMethodVersions, DriveVersion,
22};
23use grovedb_version::version::v4::GROVE_V4;
24
25/// Drive version 9.
26/// Introduced in protocol v14, carrying both of v14's drive-side changes:
27///
28/// * **Shared-prefix aggregate index fix** —
29///   `DRIVE_DOCUMENT_METHOD_VERSIONS_V4` bumps the four index walkers to v2
30///   (and the document update walker to v1) so contracts that pair an
31///   aggregating (countable / summable) index with a compound index sharing
32///   its leading property can insert, update, and delete documents.
33/// * **Contract-level ranked aggregates** — the same V4 table adds the
34///   `detect_ranked_mode` routing slot, `grove_methods.batch` gains the
35///   three indexed-tree creation slots, and `methods.verify` gains
36///   `document_ranked.verify_ranked_top_k_proof`. All are 0 at
37///   introduction; the ranked grammar itself is gated one layer up by
38///   `CONTRACT_VERSIONS_V6`'s meta schema v3.
39///
40/// Everything else matches `DRIVE_VERSION_V8`.
41pub const DRIVE_VERSION_V9: DriveVersion = DriveVersion {
42    structure: DRIVE_STRUCTURE_V1,
43    methods: DriveMethodVersions {
44        initialization: DriveInitializationMethodVersions {
45            create_initial_state_structure: 3, // changed in v8: adds shielded pool trees (commitment tree, nullifiers, anchors)
46        },
47        credit_pools: CREDIT_POOL_METHOD_VERSIONS_V1,
48        protocol_upgrade: DriveProtocolUpgradeVersions {
49            clear_version_information: 0,
50            fetch_versions_with_counter: 0,
51            fetch_proved_versions_with_counter: 0,
52            fetch_validator_version_votes: 0,
53            fetch_proved_validator_version_votes: 0,
54            remove_validators_proposed_app_versions: 0,
55            update_validator_proposed_app_version: 0,
56        },
57        prove: DriveProveMethodVersions {
58            prove_elements: 0,
59            prove_multiple_state_transition_results: 0,
60            prove_state_transition: 0,
61        },
62        balances: DriveBalancesMethodVersions {
63            add_to_system_credits: 0,
64            add_to_system_credits_operations: 0,
65            remove_from_system_credits: 0,
66            remove_from_system_credits_operations: 0,
67            calculate_total_credits_balance: 2, // ShieldedBalances root tree adds a fifth term to the equation
68        },
69        document: DRIVE_DOCUMENT_METHOD_VERSIONS_V4, // changed in v9: v2 index walkers + v1 update walker (shared-prefix aggregate indexes become insertable) and the detect_ranked_mode slot
70        vote: DRIVE_VOTE_METHOD_VERSIONS_V2,
71        contract: DRIVE_CONTRACT_METHOD_VERSIONS_V3, // changed in v8: count-tree-aware contract-insertion cost estimation (v12+ countable/range_countable doctypes)
72        fees: DriveFeesMethodVersions { calculate_fee: 0 },
73        estimated_costs: DriveEstimatedCostsMethodVersions {
74            add_estimation_costs_for_levels_up_to_contract: 0,
75            add_estimation_costs_for_levels_up_to_contract_document_type_excluded: 0,
76            add_estimation_costs_for_contested_document_tree_levels_up_to_contract: 0,
77            add_estimation_costs_for_contested_document_tree_levels_up_to_contract_document_type_excluded: 0,
78        },
79        asset_lock: DriveAssetLockMethodVersions {
80            add_asset_lock_outpoint: 0,
81            add_estimation_costs_for_adding_asset_lock: 0,
82            fetch_asset_lock_outpoint_info: 0,
83        },
84        verify: DRIVE_VERIFY_METHOD_VERSIONS_V2, // changed in v8: compacted address-balance proof envelope (verify v1)
85        identity: DRIVE_IDENTITY_METHOD_VERSIONS_V2, // changed in v9: v1 withdrawal-by-transaction-index query builder (structural, identical lowering)
86        token: DRIVE_TOKEN_METHOD_VERSIONS_V1,
87        platform_system: DrivePlatformSystemMethodVersions {
88            estimation_costs: DriveSystemEstimationCostsMethodVersions {
89                for_total_system_credits_update: 0,
90            },
91        },
92        operations: DriveOperationsMethodVersion {
93            rollback_transaction: 0,
94            drop_cache: 0,
95            commit_transaction: 0,
96            apply_partial_batch_low_level_drive_operations: 0,
97            apply_partial_batch_grovedb_operations: 0,
98            apply_batch_low_level_drive_operations: 0,
99            apply_batch_grovedb_operations: 0,
100        },
101        state_transitions: DRIVE_STATE_TRANSITION_METHOD_VERSIONS_V4, // changed: document_from_action generation 1 stamps built documents with the contract version (create assigns, replace re-assigns; paired with document serialization format 3)
102        batch_operations: DriveBatchOperationsMethodVersion {
103            convert_drive_operations_to_grove_operations: 0,
104            apply_drive_operations: 0,
105        },
106        platform_state: DrivePlatformStateMethodVersions {
107            fetch_platform_state_bytes: 0,
108            store_platform_state_bytes: 0,
109        },
110        fetch: DriveFetchMethodVersions { fetch_elements: 0 },
111        prefunded_specialized_balances: DrivePrefundedSpecializedMethodVersions {
112            fetch_single: 0,
113            prove_single: 0,
114            add_prefunded_specialized_balance: 0,
115            add_prefunded_specialized_balance_operations: 1,
116            deduct_from_prefunded_specialized_balance: 1,
117            deduct_from_prefunded_specialized_balance_operations: 0,
118            estimated_cost_for_prefunded_specialized_balance_update: 0,
119            empty_prefunded_specialized_balance: 0,
120        },
121        group: DRIVE_GROUP_METHOD_VERSIONS_V1,
122        address_funds: DRIVE_ADDRESS_FUNDS_METHOD_VERSIONS_V2,
123        shielded: DriveShieldedMethodVersions {
124            insert_note: 0,
125            insert_nullifiers: 0,
126            update_total_balance: 0,
127            record_anchor_if_changed: 0,
128            prune_anchors: 0,
129            has_anchor: 0,
130            has_nullifier: 0,
131            read_total_balance: 0,
132            notes_count: 0,
133        },
134        saved_block_transactions: DriveSavedBlockTransactionsMethodVersions {
135            store_address_balances: 0,
136            fetch_address_balances: 0,
137            prove_compacted_address_balance_changes: 1,
138            compact_address_balances: 0,
139            cleanup_expired_address_balances: 0,
140            max_blocks_before_compaction: 64,
141            max_addresses_before_compaction: 2048,
142        },
143    },
144    grove_methods: DRIVE_GROVE_METHOD_VERSIONS_V1,
145    // changed in v9: GROVE_V4 activates the indexed-tree batch cleanup
146    // gates (overwrite inspection + delete-tree actual-type cleanup).
147    // Indexed trees only exist from protocol v14, so activating the
148    // stricter cleanup with them costs older versions nothing; staying
149    // on V3 would let a batch overwrite of a ranked index orphan its
150    // per-axis secondary storage.
151    grove_version: GROVE_V4,
152};