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_group_method_versions::v1::DRIVE_CONTRACT_GROUP_METHOD_VERSIONS_V1;
3use crate::version::drive_versions::drive_contract_method_versions::v4::DRIVE_CONTRACT_METHOD_VERSIONS_V4;
4use crate::version::drive_versions::drive_credit_pool_method_versions::v1::CREDIT_POOL_METHOD_VERSIONS_V1;
5use crate::version::drive_versions::drive_document_method_versions::v4::DRIVE_DOCUMENT_METHOD_VERSIONS_V4;
6use crate::version::drive_versions::drive_group_method_versions::v1::DRIVE_GROUP_METHOD_VERSIONS_V1;
7use crate::version::drive_versions::drive_group_method_versions::DriveShieldedMethodVersions;
8use crate::version::drive_versions::drive_grove_method_versions::v1::DRIVE_GROVE_METHOD_VERSIONS_V1;
9use crate::version::drive_versions::drive_identity_method_versions::v2::DRIVE_IDENTITY_METHOD_VERSIONS_V2;
10use crate::version::drive_versions::drive_state_transition_method_versions::v4::DRIVE_STATE_TRANSITION_METHOD_VERSIONS_V4;
11use crate::version::drive_versions::drive_structure_version::v1::DRIVE_STRUCTURE_V1;
12use crate::version::drive_versions::drive_token_method_versions::v2::DRIVE_TOKEN_METHOD_VERSIONS_V2;
13use crate::version::drive_versions::drive_verify_method_versions::v3::DRIVE_VERIFY_METHOD_VERSIONS_V3;
14use crate::version::drive_versions::drive_vote_method_versions::v3::DRIVE_VOTE_METHOD_VERSIONS_V3;
15use crate::version::drive_versions::{
16    DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion,
17    DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveFetchMethodVersions,
18    DriveInitializationMethodVersions, DriveMethodVersions, DriveOperationsMethodVersion,
19    DrivePlatformStateMethodVersions, DrivePlatformSystemMethodVersions,
20    DrivePrefundedSpecializedMethodVersions, DriveProtocolUpgradeVersions,
21    DriveProveMethodVersions, DriveSavedBlockTransactionsMethodVersions,
22    DriveSystemEstimationCostsMethodVersions, DriveVersion,
23};
24use grovedb_version::version::v4::GROVE_V4;
25
26/// Drive version 9.
27/// Introduced in protocol v14, carrying both of v14's drive-side changes:
28///
29/// * **Shared-prefix aggregate index fix** —
30///   `DRIVE_DOCUMENT_METHOD_VERSIONS_V4` bumps the four index walkers to v2
31///   (and the document update walker to v1) so contracts that pair an
32///   aggregating (countable / summable) index with a compound index sharing
33///   its leading property can insert, update, and delete documents.
34/// * **Contract-level ranked aggregates** — the same V4 table adds the
35///   `detect_ranked_mode` routing slot, `grove_methods.batch` gains the
36///   three indexed-tree creation slots, and `methods.verify` gains
37///   `document_ranked.verify_ranked_top_k_proof`. All are 0 at
38///   introduction; the ranked grammar itself is gated one layer up by
39///   `CONTRACT_VERSIONS_V6`'s meta schema v3.
40/// * **Contest restart over orphaned vote trees** — the same V4 table bumps
41///   `insert_contested.add_contested_vote_subtree_for_non_identities_operations`
42///   to 1 so a new contest recreates the abstain or lock vote tree over the
43///   storage an earlier poll's cleanup left behind (it only removed the
44///   trees that received votes) instead of failing with
45///   `CorruptedContractIndexes`.
46/// * **Contract groups** — `create_initial_state_structure` 4 creates the
47///   `ContractGroups` root tree (key 68) with its groups and members subtrees;
48///   `DRIVE_CONTRACT_GROUP_METHOD_VERSIONS_V1` carries the insert, fetch, prove
49///   and estimation slots; `DRIVE_STATE_TRANSITION_METHOD_VERSIONS_V4` moves
50///   the contract create converter to 1 so a version 1 create transition also
51///   emits the group registration and membership operations.
52/// * **Tokens sharing a pre-programmed release time**:
53///   `DRIVE_TOKEN_METHOD_VERSIONS_V2` bumps `add_pre_programmed_distributions`
54///   to 1 so a contract whose tokens release at the same time queues the
55///   shared release-time tree once. v0 queued it once per token in one batch,
56///   which a node verifying batch consistency refuses as an internal error.
57/// * **Moderation election windows**: the same V4 table adds
58///   `insert_contested.fetch_charter_election_windows` (`None` before), so
59///   an `electedCharter` contest runs on the join and vote windows of its
60///   target contract instead of the generic ones.
61/// * **End-date cleanup of ended vote polls**: `DRIVE_VOTE_METHOD_VERSIONS_V3`
62///   bumps `cleanup.remove_contested_resource_vote_poll_end_date_query_operations`
63///   to 2, so the cleanup removes an end date only once none of its polls
64///   remain.
65/// * **summableOffCountIndex counter batches**: `apply_drive_operations` 1
66///   and `convert_drive_operations_to_grove_operations` 1 refuse a batch
67///   moving one document type's summableOffCountIndex counters for more than
68///   one document; convert 1 then converts as 0 does.
69/// * **Non-unique key lookups with two proofs**: the identity prove table has
70///   `prove_full_identity_by_non_unique_public_key_hash_two_proofs` and the
71///   identity verify table `verify_full_identity_by_non_unique_public_key_hash_two_proofs`,
72///   the separate index and identity proofs answering a
73///   `getIdentityByNonUniquePublicKeyHash` V0 request. Both are 0 here and in
74///   every earlier drive version, so they are no difference from V8.
75///
76/// Everything else matches `DRIVE_VERSION_V8`.
77pub const DRIVE_VERSION_V9: DriveVersion = DriveVersion {
78    structure: DRIVE_STRUCTURE_V1,
79    methods: DriveMethodVersions {
80        initialization: DriveInitializationMethodVersions {
81            create_initial_state_structure: 4, // changed in v9: adds the ContractGroups root tree with its groups and members subtrees (v3 added the shielded pool trees)
82        },
83        credit_pools: CREDIT_POOL_METHOD_VERSIONS_V1,
84        protocol_upgrade: DriveProtocolUpgradeVersions {
85            clear_version_information: 0,
86            fetch_versions_with_counter: 0,
87            fetch_proved_versions_with_counter: 0,
88            fetch_validator_version_votes: 0,
89            fetch_proved_validator_version_votes: 0,
90            remove_validators_proposed_app_versions: 0,
91            update_validator_proposed_app_version: 0,
92        },
93        prove: DriveProveMethodVersions {
94            prove_elements: 0,
95            prove_multiple_state_transition_results: 0,
96            prove_state_transition: 1, // changed in v9: a document batch proof carries the owner's balance (verify v1)
97        },
98        balances: DriveBalancesMethodVersions {
99            add_to_system_credits: 0,
100            add_to_system_credits_operations: 0,
101            remove_from_system_credits: 0,
102            remove_from_system_credits_operations: 0,
103            calculate_total_credits_balance: 2, // ShieldedBalances root tree adds a fifth term to the equation
104        },
105        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
106        vote: DRIVE_VOTE_METHOD_VERSIONS_V3, // changed in v9: the end-date cleanup of ended contested vote polls removes an end date only once none of its polls remain
107        contract: DRIVE_CONTRACT_METHOD_VERSIONS_V4, // changed in v9: add_contract_to_storage v1 writes the contract version item beside the contract; update_contract v2 creates the distribution storage and mints the base supply of tokens added by an update
108        fees: DriveFeesMethodVersions { calculate_fee: 0 },
109        estimated_costs: DriveEstimatedCostsMethodVersions {
110            add_estimation_costs_for_levels_up_to_contract: 0,
111            add_estimation_costs_for_levels_up_to_contract_document_type_excluded: 0,
112            add_estimation_costs_for_contested_document_tree_levels_up_to_contract: 0,
113            add_estimation_costs_for_contested_document_tree_levels_up_to_contract_document_type_excluded: 0,
114        },
115        asset_lock: DriveAssetLockMethodVersions {
116            add_asset_lock_outpoint: 0,
117            add_estimation_costs_for_adding_asset_lock: 0,
118            fetch_asset_lock_outpoint_info: 0,
119        },
120        verify: DRIVE_VERIFY_METHOD_VERSIONS_V3, // changed in v9: a document batch proof carries the owner's balance (verify state transition v1); the six range-total verifiers 1 (a proof that the range holds nothing verifies to zero) and the composite documents verifier 1 (sum-bearing items are documents)
121        identity: DRIVE_IDENTITY_METHOD_VERSIONS_V2, // changed in v9: v1 withdrawal-by-transaction-index query builder (structural, identical lowering)
122        token: DRIVE_TOKEN_METHOD_VERSIONS_V2, // changed in v9: add_pre_programmed_distributions v1 queues the release-time tree shared by a contract's tokens once; evonode_participation_rewards v1 pays an evonode's claim only through the epochs it read
123        platform_system: DrivePlatformSystemMethodVersions {
124            estimation_costs: DriveSystemEstimationCostsMethodVersions {
125                for_total_system_credits_update: 0,
126            },
127        },
128        operations: DriveOperationsMethodVersion {
129            rollback_transaction: 0,
130            drop_cache: 0,
131            commit_transaction: 0,
132            apply_partial_batch_low_level_drive_operations: 0,
133            apply_partial_batch_grovedb_operations: 0,
134            apply_batch_low_level_drive_operations: 1, // changed: coalesces bound current-key alias writes per batch
135            apply_batch_grovedb_operations: 0,
136        },
137        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)
138        batch_operations: DriveBatchOperationsMethodVersion {
139            convert_drive_operations_to_grove_operations: 1, // changed: refuses a batch moving one document type's summableOffCountIndex counters for more than one document
140            apply_drive_operations: 1, // changed: a batch carrying a storage refund forfeiture (a moderator's document deletion) refunds nobody; every write of one identity balance, fee pot or prefunded specialized balance in a batch is merged into one, a batch writing one token balance or supply twice is refused, a batch moving one document type's summableOffCountIndex counters for more than one document is refused, and repaid identity debt and returned missing-proposer allocations go to the applying block's processing fee pool after ordinary writes in the same transaction, unbilled
141        },
142        platform_state: DrivePlatformStateMethodVersions {
143            fetch_platform_state_bytes: 0,
144            store_platform_state_bytes: 0,
145            fetch_platform_state_recent_bytes: 0,
146            store_platform_state_recent_bytes: 0,
147            fetch_platform_state_entries_bytes: 0,
148            store_platform_state_entry_bytes: 0,
149            delete_platform_state_entry: 0,
150        },
151        fetch: DriveFetchMethodVersions { fetch_elements: 0 },
152        prefunded_specialized_balances: DrivePrefundedSpecializedMethodVersions {
153            fetch_single: 0,
154            prove_single: 0,
155            add_prefunded_specialized_balance: 0,
156            add_prefunded_specialized_balance_operations: 1,
157            deduct_from_prefunded_specialized_balance: 1,
158            deduct_from_prefunded_specialized_balance_operations: 0,
159            estimated_cost_for_prefunded_specialized_balance_update: 1, // changed: the prefunded balances layer holds three trees, the voting balances and the two contract fee pot trees
160            empty_prefunded_specialized_balance: 0,
161        },
162        group: DRIVE_GROUP_METHOD_VERSIONS_V1,
163        contract_group: DRIVE_CONTRACT_GROUP_METHOD_VERSIONS_V1,
164        address_funds: DRIVE_ADDRESS_FUNDS_METHOD_VERSIONS_V2,
165        shielded: DriveShieldedMethodVersions {
166            insert_note: 0,
167            insert_nullifiers: 0,
168            update_total_balance: 0,
169            record_anchor_if_changed: 0,
170            prune_anchors: 0,
171            has_anchor: 0,
172            has_nullifier: 0,
173            read_total_balance: 0,
174            notes_count: 0,
175        },
176        saved_block_transactions: DriveSavedBlockTransactionsMethodVersions {
177            store_address_balances: 0,
178            fetch_address_balances: 0,
179            prove_compacted_address_balance_changes: 1,
180            compact_address_balances: 0,
181            cleanup_expired_address_balances: 0,
182            max_blocks_before_compaction: 64,
183            max_addresses_before_compaction: 2048,
184        },
185    },
186    grove_methods: DRIVE_GROVE_METHOD_VERSIONS_V1,
187    // changed in v9: GROVE_V4 activates the indexed-tree batch cleanup
188    // gates (overwrite inspection + delete-tree actual-type cleanup).
189    // Indexed trees only exist from protocol v14, so activating the
190    // stricter cleanup with them costs older versions nothing; staying
191    // on V3 would let a batch overwrite of a ranked index orphan its
192    // per-axis secondary storage.
193    grove_version: GROVE_V4,
194};