Skip to content

Conversation

@shumkov
Copy link
Collaborator

@shumkov shumkov commented Mar 8, 2025

#51 fixes wrong QuorumHash (it supposed to reverse from / to hex string conversion). Unfortunately, we have a lot of legacy code that depends on buggy logic. This PR adds additional RPC methods which support legacy behaviour

Close #61

Summary by CodeRabbit

  • New Features

    • Added a method to retrieve information about a specific quorum with the quorum hash reversed.
    • Enhanced JSON deserialization for extended quorum list data.
  • Tests

    • Introduced a new test for validating the deserialization of an extended quorum list.

These changes improve the functionality and reliability of the RPC interface while ensuring enhanced data processing consistency.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 8, 2025

Walkthrough

The changes span three modules. In the hash types file, import statements have been reordered and function bodies reformatted for improved readability without modifying logic. The RPC client now updates the get_quorum_info_reversed method in the API trait to process and reverse quorum hashes, along with minor formatting adjustments. Meanwhile, the RPC JSON module gains an active test for deserializing quorum data, ensuring that the extended quorum list JSON is correctly parsed into the appropriate structures.

Changes

File(s) Change Summary
dash/src/hash_types.rs Reordered import statements in the newtypes module and reformatted multiple function bodies (partial_cmp, from_hex, to_hex, etc.) into multi-line format for enhanced readability without altering functionality.
rpc-client/src/client.rs Modified get_quorum_info_reversed method in the RpcApi trait to set result.quorum_hash to the reversed value of result.quorum_hash. Updated method signature accordingly.
rpc-json/src/lib.rs Introduced a new test deserialize_quorum_listextended() in the tests module, enabling validation of JSON deserialization into ExtendedQuorumListResult. Additionally, updated import statements to include necessary types.

Sequence Diagram(s)

sequenceDiagram
    participant C as Client Code
    participant API as RpcApi Implementation
    participant Q as Quorum Provider

    C->>API: get_quorum_info_reversed(llmq_type, quorum_hash)
    API->>Q: get_quorum_info(llmq_type, quorum_hash)
    Q-->>API: QuorumInfo
    API->>API: Reverse quorum_hash in result
    API-->>C: QuorumInfoResult
Loading

Suggested reviewers

  • QuantumExplorer
  • ogabrielides

Poem

I'm a little rabbit on the run,
Hoping these changes make code fun,
Imports shuffled, functions spread,
New RPC flows now softly tread.
With tests that check each quorum's tale,
I dance in ASCII trails! 🐇✨
Code hoppy, code hoppy—let's prevail!


📜 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 217197c and f602f6a.

📒 Files selected for processing (3)
  • rpc-client/src/client.rs (4 hunks)
  • rpc-client/src/client.rs (1 hunks)
  • rpc-client/src/client.rs (1 hunks)
🔇 Additional comments (2)
rpc-client/src/client.rs (2)

24-28: No concerns with the new imports
The additions for DisplayHex, error, json, and queryable appear standard and correct.


1237-1260: Preserves legacy reversed-hash behavior
The new get_quorum_listextended_reversed method retrieves the extended quorum list and reverses its quorum hashes for backward-compatibility. The logic appears correct and in line with the stated requirements.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.

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.

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 1

🧹 Nitpick comments (1)
rpc-client/src/client.rs (1)

449-452: Check method naming for clarity
The function name “get_instant_locks” matches returning multiple locks. Implementation calls "getislocks" and returns a Vec<String> with no apparent issues.

Consider adding a doc comment or clarifying the naming to emphasize that this method fetches multiple locks.

🛑 Comments failed to post (1)
rpc-client/src/client.rs (1)

1421-1426: ⚠️ Potential issue

Duplicate or incomplete definition of get_protx_info
This code block redefines the method in the same scope and references a stray "listdiff" snippet, causing a likely syntax error.

Apply the following diff to remove or properly merge the incomplete method:

-    /// Returns a returns detailed information about a deterministic masternode
-    fn get_protx_info(
-        &self,
-        protx_hash: &ProTxHash,
-        block_hash: Option<&BlockHash>,
-    ) -> Result<json::ProTxInfo> {
-        let mut args = ["info".into(), into_json(protx_hash.to_hex())?, opt_into_json(block_hash)?];
-        self.call::<json::ProTxInfo>("protx", handle_defaults(&mut args, &[null()]))
-        let mut args = ["listdiff".into(), into_json(base_block)?, into_json(block)?];
-        self.call::<json::MasternodeListDiff>(
-            "protx",
-            handle_defaults(&mut args, &[null(), null()]),
-        )
-    }

Make sure only the valid get_protx_info implementation remains at lines 1439–1446.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

    /// Returns a diff and a proof between two masternode list
    fn get_protx_diff(&self, base_block: u32, block: u32) -> Result<json::MasternodeDiff> {
        let mut args = ["diff".into(), into_json(base_block)?, into_json(block)?];
        self.call::<json::MasternodeDiff>("protx", handle_defaults(&mut args, &[null()]))
    }

    // Ensure that only the valid `get_protx_info` implementation remains here (lines 1439–1446).
    // The duplicate/incomplete `get_protx_info` definition (shown below) has been removed:
    //
    // -    /// Returns a returns detailed information about a deterministic masternode
    // -    fn get_protx_info(
    // -        &self,
    // -        protx_hash: &ProTxHash,
    // -        block_hash: Option<&BlockHash>,
    // -    ) -> Result<json::ProTxInfo> {
    // -        let mut args = ["info".into(), into_json(protx_hash.to_hex())?, opt_into_json(block_hash)?];
    // -        self.call::<json::ProTxInfo>("protx", handle_defaults(&mut args, &[null()]))
    // -        let mut args = ["listdiff".into(), into_json(base_block)?, into_json(block)?];
    // -        self.call::<json::MasternodeListDiff>(
    // -            "protx",
    // -            handle_defaults(&mut args, &[null(), null()]),
    // -        )
    // -    }

@shumkov shumkov self-assigned this Mar 11, 2025
@shumkov shumkov moved this to In review / testing in Platform team Mar 11, 2025
@shumkov shumkov requested a review from QuantumExplorer March 11, 2025 08:12
@shumkov shumkov merged commit deb97ec into master Mar 11, 2025
2 of 17 checks passed
@github-project-automation github-project-automation bot moved this from In review / testing to Done in Platform team Mar 11, 2025
@QuantumExplorer QuantumExplorer deleted the feat/quorum-list-extended-reversed branch October 20, 2025 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants