Skip to content
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

refactor(sdk): contested resource as struct type #2225

Merged
merged 14 commits into from
Oct 9, 2024

Conversation

QuantumExplorer
Copy link
Member

@QuantumExplorer QuantumExplorer commented Oct 8, 2024

Issue being fixed or feature implemented

changed

pub enum ContestedResource {
    /// Generic [Value]
    Value(Value),
}

to pub struct ContestedResource(pub Value)

What was done?

Also some minor fixes to tokio sleeper feature.

How Has This Been Tested?

Breaking Changes

Breaking but since this is not used yet in production we can let it slide.

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

Release Notes

  • New Features

    • Introduced tokio-sleep feature in SDK and DAPI client for enhanced asynchronous operations.
    • Added new public export for query_types in the SDK to facilitate complex queries.
  • Improvements

    • Enhanced error handling and verification in proof verification processes, improving data integrity.
    • Simplified the representation of ContestedResource by changing it from an enum to a struct.
  • Tests

    • Updated test cases to reflect changes in the ContestedResource structure.
    • Added several new JSON files for testing purposes, ensuring better coverage of functionality.
  • Chores

    • Removed outdated JSON files that are no longer needed.

Copy link
Contributor

coderabbitai bot commented Oct 8, 2024

Walkthrough

The pull request includes updates across multiple files, primarily focusing on the Cargo.toml files for the rs-dapi-client and rs-sdk packages, along with modifications to the proof.rs and types.rs files in the rs-drive-proof-verifier package. Key changes involve the addition of a new feature tokio-sleep, updates to dependency configurations, and enhancements to the FromProof trait implementations for error handling and data verification. The ContestedResource type has been restructured from an enum to a struct, simplifying its representation.

Changes

File Path Change Summary
packages/rs-dapi-client/Cargo.toml Updated version to 1.4.0-dev.7, added feature tokio-sleep, expanded mocks feature dependencies, modified backon dependency.
packages/rs-drive-proof-verifier/src/proof.rs Updated FromProof trait implementations with enhanced error handling and verification for several request types.
packages/rs-drive-proof-verifier/src/types.rs Changed ContestedResource from an enum to a struct, updated related implementations.
packages/rs-sdk/Cargo.toml Updated version to 1.4.0-dev.7, added feature tokio-sleep, documented existing features.
packages/rs-sdk/src/lib.rs Added public export pub use drive_proof_verifier::types as query_types;.
packages/rs-sdk/tests/fetch/contested_resource.rs Modified destructuring of ContestedResource in tests to access inner value directly.
packages/rs-sdk/tests/vectors/check_mn_voting_prerequisities/quorum_pubkey-106-41ef25a6baff2c7a3cf388c77c826c1ffa6fb229b31c0802b1808d2c85dbc248.json New file added containing a hash value.
packages/rs-sdk/tests/vectors/contested_resources_fields_0760ac4854fc8db803bbcbab8709f390bd31511a05e29cd3f170b48ca6b87584/quorum_pubkey-106-41ef25a6baff2c7a3cf388c77c826c1ffa6fb229b31c0802b1808d2c85dbc248.json New file added containing a hash value.
packages/rs-sdk/tests/vectors/contested_resources_fields_473cf8e4a270ced75e199e5a3e907b4df4cd66b64365d1ac77c45bcaed443a03/quorum_pubkey-106-41ef25a6baff2c7a3cf388c77c826c1ffa6fb229b31c0802b1808d2c85dbc248.json New file added containing a hash value.
packages/rs-sdk/tests/vectors/contested_resources_fields_b7df460e812b958de6e703d8ea325df9aab3448d0409ece3f0baf1d26629e44f/quorum_pubkey-106-41ef25a6baff2c7a3cf388c77c826c1ffa6fb229b31c0802b1808d2c85dbc248.json New file added containing a hash value.
packages/rs-sdk/tests/vectors/contested_resources_fields_ccb199c48ee58a8bb98742b964cba7bda3b4469b740201d2628f15f926f39347/quorum_pubkey-106-41ef25a6baff2c7a3cf388c77c826c1ffa6fb229b31c0802b1808d2c85dbc248.json New file added containing a hash value.
packages/rs-sdk/tests/vectors/check_mn_voting_prerequisities/quorum_pubkey-106-74bc78bfed100cb1c7da3b1aeeaff1e5767efb0daf93c69cc8294ee246526a09.json File deleted, previously contained a hash value.
packages/rs-sdk/tests/vectors/contested_resources_fields_0760ac4854fc8db803bbcbab8709f390bd31511a05e29cd3f170b48ca6b87584/quorum_pubkey-106-74bc78bfed100cb1c7da3b1aeeaff1e5767efb0daf93c69cc8294ee246526a09.json File deleted, previously contained a hash value.
packages/rs-sdk/tests/vectors/contested_resources_fields_473cf8e4a270ced75e199e5a3e907b4df4cd66b64365d1ac77c45bcaed443a03/quorum_pubkey-106-74bc78bfed100cb1c7da3b1aeeaff1e5767efb0daf93c69cc8294ee246526a09.json File deleted, previously contained a hash value.
packages/rs-sdk/tests/vectors/contested_resources_fields_b7df460e812b958de6e703d8ea325df9aab3448d0409ece3f0baf1d26629e44f/quorum_pubkey-106-74bc78bfed100cb1c7da3b1aeeaff1e5767efb0daf93c69cc8294ee246526a09.json File deleted, previously contained a hash value.
packages/rs-sdk/tests/vectors/contested_resources_fields_ccb199c48ee58a8bb98742b964cba7bda3b4469b740201d2628f15f926f39347/quorum_pubkey-106-74bc78bfed100cb1c7da3b1aeeaff1e5767efb0daf93c69cc8294ee246526a09.json File deleted, previously contained a hash value.

