Skip to content

Commit 21fe75f

Browse files
UdjinM6claude
authored andcommitted
fix: guard GetProTxHash() behind is_masternode check, add CQuorum safety assert
In TriggerQuorumDataRecoveryThreads, avoid calling GetProTxHash() in observer mode where it returns a null hash. Also adds missing const qualifier and fixes operator spacing. Assert m_quorum_base_block_index in CQuorum constructor, consistent with the existing qc != nullptr assertion. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 27129d9 commit 21fe75f

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/llmq/net_quorum.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -445,15 +445,14 @@ void NetQuorum::TriggerQuorumDataRecoveryThreads(gsl::not_null<const CBlockIndex
445445
{
446446
if (!m_quorums_recovery) return;
447447

448-
bool is_masternode = m_role->IsMasternode();
449-
450-
LogPrint(BCLog::LLMQ, "NetQuorum::%s -- Process block %s\n", __func__, block_index->GetBlockHash().ToString());
448+
const bool is_masternode = m_role->IsMasternode();
449+
const uint256 proTxHash = is_masternode ? m_role->GetProTxHash() : uint256{};
451450

452-
const uint256 proTxHash = m_role->GetProTxHash();
451+
LogPrint(BCLog::LLMQ, "NetQuorum::%s -- Process block %s as protx_hash=%s\n", __func__, block_index->GetBlockHash().ToString(), proTxHash.ToString());
453452

454453
for (const auto& params : Params().GetConsensus().llmqs) {
455454
auto vecQuorums = m_qman.ScanQuorums(params.type, block_index, params.keepOldConnections);
456-
const bool fWeAreQuorumTypeMember = is_masternode &&std::ranges::any_of(vecQuorums, [&proTxHash](const auto& pQuorum) {
455+
const bool fWeAreQuorumTypeMember = is_masternode && std::ranges::any_of(vecQuorums, [&proTxHash](const auto& pQuorum) {
457456
return pQuorum->IsValidMember(proTxHash);
458457
});
459458

src/llmq/quorums.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ CQuorum::CQuorum(const Consensus::LLMQParams& _params, CBLSWorker& _blsWorker,
111111
blsCache{_blsWorker}
112112
{
113113
assert(qc != nullptr);
114+
assert(m_quorum_base_block_index != nullptr);
114115
}
115116

116117
bool CQuorum::SetVerificationVector(const std::vector<CBLSPublicKey>& quorumVecIn)

0 commit comments

Comments
 (0)