Skip to content

fix: require chainlock signatures only after V20 activation#405

Merged
xdustinface merged 1 commit intov0.42-devfrom
fix/pre-v20-missing-signatures
Feb 4, 2026
Merged

fix: require chainlock signatures only after V20 activation#405
xdustinface merged 1 commit intov0.42-devfrom
fix/pre-v20-missing-signatures

Conversation

@xdustinface
Copy link
Collaborator

@xdustinface xdustinface commented Feb 2, 2026

Pre-V20 blocks have no chainlock signatures in MnListDiff responses, but we currently incorrectly trigger failures when they are missing below v20 activation height.

V20 activation heights (from Dash Core src/chainparams.cpp):

  • Mainnet: 1,987,776
  • Testnet: 905,100

Added v20_activation_height() to NetworkExt and check in apply_diff and from_diff to only require signatures for post-V20 blocks.

See DIP-0029.

Summary by CodeRabbit

  • New Features
    • V20 protocol support with network-specific activation heights: mainnet (block 1,987,776), testnet (block 905,100), and immediate activation on devnet/regtest
    • Protocol-aware chainlock signature validation: signatures enforced for post-V20 blocks while maintaining backward compatibility for pre-V20 protocol versions

Pre-V20 blocks have no chainlock signatures in `MnListDiff` responses, but we currently incorrectly trigger failures
when they are missing below v20 activation height.

V20 activation heights (from Dash Core src/chainparams.cpp):
- Mainnet: 1,987,776
- Testnet: 905,100

Added `v20_activation_height()` to `NetworkExt` and check in
`apply_diff` and `from_diff` to only require signatures for post-V20 blocks.

See DIP-0029.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 2, 2026

📝 Walkthrough

Walkthrough

This change adds network-aware V20 activation height tracking to the masternode list module. A new v20_activation_height() method is introduced to the NetworkExt trait, returning network-specific heights. The apply_diff method is updated to accept a Network parameter and enforce chainlock signature requirements based on whether the diff height meets the V20 activation threshold.

Changes

Cohort / File(s) Summary
Network Constants
dash/src/network/constants.rs
Adds v20_activation_height() method to NetworkExt trait and implements it for Network, returning 1,987,776 for Dash, 905,100 for Testnet, and 0 for Devnet/Regtest.
Masternode List Diff Application
dash/src/sml/masternode_list/apply_diff.rs, dash/src/sml/masternode_list/from_diff.rs
Threads Network parameter through diff application to enable network-based gating of chainlock signatures. Enforces signature requirements post-V20 while allowing missing signatures pre-V20. Replaces direct array indexing with safe optional retrieval (get().copied().flatten()). Adds unit tests validating both V20 phases.
Masternode List Engine
dash/src/sml/masternode_list_engine/mod.rs
Updates apply_diff call site to pass self.network, enabling network context during diff application and rotation signature computation.

Sequence Diagram

sequenceDiagram
    participant Engine as MasternodeListEngine
    participant Diff as apply_diff
    participant Network as NetworkExt
    participant Sigs as Signature Validation

    Engine->>Diff: apply_diff(..., network)
    Diff->>Network: v20_activation_height()
    Network-->>Diff: activation_height
    
    alt diff_end_height >= v20_activation_height
        Diff->>Sigs: Check signatures present
        alt Signatures available
            Sigs->>Sigs: Safe retrieve via get().copied().flatten()
            Sigs-->>Diff: VerifyingChainLockSignaturesType
            Diff-->>Engine: Result(MasternodeList, signature)
        else Missing signatures
            Sigs-->>Diff: IncompleteSignatureSet error
            Diff-->>Engine: Err(IncompleteSignatureSet)
        end
    else Pre-V20 (diff_end_height < activation_height)
        Diff->>Sigs: Skip strict signature check
        Sigs->>Sigs: Use available signatures if present
        Sigs-->>Diff: Optional signature result
        Diff-->>Engine: Result(MasternodeList, optional_sig)
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 V20 heights are now aware,
Networks know when signatures care—
Pre-block days were kind and free,
Post-V20: strict as can be! ✨
Safe retrieval hops along the way,
Making chainlocks bright and gay!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding network-aware V20 activation height checks to require chainlock signatures only after V20 activation, which is the core functionality across all modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/pre-v20-missing-signatures

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.

Copy link
Collaborator

@ZocoLini ZocoLini left a comment

Choose a reason for hiding this comment

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

Not sure about having a method with hardcoded heights where v20 starts, there is no other way to know it?? the v doesn't come in the data provided by the network??

@xdustinface
Copy link
Collaborator Author

there is no other way to know it?? the v doesn't come in the data provided by the network??

Not since it's activated i think. We could probably at some point introduce a chainparams module which mirrors chainparams.cpp in core.

@xdustinface xdustinface merged commit b5a7c0a into v0.42-dev Feb 4, 2026
53 of 54 checks passed
@xdustinface xdustinface deleted the fix/pre-v20-missing-signatures branch February 4, 2026 23:13
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