Possibly related PRs

Suggested reviewers

  • shumkov

Poem

In the code where bunnies hop,
New features sprout, we can't stop!
With tokio-sleep, we take a leap,
Through proofs and types, our data we keep.
So let’s rejoice, with hops and cheer,
For every change, we hold so dear! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 9921618 and 8a1f526.

📒 Files selected for processing (15)
  • packages/rs-sdk/tests/fetch/contested_resource.rs (5 hunks)
  • packages/rs-sdk/tests/vectors/check_mn_voting_prerequisities/quorum_pubkey-106-41ef25a6baff2c7a3cf388c77c826c1ffa6fb229b31c0802b1808d2c85dbc248.json (1 hunks)
  • packages/rs-sdk/tests/vectors/check_mn_voting_prerequisities/quorum_pubkey-106-74bc78bfed100cb1c7da3b1aeeaff1e5767efb0daf93c69cc8294ee246526a09.json (0 hunks)
  • packages/rs-sdk/tests/vectors/contested_resources_fields_0760ac4854fc8db803bbcbab8709f390bd31511a05e29cd3f170b48ca6b87584/quorum_pubkey-106-41ef25a6baff2c7a3cf388c77c826c1ffa6fb229b31c0802b1808d2c85dbc248.json (1 hunks)
  • packages/rs-sdk/tests/vectors/contested_resources_fields_0760ac4854fc8db803bbcbab8709f390bd31511a05e29cd3f170b48ca6b87584/quorum_pubkey-106-74bc78bfed100cb1c7da3b1aeeaff1e5767efb0daf93c69cc8294ee246526a09.json (0 hunks)
  • packages/rs-sdk/tests/vectors/contested_resources_fields_473cf8e4a270ced75e199e5a3e907b4df4cd66b64365d1ac77c45bcaed443a03/quorum_pubkey-106-41ef25a6baff2c7a3cf388c77c826c1ffa6fb229b31c0802b1808d2c85dbc248.json (1 hunks)
  • packages/rs-sdk/tests/vectors/contested_resources_fields_473cf8e4a270ced75e199e5a3e907b4df4cd66b64365d1ac77c45bcaed443a03/quorum_pubkey-106-74bc78bfed100cb1c7da3b1aeeaff1e5767efb0daf93c69cc8294ee246526a09.json (0 hunks)
  • packages/rs-sdk/tests/vectors/contested_resources_fields_948b5a301af5fc73db7fed418a4fe90f64952b4ddd6b03a7f21d029dc110af50/quorum_pubkey-106-41ef25a6baff2c7a3cf388c77c826c1ffa6fb229b31c0802b1808d2c85dbc248.json (1 hunks)
  • packages/rs-sdk/tests/vectors/contested_resources_fields_948b5a301af5fc73db7fed418a4fe90f64952b4ddd6b03a7f21d029dc110af50/quorum_pubkey-106-74bc78bfed100cb1c7da3b1aeeaff1e5767efb0daf93c69cc8294ee246526a09.json (0 hunks)
  • packages/rs-sdk/tests/vectors/contested_resources_fields_9f57b982b3e3b0286093d8b48ab27b87b22f67a172579913f2fec7a6b5ea31b7/quorum_pubkey-106-41ef25a6baff2c7a3cf388c77c826c1ffa6fb229b31c0802b1808d2c85dbc248.json (1 hunks)
  • packages/rs-sdk/tests/vectors/contested_resources_fields_9f57b982b3e3b0286093d8b48ab27b87b22f67a172579913f2fec7a6b5ea31b7/quorum_pubkey-106-74bc78bfed100cb1c7da3b1aeeaff1e5767efb0daf93c69cc8294ee246526a09.json (0 hunks)
  • packages/rs-sdk/tests/vectors/contested_resources_fields_b7df460e812b958de6e703d8ea325df9aab3448d0409ece3f0baf1d26629e44f/quorum_pubkey-106-41ef25a6baff2c7a3cf388c77c826c1ffa6fb229b31c0802b1808d2c85dbc248.json (1 hunks)
  • packages/rs-sdk/tests/vectors/contested_resources_fields_b7df460e812b958de6e703d8ea325df9aab3448d0409ece3f0baf1d26629e44f/quorum_pubkey-106-74bc78bfed100cb1c7da3b1aeeaff1e5767efb0daf93c69cc8294ee246526a09.json (0 hunks)
  • packages/rs-sdk/tests/vectors/contested_resources_fields_ccb199c48ee58a8bb98742b964cba7bda3b4469b740201d2628f15f926f39347/quorum_pubkey-106-41ef25a6baff2c7a3cf388c77c826c1ffa6fb229b31c0802b1808d2c85dbc248.json (1 hunks)
  • packages/rs-sdk/tests/vectors/contested_resources_fields_ccb199c48ee58a8bb98742b964cba7bda3b4469b740201d2628f15f926f39347/quorum_pubkey-106-74bc78bfed100cb1c7da3b1aeeaff1e5767efb0daf93c69cc8294ee246526a09.json (0 hunks)
