Skip to content

Conversation

@PastaPastaPasta
Copy link
Member

Issue being fixed or feature implemented

Avoiding using raw size as indication for special logic; use a helper function in-case the conditions change in the future (however unlikely that may be)

What was done?

added helper for is_single_member

How Has This Been Tested?

builds

Breaking Changes

Checklist:

Go over all the following points, and put an x in all the boxes that apply.

  • 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 made corresponding changes to the documentation
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

@PastaPastaPasta PastaPastaPasta added this to the 23.1 milestone Oct 21, 2025
@github-actions
Copy link

github-actions bot commented Oct 21, 2025

⚠️ Potential Merge Conflicts Detected

This PR has potential conflicts with the following open PRs:

Please coordinate with the authors of these PRs to avoid merge conflicts.

@coderabbitai
Copy link

coderabbitai bot commented Oct 21, 2025

Walkthrough

This change adds [[nodiscard]] constexpr bool is_single_member() const { return size == 1; } to LLMQParams and replaces direct size == 1 checks with is_single_member() in five files: src/llmq/params.h, src/llmq/commitment.cpp, src/llmq/dkgsessionhandler.cpp, src/llmq/signing_shares.cpp, and src/rpc/quorums.cpp. The code paths for single-member and multi-member quorums are preserved; only the predicate used to detect single-member quorums is centralized into the new accessor.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant Params as LLMQParams
    participant Single as Single-member flow
    participant Multi as Multi-member flow
    Note over Params: New method: is_single_member()
    Caller->>Params: params.is_single_member()
    alt is_single_member == true
        Params-->>Caller: true
        Caller->>Single: Single-member handling
        Single-->>Caller: verify member signature / emit operator pubKeyShare / finalize commitment
    else is_single_member == false
        Params-->>Caller: false
        Caller->>Multi: Multi-member handling
        Multi-->>Caller: verify aggregated signatures / check quorumVvecHash / queue or secure-aggregate paths
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "refactor: replace size check with is_single_member() method for clarity" directly and accurately describes the main changes in the changeset. The title clearly identifies that a helper method is being introduced to replace raw size checks across multiple files, which is exactly what the raw summary shows happening in params.h, commitment.cpp, dkgsessionhandler.cpp, signing_shares.cpp, and quorums.cpp. The title is concise, uses clear language, and is specific enough that a developer scanning the history would immediately understand the primary purpose of the change.
Description Check ✅ Passed The PR description is related to the changeset and provides relevant context about the change. It explains the motivation ("avoiding using raw size as indication for special logic") and specifies what was done ("added helper for is_single_member"), both of which align with the actual changes shown in the raw summary. The description clearly articulates the rationale for the refactor (allowing conditions to change in the future if needed), which is consistent with introducing an abstraction layer through the helper method.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 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 2f540be and 90a3b57.

📒 Files selected for processing (5)
  • src/llmq/commitment.cpp (2 hunks)
  • src/llmq/dkgsessionhandler.cpp (1 hunks)
  • src/llmq/params.h (1 hunks)
  • src/llmq/signing_shares.cpp (2 hunks)
  • src/rpc/quorums.cpp (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/rpc/quorums.cpp
  • src/llmq/commitment.cpp
🧰 Additional context used
📓 Path-based instructions (1)
src/**/*.{cpp,h,cc,cxx,hpp}

📄 CodeRabbit inference engine (CLAUDE.md)

src/**/*.{cpp,h,cc,cxx,hpp}: Dash Core C++ codebase must be written in C++20 and require at least Clang 16 or GCC 11.1
Dash uses unordered_lru_cache for efficient caching with LRU eviction

Files:

  • src/llmq/signing_shares.cpp
  • src/llmq/dkgsessionhandler.cpp
  • src/llmq/params.h
🧠 Learnings (2)
📓 Common learnings
Learnt from: knst
PR: dashpay/dash#6692
File: src/llmq/commitment.cpp:54-60
Timestamp: 2025-08-19T15:08:00.835Z
Learning: In Dash Core, llmq_params.size == 1 is used only for regtest environments, not on public networks, which significantly reduces the risk profile of code paths specific to single-member quorums.
📚 Learning: 2025-08-19T15:08:00.835Z
Learnt from: knst
PR: dashpay/dash#6692
File: src/llmq/commitment.cpp:54-60
Timestamp: 2025-08-19T15:08:00.835Z
Learning: In Dash Core, llmq_params.size == 1 is used only for regtest environments, not on public networks, which significantly reduces the risk profile of code paths specific to single-member quorums.

Applied to files:

  • src/llmq/params.h
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Lint / Run linters
🔇 Additional comments (4)
src/llmq/params.h (1)

124-124: LGTM! Clean abstraction for single-member detection.

The new is_single_member() method is well-designed:

  • Uses [[nodiscard]] to prevent silent bugs
  • Marked constexpr for compile-time evaluation where possible
  • Follows the existing pattern of accessor methods in this struct
  • Provides clear semantic intent compared to raw size == 1 checks
src/llmq/signing_shares.cpp (2)

784-784: LGTM! Improved readability for single-member signature recovery.

The replacement of quorum->params.size == 1 with quorum->params.is_single_member() makes the special-case logic clearer. The semantic meaning is preserved while improving code maintainability.


1553-1553: LGTM! Consistent use of the new predicate.

The replacement correctly uses is_single_member() to determine whether to sign with the operator key (single-member path) vs. the secret key share (multi-member DKG path). The logic is unchanged and the intent is now more explicit.

src/llmq/dkgsessionhandler.cpp (1)

554-554: LGTM! Consistent refactoring in DKG handler.

The replacement of params.size == 1 with params.is_single_member() correctly identifies the single-member quorum path, where FinalizeSingleCommitment is called instead of the full multi-phase DKG process. The logic is preserved and the intent is now clearer.

Based on learnings: This code path is only active in regtest environments, which reduces the risk profile.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

knst
knst previously approved these changes Oct 22, 2025
Copy link
Collaborator

@knst knst left a comment

Choose a reason for hiding this comment

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

utACK 2f540be

ss3.str(), quorumPublicKey.ToString(), commitmentHash.ToString());
}
if (llmq_params.size == 1) {
if (llmq_params.is_single_member()) {
Copy link

Choose a reason for hiding this comment

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

let's change this one too

if (llmq_params.size != 1 && quorumVvecHash.IsNull()) {

Copy link
Collaborator

@knst knst left a comment

Choose a reason for hiding this comment

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

utACK 90a3b57

Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

utACK 90a3b57

@PastaPastaPasta PastaPastaPasta merged commit 58acea6 into dashpay:develop Oct 25, 2025
31 of 35 checks passed
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.

3 participants