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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 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 1bdf836
move-only: move DKG session handler participant logic to `llmq/active`
kwvg b59baac
refactor: separate active session handler routines into dedicated class
kwvg bb90306
move-only: move DKG session participant logic to `llmq/active`
kwvg 01c0b94
refactor: separate active session routines into dedicated class
kwvg 004b3b7
refactor: drop `CActiveMasternodeManager` from chainstate init
kwvg e9f8294
refactor: move `CActiveMasternodeManager` to `ActiveContext`
kwvg f0468e6
refactor: merge `CActiveMasternodeInfo` into `CActiveMasternodeManager`
kwvg 19b2ee5
refactor: merge `ActiveNotificationInterface` into `ActiveContext`
kwvg d115e0e
refactor: consolidate masternode mode logic to `src/active/`
kwvg 70e6372
refactor: `InitNewQuorum()` is the only place where real `curSession`…
kwvg a93f8ae
refactor: keep base DKG handler lightweight, follow IWYU
kwvg de4d0ea
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.
Uh oh!
There was an error while loading. Please reload this page.