💤 Files with no reviewable changes (7)
  • packages/rs-sdk/tests/vectors/check_mn_voting_prerequisities/quorum_pubkey-106-74bc78bfed100cb1c7da3b1aeeaff1e5767efb0daf93c69cc8294ee246526a09.json
  • packages/rs-sdk/tests/vectors/contested_resources_fields_0760ac4854fc8db803bbcbab8709f390bd31511a05e29cd3f170b48ca6b87584/quorum_pubkey-106-74bc78bfed100cb1c7da3b1aeeaff1e5767efb0daf93c69cc8294ee246526a09.json
  • packages/rs-sdk/tests/vectors/contested_resources_fields_473cf8e4a270ced75e199e5a3e907b4df4cd66b64365d1ac77c45bcaed443a03/quorum_pubkey-106-74bc78bfed100cb1c7da3b1aeeaff1e5767efb0daf93c69cc8294ee246526a09.json
  • packages/rs-sdk/tests/vectors/contested_resources_fields_948b5a301af5fc73db7fed418a4fe90f64952b4ddd6b03a7f21d029dc110af50/quorum_pubkey-106-74bc78bfed100cb1c7da3b1aeeaff1e5767efb0daf93c69cc8294ee246526a09.json
  • packages/rs-sdk/tests/vectors/contested_resources_fields_9f57b982b3e3b0286093d8b48ab27b87b22f67a172579913f2fec7a6b5ea31b7/quorum_pubkey-106-74bc78bfed100cb1c7da3b1aeeaff1e5767efb0daf93c69cc8294ee246526a09.json
  • packages/rs-sdk/tests/vectors/contested_resources_fields_b7df460e812b958de6e703d8ea325df9aab3448d0409ece3f0baf1d26629e44f/quorum_pubkey-106-74bc78bfed100cb1c7da3b1aeeaff1e5767efb0daf93c69cc8294ee246526a09.json
  • packages/rs-sdk/tests/vectors/contested_resources_fields_ccb199c48ee58a8bb98742b964cba7bda3b4469b740201d2628f15f926f39347/quorum_pubkey-106-74bc78bfed100cb1c7da3b1aeeaff1e5767efb0daf93c69cc8294ee246526a09.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/rs-sdk/tests/fetch/contested_resource.rs
