Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
7978822
refactor: quorum members: remove QuorumObserverParent; participant is…
knst Mar 14, 2026
9bb50db
refactor: merge QuorumObserver and ObserverContext classes to the one…
knst Mar 14, 2026
93f168a
refactor: remove QuorumRoleBase by moving its functionality directly …
knst Mar 14, 2026
5ded711
refactor: rename src/llmq/observer/context to src/llmq/observer
knst Mar 14, 2026
f4cbf92
refactor: inline QuorumParticipant to ActiveContext
knst Mar 14, 2026
0f1174a
refactor: remove multiple friends of CDKGSession
knst Mar 14, 2026
6c99cb0
fix: parameter 'params' shadows member inherited from type 'CDKGSessi…
knst Mar 24, 2026
6a2f291
refactor: remove duplicated code between QuorumRole's UpdatedBlockTip…
knst Mar 24, 2026
c86e4f6
refactor: it's always either observer_ctx or active_ctx, not both cre…
knst Mar 24, 2026
1be8863
refactor: move out network code to new NetQuorum from CQuorumManager
knst Mar 25, 2026
b47de25
refactor: remove net related code ProcessContribQGETDATA and ProcessC…
knst Mar 26, 2026
e2df648
refactor: drop argument request_limit_exceeded in ProcessContribQGETDATA
knst Mar 26, 2026
8bc5744
fix: review comments - missing forward declaration, protection for no…
knst Apr 1, 2026
55d8025
refactor: safety belt to be sure that CQuorum is initialized properly…
knst Apr 1, 2026
27129d9
fix: defer full InitializeCurrentBlockTip broadcast on masternodes
UdjinM6 Apr 4, 2026
21fe75f
fix: guard GetProTxHash() behind is_masternode check, add CQuorum saf…
UdjinM6 Apr 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ BITCOIN_CORE_H = \
active/dkgsession.h \
active/dkgsessionhandler.h \
active/masternode.h \
active/quorums.h \
addrdb.h \
addressindex.h \
spentindex.h \
Expand Down Expand Up @@ -282,19 +281,19 @@ BITCOIN_CORE_H = \
llmq/dkgsessionhandler.h \
llmq/dkgsessionmgr.h \
llmq/ehf_signals.h \
llmq/observer.h \
llmq/options.h \
llmq/params.h \
llmq/quorums.h \
llmq/quorumsman.h \
llmq/signhash.h \
llmq/signing.h \
llmq/net_quorum.h \
llmq/net_signing.h \
llmq/signing_shares.h \
llmq/snapshot.h \
llmq/types.h \
llmq/utils.h \
llmq/observer/context.h \
llmq/observer/quorums.h \
logging.h \
logging/timer.h \
mapport.h \
Expand Down Expand Up @@ -485,7 +484,6 @@ libbitcoin_node_a_SOURCES = \
active/dkgsession.cpp \
active/dkgsessionhandler.cpp \
active/masternode.cpp \
active/quorums.cpp \
addrdb.cpp \
addressindex.cpp \
addrman.cpp \
Expand Down Expand Up @@ -554,7 +552,9 @@ libbitcoin_node_a_SOURCES = \
llmq/dkgsessionhandler.cpp \
llmq/dkgsessionmgr.cpp \
llmq/ehf_signals.cpp \
llmq/net_quorum.cpp \
llmq/net_signing.cpp \
llmq/observer.cpp \
llmq/options.cpp \
llmq/quorums.cpp \
llmq/quorumsman.cpp \
Expand All @@ -563,8 +563,6 @@ libbitcoin_node_a_SOURCES = \
llmq/signing_shares.cpp \
llmq/snapshot.cpp \
llmq/utils.cpp \
llmq/observer/context.cpp \
llmq/observer/quorums.cpp \
mapport.cpp \
masternode/meta.cpp \
masternode/payments.cpp \
Expand Down
52 changes: 32 additions & 20 deletions src/active/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@

