Skip to content

fix(platform)!: properly use withdrawal system data contract. #2675

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Jun 24, 2025

Conversation

QuantumExplorer
Copy link
Member

@QuantumExplorer QuantumExplorer commented Jun 19, 2025

Issue being fixed or feature implemented

Two big issues here: the first is that system contracts were changing their configuration on load, going from config v0 to config v1. This would cause them to start using the typed integers and all hell would break loose. Now instead we continue to use non typed integers in pre 2.0 system contracts.

The second issue is that for some methods we were getting the withdrawal contract from disk (or cache) and for some methods we were getting it from the system contract. Now we only get it from the system contract.

How Has This Been Tested?

Added tests.

Breaking Changes

Yes

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Summary by CodeRabbit

  • New Features

    • Added a method to fetch all withdrawal documents grouped and sorted by status.
    • Introduced a new error variant providing additional context for protocol errors.
    • Added a test for withdrawal document deserialization.
  • Bug Fixes

    • Improved error messages for failed varint reads during document property parsing.
  • Refactor

    • Centralized and customized configuration logic for system data contracts.
    • Enhanced debug logging for withdrawal processing and document status counts.
    • Updated document deserialization error handling to include more context.
    • Refactored withdrawal document fetching to use cached contracts.
  • Tests

    • Updated and expanded tests for withdrawal document queries and root hash expectations.
    • Adjusted test data to use the latest contract format version.
  • Documentation

    • Improved and clarified code comments and documentation throughout the codebase.

Copy link
Contributor

coderabbitai bot commented Jun 19, 2025