🧰 Additional context used
🪛 Biome
packages/rs-sdk/tests/vectors/check_mn_voting_prerequisities/quorum_pubkey-106-41ef25a6baff2c7a3cf388c77c826c1ffa6fb229b31c0802b1808d2c85dbc248.json

[error] 1-1: String values must be double quoted.

(parse)

packages/rs-sdk/tests/vectors/contested_resources_fields_0760ac4854fc8db803bbcbab8709f390bd31511a05e29cd3f170b48ca6b87584/quorum_pubkey-106-41ef25a6baff2c7a3cf388c77c826c1ffa6fb229b31c0802b1808d2c85dbc248.json

[error] 1-1: String values must be double quoted.

(parse)

packages/rs-sdk/tests/vectors/contested_resources_fields_473cf8e4a270ced75e199e5a3e907b4df4cd66b64365d1ac77c45bcaed443a03/quorum_pubkey-106-41ef25a6baff2c7a3cf388c77c826c1ffa6fb229b31c0802b1808d2c85dbc248.json

[error] 1-1: String values must be double quoted.

(parse)

packages/rs-sdk/tests/vectors/contested_resources_fields_948b5a301af5fc73db7fed418a4fe90f64952b4ddd6b03a7f21d029dc110af50/quorum_pubkey-106-41ef25a6baff2c7a3cf388c77c826c1ffa6fb229b31c0802b1808d2c85dbc248.json

[error] 1-1: String values must be double quoted.

(parse)

packages/rs-sdk/tests/vectors/contested_resources_fields_9f57b982b3e3b0286093d8b48ab27b87b22f67a172579913f2fec7a6b5ea31b7/quorum_pubkey-106-41ef25a6baff2c7a3cf388c77c826c1ffa6fb229b31c0802b1808d2c85dbc248.json

[error] 1-1: String values must be double quoted.

(parse)

packages/rs-sdk/tests/vectors/contested_resources_fields_b7df460e812b958de6e703d8ea325df9aab3448d0409ece3f0baf1d26629e44f/quorum_pubkey-106-41ef25a6baff2c7a3cf388c77c826c1ffa6fb229b31c0802b1808d2c85dbc248.json

[error] 1-1: String values must be double quoted.

(parse)

packages/rs-sdk/tests/vectors/contested_resources_fields_ccb199c48ee58a8bb98742b964cba7bda3b4469b740201d2628f15f926f39347/quorum_pubkey-106-41ef25a6baff2c7a3cf388c77c826c1ffa6fb229b31c0802b1808d2c85dbc248.json

[error] 1-1: String values must be double quoted.

(parse)


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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 Feat/sdk contested resources fixes2 refactor(sdk): contested resource as struct type Oct 8, 2024
@QuantumExplorer QuantumExplorer added this to the v1.4.0 milestone Oct 8, 2024
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: 0

🧹 Outside diff range and nitpick comments (5)
packages/rs-sdk/Cargo.toml (1)

Line range hint 76-86: Informative comments added for testing features.

The added comments for offline-testing and network-testing features provide clear explanations about their behavior and precedence. This improves code maintainability and user understanding.

Consider adding a brief explanation of what each testing mode does. For example:

 # Run integration tests using test vectors from `tests/vectors/` instead of connecting to live Dash Platform.
+# This mode uses pre-recorded responses for testing, ensuring consistent and reproducible results.
 #
 # This feature is enabled by default to allow testing without connecting to the Dash Platform as
 # part of CI/CD workflows.
 #
 # If both `offline-testing` and `network-testing` are enabled, "offline-testing" will take precedence.
 offline-testing = ["mocks"]

 # Run integration tests using a live Dash Platform network.
+# This mode connects to an actual Dash Platform instance, allowing for real-world interaction testing.
 #
 # Requires configuration of Dash Platform connectivity.
 # See [README.md] for more details.
 #
 # If both `offline-testing` and `network-testing` are enabled, "offline-testing" will take precedence.
 network-testing = ["mocks"]