#include <active/dkgsessionhandler.h>
#include <active/masternode.h>
#include <active/quorums.h>
#include <bls/bls_worker.h>
#include <chainlock/handler.h>
#include <chainlock/signing.h>
#include <evo/deterministicmns.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/quorums.h>
#include <llmq/quorumsman.h>
#include <llmq/signing_shares.h>
#include <masternode/sync.h>
#include <util/check.h>
#include <validation.h>
#include <validationinterface.h>
Expand All @@ -30,17 +32,16 @@ ActiveContext::ActiveContext(CBLSWorker& bls_worker, ChainstateManager& chainman
llmq::CQuorumBlockProcessor& qblockman, llmq::CQuorumManager& qman,
llmq::CQuorumSnapshotManager& qsnapman, llmq::CSigningManager& sigman,
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_qman{qman},
const util::DbWrapperParams& db_params, bool quorums_watch) :
llmq::QuorumRole{qman},
m_bls_worker{bls_worker},
m_quorums_watch{quorums_watch},
nodeman{std::make_unique<CActiveMasternodeManager>(connman, dmnman, operator_sk)},
dkgdbgman{std::make_unique<llmq::CDKGDebugManager>(dmnman, qsnapman, chainman)},
qdkgsman{std::make_unique<llmq::CDKGSessionManager>(dmnman, qsnapman, chainman, sporkman, db_params, quorums_watch)},
shareman{std::make_unique<llmq::CSigSharesManager>(connman, chainman, sigman, *nodeman, qman, sporkman)},
gov_signer{std::make_unique<GovernanceSigner>(connman, dmnman, govman, *nodeman, chainman, mn_sync)},
ehf_sighandler{std::make_unique<llmq::CEHFSignalsHandler>(chainman, 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(), chainlocks, clhandler, isman,
qman, sigman, *shareman, mn_sync)},
is_signer{std::make_unique<instantsend::InstantSendSigner>(chainman.ActiveChainstate(), chainlocks, isman, sigman,
Expand All @@ -52,17 +53,16 @@ ActiveContext::ActiveContext(CBLSWorker& bls_worker, ChainstateManager& chainman
qblockman, qsnapman, *nodeman, chainman, sporkman,
llmq_params, quorums_watch, quorum_idx);
});
m_qman.ConnectManagers(qman_handler.get(), qdkgsman.get());
m_qman.ConnectManagers(this, qdkgsman.get());
}

ActiveContext::~ActiveContext()
{
m_qman.DisconnectManagers();
}

void ActiveContext::Start(CConnman& connman, PeerManager& peerman, int16_t worker_count)
void ActiveContext::Start(CConnman& connman, PeerManager& peerman)
{
qman_handler->Start(worker_count);
qdkgsman->StartThreads(connman, peerman);
cl_signer->Start();
cl_signer->RegisterRecoveryInterface();
Expand All @@ -81,7 +81,6 @@ void ActiveContext::Stop()
cl_signer->UnregisterRecoveryInterface();
cl_signer->Stop();
qdkgsman->StopThreads();
qman_handler->Stop();
}

CCoinJoinServer& ActiveContext::GetCJServer() const
Expand All @@ -96,14 +95,6 @@ void ActiveContext::SetCJServer(gsl::not_null<CCoinJoinServer*> cj_server)
m_cj_server = cj_server;
}

void ActiveContext::InitializeCurrentBlockTip(const CBlockIndex* tip, bool ibd)
{
UpdatedBlockTip(tip, nullptr, ibd);
if (tip) {
qman_handler->InitializeQuorumConnections(tip);
}
}

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
Expand All @@ -113,5 +104,26 @@ void ActiveContext::UpdatedBlockTip(const CBlockIndex* pindexNew, const CBlockIn
ehf_sighandler->UpdatedBlockTip(pindexNew);
gov_signer->UpdatedBlockTip(pindexNew);
qdkgsman->UpdatedBlockTip(pindexNew, fInitialDownload);
qman_handler->UpdatedBlockTip(pindexNew, fInitialDownload);
}

bool ActiveContext::IsMasternode() const
{
// We are only initialized if masternode mode is enabled
return true;
}

bool ActiveContext::IsWatching() const
{
// Watch-only mode can co-exist with masternode mode
return m_quorums_watch;
}

uint256 ActiveContext::GetProTxHash() const
{
return nodeman->GetProTxHash();
}