"""

Walkthrough

This set of changes introduces enhanced error reporting, logging, and configuration flexibility across the withdrawal and data contract modules. It adds new helper methods for fetching withdrawal documents, updates test expectations, refines serialization and deserialization logic, and centralizes system contract configuration logic. Several tests and comments are updated for clarity and accuracy.

Changes

File(s) Change Summary
.../data_contract/config/v0/mod.rs
.../data_contract/serialized_version/v1/mod.rs
Updated default trait usage and config import from V0 to V1 in serialization.
.../data_contract/document_type/property/mod.rs Enhanced error message for varint reading to include attempted length.
.../data_contract/mod.rs Removed redundant assignment in test.
.../document/serialization_traits/platform_serialization_conversion/mod.rs Added new test for withdrawal document deserialization with detailed comments.
.../system_data_contracts.rs Added ConfigurationForSystemContract trait and implementation; refactored config logic in contract creation.
.../platform_events/withdrawals/pool_withdrawals_into_transactions_queue/v1/mod.rs Added detailed debug and trace logging for withdrawal document processing.
.../query/document_query/v0/mod.rs Changed test data types from unsigned to signed integers in queries and properties.
.../drive/document/query/query_documents/v0/mod.rs Wrapped deserialization errors with additional context using new error variant.
.../drive/identity/withdrawals/document/fetch_oldest_withdrawal_documents_by_status/mod.rs Added public helper method for fetching and grouping withdrawal documents by status.
.../drive/identity/withdrawals/document/fetch_oldest_withdrawal_documents_by_status/v0/mod.rs Refactored contract loading, added grouping/sorting method, and extended tests for withdrawal documents.
.../error/mod.rs Added ProtocolWithInfoString error variant for enhanced error context.
.../deterministic_root_hash.rs
.../query_tests.rs
Updated expected root hash values in tests.
.../supporting_files/contract/withdrawals/withdrawals-contract.json Updated contract format version from "0" to "1".
.../version/drive_versions/v4.rs Modified comments only; no code changes.
.../version/v9.rs Updated DPP method versions and expanded documentation for PLATFORM_V9.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant SystemDataContract
    participant PlatformVersion
    participant DataContractFactory

    Caller->>SystemDataContract: configuration_in_platform_version(platform_version)
    SystemDataContract->>PlatformVersion: (reads version info)
    SystemDataContract-->>Caller: DataContractConfig
    Caller->>DataContractFactory: create(..., DataContractConfig, ...)
    DataContractFactory-->>Caller: DataContract
Loading
sequenceDiagram
    participant Drive
    participant Transaction
    participant PlatformVersion
    participant WithdrawalContractCache

    Drive->>WithdrawalContractCache: load withdrawals contract
    Drive->>Drive: query all withdrawal documents
    Drive-->>Drive: group documents by status, sort by updatedAt
    Drive-->>Caller: BTreeMap<status, Vec<Document>>
Loading

Possibly related PRs

Suggested labels

rs-sdk

Suggested reviewers

  • shumkov
  • pauldelucia

Poem

A bunny hopped through fields of code,
Sorting docs by status, lightening the load.
With logs and errors now clearer to see,
Withdrawal contracts grouped as they should be.
Version bumps and hashes align,
This rabbit’s work is simply divine! 🐇✨
"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ffb345b and 0d0314d.

📒 Files selected for processing (1)
  • packages/rs-drive-abci/tests/strategy_tests/masternodes.rs (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/rs-drive-abci/tests/strategy_tests/masternodes.rs
⏰ Context from checks skipped due to timeout of 90000ms (19)
  • GitHub Check: Rust packages (drive-abci) / Linting
  • GitHub Check: Rust packages (drive-abci) / Check each feature
  • GitHub Check: Rust packages (drive) / Formatting
  • GitHub Check: Rust packages (drive) / Linting
  • GitHub Check: Rust packages (dpp) / Tests
  • GitHub Check: Rust packages (dpp) / Formatting
  • GitHub Check: Rust packages (dpp) / Linting
  • GitHub Check: Rust packages (wasm-dpp) / Tests
  • GitHub Check: Rust packages (wasm-dpp) / Unused dependencies
  • GitHub Check: Rust packages (dash-sdk) / Formatting
  • GitHub Check: Rust packages (wasm-dpp) / Formatting
  • GitHub Check: Rust packages (dash-sdk) / Linting
  • GitHub Check: Rust packages (wasm-dpp) / Linting
  • GitHub Check: Rust packages (dash-sdk) / Unused dependencies
  • GitHub Check: Rust packages (dash-sdk) / Check each feature
  • GitHub Check: Rust packages (dash-sdk) / Tests
  • GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
  • GitHub Check: Build Docker images (Drive, drive, drive-abci) / Build Drive image
  • GitHub Check: Build JS packages / Build JS
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@QuantumExplorer QuantumExplorer changed the title temp: withdrawal fix branch fix(platform): properly use withdrawal system data contract. Jun 23, 2025
@QuantumExplorer QuantumExplorer marked this pull request as ready for review June 24, 2025 08:38
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (2)
packages/rs-drive/tests/query_tests.rs (2)

6551-6552: Duplicate literal root hash

Same vector re-appears here. Re-use the shared constant/helper proposed above.


6652-6653: Yet another copy of the same hash

Third occurrence – extract to one place to keep the tests DRY and less error-prone.

🧹 Nitpick comments (4)
packages/rs-drive/tests/query_tests.rs (1)

6471-6472: Hard-coded root hash updated – please centralise it

The new 32-byte vector is now the third literal copy in this module. Consider extracting a const EXPECTED_WITHDRAWAL_HASH: [u8; 32] = *b"..."; (or decode from a hex string) and reference it in each assertion to avoid triple maintenance next time the hash shifts.

packages/rs-dpp/src/data_contract/serialized_version/v1/mod.rs (1)

1-2: Defaulting to DataContractConfigV1 may break backward-compatibility

Changing the serde default provider from V0 to V1 means that deserializing legacy contracts without a config field will now get V1 defaults, not V0.
If V1 introduces semantics that older nodes don’t understand (or if hashes are included in merkle proofs) this becomes a consensus risk.

Please verify:

  1. Whether platform version gating already ensures only v9+ nodes see these objects.
  2. That V1 default values are binary-compatible with the previous V0 defaults, or migrations are handled elsewhere.

If unsure, keep the provider on V0 and upgrade through an explicit contract bump.

Also applies to: 28-31

packages/rs-dpp/src/system_data_contracts.rs (1)

19-42: Consider grouping contracts by configuration type for better readability

The implementation correctly handles different configurations for system contracts. Consider reorganizing the match arms to group by configuration type for improved readability:

 impl ConfigurationForSystemContract for SystemDataContract {
     fn configuration_in_platform_version(
         &self,
         platform_version: &PlatformVersion,
     ) -> Result<DataContractConfig, ProtocolError> {
+        let mut config = DataContractConfig::default_for_version(platform_version)?;
+        
+        let sized_integer_types_enabled = match self {
+            SystemDataContract::TokenHistory | SystemDataContract::KeywordSearch => true,
+            _ => false,
+        };
+        
+        config.set_sized_integer_types_enabled(sized_integer_types_enabled);
+        Ok(config)
-        match self {
-            SystemDataContract::Withdrawals
-            | SystemDataContract::MasternodeRewards
-            | SystemDataContract::FeatureFlags
-            | SystemDataContract::DPNS
-            | SystemDataContract::Dashpay
-            | SystemDataContract::WalletUtils => {
-                let mut config = DataContractConfig::default_for_version(platform_version)?;
-                config.set_sized_integer_types_enabled(false);
-                Ok(config)
-            }
-            SystemDataContract::TokenHistory | SystemDataContract::KeywordSearch => {
-                let mut config = DataContractConfig::default_for_version(platform_version)?;
-                config.set_sized_integer_types_enabled(true);
-                Ok(config)
-            }
-        }
     }
 }
packages/rs-drive/src/drive/identity/withdrawals/document/fetch_oldest_withdrawal_documents_by_status/v0/mod.rs (1)

406-548: Consider extracting document parsing logic to reduce duplication

The test effectively verifies the grouped fetch functionality. However, the document parsing logic (lines 443-502) is duplicated from the previous test. Consider extracting this into a helper function to improve maintainability.

Create a helper function to reduce duplication:

fn parse_and_setup_withdrawal_documents(
    drive: &Drive,
    data_contract: &DataContract,
    document_type: &DocumentType,
    transaction: TransactionArg,
    platform_version: &PlatformVersion,
) -> Result<(usize, usize), Error> {
    // Move the common parsing logic here
    // Return (total_count, queued_count)
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c5142f6 and 15ab7e6.

📒 Files selected for processing (17)
  • packages/rs-dpp/src/data_contract/config/v0/mod.rs (1 hunks)
  • packages/rs-dpp/src/data_contract/document_type/property/mod.rs (1 hunks)
  • packages/rs-dpp/src/data_contract/mod.rs (0 hunks)
  • packages/rs-dpp/src/data_contract/serialized_version/v1/mod.rs (2 hunks)
  • packages/rs-dpp/src/document/serialization_traits/platform_serialization_conversion/mod.rs (1 hunks)
  • packages/rs-dpp/src/system_data_contracts.rs (2 hunks)
  • packages/rs-drive-abci/src/execution/platform_events/withdrawals/pool_withdrawals_into_transactions_queue/v1/mod.rs (4 hunks)
  • packages/rs-drive-abci/src/query/document_query/v0/mod.rs (8 hunks)
  • packages/rs-drive/src/drive/document/query/query_documents/v0/mod.rs (1 hunks)
  • packages/rs-drive/src/drive/identity/withdrawals/document/fetch_oldest_withdrawal_documents_by_status/mod.rs (2 hunks)
  • packages/rs-drive/src/drive/identity/withdrawals/document/fetch_oldest_withdrawal_documents_by_status/v0/mod.rs (9 hunks)
  • packages/rs-drive/src/error/mod.rs (1 hunks)
  • packages/rs-drive/tests/deterministic_root_hash.rs (1 hunks)
  • packages/rs-drive/tests/query_tests.rs (3 hunks)
  • packages/rs-drive/tests/supporting_files/contract/withdrawals/withdrawals-contract.json (1 hunks)
  • packages/rs-platform-version/src/version/drive_versions/v4.rs (2 hunks)
  • packages/rs-platform-version/src/version/v9.rs (3 hunks)
💤 Files with no reviewable changes (1)
  • packages/rs-dpp/src/data_contract/mod.rs
🧰 Additional context used
📓 Path-based instructions (2)
`packages/rs-drive/**`: Drive is the platform's decentralized storage component, implementing a replicated state machine for storing and retrieving application data.

packages/rs-drive/**: Drive is the platform's decentralized storage component, implementing a replicated state machine for storing and retrieving application data.

  • packages/rs-drive/tests/supporting_files/contract/withdrawals/withdrawals-contract.json
  • packages/rs-drive/tests/deterministic_root_hash.rs
  • packages/rs-drive/src/error/mod.rs
  • packages/rs-drive/src/drive/document/query/query_documents/v0/mod.rs
  • packages/rs-drive/src/drive/identity/withdrawals/document/fetch_oldest_withdrawal_documents_by_status/mod.rs
  • packages/rs-drive/src/drive/identity/withdrawals/document/fetch_oldest_withdrawal_documents_by_status/v0/mod.rs
  • packages/rs-drive/tests/query_tests.rs
`packages/rs-dpp/**`: This directory contains the Rust implementation of the Dash Platform Protocol (DPP), which defines data structures and validation rules.

packages/rs-dpp/**: This directory contains the Rust implementation of the Dash Platform Protocol (DPP), which defines data structures and validation rules.

  • packages/rs-dpp/src/data_contract/serialized_version/v1/mod.rs
  • packages/rs-dpp/src/data_contract/document_type/property/mod.rs
  • packages/rs-dpp/src/data_contract/config/v0/mod.rs
  • packages/rs-dpp/src/document/serialization_traits/platform_serialization_conversion/mod.rs
  • packages/rs-dpp/src/system_data_contracts.rs
🧠 Learnings (1)
📓 Common learnings
Learnt from: QuantumExplorer
PR: dashpay/platform#2257
File: packages/rs-drive-abci/src/mimic/test_quorum.rs:159-164
Timestamp: 2024-11-20T16:16:01.830Z
Learning: QuantumExplorer prefers not to receive auto-generated messages asking to post on social media.
⏰ Context from checks skipped due to timeout of 90000ms (16)
  • GitHub Check: Rust packages (dpp) / Check each feature
  • GitHub Check: Rust packages (dpp) / Tests
  • GitHub Check: Rust packages (dpp) / Linting
  • GitHub Check: Rust packages (wasm-dpp) / Unused dependencies
  • GitHub Check: Rust packages (wasm-dpp) / Formatting
  • GitHub Check: Rust packages (wasm-dpp) / Tests
  • GitHub Check: Rust packages (dash-sdk) / Tests
  • GitHub Check: Rust packages (wasm-dpp) / Linting
  • GitHub Check: Rust packages (dash-sdk) / Linting
  • GitHub Check: Rust packages (dash-sdk) / Check each feature
  • GitHub Check: Rust packages (dash-sdk) / Formatting
  • GitHub Check: Rust packages (dash-sdk) / Unused dependencies
  • GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
  • GitHub Check: Build JS packages / Build JS
  • GitHub Check: Build Docker images (Drive, drive, drive-abci) / Build Drive image
  • GitHub Check: Build Docker images (DAPI, dapi, dapi) / Build DAPI image
🔇 Additional comments (25)
packages/rs-drive/src/error/mod.rs (1)

70-72: Enhanced error reporting with contextual information

This addition improves debugging capabilities by allowing protocol errors to be wrapped with additional context strings. The implementation correctly formats the error message to include both the protocol error and the contextual information.

packages/rs-drive/tests/supporting_files/contract/withdrawals/withdrawals-contract.json (1)

2-2: Contract format version updated to align with platform versioning

The format version upgrade from "0" to "1" aligns with the broader platform versioning updates and data contract serialization changes. This change is consistent with the PR objective to properly use the withdrawal system data contract.

packages/rs-platform-version/src/version/drive_versions/v4.rs (2)

52-52: Documentation update for contract version change

The comment addition helps track that the contract field was modified in this version, which is good practice for version documentation.


105-105: Documentation update for grove version field

The comment helps document the grove_version field, improving code maintainability.

packages/rs-drive/tests/deterministic_root_hash.rs (1)

305-305: Updated test expectation for newer protocol versions

The hash expectation update reflects changes in data contract serialization and platform versioning for protocol versions above 8. This correctly maintains backward compatibility while accommodating the new hash calculation results.

packages/rs-dpp/src/data_contract/document_type/property/mod.rs (1)

534-537: ```shell
#!/bin/bash

Show the imports and constants near the top of the file to check for existing limits

sed -n '1,200p' packages/rs-dpp/src/data_contract/document_type/property/mod.rs


Explanation: Inspecting existing constants and imports to ensure we don't duplicate or conflict with other limits before adding MAX_VARINT_LEN.

</details>
<details>
<summary>packages/rs-dpp/src/data_contract/config/v0/mod.rs (1)</summary>

`103-116`: **Default impl refactor looks good**

Swapping `std::default::Default` for `Default` is idiomatic and keeps behaviour unchanged.

</details>
<details>
<summary>packages/rs-platform-version/src/version/v9.rs (1)</summary>

`8-9`: **Ensure all version constants stay in lock-step**

Importing `DPP_METHOD_VERSIONS_V2` and wiring it into `PLATFORM_V9` is correct, but note that:

* `STATE_TRANSITION_METHOD_VERSIONS_V1` remains unchanged – confirm V2 methods don’t require a bump here.
* Doc comment was updated to reflect token support; great for clarity.

No action required if the above matrix was validated in CI.  
 


Also applies to: 32-32, 56-56

</details>
<details>
<summary>packages/rs-drive-abci/src/query/document_query/v0/mod.rs (5)</summary>

`775-778`: **LGTM: Consistent value type normalization.**

The change from various unsigned integer types to `Value::I64` for document properties aligns with the broader standardization effort mentioned in the AI summary. This ensures compatibility with the enhanced document processing improvements.

---

`939-942`: **LGTM: Test data consistency maintained.**

The systematic conversion to `Value::I64` for withdrawal document properties maintains test consistency while supporting the unified document handling approach.

---

`1103-1106`: **LGTM: Proper value type unification.**

The change to `Value::I64` for document properties continues the consistent pattern throughout the test suite.

---

`1259-1262`: **LGTM: Final test case alignment.**

The conversion to `Value::I64` completes the systematic update across all test cases.

---

`1304-1308`: **LGTM: Query clause consistency.**

The update of query clause values to use `Value::I64` ensures compatibility with the document property changes and maintains test coherence.



Also applies to: 1430-1433, 1475-1479, 1489-1490, 1497-1497

</details>
<details>
<summary>packages/rs-drive/src/drive/document/query/query_documents/v0/mod.rs (2)</summary>

`95-105`: **LGTM: Enhanced error context for debugging.**

The new error handling wraps deserialization failures with valuable debugging context including hex-encoded document bytes and contract information. This will significantly improve troubleshooting when document deserialization fails.

---

`106-106`: **LGTM: Proper error type propagation.**

The change from `ProtocolError` to `Error` in the collect result type is necessary to handle the new `Error::ProtocolWithInfoString` variant.

</details>
<details>
<summary>packages/rs-dpp/src/document/serialization_traits/platform_serialization_conversion/mod.rs (1)</summary>

`146-200`: **LGTM: Comprehensive withdrawal deserialization test.**

This test provides excellent coverage for withdrawal document deserialization with:
- Detailed comments explaining each byte segment of the serialized format
- Real-world withdrawal document data
- Proper use of latest platform version and contract loading

The extensive documentation of the serialization format (header, metadata, user properties) is particularly valuable for understanding the withdrawal document structure.

</details>
<details>
<summary>packages/rs-drive-abci/src/execution/platform_events/withdrawals/pool_withdrawals_into_transactions_queue/v1/mod.rs (3)</summary>

`45-99`: **Enhanced observability with comprehensive withdrawal status logging.**

The addition of detailed debug logging when no queued withdrawals are found provides valuable insights into system state. The code properly:
- Fetches and categorizes withdrawals by all status types
- Logs meaningful counts for each status
- Uses appropriate debug level for operational information

---

`107-112`: **LGTM: Appropriate trace logging for detailed diagnostics.**

The trace-level logging for withdrawal limit calculations provides detailed diagnostic information without cluttering regular debug output.

---

`154-158`: **LGTM: Clear logging for empty document processing.**

The debug log clearly indicates when no documents are available for processing after applying withdrawal limits.

</details>
<details>
<summary>packages/rs-drive/src/drive/identity/withdrawals/document/fetch_oldest_withdrawal_documents_by_status/mod.rs (1)</summary>

`7-7`: **LGTM: Well-designed helper method with proper versioning.**

The new `fetch_oldest_withdrawal_documents` method provides a useful complement to the existing status-filtered method by returning all withdrawal documents grouped by status. The implementation follows the established versioning pattern and has a clear, descriptive name that indicates it fetches documents without status filtering.

The `BTreeMap<u8, Vec<Document>>` return type is appropriate for grouping documents by status values.



Also applies to: 42-63

</details>
<details>
<summary>packages/rs-dpp/src/system_data_contracts.rs (3)</summary>

`7-18`: **Well-designed trait for system contract configuration**

The new `ConfigurationForSystemContract` trait provides a clean abstraction for retrieving contract-specific configurations based on platform version. The imports and trait definition follow Rust best practices.

---

`62-67`: **Correct integration of configuration mechanism**

The modification properly uses the new trait method to provide contract-specific configuration instead of the previous hardcoded `None` value.

---

`157-170`: **Good test coverage for configuration versioning**

The comments clearly explain the configuration version differences, and the byte length assertions effectively verify that the configuration changes impact serialization as expected.

</details>
<details>
<summary>packages/rs-drive/src/drive/identity/withdrawals/document/fetch_oldest_withdrawal_documents_by_status/v0/mod.rs (2)</summary>

`23-26`: **Efficient use of cached system contracts**

Good optimization to use the cached withdrawals contract instead of loading it each time. This improves performance by avoiding redundant contract loading.

---

`270-404`: **Excellent test coverage with real testnet data**

Great approach to test with actual testnet withdrawal documents. The test thoroughly verifies:
- Document limit enforcement
- Sorting by updatedAt timestamp
- Status filtering correctness

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Copy link
Member Author

@QuantumExplorer QuantumExplorer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self Reviewed

@QuantumExplorer QuantumExplorer changed the title fix(platform): properly use withdrawal system data contract. fix(platform)!: properly use withdrawal system data contract. Jun 24, 2025
@QuantumExplorer QuantumExplorer merged commit 97ed253 into v2.0-dev Jun 24, 2025
155 of 156 checks passed
@QuantumExplorer QuantumExplorer deleted the fix/withdrawals2 branch June 24, 2025 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants