Skip to content

Commit b60bcdb

Browse files
docs(platform): add Parameters and Returns sections to 4.1 and 4.2 dispatchers (#5063)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent c1dcfc9 commit b60bcdb

52 files changed

Lines changed: 956 additions & 0 deletions

File tree

  • packages
    • rs-drive-abci/src/execution
      • platform_events
        • state_transition_processing
          • process_validation_result
          • record_added_balance_outputs
        • withdrawals
          • has_pending_withdrawal_work
          • record_credit_inflows_for_withdrawals
          • record_total_credits_history_for_withdrawals
      • validation/state_transition/state_transitions/data_contract_common/data_contract_reference_validation
    • rs-drive/src
      • drive
        • contract_groups
          • estimated_costs
            • for_insert_contract_group_memberships
            • for_insert_contract_group
          • fetch
            • fetch_contract_group_info
            • fetch_contract_group_memberships_for_contract
            • fetch_contract_group_members
          • insert
            • insert_contract_group_memberships
            • insert_contract_group
          • prove
            • prove_contract_group_info
            • prove_contract_group_memberships_for_contract
            • prove_contract_group_members
        • contract/moderation
          • add_contract_document_removal
          • estimated_costs
          • fetch_contract_document_removals
          • insert_contract_document_removal_trees
          • prove_contract_document_removals
        • document
          • delete/delete_index_only_document_for_contract_operations
          • index_uniqueness/validate_restored_document_uniqueness
          • insert_contested/fetch_charter_election_windows
          • insert/add_history_operations
          • query
            • query_chained_documents
            • query_composite_documents
        • identity/withdrawals
          • fetch_total_credits_in_platform_a_day_ago
          • record_credit_inflow
          • record_total_credits_history
        • platform_state
          • delete_platform_state_entry
          • fetch_platform_state_entries_bytes
          • fetch_platform_state_recent_bytes
          • store_platform_state_entry_bytes
          • store_platform_state_recent_bytes
        • tokens
          • distribution
            • add_once_per_identity_distribution
            • fetch/once_per_identity_distribution_claim
            • mark_once_per_identity_release_as_distributed
          • estimated_costs/for_token_once_per_identity_distribution
      • query
        • drive_document_having_query/mode_detection
        • drive_document_ranked_query/mode_detection
        • non_primary_key_path_query
        • where_clause_grouping
      • verify
        • chained_document/verify_chained_documents_proof
        • composite_document/verify_composite_documents_proof
        • contract_groups
          • verify_contract_group_info
          • verify_contract_group_memberships_for_contract
          • verify_contract_group_members
        • contract_moderation/verify_contract_document_removals
        • document_having/verify_having_range_proof
        • document_ranked/verify_ranked_top_k_proof

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/process_validation_result/mod.rs‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,27 @@ where
2828
/// across the bump — only this helper's behavior is — so only this helper is versioned; the loop
2929
/// calls this dispatcher exactly like `execute_event_v0` calls the dispatching
3030
/// `record_added_balance_outputs`.
31+
///
32+
/// # Parameters
33+
///
34+
/// * `raw_state_transition`: The raw transition bytes, used to hash it for logs and to tag
35+
/// errors.
36+
/// * `state_transition_name`: The transition's name, used in logs and errors.
37+
/// * `validation_result`: The validation outcome: the execution event (if any) and the
38+
/// consensus errors.
39+
/// * `block_info`: The block being executed.
40+
/// * `transaction`: The GroveDB transaction.
41+
/// * `block_credit_mints`: Accumulates the credits the applied operations mint into Platform.
42+
/// * `platform_version`: The platform version.
43+
/// * `previous_fee_versions`: The fee versions of earlier epochs, used to price the fees.
44+
///
45+
/// # Returns
46+
///
47+
/// * `Ok(StateTransitionExecutionResult)`: `SuccessfulExecution`, `PaidConsensusError`,
48+
/// `UnpaidConsensusError` (no event to charge, a free invalid event, or an unpaid event), or
49+
/// `InternalError` when an invalid transition could not pay for its processing.
50+
/// * `Err(StateTransitionAwareError)` when the method version is unknown or executing the event
51+
/// fails, tagged with the raw transition and its name.
3152
#[allow(clippy::too_many_arguments)]
3253
pub(in crate::execution) fn process_validation_result<'a>(
3354
&self,

‎packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/record_added_balance_outputs/mod.rs‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ where
4444
/// OWN version field (`process_raw_state_transitions`), not this one — but both bump to v1
4545
/// together in the v13 method set, so the expansion activates atomically. Neither site carries a
4646
/// version conditional inside a _v0 function; the version is chosen by dispatch.
47+
///
48+
/// # Parameters
49+
///
50+
/// * `address_balances_in_update`: The block's address-balance update map the credits are
51+
/// merged into, or `None` when the caller does not track them (then nothing is recorded).
52+
/// * `added_to_balance_outputs`: The credits the event added to each address, if any.
53+
/// * `origin`: Which event family produced the credits; v0 drops `ShieldedSpend` credits.
54+
/// * `platform_version`: The platform version.
55+
///
56+
/// # Returns
57+
///
58+
/// * `Ok(())` once the credits the version records are merged into the map (an existing
59+
/// `SetCredits` or `AddToCredits` entry grows by the amount, saturating).
60+
/// * `Err(Error)` when the method version is unknown.
4761
pub(in crate::execution) fn record_added_balance_outputs(
4862
&self,
4963
address_balances_in_update: Option<&mut BTreeMap<PlatformAddress, CreditOperation>>,

‎packages/rs-drive-abci/src/execution/platform_events/withdrawals/has_pending_withdrawal_work/mod.rs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ where
1818
/// Tenderdash proposes the next height without waiting for transactions or the empty-block
1919
/// interval. Not consensus: a read only, it never touches the state or the app hash, and the
2020
/// hint is local to the node that returns it.
21+
///
22+
/// # Parameters
23+
///
24+
/// * `transaction`: The GroveDB transaction.
25+
/// * `platform_version`: The platform version.
26+
///
27+
/// # Returns
28+
///
29+
/// * `Ok(true)` when the untied withdrawal transactions queue holds at least one transaction,
30+
/// `Ok(false)` when it is empty.
31+
/// * `Err(Error)` when the method version is unknown or the queue read fails.
2132
pub fn has_pending_withdrawal_work(
2233
&self,
2334
transaction: TransactionArg,

‎packages/rs-drive-abci/src/execution/platform_events/withdrawals/record_credit_inflows_for_withdrawals/mod.rs‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,20 @@ where
2121
///
2222
/// Runs as a system event once per block, so nobody pays fees for the write; a block that
2323
/// minted nothing writes nothing.
24+
///
25+
/// # Parameters
26+
///
27+
/// * `credit_mints`: The credits the block minted into Platform.
28+
/// * `block_info`: The block being executed; its time sets when the inflow expires.
29+
/// * `transaction`: The GroveDB transaction.
30+
/// * `platform_version`: The platform version.
31+
///
32+
/// # Returns
33+
///
34+
/// * `Ok(())` once the inflow is recorded, or at once when `credit_mints` is zero or the
35+
/// protocol version has no credit inflows (the method version is `None`).
36+
/// * `Err(Error)` when the method version (or the Drive method it calls) is unknown or not
37+
/// active, or the write fails.
2438
pub(in crate::execution) fn record_credit_inflows_for_withdrawals(
2539
&self,
2640
credit_mints: Credits,

‎packages/rs-drive-abci/src/execution/platform_events/withdrawals/record_total_credits_history_for_withdrawals/mod.rs‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,20 @@ where
2121
/// move the total in a block) and before the app hash is taken; blocks that leave the total
2222
/// untouched cost one read and no write. Until an entry is a day old the limit applies its
2323
/// bootstrap rule, so pooling never depends on this block's entry.
24+
///
25+
/// # Parameters
26+
///
27+
/// * `block_info`: The block being executed; its time keys the new entry.
28+
/// * `transaction`: The GroveDB transaction.
29+
/// * `platform_version`: The platform version; its withdrawal constants bound the prune.
30+
///
31+
/// # Returns
32+
///
33+
/// * `Ok(())` once the history holds this block's total (unchanged when the total equals the
34+
/// latest entry), or at once when the protocol version has no history (the method version
35+
/// is `None`).
36+
/// * `Err(Error)` when the method version (or the Drive method it calls) is unknown or not
37+
/// active, the total credits are missing from state, or a read or write fails.
2438
pub(in crate::execution) fn record_total_credits_history_for_withdrawals(
2539
&self,
2640
block_info: &BlockInfo,

‎packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_common/data_contract_reference_validation/mod.rs‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,22 @@ use crate::execution::types::state_transition_execution_context::StateTransition
1919
/// named) must contain the referenced document type, and that type must forbid
2020
/// deletion. Identity, contract and token targets declare nothing beyond their
2121
/// kind, so they have nothing to validate here.
22+
///
23+
/// # Parameters
24+
///
25+
/// * `contract`: The contract being created or updated, whose declarations are checked.
26+
/// * `drive`: The Drive that foreign referenced contracts are fetched from.
27+
/// * `block_info`: The block being executed; its epoch prices the contract fetches.
28+
/// * `execution_context`: The execution context the contract fetch fees are billed to.
29+
/// * `transaction`: The GroveDB transaction.
30+
/// * `platform_version`: The platform version.
31+
///
32+
/// # Returns
33+
///
34+
/// * `Ok(SimpleConsensusValidationResult)`: valid when every declaration holds, otherwise
35+
/// carrying the consensus error of the first invalid declaration.
36+
/// * `Err(Error)` when the method version is unknown, a contract fetch fails or returns no
37+
/// fee, or checking whether a document type records creator ids fails.
2238
pub(in crate::execution::validation::state_transition) fn validate_data_contract_references(
2339
contract: &DataContract,
2440
drive: &Drive,

‎packages/rs-drive/src/drive/contract/moderation/add_contract_document_removal/mod.rs‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,25 @@ impl Drive {
1818
/// `replaces_existing` the replacement of the one the document has: a restore marks the
1919
/// record restored, and the deletion of a restored document writes a fresh record in its
2020
/// place. `moderator_id` pays for the record, or for the bytes a replacement adds.
21+
///
22+
/// # Parameters
23+
///
24+
/// * `contract_id`: The contract the document belonged to.
25+
/// * `document_type_name`: The document's type.
26+
/// * `document_id`: The deleted document's id, which keys the record.
27+
/// * `removal`: The record: owner, moderator, time, document hash, restoration and reason.
28+
/// * `replaces_existing`: Whether the document already has a record this one replaces.
29+
/// * `moderator_id`: The moderator that pays for the record, named in its storage flags.
30+
/// * `block_info`: The block being executed; its epoch goes in the storage flags.
31+
/// * `estimated_costs_only_with_layer_info`: The estimation map, when only estimating costs.
32+
/// * `transaction`: The GroveDB transaction.
33+
/// * `platform_version`: The platform version.
34+
///
35+
/// # Returns
36+
///
37+
/// * `Ok(Vec<LowLevelDriveOperation>)` with the insert (or, outside estimation, the
38+
/// replace) of the record.
39+
/// * `Err(Error)` when the method version is unknown or building an operation fails.
2140
#[allow(clippy::too_many_arguments)]
2241
pub fn add_contract_document_removal_operations(
2342
&self,

‎packages/rs-drive/src/drive/contract/moderation/estimated_costs/mod.rs‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ use std::collections::HashMap;
1212
impl Drive {
1313
/// Adds the estimated layer information for creating a contract's moderation list trees:
1414
/// the levels up to the contract and the contract's own subtree.
15+
///
16+
/// # Parameters
17+
///
18+
/// * `contract_id`: The contract whose moderation trees are created.
19+
/// * `estimated_costs_only_with_layer_info`: The estimation map the layers are added to.
20+
/// * `drive_version`: The drive version.
21+
///
22+
/// # Returns
23+
///
24+
/// * `Ok(())` once the layers are added to the map.
25+
/// * `Err(Error)` when the method version, or that of a nested estimation, is unknown.
1526
pub(crate) fn add_estimation_costs_for_contract_moderation_trees(
1627
contract_id: [u8; 32],
1728
estimated_costs_only_with_layer_info: &mut HashMap<KeyInfoPath, EstimatedLayerInformation>,
@@ -38,6 +49,18 @@ impl Drive {
3849

3950
/// Adds the estimated layer information for writing one entry of a contract's moderation
4051
/// list: the levels up to the contract, the contract's subtree and the list's tree.
52+
///
53+
/// # Parameters
54+
///
55+
/// * `contract_id`: The contract the list belongs to.
56+
/// * `list`: The moderation list the entry is written to.
57+
/// * `estimated_costs_only_with_layer_info`: The estimation map the layers are added to.
58+
/// * `drive_version`: The drive version.
59+
///
60+
/// # Returns
61+
///
62+
/// * `Ok(())` once the layers are added to the map.
63+
/// * `Err(Error)` when the method version, or that of a nested estimation, is unknown.
4164
pub(crate) fn add_estimation_costs_for_contract_moderation_entry(
4265
contract_id: [u8; 32],
4366
list: ContractModerationList,
@@ -67,6 +90,17 @@ impl Drive {
6790
/// Adds the estimated layer information for writing or deleting moderation action counts
6891
/// of an elected contract: the levels up to the contract, the contract's subtree and the
6992
/// tree of the counts.
93+
///
94+
/// # Parameters
95+
///
96+
/// * `contract_id`: The elected contract the counts belong to.
97+
/// * `estimated_costs_only_with_layer_info`: The estimation map the layers are added to.
98+
/// * `drive_version`: The drive version.
99+
///
100+
/// # Returns
101+
///
102+
/// * `Ok(())` once the layers are added to the map.
103+
/// * `Err(Error)` when the method version, or that of a nested estimation, is unknown.
70104
pub(crate) fn add_estimation_costs_for_contract_moderation_action_counts(
71105
contract_id: [u8; 32],
72106
estimated_costs_only_with_layer_info: &mut HashMap<KeyInfoPath, EstimatedLayerInformation>,
@@ -93,6 +127,17 @@ impl Drive {
93127

94128
/// Adds the layers a contract insertion or update touches when it creates the trees of
95129
/// the document removal records.
130+
///
131+
/// # Parameters
132+
///
133+
/// * `contract_id`: The contract whose removal trees are created.
134+
/// * `estimated_costs_only_with_layer_info`: The estimation map the layers are added to.
135+
/// * `drive_version`: The drive version.
136+
///
137+
/// # Returns
138+
///
139+
/// * `Ok(())` once the layers are added to the map.
140+
/// * `Err(Error)` when the method version, or that of a nested estimation, is unknown.
96141
pub(crate) fn add_estimation_costs_for_contract_document_removal_trees(
97142
contract_id: [u8; 32],
98143
estimated_costs_only_with_layer_info: &mut HashMap<KeyInfoPath, EstimatedLayerInformation>,
@@ -118,6 +163,18 @@ impl Drive {
118163
}
119164

120165
/// Adds the layers the record of a moderator's document deletion is written through.
166+
///
167+
/// # Parameters
168+
///
169+
/// * `contract_id`: The contract the document belonged to.
170+
/// * `document_type_name`: The document's type, whose removal tree holds the record.
171+
/// * `estimated_costs_only_with_layer_info`: The estimation map the layers are added to.
172+
/// * `drive_version`: The drive version.
173+
///
174+
/// # Returns
175+
///
176+
/// * `Ok(())` once the layers are added to the map.
177+
/// * `Err(Error)` when the method version, or that of a nested estimation, is unknown.
121178
pub(crate) fn add_estimation_costs_for_contract_document_removal(
122179
contract_id: [u8; 32],
123180
document_type_name: &str,

‎packages/rs-drive/src/drive/contract/moderation/fetch_contract_document_removals/mod.rs‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@ impl Drive {
1818
/// The records of the documents a contract's moderators deleted, within one document type:
1919
/// the ones of the ids named, or one page in document id order. A contract or a document
2020
/// type that keeps no records reads as none.
21+
///
22+
/// # Parameters
23+
///
24+
/// * `contract_id`: The contract whose moderators deleted the documents.
25+
/// * `query`: The document type and the selection: document ids, or a page.
26+
/// * `transaction`: The GroveDB transaction.
27+
/// * `platform_version`: The platform version.
28+
///
29+
/// # Returns
30+
///
31+
/// * `Ok(Vec<ContractDocumentRemovalEntry>)` with the records found, in document id order;
32+
/// empty when the contract or the document type keeps no records.
33+
/// * `Err(Error)` when the method version is unknown, the query names no ids, too many or a
34+
/// repeated id, or has a limit of zero or above the maximum, a read fails, or a stored
35+
/// record is malformed.
2136
pub fn fetch_contract_document_removals(
2237
&self,
2338
contract_id: Identifier,
@@ -50,6 +65,22 @@ impl Drive {
5065
/// consensus validation can bill it. The document type must be one whose documents
5166
/// moderators may delete: its records tree exists since the type was created, so a
5267
/// missing record reads as `None` and nothing else does.
68+
///
69+
/// # Parameters
70+
///
71+
/// * `contract_id`: The contract the document belonged to.
72+
/// * `document_type_name`: The document's type.
73+
/// * `document_id`: The document's id.
74+
/// * `epoch`: The epoch the read is priced in.
75+
/// * `transaction`: The GroveDB transaction.
76+
/// * `platform_version`: The platform version.
77+
///
78+
/// # Returns
79+
///
80+
/// * `Ok((FeeResult, Option<ContractDocumentRemoval>))`: the fee of the read and the
81+
/// record, `None` when the document has none.
82+
/// * `Err(Error)` when the method version is unknown, the read fails, the record is
83+
/// malformed, or the fee cannot be calculated.
5384
pub fn fetch_contract_document_removal_with_fee(
5485
&self,
5586
contract_id: Identifier,

‎packages/rs-drive/src/drive/contract/moderation/insert_contract_document_removal_trees/mod.rs‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,22 @@ impl Drive {
2222
/// root exists is read off the stored contract, and a type's tree is created exactly
2323
/// once, with the type. A contract without such a document type has no root, so its other
2424
/// tree keeps the shape it would have had. No tree is made lazily by the first removal.
25+
///
26+
/// # Parameters
27+
///
28+
/// * `contract_id`: The contract the trees belong to.
29+
/// * `with_root`: Whether to also create the tree of all the records.
30+
/// * `document_type_names`: The document types to create a records tree for.
31+
/// * `storage_flags`: The storage flags of the new trees.
32+
/// * `estimated_costs_only_with_layer_info`: The estimation map, when only estimating costs.
33+
/// * `transaction`: The GroveDB transaction.
34+
/// * `batch_operations`: The operations accumulator the tree inserts are appended to.
35+
/// * `platform_version`: The platform version.
36+
///
37+
/// # Returns
38+
///
39+
/// * `Ok(())` once the tree inserts are appended to `batch_operations`.
40+
/// * `Err(Error)` when the method version is unknown or building an insert fails.
2541
#[allow(clippy::too_many_arguments)]
2642
pub fn insert_contract_document_removal_trees_operations(
2743
&self,

0 commit comments

Comments
 (0)