bool ActiveContext::SetQuorumSecretKeyShare(llmq::CQuorum& quorum, Span<CBLSSecretKey> skContributions) const
{
return quorum.SetSecretKeyShare(m_bls_worker.AggregateSecretKeys(skContributions), nodeman->GetProTxHash());
}
29 changes: 13 additions & 16 deletions src/active/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,19 @@
#ifndef BITCOIN_ACTIVE_CONTEXT_H
#define BITCOIN_ACTIVE_CONTEXT_H

#include <llmq/options.h>
#include <llmq/quorumsman.h>

#include <validationinterface.h>

#include <gsl/pointers.h>
#include <span.h>

#include <memory>

class CActiveMasternodeManager;
class CBLSSecretKey;
class CBLSWorker;
class ChainstateManager;
class CCoinJoinServer;
class CConnman;
class CDeterministicMNManager;
class CGovernanceManager;
class CMasternodeMetaMan;
class CMasternodeSync;
Expand All @@ -38,23 +36,19 @@ class InstantSendSigner;
} // namespace instantsend
namespace llmq {
class CDKGDebugManager;
class CDKGSessionManager;
class CEHFSignalsHandler;
class CInstantSendManager;
class CQuorumBlockProcessor;
class CQuorumManager;
class CQuorumSnapshotManager;
class CSigningManager;
class CSigSharesManager;
class QuorumParticipant;
} // namespace llmq
namespace util {
struct DbWrapperParams;
} // namespace util

struct ActiveContext final : public CValidationInterface {
struct ActiveContext final : public llmq::QuorumRole, public CValidationInterface {
private:
llmq::CQuorumManager& m_qman;
CBLSWorker& m_bls_worker;
const bool m_quorums_watch{false};

public:
ActiveContext() = delete;
Expand All @@ -67,17 +61,21 @@ struct ActiveContext final : public CValidationInterface {
llmq::CQuorumBlockProcessor& qblockman, llmq::CQuorumManager& qman,
llmq::CQuorumSnapshotManager& qsnapman, llmq::CSigningManager& sigman,
const CMasternodeSync& mn_sync, const CBLSSecretKey& operator_sk,
const llmq::QvvecSyncModeMap& sync_map, const util::DbWrapperParams& db_params,
bool quorums_recovery, bool quorums_watch);
const util::DbWrapperParams& db_params, bool quorums_watch);
~ActiveContext();

void Start(CConnman& connman, PeerManager& peerman, int16_t worker_count);
void Start(CConnman& connman, PeerManager& peerman);
void Stop();
void InitializeCurrentBlockTip(const CBlockIndex* tip, bool ibd);

CCoinJoinServer& GetCJServer() const;
void SetCJServer(gsl::not_null<CCoinJoinServer*> cj_server);

// QuorumRole
bool IsMasternode() const override;
bool IsWatching() const override;
uint256 GetProTxHash() const override;
bool SetQuorumSecretKeyShare(llmq::CQuorum& quorum, Span<CBLSSecretKey> skContributions) const override;

protected:
// CValidationInterface
void UpdatedBlockTip(const CBlockIndex* pindexNew, const CBlockIndex* pindexFork, bool fInitialDownload) override;
Expand All @@ -95,7 +93,6 @@ struct ActiveContext final : public CValidationInterface {
private:
const std::unique_ptr<GovernanceSigner> gov_signer;
const std::unique_ptr<llmq::CEHFSignalsHandler> ehf_sighandler;
const std::unique_ptr<llmq::QuorumParticipant> qman_handler;
const std::unique_ptr<chainlock::ChainLockSigner> cl_signer;

public:
Expand Down
4 changes: 2 additions & 2 deletions src/active/dkgsession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ ActiveDKGSession::ActiveDKGSession(CBLSWorker& bls_worker, CDeterministicMNManag
CDKGSessionManager& qdkgsman, CMasternodeMetaMan& mn_metaman,
CQuorumSnapshotManager& qsnapman, const CActiveMasternodeManager& mn_activeman,
const ChainstateManager& chainman, const CSporkManager& sporkman,
const CBlockIndex* base_block_index, const Consensus::LLMQParams& params) :
CDKGSession(bls_worker, dmnman, dkgdbgman, qdkgsman, qsnapman, chainman, base_block_index, params),
const CBlockIndex* base_block_index, const Consensus::LLMQParams& llmq_params) :
CDKGSession(bls_worker, dmnman, dkgdbgman, qdkgsman, qsnapman, chainman, base_block_index, llmq_params),
m_mn_metaman{mn_metaman},
m_mn_activeman{mn_activeman},
m_sporkman{sporkman},
Expand Down
52 changes: 8 additions & 44 deletions src/active/dkgsessionhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ bool ActiveDKGSessionHandler::InitNewQuorum(gsl::not_null<const CBlockIndex*> pQ

if (!curSession->Init(m_mn_activeman.GetProTxHash(), quorumIndex)) {
LogPrintf("ActiveDKGSessionHandler::%s -- height[%d] quorum initialization failed for %s qi[%d]\n", __func__,
pQuorumBaseBlockIndex->nHeight, curSession->params.name, quorumIndex);
pQuorumBaseBlockIndex->nHeight, params.name, quorumIndex);
return false;
}

LogPrintf("ActiveDKGSessionHandler::%s -- height[%d] quorum initialization OK for %s qi[%d]\n", __func__, pQuorumBaseBlockIndex->nHeight, curSession->params.name, quorumIndex);
LogPrintf("ActiveDKGSessionHandler::%s -- height[%d] quorum initialization OK for %s qi[%d]\n", __func__, pQuorumBaseBlockIndex->nHeight, params.name, quorumIndex);
return true;
}