packages/rs-sdk/tests/fetch/contested_resource.rs (3)

108-108: LGTM! Consider adding a type annotation for clarity.

The change from ContestedResource::Value(start_value) to ContestedResource(start_value) simplifies the code and reflects the updated structure of ContestedResource. This change is correct and aligns with the new implementation.

For improved readability, consider adding a type annotation to start_value:

- let ContestedResource(start_value) = start.clone();
+ let ContestedResource(start_value): ContestedResource = start.clone();

This would make the type of start_value explicit and help future readers understand the code more easily.


220-222: LGTM! Consider consistent formatting for improved readability.

The change from ContestedResource::Value(last) to ContestedResource(last) correctly reflects the updated structure of ContestedResource. This modification is consistent with the changes made in the contested_resources_start_at_value function.

For improved readability and consistency with the rest of the codebase, consider adjusting the formatting slightly:

- let ContestedResource(last) =
-     rss.0.into_iter().last().expect("last contested resource");
+ let ContestedResource(last) = rss.0
+     .into_iter()
+     .last()
+     .expect("last contested resource");

This change maintains the single-line destructuring while improving the overall readability of the code.


PLAN-656 References Found Without Corresponding Issue Tracker Entry

The codebase contains multiple references to PLAN-656 as TODO comments and disabled tests. However, no corresponding issue was found in the GitHub issue tracker.

  • Action Items:
    • Verify if PLAN-656 exists in an internal issue tracking system.
    • If it exists internally, ensure that it's documented in the public issue tracker for better visibility.
    • If PLAN-656 has been resolved, update the code comments and re-enable the affected tests.
    • If PLAN-656 is no longer relevant, consider removing the related comments and tests to maintain code cleanliness.
🔗 Analysis chain

Line range hint 1-465: Overall changes look good. Consider addressing PLAN-656.

The modifications to this file consistently reflect the updated structure of ContestedResource, changing from an enum to a struct. These changes are minimal and focused, maintaining the existing test behavior while adapting to the new type structure.

The presence of "PLAN_656" in the contested_resources_limit_PLAN_656 function name suggests an ongoing issue or plan. It would be beneficial to verify the status of this issue and update the function name or add a comment if it has been resolved.

To check the status of PLAN-656, you can run the following command:

If the issue has been resolved, consider updating the function name or adding a comment to explain its historical context.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any mentions of PLAN-656 in the codebase or issue tracker
rg -i "PLAN-656|PLAN 656" --type rust
gh issue list --search "PLAN-656 in:title,body"

Length of output: 602

packages/rs-drive-proof-verifier/src/proof.rs (1)

1382-1382: Simplify the map function by removing the closure

You can make the code more concise by passing the ContestedResource constructor directly to the map function instead of using a closure.

Apply this diff to simplify the code:

-                items.into_iter().map(|v| ContestedResource(v)).collect();
+                items.into_iter().map(ContestedResource).collect();
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 5aed75a and 9921618.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (6)
  • packages/rs-dapi-client/Cargo.toml (2 hunks)
  • packages/rs-drive-proof-verifier/src/proof.rs (1 hunks)
  • packages/rs-drive-proof-verifier/src/types.rs (4 hunks)
  • packages/rs-sdk/Cargo.toml (1 hunks)
  • packages/rs-sdk/src/lib.rs (1 hunks)
  • packages/rs-sdk/tests/fetch/contested_resource.rs (2 hunks)
🧰 Additional context used
🔇 Additional comments (10)
packages/rs-dapi-client/Cargo.toml (2)

8-8: LGTM: New feature tokio-sleep added

The addition of the tokio-sleep feature is a good improvement. It allows users to opt-in for tokio-based sleep functionality, which is likely used for backoff or retry mechanisms. This change enhances the flexibility of the package.


23-23: Verify the backon dependency configuration

The modification of the backon dependency might lead to unexpected behavior:

  1. Removing default-features = false means the package will now use the default features of backon, which may include unnecessary dependencies.
  2. The explicit features = ["tokio-sleep"] has been removed, which seems to contradict the addition of the tokio-sleep feature we just reviewed.

