mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 13:03:17 +01:00
Disable new connection handling and concentrated recovery for large LLMQs (#3548)
* Rename CollectSigSharesToSend to CollectSigSharesToSendConcentrated * Allow to disable concentrated recovery and new connection handling for large LLMQs
This commit is contained in:
parent
c72bc354f8
commit
772b6bfe7c
@ -446,7 +446,7 @@ void CDKGSession::VerifyAndComplain(CDKGPendingMessages& pendingMessages)
|
||||
|
||||
void CDKGSession::VerifyConnectionAndMinProtoVersions()
|
||||
{
|
||||
if (!sporkManager.IsSporkActive(SPORK_21_QUORUM_ALL_CONNECTED)) {
|
||||
if (!CLLMQUtils::IsAllMembersConnectedEnabled(params.type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -530,7 +530,7 @@ void CDKGSessionHandler::HandleDKGRound()
|
||||
});
|
||||
|
||||
CLLMQUtils::EnsureQuorumConnections(params.type, pindexQuorum, curSession->myProTxHash, gArgs.GetBoolArg("-watchquorums", DEFAULT_WATCH_QUORUMS));
|
||||
if (curSession->AreWeMember() && sporkManager.IsSporkActive(SPORK_21_QUORUM_ALL_CONNECTED)) {
|
||||
if (curSession->AreWeMember() && CLLMQUtils::IsAllMembersConnectedEnabled(params.type)) {
|
||||
CLLMQUtils::AddQuorumProbeConnections(params.type, pindexQuorum, curSession->myProTxHash);
|
||||
}
|
||||
|
||||
|
@ -739,7 +739,7 @@ void CSigSharesManager::ProcessSigShare(NodeId nodeId, const CSigShare& sigShare
|
||||
|
||||
// prepare node set for direct-push in case this is our sig share
|
||||
std::set<NodeId> quorumNodes;
|
||||
if (!sporkManager.IsSporkActive(SPORK_21_QUORUM_ALL_CONNECTED)) {
|
||||
if (!CLLMQUtils::IsAllMembersConnectedEnabled(llmqType)) {
|
||||
if (sigShare.quorumMember == quorum->GetMemberIndex(activeMasternodeInfo.proTxHash)) {
|
||||
quorumNodes = connman.GetMasternodeQuorumNodes((Consensus::LLMQType) sigShare.llmqType, sigShare.quorumHash);
|
||||
}
|
||||
@ -755,7 +755,9 @@ void CSigSharesManager::ProcessSigShare(NodeId nodeId, const CSigShare& sigShare
|
||||
if (!sigShares.Add(sigShare.GetKey(), sigShare)) {
|
||||
return;
|
||||
}
|
||||
sigSharesToAnnounce.Add(sigShare.GetKey(), true);
|
||||
if (!CLLMQUtils::IsAllMembersConnectedEnabled(llmqType)) {
|
||||
sigSharesToAnnounce.Add(sigShare.GetKey(), true);
|
||||
}
|
||||
|
||||
// Update the time we've seen the last sigShare
|
||||
timeSeenForSessions[sigShare.GetSignHash()] = GetAdjustedTime();
|
||||
@ -909,6 +911,10 @@ void CSigSharesManager::CollectSigSharesToRequest(std::unordered_map<NodeId, std
|
||||
auto& signHash = p2.first;
|
||||
auto& session = p2.second;
|
||||
|
||||
if (CLLMQUtils::IsAllMembersConnectedEnabled(session.llmqType)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (quorumSigningManager->HasRecoveredSigForSession(signHash)) {
|
||||
continue;
|
||||
}
|
||||
@ -982,6 +988,10 @@ void CSigSharesManager::CollectSigSharesToSend(std::unordered_map<NodeId, std::u
|
||||
auto& signHash = p2.first;
|
||||
auto& session = p2.second;
|
||||
|
||||
if (CLLMQUtils::IsAllMembersConnectedEnabled(session.llmqType)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (quorumSigningManager->HasRecoveredSigForSession(signHash)) {
|
||||
continue;
|
||||
}
|
||||
@ -1016,7 +1026,7 @@ void CSigSharesManager::CollectSigSharesToSend(std::unordered_map<NodeId, std::u
|
||||
}
|
||||
}
|
||||
|
||||
void CSigSharesManager::CollectSigSharesToSend(std::unordered_map<NodeId, std::vector<CSigShare>>& sigSharesToSend, const std::vector<CNode*>& vNodes)
|
||||
void CSigSharesManager::CollectSigSharesToSendConcentrated(std::unordered_map<NodeId, std::vector<CSigShare>>& sigSharesToSend, const std::vector<CNode*>& vNodes)
|
||||
{
|
||||
AssertLockHeld(cs);
|
||||
|
||||
@ -1031,6 +1041,10 @@ void CSigSharesManager::CollectSigSharesToSend(std::unordered_map<NodeId, std::v
|
||||
auto curTime = GetTime<std::chrono::milliseconds>().count();
|
||||
|
||||
for (auto& p : signedSessions) {
|
||||
if (!CLLMQUtils::IsAllMembersConnectedEnabled(p.second.quorum->params.type)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (p.second.attempt > p.second.quorum->params.recoveryMembers) {
|
||||
continue;
|
||||
}
|
||||
@ -1139,13 +1153,10 @@ bool CSigSharesManager::SendMessages()
|
||||
|
||||
{
|
||||
LOCK(cs);
|
||||
if (!sporkManager.IsSporkActive(SPORK_21_QUORUM_ALL_CONNECTED)) {
|
||||
CollectSigSharesToRequest(sigSharesToRequest);
|
||||
CollectSigSharesToSend(sigShareBatchesToSend);
|
||||
CollectSigSharesToAnnounce(sigSharesToAnnounce);
|
||||
} else {
|
||||
CollectSigSharesToSend(sigSharesToSend, vNodesCopy);
|
||||
}
|
||||
CollectSigSharesToRequest(sigSharesToRequest);
|
||||
CollectSigSharesToSend(sigShareBatchesToSend);
|
||||
CollectSigSharesToAnnounce(sigSharesToAnnounce);
|
||||
CollectSigSharesToSendConcentrated(sigSharesToSend, vNodesCopy);
|
||||
|
||||
for (auto& p : sigSharesToRequest) {
|
||||
for (auto& p2 : p.second) {
|
||||
@ -1585,7 +1596,7 @@ void CSigSharesManager::Sign(const CQuorumCPtr& quorum, const uint256& id, const
|
||||
signHash.ToString(), sigShare.id.ToString(), sigShare.msgHash.ToString(), quorum->params.type, quorum->qc.quorumHash.ToString(), t.count());
|
||||
ProcessSigShare(-1, sigShare, *g_connman, quorum);
|
||||
|
||||
if (sporkManager.IsSporkActive(SPORK_21_QUORUM_ALL_CONNECTED)) {
|
||||
if (CLLMQUtils::IsAllMembersConnectedEnabled(quorum->params.type)) {
|
||||
LOCK(cs);
|
||||
auto& session = signedSessions[sigShare.GetSignHash()];
|
||||
session.sigShare = sigShare;
|
||||
@ -1598,6 +1609,10 @@ void CSigSharesManager::Sign(const CQuorumCPtr& quorum, const uint256& id, const
|
||||
// causes all known sigShares to be re-announced
|
||||
void CSigSharesManager::ForceReAnnouncement(const CQuorumCPtr& quorum, Consensus::LLMQType llmqType, const uint256& id, const uint256& msgHash)
|
||||
{
|
||||
if (!CLLMQUtils::IsAllMembersConnectedEnabled(llmqType)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LOCK(cs);
|
||||
auto signHash = CLLMQUtils::BuildSignHash(llmqType, quorum->qc.quorumHash, id, msgHash);
|
||||
auto sigs = sigShares.GetAllForSignHash(signHash);
|
||||
|
@ -450,7 +450,7 @@ private:
|
||||
bool SendMessages();
|
||||
void CollectSigSharesToRequest(std::unordered_map<NodeId, std::unordered_map<uint256, CSigSharesInv, StaticSaltedHasher>>& sigSharesToRequest);
|
||||
void CollectSigSharesToSend(std::unordered_map<NodeId, std::unordered_map<uint256, CBatchedSigShares, StaticSaltedHasher>>& sigSharesToSend);
|
||||
void CollectSigSharesToSend(std::unordered_map<NodeId, std::vector<CSigShare>>& sigSharesToSend, const std::vector<CNode*>& vNodes);
|
||||
void CollectSigSharesToSendConcentrated(std::unordered_map<NodeId, std::vector<CSigShare>>& sigSharesToSend, const std::vector<CNode*>& vNodes);
|
||||
void CollectSigSharesToAnnounce(std::unordered_map<NodeId, std::unordered_map<uint256, CSigSharesInv, StaticSaltedHasher>>& sigSharesToAnnounce);
|
||||
bool SignPendingSigShares();
|
||||
void WorkThreadMain();
|
||||
|
@ -44,6 +44,18 @@ uint256 CLLMQUtils::BuildSignHash(Consensus::LLMQType llmqType, const uint256& q
|
||||
return h.GetHash();
|
||||
}
|
||||
|
||||
bool CLLMQUtils::IsAllMembersConnectedEnabled(Consensus::LLMQType llmqType)
|
||||
{
|
||||
auto spork21 = sporkManager.GetSporkValue(SPORK_21_QUORUM_ALL_CONNECTED);
|
||||
if (spork21 == 0) {
|
||||
return true;
|
||||
}
|
||||
if (spork21 == 1 && llmqType != Consensus::LLMQ_400_60 && llmqType != Consensus::LLMQ_400_85) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
uint256 CLLMQUtils::DeterministicOutboundConnection(const uint256& proTxHash1, const uint256& proTxHash2)
|
||||
{
|
||||
// We need to deterministically select who is going to initiate the connection. The naive way would be to simply
|
||||
@ -70,7 +82,7 @@ std::set<uint256> CLLMQUtils::GetQuorumConnections(Consensus::LLMQType llmqType,
|
||||
{
|
||||
auto& params = Params().GetConsensus().llmqs.at(llmqType);
|
||||
|
||||
if (sporkManager.IsSporkActive(SPORK_21_QUORUM_ALL_CONNECTED)) {
|
||||
if (IsAllMembersConnectedEnabled(llmqType)) {
|
||||
auto mns = GetAllQuorumMembers(llmqType, pindexQuorum);
|
||||
std::set<uint256> result;
|
||||
|
||||
|
@ -31,6 +31,7 @@ public:
|
||||
return BuildSignHash((Consensus::LLMQType)s.llmqType, s.quorumHash, s.id, s.msgHash);
|
||||
}
|
||||
|
||||
static bool IsAllMembersConnectedEnabled(Consensus::LLMQType llmqType);
|
||||
static uint256 DeterministicOutboundConnection(const uint256& proTxHash1, const uint256& proTxHash2);
|
||||
static std::set<uint256> GetQuorumConnections(Consensus::LLMQType llmqType, const CBlockIndex* pindexQuorum, const uint256& forMember, bool onlyOutbound);
|
||||
static std::set<uint256> GetQuorumRelayMembers(Consensus::LLMQType llmqType, const CBlockIndex* pindexQuorum, const uint256& forMember, bool onlyOutbound);
|
||||
|
Loading…
Reference in New Issue
Block a user