Expand Down Expand Up @@ -461,11 +461,11 @@ void ActiveDKGSessionHandler::HandleDKGRound(CConnman& connman, PeerManager& pee

const auto tip_mn_list = m_dmnman.GetListAtChainTip();
utils::EnsureQuorumConnections(params, connman, m_sporkman, {m_dmnman, m_qsnapman, m_chainman, pQuorumBaseBlockIndex},
tip_mn_list, curSession->myProTxHash, /*is_masternode=*/true, m_quorums_watch);
tip_mn_list, curSession->ProTx(), /*is_masternode=*/true, m_quorums_watch);
if (curSession->AreWeMember()) {
utils::AddQuorumProbeConnections(params, connman, m_mn_metaman, m_sporkman,
{m_dmnman, m_qsnapman, m_chainman, pQuorumBaseBlockIndex}, tip_mn_list,
curSession->myProTxHash);
curSession->ProTx());
}

WaitForNextPhase(QuorumPhase::Initialized, QuorumPhase::Contribute, curQuorumHash);
Expand Down Expand Up @@ -527,58 +527,22 @@ void ActiveDKGSessionHandler::PhaseHandlerThread(CConnman& connman, PeerManager&

bool ActiveDKGSessionHandler::GetContribution(const uint256& hash, CDKGContribution& ret) const
{
if (!curSession) {
return false;
}
LOCK(curSession->invCs);
auto it = curSession->contributions.find(hash);
if (it != curSession->contributions.end()) {
ret = it->second;
return true;
}
return false;
return curSession && curSession->GetContribution(hash, ret);
}

bool ActiveDKGSessionHandler::GetComplaint(const uint256& hash, CDKGComplaint& ret) const
{
if (!curSession) {
return false;
}
LOCK(curSession->invCs);
auto it = curSession->complaints.find(hash);
if (it != curSession->complaints.end()) {
ret = it->second;
return true;
}
return false;
return curSession && curSession->GetComplaint(hash, ret);
}

bool ActiveDKGSessionHandler::GetJustification(const uint256& hash, CDKGJustification& ret) const
{
if (!curSession) {
return false;
}
LOCK(curSession->invCs);
auto it = curSession->justifications.find(hash);
if (it != curSession->justifications.end()) {
ret = it->second;
return true;
}
return false;
return curSession && curSession->GetJustification(hash, ret);
}

bool ActiveDKGSessionHandler::GetPrematureCommitment(const uint256& hash, CDKGPrematureCommitment& ret) const
{
if (!curSession) {
return false;
}
LOCK(curSession->invCs);
auto it = curSession->prematureCommitments.find(hash);
if (it != curSession->prematureCommitments.end() && curSession->validCommitments.count(hash)) {
ret = it->second;
return true;
}
return false;
return curSession && curSession->GetPrematureCommitment(hash, ret);
}

QuorumPhase ActiveDKGSessionHandler::GetPhase() const
Expand Down
Loading
Loading