To ensure consistency and avoid potential issues, consider the following options:

  1. If tokio-sleep is intended to be an optional feature:
backon = { version = "1.2", default-features = false, optional = true }

Then update the tokio-sleep feature to:

tokio-sleep = ["dep:backon", "backon/tokio-sleep"]
  1. If tokio-sleep should always be available:
backon = { version = "1.2", default-features = false, features = ["tokio-sleep"] }

Please verify the intended behavior and adjust the configuration accordingly.

To check the impact of this change, you can run:

This will show the dependency tree and help verify if backon is correctly included with the tokio-sleep feature.

packages/rs-sdk/src/lib.rs (1)

79-79: Approved: New export enhances SDK functionality.

The addition of pub use drive_proof_verifier::types as query_types; is a good enhancement to the SDK's interface. It makes additional types available for complex query operations, which can improve the SDK's usability.

Consider adding a brief documentation comment above this line to explain the purpose and contents of the query_types module. This will help users understand what types are available and how they can be used.

Example:

/// Re-exports types from the drive_proof_verifier module for query operations.
pub use drive_proof_verifier::types as query_types;

To ensure this change doesn't introduce any breaking changes, please run the following script:

packages/rs-sdk/Cargo.toml (3)

Line range hint 3-3: Version update looks good.

The package version has been updated to 1.4.0-dev.7, which follows semantic versioning principles and indicates a development version.


Line range hint 1-114: Overall, the changes to Cargo.toml are well-structured and beneficial.

The version update, new feature addition, and improved documentation for testing features all contribute to better project management and developer understanding. The suggestions provided are minor and aimed at further enhancing clarity.


60-60: New tokio-sleep feature looks good.

The addition of the tokio-sleep feature, which depends on rs-dapi-client/tokio-sleep, is clear and consistent with the project structure.

To ensure this feature is properly utilized, please run the following script to check for its usage:

packages/rs-drive-proof-verifier/src/types.rs (4)

244-247: Simplified Into<Value> implementation

The Into<Value> implementation for ContestedResource has been updated to directly return the inner Value. This change is consistent with the new struct definition and simplifies the conversion process, making it more efficient.


257-257: Updated serialization and deserialization for ContestedResource

The platform_encode and platform_versioned_decode implementations for ContestedResource have been updated to work with the new struct definition. They now directly encode/decode the inner Value, which is consistent with the changes made to the type.

These modifications ensure that serialization and deserialization work correctly with the new ContestedResource type.

Also applies to: 267-267


227-228: Simplified ContestedResource type

The change from an enum to a struct with a single Value field simplifies the ContestedResource type. This makes it more straightforward to use and understand.

However, consider the following points:

  1. The public field allows direct access to the Value, which might break encapsulation. Consider making the field private and providing a getter method if direct access is necessary.
  2. This change might affect other parts of the codebase that expect ContestedResource to be an enum. Ensure that all usages of this type have been updated accordingly.

To verify the impact of this change, run the following script:


Line range hint 227-267: Summary of ContestedResource changes

The modifications to ContestedResource and its related implementations have simplified the type and made it more straightforward to use. The changes include:

  1. Converting ContestedResource from an enum to a struct with a single Value field.
  2. Updating the Into<Value> implementation to directly return the inner Value.
  3. Modifying the platform_encode and platform_versioned_decode implementations to work with the new struct definition.

These changes should improve code readability and potentially performance. However, it's crucial to ensure that these modifications don't negatively impact other parts of the codebase that may rely on the previous enum structure of ContestedResource.

Consider the following steps to ensure a smooth transition:

  1. Review all usages of ContestedResource throughout the codebase to update any code that might have been relying on the enum structure.
  2. Update any documentation or comments that describe the ContestedResource type to reflect its new structure.
  3. If there are any public APIs that expose ContestedResource, consider versioning the API or providing a migration guide for users of your library.

To help identify potential areas that might need updates, run the following script:

This will help you identify areas of the code and documentation that might need to be updated in light of these changes.

@QuantumExplorer QuantumExplorer merged commit a646669 into v1.4-dev Oct 9, 2024
32 checks passed
@QuantumExplorer QuantumExplorer deleted the feat/sdkContestedResourcesFixes2 branch October 9, 2024 14:50
packages/rs-sdk/Cargo.toml Show resolved Hide resolved
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