forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
refactor: extract CActiveMasternodeManager from LLMQContext (3/n, DKG session isolation, ActiveContext consolidation)
#7065
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kwvg
wants to merge
12
commits into
dashpay:develop
Choose a base branch
from
kwvg:active_p4
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,903
−1,790
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
394c66b
refactor: use `unique_ptr` in DKG session handler map
kwvg 831dbfe
refactor: move DKG session handler init out of ctor
kwvg 92a5e25
move-only: move DKG session handler participant logic to `llmq/active`
kwvg 4a81bd6
refactor: separate active session handler routines into dedicated class
kwvg 1cab80c
move-only: move DKG session participant logic to `llmq/active`
kwvg 268d2aa
refactor: separate active session routines into dedicated class
kwvg 7678e38
refactor: drop `CActiveMasternodeManager` from chainstate init
kwvg e41c56b
refactor: move `CActiveMasternodeManager` to `ActiveContext`
kwvg f341bc4
refactor: merge `CActiveMasternodeInfo` into `CActiveMasternodeManager`
kwvg 736201f
refactor: merge `ActiveNotificationInterface` into `ActiveContext`
kwvg 50b64ac
refactor: consolidate masternode mode logic to `src/active/`
kwvg 7ae88ee
chore: update lint circular dependencies allowlist
kwvg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| // Copyright (c) 2025 The Dash Core developers | ||
| // Distributed under the MIT software license, see the accompanying | ||
| // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
|
||
| #include <active/context.h> | ||
|
|
||
| #include <active/dkgsessionhandler.h> | ||
| #include <active/masternode.h> | ||
| #include <active/quorums.h> | ||
| #include <chainlock/chainlock.h> | ||
| #include <chainlock/signing.h> | ||
| #include <governance/governance.h> | ||
| #include <governance/signing.h> | ||
| #include <instantsend/instantsend.h> | ||
| #include <instantsend/signing.h> | ||
| #include <llmq/context.h> | ||
| #include <llmq/debug.h> | ||
| #include <llmq/dkgsessionmgr.h> | ||
| #include <llmq/ehf_signals.h> | ||
| #include <llmq/quorumsman.h> | ||
| #include <llmq/signing_shares.h> | ||
|
|
||
| #include <util/check.h> | ||
| #include <validation.h> | ||
|
|
||
| ActiveContext::ActiveContext(CBLSWorker& bls_worker, ChainstateManager& chainman, CConnman& connman, | ||
| CDeterministicMNManager& dmnman, CGovernanceManager& govman, | ||
| CMasternodeMetaMan& mn_metaman, CMNHFManager& mnhfman, CSporkManager& sporkman, | ||
| CTxMemPool& mempool, llmq::CChainLocksHandler& clhandler, llmq::CInstantSendManager& isman, | ||
| llmq::CQuorumBlockProcessor& qblockman, llmq::CQuorumManager& qman, | ||
| llmq::CQuorumSnapshotManager& qsnapman, llmq::CSigningManager& sigman, | ||
| PeerManager& peerman, const CMasternodeSync& mn_sync, const CBLSSecretKey& operator_sk, | ||
| const llmq::QvvecSyncModeMap& sync_map, const util::DbWrapperParams& db_params, | ||
| bool quorums_recovery, bool quorums_watch) : | ||
| m_clhandler{clhandler}, | ||
| m_isman{isman}, | ||
| m_qman{qman}, | ||
| nodeman{std::make_unique<CActiveMasternodeManager>(connman, dmnman, operator_sk)}, | ||
| dkgdbgman{std::make_unique<llmq::CDKGDebugManager>()}, | ||
| qdkgsman{std::make_unique<llmq::CDKGSessionManager>(dmnman, qsnapman, chainman, sporkman, db_params, quorums_watch)}, | ||
| shareman{std::make_unique<llmq::CSigSharesManager>(connman, chainman.ActiveChainstate(), sigman, peerman, *nodeman, | ||
| qman, sporkman)}, | ||
| gov_signer{std::make_unique<GovernanceSigner>(connman, dmnman, govman, *nodeman, chainman, mn_sync)}, | ||
| ehf_sighandler{std::make_unique<llmq::CEHFSignalsHandler>(chainman, mnhfman, sigman, *shareman, qman)}, | ||
| qman_handler{std::make_unique<llmq::QuorumParticipant>(bls_worker, connman, dmnman, qman, qsnapman, *nodeman, chainman, | ||
| mn_sync, sporkman, sync_map, quorums_recovery, quorums_watch)}, | ||
| cl_signer{std::make_unique<chainlock::ChainLockSigner>(chainman.ActiveChainstate(), clhandler, sigman, *shareman, | ||
| sporkman, mn_sync)}, | ||
| is_signer{std::make_unique<instantsend::InstantSendSigner>(chainman.ActiveChainstate(), clhandler, isman, sigman, | ||
| *shareman, qman, sporkman, mempool, mn_sync)} | ||
| { | ||
| qdkgsman->InitializeHandlers([&](const Consensus::LLMQParams& llmq_params, | ||
| int quorum_idx) -> std::unique_ptr<llmq::ActiveDKGSessionHandler> { | ||
| return std::make_unique<llmq::ActiveDKGSessionHandler>(bls_worker, dmnman, mn_metaman, *dkgdbgman, *qdkgsman, | ||
| qblockman, qsnapman, *nodeman, chainman, sporkman, | ||
| llmq_params, quorums_watch, quorum_idx); | ||
| }); | ||
| m_clhandler.ConnectSigner(cl_signer.get()); | ||
| m_isman.ConnectSigner(is_signer.get()); | ||
| m_qman.ConnectManagers(qman_handler.get(), qdkgsman.get()); | ||
| } | ||
|
|
||
| ActiveContext::~ActiveContext() | ||
| { | ||
| m_qman.DisconnectManagers(); | ||
| m_isman.DisconnectSigner(); | ||
| m_clhandler.DisconnectSigner(); | ||
| } | ||
|
|
||
| void ActiveContext::Interrupt() | ||
| { | ||
| shareman->InterruptWorkerThread(); | ||
| } | ||
|
|
||
| void ActiveContext::Start(CConnman& connman, PeerManager& peerman) | ||
| { | ||
| qman_handler->Start(); | ||
| qdkgsman->StartThreads(connman, peerman); | ||
| shareman->Start(); | ||
| cl_signer->RegisterRecoveryInterface(); | ||
| is_signer->RegisterRecoveryInterface(); | ||
| shareman->RegisterRecoveryInterface(); | ||
| } | ||
|
|
||
| void ActiveContext::Stop() | ||
| { | ||
| shareman->UnregisterRecoveryInterface(); | ||
| is_signer->UnregisterRecoveryInterface(); | ||
| cl_signer->UnregisterRecoveryInterface(); | ||
| shareman->Stop(); | ||
| qdkgsman->StopThreads(); | ||
| qman_handler->Stop(); | ||
| } | ||
|
|
||
| CCoinJoinServer& ActiveContext::GetCJServer() const | ||
| { | ||
| return *Assert(m_cj_server); | ||
| } | ||
|
|
||
| void ActiveContext::SetCJServer(gsl::not_null<CCoinJoinServer*> cj_server) | ||
| { | ||
| // Prohibit double initialization | ||
| assert(m_cj_server == nullptr); | ||
| m_cj_server = cj_server; | ||
| } | ||
|
|
||
| void ActiveContext::UpdatedBlockTip(const CBlockIndex* pindexNew, const CBlockIndex* pindexFork, bool fInitialDownload) | ||
| { | ||
| if (fInitialDownload || pindexNew == pindexFork) // In IBD or blocks were disconnected without any new ones | ||
| return; | ||
|
|
||
| nodeman->UpdatedBlockTip(pindexNew, pindexFork, fInitialDownload); | ||
| ehf_sighandler->UpdatedBlockTip(pindexNew); | ||
| gov_signer->UpdatedBlockTip(pindexNew); | ||
| qdkgsman->UpdatedBlockTip(pindexNew, fInitialDownload); | ||
| qman_handler->UpdatedBlockTip(pindexNew, fInitialDownload); | ||
| } | ||
|
|
||
| void ActiveContext::NotifyRecoveredSig(const std::shared_ptr<const llmq::CRecoveredSig>& sig, bool proactive_relay) | ||
| { | ||
| shareman->NotifyRecoveredSig(sig, proactive_relay); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix clang-format issues to satisfy CI
CI reports a Clang Diff Format Check failure for this file. Please run the project’s clang-format script (e.g.
clang-format-diff.pyover this hunk) to normalize indentation and spacing before merging.🧰 Tools
🪛 Cppcheck (2.19.0)
[error] 10-10: failed to evaluate #if condition, undefined function-like macro invocation
(syntaxError)
[error] 24-24: #error No known always_inline attribute for this platform.
(preprocessorErrorDirective)
🪛 GitHub Actions: Clang Diff Format Check
[error] 1-1: Clang format differences found. Run the clang-format-diff.py script to fix formatting in this file.
🤖 Prompt for AI Agents