Skip to content

Conversation

@UdjinM6
Copy link

@UdjinM6 UdjinM6 commented Mar 4, 2025

Issue being fixed or feature implemented

Currently cycleHash is calculated based on the current chain height we are signing isdlock at. This however can result in cycleHash to be a block hash of a new cycle where DKG is still in progress which can be confusing to verifiers.

What was done?

Select a signing quorum first and then calculate cycleHash based on the quorum's base block index instead of using the current chain height.

How Has This Been Tested?

Running a testnet MN for some time. It's creating new isdlocks and processing isdlocks from other nodes with no issues.

Breaking Changes

None, cycleHash is simply going to be more accurate now.

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 made corresponding changes to the documentation
  • I have assigned this pull request to a milestone

@UdjinM6 UdjinM6 added this to the 23 milestone Mar 4, 2025
@coderabbitai
Copy link

coderabbitai bot commented Mar 4, 2025

Walkthrough

The pull request introduces significant modifications to the TrySignInstantSendLock method in the CInstantSendManager class located in src/llmq/instantsend.cpp. The method now utilizes the SelectQuorumForSigning function to retrieve the quorum for signing, replacing the previous direct calculation of the cycle hash based on the DKG interval and current chain height. Improved error handling is implemented, allowing for an early exit and logging if quorum selection fails. The AsyncSignIfMember method signature has been updated to include the quorum's base block hash. In src/version.h, protocol version constants have been incremented, with PROTOCOL_VERSION and MIN_MASTERNODE_PROTO_VERSION updated from 70236 to 70237, and a new constant ISDLOCK_CYCLEHASH_UPDATE_VERSION introduced. The P2P_VERSION constant in test/functional/test_framework/p2p.py has also been updated to 70237. The release notes document specifies changes in the isdlock message to reflect the new handling of the cycleHash.


📜 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 31f9c2a and d150a65.

📒 Files selected for processing (4)
  • doc/release-notes-6608.md (1 hunks)
  • src/llmq/instantsend.cpp (2 hunks)
  • src/version.h (3 hunks)
  • test/functional/test_framework/p2p.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • doc/release-notes-6608.md
  • test/functional/test_framework/p2p.py
  • src/version.h
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build slim container / Build container
  • GitHub Check: Build container / Build container
🔇 Additional comments (3)
src/llmq/instantsend.cpp (3)

681-689: Good improvement: Properly selecting quorum for signing

This change improves the code by explicitly selecting a quorum for signing and adding proper error handling when a quorum can't be found. The early return with appropriate logging helps prevent potential issues further in the execution flow.


691-694: Improved cycleHash calculation based on quorum base block

This is the core fix for the PR. By calculating cycleHash based on the selected quorum's base block index rather than the current chain height, you ensure that the hash correctly represents the cycle starting block of the signing quorum. This should prevent the previous confusion for verifiers where a block hash from a new cycle might be produced while DKG is still ongoing.


704-704: Updated method call with quorum base block hash

The AsyncSignIfMember call has been updated to include the quorum's base block hash as an additional parameter, which aligns with the PR's objective to use quorum-based information consistently.

✨ 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 plan to trigger planning for file edits and PR creation.
  • @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

@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

🧹 Nitpick comments (1)
src/llmq/instantsend.cpp (1)

680-682: Consider safer handling of llmq_params_opt instead of assert
Currently, relying on assert(llmq_params_opt) could cause a crash in production if params.llmqTypeDIP0024InstantSend were ever invalid in a release build (where NDEBUG might disable asserts). A more robust approach might be to return early with an error log if llmq_params_opt is not set, rather than asserting.

 if (!llmq_params_opt) {
-    assert(llmq_params_opt);
+    LogPrint(BCLog::INSTANTSEND, 
+             "CInstantSendManager::%s -- missing LLMQ params for type=%d\n", __func__, (int)llmqType);
+    return;
 }
 const auto& llmq_params = llmq_params_opt.value();
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7fc9a7b and 88bf3fa.

