platform icon indicating copy to clipboard operation
platform copied to clipboard

feat(sdk): asset lock quorum and core locked height verification

Open lklimek opened this issue 1 year ago • 1 comments

Issue being fixed or feature implemented

We want to be able to check if the platform can process an asset lock.

What was done?

Added AssetLockProofVerifier trait with verify() method, implemented on AssetLockProof.

How Has This Been Tested?

Added test.

Note: Requires #2061 to pass the tests.

Breaking Changes

None

Checklist:

  • [x] I have performed a self-review of my own code
  • [x] I have commented my code, particularly in hard-to-understand areas
  • [x] 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
  • [x] I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • [x] I have assigned this pull request to a milestone

Summary by CodeRabbit

  • New Features

    • Expanded gRPC response capabilities with added metadata and proof operations.
    • Introduced asynchronous support for token operations and asset lock verification.
    • Integrated improved network configuration access, enhancing SDK usability.
    • Added new public modules to support asset locking and state transitions.
    • Added new error variants to enhance error handling.
  • Bug Fixes

    • Reorganized API request and response listings for greater consistency.
  • Tests

    • Introduced comprehensive tests for asset lock proofs.
  • Documentation

    • Updated documentation and comments to improve clarity and future maintenance.
    • Enhanced comments for better understanding of epoch information.

lklimek avatar Jul 31 '24 10:07 lklimek

Walkthrough

This pull request implements broad modifications across several packages. It updates configuration arrays with new request and response entries, refactors trait implementations to support asynchronous operations, and reorganizes module structures and imports. Error handling is enhanced with new error variants, and testing capabilities are expanded with asset lock proof tests and JSON vectors. Minor improvements include documentation updates, removal of unnecessary cloning, and dependency modifications.

Changes

File(s) Change Summary
packages/dapi-grpc/build.rs Updated configure_platform to modify VERSIONED_REQUESTS and VERSIONED_RESPONSES: added four new entries each, removed several, and reordered entries alphabetically.
packages/rs-dapi-client/src/executor.rs Added VersionedGrpcResponse trait implementation for ExecutionResponse<T> with new methods: metadata, proof, and proof_owned.
packages/rs-dpp/src/core_types/validator_set/v0/mod.rs Simplified test by replacing a clone of pro_tx_hash with direct assignment.
packages/rs-sdk/src/error.rs Introduced new error variants (QuorumNotFound, CoreLockedHeightNotYetAvailable, InvalidAssetLock) and updated the can_retry method to include them.
packages/rs-sdk/src/platform/transition.rs Modified module declarations: added pub mod asset_lock;, pub mod builder;, and updated fungible_tokens declarations.
packages/rs-sdk/src/platform/transition/asset_lock.rs New file added; defines the AssetLockProofVerifier trait with an async verify method and helper function fetch_platform_locked_height.
packages/rs-sdk/src/platform/transition/put_identity.rs Reorganized imports by moving BroadcastRequestForNewIdentity and repositioning other imports.
packages/rs-sdk/src/platform/types/epoch.rs Updated documentation for the Epoch type alias, changing its comment to "Epoch information".
packages/rs-sdk/src/sdk.rs Changed network field from public to private; added a public network() getter; updated SdkBuilder default network and documentation.
packages/rs-sdk/tests/fetch/asset_lock.rs New test file; added async helper current_platform_state and test function test_asset_lock_proof to validate asset lock proofs.
packages/rs-sdk/tests/fetch/mod.rs Added a new module declaration for asset_lock.
packages/rs-sdk/tests/vectors/test_asset_lock_proof/*.json New JSON test vector file added, containing a quorum public key hash.
packages/rs-dpp/Cargo.toml Activated the "validation" feature in the dash-sdk-features section.
packages/rs-sdk/src/platform/fetch_unproved.rs Modified argument from sdk.network to sdk.network() in a function call.
packages/rs-drive-proof-verifier/src/provider.rs Removed the lifetime constraint from the ContextProvider trait implementation for std::sync::Mutex<T>.
packages/rs-drive-proof-verifier/src/types/evonode_status.rs Removed an unnecessary clone on the protocol field when converting from GetStatusResponse.
packages/rs-drive-proof-verifier/src/verify.rs Modified signature verification by passing signature by value instead of by reference.
packages/rs-sdk/src/platform/query.rs Updated lifetime annotation from an explicit 'a to an anonymous lifetime '_ in the Query trait implementation.
packages/rs-sdk/src/platform/types/proposed_blocks.rs Removed an extraneous blank line in documentation comments.
packages/rs-sdk/tests/fetch/config.rs Applied conditional compilation to the platform_ca_cert_path field based on feature flags.
packages/rs-sdk/src/platform/transition/fungible_tokens/* For files (burn.rs, destroy.rs, emergency_action.rs, freeze.rs, mint.rs, transfer.rs, unfreeze.rs): Added #[async_trait::async_trait] to StateTransitionBuilder implementations to support asynchronous operations.

Sequence Diagram(s)

sequenceDiagram
  participant SDK as Sdk
  participant ALProof as AssetLockProof
  participant Fetch as fetch_platform_locked_height
  SDK->>ALProof: verify(sdk)
  ALProof->>Fetch: fetch_platform_locked_height(sdk)
  Fetch-->>ALProof: current locked height
  ALProof->>ALProof: Validate proof (chain/instant)
  ALProof-->>SDK: Return verification result

Suggested labels

js-sdk

Suggested reviewers

  • QuantumExplorer
  • shumkov

Poem

I’m a rabbit in the code burrow, leaping high,
Changes sprout like carrots under the sky.
Async flows and proofs set the stage,
In this diff’s dance, I proudly engage.
Hopping through tests with a joyful sigh!
🐰✨

[!TIP]

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments. - To enable this feature, set early_access to true under in the settings.

📜 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 ed981b66eaedd2c7b73d0d0bb808be590716df90 and bb8dcff74349e19c1117efdb6bd85c369d35b4eb.

📒 Files selected for processing (1)
  • packages/rs-dpp/Cargo.toml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/rs-dpp/Cargo.toml
⏰ Context from checks skipped due to timeout of 90000ms (16)
  • GitHub Check: Rust packages (dapi-grpc) / Detect immutable structure changes
  • GitHub Check: Rust packages (drive-abci) / Tests
  • GitHub Check: Rust packages (drive-abci) / Linting
  • GitHub Check: Rust packages (drive-abci) / Unused dependencies
  • GitHub Check: Rust packages (drive) / Tests
  • GitHub Check: Rust packages (drive) / Linting
  • GitHub Check: Rust packages (drive) / Formatting
  • GitHub Check: Rust packages (wasm-dpp) / Linting
  • GitHub Check: Rust packages (wasm-dpp) / Tests
  • GitHub Check: Rust packages (dpp) / Linting
  • GitHub Check: Rust packages (dpp) / Tests
  • GitHub Check: Rust packages (dpp) / Unused dependencies
  • 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 Docker images (DAPI, dapi, dapi) / Build DAPI image
  • GitHub Check: Build JS packages / Build JS

🪧 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 generate docstrings to generate docstrings for 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.

coderabbitai[bot] avatar Dec 10 '24 09:12 coderabbitai[bot]