-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix: A set of qdata
/qwatch
related fixes
#5745
Changes from all commits
3bcac49
96af245
ca52477
825fac1
92da3bf
78e20eb
33b5ca1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -189,10 +189,21 @@ void CDKGSessionManager::ProcessMessage(CNode& pfrom, const CQuorumManager& quor | |
} | ||
|
||
if (msg_type == NetMsgType::QWATCH) { | ||
if (!fMasternodeMode) { | ||
// non-masternodes should never receive this | ||
m_peerman->Misbehaving(pfrom.GetId(), 10); | ||
return; | ||
} | ||
pfrom.qwatch = true; | ||
return; | ||
} | ||
|
||
if ((!fMasternodeMode && !utils::IsWatchQuorumsEnabled())) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. potentially conflict with #5790 - one of PR to edit; depends which one get merge first. |
||
// regular non-watching nodes should never receive any of these | ||
m_peerman->Misbehaving(pfrom.GetId(), 10); | ||
return; | ||
} | ||
|
||
if (vRecv.empty()) { | ||
m_peerman->Misbehaving(pfrom.GetId(), 100); | ||
return; | ||
|
@@ -429,13 +440,15 @@ bool CDKGSessionManager::GetEncryptedContributions(Consensus::LLMQType llmqType, | |
} | ||
} | ||
if (nRequestedMemberIdx == std::numeric_limits<size_t>::max()) { | ||
LogPrint(BCLog::LLMQ, "CDKGSessionManager::%s -- not a member, nProTxHash=%s\n", __func__, nProTxHash.ToString()); | ||
return false; | ||
} | ||
|
||
for (const auto i : irange::range(members.size())) { | ||
if (validMembers[i]) { | ||
CBLSIESMultiRecipientObjects<CBLSSecretKey> encryptedContributions; | ||
if (!db->Read(std::make_tuple(DB_ENC_CONTRIB, llmqType, pQuorumBaseBlockIndex->GetBlockHash(), members[i]->proTxHash), encryptedContributions)) { | ||
LogPrint(BCLog::LLMQ, "CDKGSessionManager::%s -- can't read from db, nProTxHash=%s\n", __func__, nProTxHash.ToString()); | ||
return false; | ||
} | ||
vecRet.emplace_back(encryptedContributions.Get(nRequestedMemberIdx)); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -223,7 +223,7 @@ void CQuorumManager::Stop() | |
|
||
void CQuorumManager::TriggerQuorumDataRecoveryThreads(const CBlockIndex* pIndex) const | ||
{ | ||
if (!fMasternodeMode || !utils::QuorumDataRecoveryEnabled() || pIndex == nullptr) { | ||
if ((!fMasternodeMode && !utils::IsWatchQuorumsEnabled()) || !utils::QuorumDataRecoveryEnabled() || pIndex == nullptr) { | ||
return; | ||
} | ||
|
||
|
@@ -274,15 +274,13 @@ void CQuorumManager::TriggerQuorumDataRecoveryThreads(const CBlockIndex* pIndex) | |
|
||
void CQuorumManager::UpdatedBlockTip(const CBlockIndex* pindexNew, bool fInitialDownload) const | ||
{ | ||
if (!m_mn_sync->IsBlockchainSynced()) { | ||
return; | ||
} | ||
if (!m_mn_sync->IsBlockchainSynced()) return; | ||
|
||
for (const auto& params : Params().GetConsensus().llmqs) { | ||
CheckQuorumConnections(params, pindexNew); | ||
} | ||
|
||
{ | ||
if (fMasternodeMode || utils::IsWatchQuorumsEnabled()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see many check "fMasternodeMode || utils::IsWatchQuorumsEnabled()" - maybe move a boolean flag bool IsWatchQuorumsEnabled()
{
static bool fIsWatchQuroumsEnabled = gArgs.GetBoolArg("-watchquorums", DEFAULT_WATCH_QUORUMS);
return fIsWatchQuroumsEnabled ||fMasternodeMode ;
} |
||
// Cleanup expired data requests | ||
LOCK(cs_data_requests); | ||
auto it = mapQuorumDataRequests.begin(); | ||
|
@@ -301,6 +299,8 @@ void CQuorumManager::UpdatedBlockTip(const CBlockIndex* pindexNew, bool fInitial | |
|
||
void CQuorumManager::CheckQuorumConnections(const Consensus::LLMQParams& llmqParams, const CBlockIndex* pindexNew) const | ||
{ | ||
if (!fMasternodeMode && !utils::IsWatchQuorumsEnabled()) return; | ||
|
||
auto lastQuorums = ScanQuorums(llmqParams.type, pindexNew, (size_t)llmqParams.keepOldConnections); | ||
|
||
auto connmanQuorumsToDelete = connman.GetMasternodeQuorums(llmqParams.type); | ||
|
@@ -452,8 +452,8 @@ bool CQuorumManager::RequestQuorumData(CNode* pfrom, Consensus::LLMQType llmqTyp | |
LogPrint(BCLog::LLMQ, "CQuorumManager::%s -- Version must be %d or greater.\n", __func__, LLMQ_DATA_MESSAGES_VERSION); | ||
return false; | ||
} | ||
if (pfrom->GetVerifiedProRegTxHash().IsNull() && !pfrom->qwatch) { | ||
LogPrint(BCLog::LLMQ, "CQuorumManager::%s -- pfrom is neither a verified masternode nor a qwatch connection\n", __func__); | ||
if (pfrom->GetVerifiedProRegTxHash().IsNull()) { | ||
LogPrint(BCLog::LLMQ, "CQuorumManager::%s -- pfrom is not a verified masternode\n", __func__); | ||
return false; | ||
} | ||
if (!GetLLMQParams(llmqType).has_value()) { | ||
|
@@ -472,8 +472,8 @@ bool CQuorumManager::RequestQuorumData(CNode* pfrom, Consensus::LLMQType llmqTyp | |
LOCK(cs_data_requests); | ||
const CQuorumDataRequestKey key(pfrom->GetVerifiedProRegTxHash(), true, pQuorumBaseBlockIndex->GetBlockHash(), llmqType); | ||
const CQuorumDataRequest request(llmqType, pQuorumBaseBlockIndex->GetBlockHash(), nDataMask, proTxHash); | ||
auto [old_pair, exists] = mapQuorumDataRequests.emplace(key, request); | ||
if (!exists) { | ||
auto [old_pair, inserted] = mapQuorumDataRequests.emplace(key, request); | ||
if (!inserted) { | ||
if (old_pair->second.IsExpired(/*add_bias=*/true)) { | ||
old_pair->second = request; | ||
} else { | ||
|
@@ -719,8 +719,8 @@ void CQuorumManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, C | |
} | ||
|
||
if (msg_type == NetMsgType::QDATA) { | ||
if ((!fMasternodeMode && !utils::IsWatchQuorumsEnabled()) || (pfrom.GetVerifiedProRegTxHash().IsNull() && !pfrom.qwatch)) { | ||
errorHandler("Not a verified masternode or a qwatch connection"); | ||
if ((!fMasternodeMode && !utils::IsWatchQuorumsEnabled()) || pfrom.GetVerifiedProRegTxHash().IsNull()) { | ||
errorHandler("Not a verified masternode and -watchquorums is not enabled"); | ||
return; | ||
} | ||
|
||
|
@@ -1011,7 +1011,7 @@ void CQuorumManager::StartCleanupOldQuorumDataThread(const CBlockIndex* pIndex) | |
// window and it's better to have more room so we pick next cycle. | ||
// dkgMiningWindowStart for small quorums is 10 i.e. a safe block to start | ||
// these calculations is at height 576 + 24 * 2 + 10 = 576 + 58. | ||
if (!fMasternodeMode || pIndex == nullptr || (pIndex->nHeight % 576 != 58)) { | ||
if ((!fMasternodeMode && !utils::IsWatchQuorumsEnabled()) || pIndex == nullptr || (pIndex->nHeight % 576 != 58)) { | ||
return; | ||
} | ||
|
||
|
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.
just a notice: refactored in #5782 - one of these 2 PR should be changed after other is merged