📒 Files selected for processing (1)
  • src/llmq/instantsend.cpp (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: x86_64-apple-darwin / Build depends
  • GitHub Check: x86_64-pc-linux-gnu_multiprocess / Build depends
  • GitHub Check: arm-linux-gnueabihf / Build depends
  • GitHub Check: x86_64-pc-linux-gnu_nowallet / Build depends
  • GitHub Check: x86_64-pc-linux-gnu / Build depends
🔇 Additional comments (3)
src/llmq/instantsend.cpp (3)

684-689: Good early return upon missing quorum
The immediate return with a log message is clear and prevents further processing when quorum selection fails. This behavior helps avoid null pointer issues later in the function.


690-692: Verify safety of GetAncestor call
This code calculates the DKG cycle height and uses GetAncestor(cycle_height) to retrieve a block index. While it’s typically valid for well-formed blocks, consider guarding against a null return in case of an unusual or partial chain scenario, for robustness.


703-703: Appropriate inclusion of the quorum base block hash
Passing quorum->m_quorum_base_block_index->GetBlockHash() to AsyncSignIfMember aligns with the new quorum-centric logic. Make sure all internal usages of this additional parameter handle it carefully, especially if the base block transforms or changes in future expansions.

@PastaPastaPasta
Copy link
Member

I think we should tie this to a new protocol version. Do you agree?

Copy link

@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

🧹 Nitpick comments (2)
doc/release-notes-6608.md (2)

4-4: Improve Punctuation and Clarity in the Description

The description on line 4 is a bit hard to read due to missing commas and an omitted article. Consider revising it for clarity. For example, inserting a comma after "Dash Core" and adding "the" before "P2P protocol version" would improve readability.
Diff suggestion:

-* `cycleHash` field in `isdlock` message will now represent a DKG cycle starting block of the signing quorum instead of a DKG cycle starting block corresponding to the current chain height. While this is fully backwards compatible with older versions of Dash Core other implementations might not be expecting this so P2P protocol version was bumped to 70236.
+* `cycleHash` field in `isdlock` message will now represent a DKG cycle starting block of the signing quorum instead of a DKG cycle starting block corresponding to the current chain height. While this is fully backwards compatible with older versions of Dash Core, other implementations might not be expecting this, so the P2P protocol version was bumped to 70236.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~4-~4: A comma might be missing here.
Context: ... compatible with older versions of Dash Core other implementations might not be expe...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)


[uncategorized] ~4-~4: A comma might be missing here.
Context: ... implementations might not be expecting this so P2P protocol version was bumped to 7...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)


[uncategorized] ~4-~4: You might be missing the article “the” here.
Context: ...ntations might not be expecting this so P2P protocol version was bumped to 70236.

(AI_EN_LECTOR_MISSING_DETERMINER_THE)


5-5: Remove Unintended Stray Text

It appears that line 5 contains an unintended stray "5". If this text is not part of the intended content, please remove it.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 843caa1 and 8351386.

📒 Files selected for processing (1)
  • doc/release-notes-6608.md (1 hunks)
🧰 Additional context used
🪛 LanguageTool
doc/release-notes-6608.md

[uncategorized] ~4-~4: A comma might be missing here.
Context: ... compatible with older versions of Dash Core other implementations might not be expe...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)


[uncategorized] ~4-~4: A comma might be missing here.
Context: ... implementations might not be expecting this so P2P protocol version was bumped to 7...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)


[uncategorized] ~4-~4: You might be missing the article “the” here.
Context: ...ntations might not be expecting this so P2P protocol version was bumped to 70236.

(AI_EN_LECTOR_MISSING_DETERMINER_THE)

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: linux64_ubsan-test / Test source
  • GitHub Check: linux64_sqlite-test / Test source
  • GitHub Check: linux64-test / Test source
  • GitHub Check: linux64_multiprocess-build / Build source
🔇 Additional comments (1)
doc/release-notes-6608.md (1)

1-2: Section Header Looks Good

The header "P2P Changes" and its underline are clear and appropriately formatted.

@PastaPastaPasta
Copy link
Member

Shouldn't we actually change the logic based on the protocol version?

PastaPastaPasta
PastaPastaPasta previously approved these changes Apr 1, 2025
Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

Choose a reason for hiding this comment

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

utACK bbfb4c9

@UdjinM6
Copy link
Author

UdjinM6 commented Apr 1, 2025

rebased simply to make GH CI happy, no code changes

Copy link

@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

🧹 Nitpick comments (1)
src/llmq/instantsend.cpp (1)

681-689: Consider adding a comment explaining the rationale for this change.

While the code is well-structured, adding a comment explaining why the cycleHash is now based on the quorum's base block rather than the current chain height would improve maintainability and help future developers understand the reasoning behind this approach.

 const auto& llmq_params_opt = Params().GetLLMQ(llmqType);
 assert(llmq_params_opt);
+// Select the quorum for signing and use its base block to calculate cycleHash
+// This ensures cycleHash represents a cycle starting block of the signing quorum
+// rather than using current chain height which might be from a different cycle
 const auto quorum = SelectQuorumForSigning(llmq_params_opt.value(), m_chainstate.m_chain, qman, id);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between bbfb4c9 and 31f9c2a.

📒 Files selected for processing (2)
  • doc/release-notes-6608.md (1 hunks)
  • src/llmq/instantsend.cpp (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • doc/release-notes-6608.md
🔇 Additional comments (3)
src/llmq/instantsend.cpp (3)

681-693: Improved logic for calculating cycleHash using signing quorum's base block.

The new implementation correctly resolves the issue mentioned in the PR objectives by using the quorum's base block index to calculate cycleHash rather than the current chain height. This ensures that the cycleHash represents a cycle starting block of the signing quorum, preventing confusion when DKG is ongoing.

The code also includes proper error handling with early return if quorum selection fails.


704-704: Updated method signature for AsyncSignIfMember to include quorum's base block hash.

The method call has been properly updated to include the quorum's base block hash as an additional parameter, which aligns with the improved method for calculating cycleHash.


681-693:

❓ Verification inconclusive

Verify protocol version update is properly handled.

The PR indicates this change requires a protocol version update (70235 -> 70236). Ensure all code paths properly handle both the old and new behavior based on protocol version for backward compatibility.


🏁 Script executed:

#!/bin/bash
# Check if the code handles the protocol version update properly

# Look for ISDLOCK_CYCLEHASH_UPDATE_VERSION constant
grep -r "ISDLOCK_CYCLEHASH_UPDATE_VERSION" --include="*.h" --include="*.cpp" .

# Check for version checks related to the cycleHash calculation
grep -r "cycleHash" --include="*.cpp" . | grep -i "version"

Length of output: 211


Protocol Version Handling in CycleHash Calculation

The PR updates the protocol version constant (ISDLOCK_CYCLEHASH_UPDATE_VERSION at 70236), but our search shows no explicit version-check condition around the cycleHash calculation in the shown code. Please verify that:

  • The new cycleHash computation is gated by a protocol version check (or that older nodes/processes follow an alternative code path) to ensure proper backward compatibility.
  • Other related code paths correctly differentiate between protocol versions 70235 and 70236.

@github-actions
Copy link

github-actions bot commented Apr 3, 2025

This pull request has conflicts, please rebase.

Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

Choose a reason for hiding this comment

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

utACK d150a65

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 d150a65

@PastaPastaPasta PastaPastaPasta merged commit 5e4a892 into dashpay:develop Apr 13, 2025
55 of 58 checks passed
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Apr 14, 2025
…g block of the signing quorum

d150a65 docs: add release notes (UdjinM6)
85c6b58 feat: bump PROTOCOL_VERSION/MIN_MASTERNODE_PROTO_VERSION to 70237 (UdjinM6)
c20dfd8 fix: `cycleHash` should represent a cycle starting block of the signing quorum (UdjinM6)

Pull request description:

  ## Issue being fixed or feature implemented
  Currently `cycleHash` is calculated based on the current chain height we are signing `isdlock` at. This however can result in `cycleHash` to be a block hash of a new cycle where DKG is still in progress which can be confusing to verifiers.

  ## What was done?
  Select a signing quorum first and then calculate `cycleHash` based on the quorum's base block index instead of using the current chain height.

  ## How Has This Been Tested?
  Running a testnet MN for some time. It's creating new `isdlock`s and processing `isdlock`s from other nodes with no issues.

  ## Breaking Changes
  None, `cycleHash` is simply going to be more accurate now.

  ## 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 made corresponding changes to the documentation
  - [ ] I have assigned this pull request to a milestone

ACKs for top commit:
  PastaPastaPasta:
    utACK d150a65
  knst:
    utACK d150a65

Tree-SHA512: ff7e8a9f37aded9ac330185a34db0eef346c6a3f4a6e22f11a6081ff074a789d260fbdf9efc1d8590d4013ecd95a273e07126dfcb5a7f6d6ebebdb45a543f053
PastaPastaPasta added a commit that referenced this pull request Apr 15, 2025
8b4ab03 fix: suppress MIN_MASTERNODE_PROTO_VERSION bump in 6608 (pasta)
aca04d1 chore: bump build to 22.1.2 (pasta)
d9d8c24 docs: add release notes for 22.1.2 (pasta)
fb45240 Merge #6608: fix: `cycleHash` should represent a cycle starting block of the signing quorum (pasta)
9d1498c Merge #6625: fix: adjust quorum rotation data results in some edge cases, add tests (pasta)
dfc1119 Merge #6622: fix: efficient build mnlistdiffs in rotation info (pasta)
6fd626b Merge #6586: fix: revert deployment images back to Ubuntu 22.04 LTS (`jammy`), pin QEMU to avoid segfault (pasta)
affa9d1 Merge #6599: fix: follow-up #6546 to bump copyright year in COPYING and debian's package (pasta)
f6163a2 Merge #6593: fix: resolve potential deadlock in coinjoin_tests (pasta)
243e0ab Merge #6585: fix: Do not assert special tx type for cbtx in simplified mn list diff output (pasta)
497f95c Merge #6581: perf: speedup of CBLSLazyPublicKey::operator== when comparing to the default / null object; speedup CDeterministicMNList::AddMN by avoiding check to IsValid when a nullcheck is sufficient (pasta)

Pull request description:

  ## Issue being fixed or feature implemented
  Backports for a new version, v22.1.2

  ## What was done?
  See release notes

  ## How Has This Been Tested?

  ## Breaking Changes
  None

  ## 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
  - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  UdjinM6:
    utACK 8b4ab03
  knst:
    utACK 8b4ab03

Tree-SHA512: 9f2f65e315940197cc2b75a6b0a858d624256cbe668272ff6dfa216eceda1ba9338484d47afc569202b3b5cc75b4dcb825209efe3a3d3ccec57c741f75c40577
@UdjinM6 UdjinM6 modified the milestones: 23, 22.1.2 Apr 16, 2025
PastaPastaPasta added a commit that referenced this pull request Apr 23, 2025
8b4ab03 fix: suppress MIN_MASTERNODE_PROTO_VERSION bump in 6608 (pasta)
aca04d1 chore: bump build to 22.1.2 (pasta)
d9d8c24 docs: add release notes for 22.1.2 (pasta)
fb45240 Merge #6608: fix: `cycleHash` should represent a cycle starting block of the signing quorum (pasta)
9d1498c Merge #6625: fix: adjust quorum rotation data results in some edge cases, add tests (pasta)
dfc1119 Merge #6622: fix: efficient build mnlistdiffs in rotation info (pasta)
6fd626b Merge #6586: fix: revert deployment images back to Ubuntu 22.04 LTS (`jammy`), pin QEMU to avoid segfault (pasta)
affa9d1 Merge #6599: fix: follow-up #6546 to bump copyright year in COPYING and debian's package (pasta)
f6163a2 Merge #6593: fix: resolve potential deadlock in coinjoin_tests (pasta)
243e0ab Merge #6585: fix: Do not assert special tx type for cbtx in simplified mn list diff output (pasta)
497f95c Merge #6581: perf: speedup of CBLSLazyPublicKey::operator== when comparing to the default / null object; speedup CDeterministicMNList::AddMN by avoiding check to IsValid when a nullcheck is sufficient (pasta)
4298d73 chore: bump to 22.1.1 (pasta)
fc65a16 chore: release notes for 22.1.1 (pasta)
38762f7 Merge #6574: fix: ReconnectionInfo should also store Dash-specific flags (pasta)
580b74c Merge #6566: fix(qt): avoid leaking balance and CJ info in GUI when in discreet mode (pasta)

Pull request description:

  ## Issue being fixed or feature implemented

  ## What was done?
  ff-ed `master` 21.1.0 -> 21.1.2, merging it back into `develop` now

  ## How Has This Been Tested?

  ## Breaking Changes

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

ACKs for top commit:
  PastaPastaPasta:
    utACK 73fa780; gonna merge as this changes docs only

Tree-SHA512: f04fe461edc05c38771d684bd5d60327076251b8004723027276b104989ea6d84f7f77cce31f310f058e81f2c25411ab5a15b563cd3db66091ccaf33da459e3c
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