Skip to content

Commit c6818fd

Browse files
committed
Merge #2949: Dash LLMQ backports part 4
c7e2beb scripted-diff: Refactor llmq type consensus param names (dashpay#3093) (UdjinM6) af7bb99 Re-verify invalid IS sigs when the active quorum set rotated (dashpay#3052) (Alexander Block) be20a71 Remove recovered sigs from the LLMQ db when corresponding IS locks get confirmed (dashpay#3048) (Alexander Block) 802a933 Don't wake up select if it was already woken up (dashpay#2863) (Alexander Block) 436300d Disable optimistic send in PushMessage by default (dashpay#2859) (Alexander Block) 44ad484 Optimize LLMQs sending of sig shares (dashpay#2704) (Alexander Block) e01ad46 Fix db leaks in LLMQ db (dashpay#2914) (Alexander Block) d2a2d15 Print inputs on which we voted and quorums used for signing (dashpay#2907) (Alexander Block) dce46ad Bail out in few more places when blockchain is not synced yet (dashpay#2888) (UdjinM6) 965a4a7 Use lazy BLS signatures more often and don't always verify self-recovered sigs (dashpay#2860) (Alexander Block) f4a5a04 cherry pick dashpay#2889 (UdjinM6) Pull request description: each commit backports a different PR ACKs for top commit: c7e2beb Duddino: utACK c7e2beb Liquid369: utACK c7e2beb Tree-SHA512: 86425039d01990ff04eea95f5ea4bee4821eaa80c33bab147d5b9407589c799c8293c2da5d5faf10e7e66b65d568444318c87fc274f39b42d2b69b80abafb417
2 parents a8fae51 + c7e2beb commit c6818fd

13 files changed

+385
-109
lines changed

src/chainparams.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ class CMainParams : public CChainParams
358358

359359
nLLMQConnectionRetryTimeout = 60;
360360

361-
consensus.llmqChainLocks = Consensus::LLMQ_400_60;
361+
consensus.llmqTypeChainLocks = Consensus::LLMQ_400_60;
362362

363363
// Tier two
364364
nFulfilledRequestExpireTime = 60 * 60; // fulfilled requests expire in 1 hour
@@ -505,7 +505,7 @@ class CTestNetParams : public CChainParams
505505

506506
nLLMQConnectionRetryTimeout = 60;
507507

508-
consensus.llmqChainLocks = Consensus::LLMQ_400_60;
508+
consensus.llmqTypeChainLocks = Consensus::LLMQ_400_60;
509509

510510
// Tier two
511511
nFulfilledRequestExpireTime = 60 * 60; // fulfilled requests expire in 1 hour
@@ -649,7 +649,7 @@ class CRegTestParams : public CChainParams
649649
consensus.llmqs[Consensus::LLMQ_TEST] = llmq_test;
650650
nLLMQConnectionRetryTimeout = 10;
651651

652-
consensus.llmqChainLocks = Consensus::LLMQ_TEST;
652+
consensus.llmqTypeChainLocks = Consensus::LLMQ_TEST;
653653

654654
// Tier two
655655
nFulfilledRequestExpireTime = 60 * 60; // fulfilled requests expire in 1 hour

src/consensus/params.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ struct Params {
278278
// LLMQ
279279
std::map<LLMQType, LLMQParams> llmqs;
280280
Optional<LLMQParams> GetLLMQParams(uint8_t llmqtype) const;
281-
LLMQType llmqChainLocks;
281+
LLMQType llmqTypeChainLocks;
282282
};
283283
} // namespace Consensus
284284

src/evo/evonotificationinterface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void EvoNotificationInterface::AcceptedBlockHeader(const CBlockIndex* pindexNew)
2525
void EvoNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload)
2626
{
2727
// background thread updates
28-
llmq::chainLocksHandler->UpdatedBlockTip(pindexNew, pindexFork);
28+
llmq::chainLocksHandler->UpdatedBlockTip(pindexNew);
2929
llmq::quorumDKGSessionManager->UpdatedBlockTip(pindexNew, fInitialDownload);
3030
llmq::quorumManager->UpdatedBlockTip(pindexNew, fInitialDownload);
3131
}

src/llmq/quorums.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "quorums_commitment.h"
1616
#include "quorums_dkgsessionmgr.h"
1717
#include "shutdown.h"
18+
#include "tiertwo/tiertwo_sync_state.h"
1819
#include "univalue.h"
1920
#include "validation.h"
2021

@@ -165,7 +166,7 @@ CQuorumManager::CQuorumManager(CEvoDB& _evoDb, CBLSWorker& _blsWorker, CDKGSessi
165166

166167
void CQuorumManager::UpdatedBlockTip(const CBlockIndex* pindexNew, bool fInitialDownload)
167168
{
168-
if (fInitialDownload || !activeMasternodeManager || !deterministicMNManager->IsDIP3Enforced(pindexNew->nHeight)) {
169+
if (!g_tiertwo_sync_state.IsBlockchainSynced() || !activeMasternodeManager) {
169170
return;
170171
}
171172

src/llmq/quorums_chainlocks.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "scheduler.h"
1414
#include "spork.h"
1515
#include "sporkid.h"
16+
#include "tiertwo/tiertwo_sync_state.h"
1617
#include "validation.h"
1718

1819
namespace llmq
@@ -108,7 +109,7 @@ void CChainLocksHandler::ProcessNewChainLock(NodeId from, const llmq::CChainLock
108109

109110
uint256 requestId = ::SerializeHash(std::make_pair(CLSIG_REQUESTID_PREFIX, clsig.nHeight));
110111
uint256 msgHash = clsig.blockHash;
111-
if (!quorumSigningManager->VerifyRecoveredSig(Params().GetConsensus().llmqChainLocks, clsig.nHeight, requestId, msgHash, clsig.sig)) {
112+
if (!quorumSigningManager->VerifyRecoveredSig(Params().GetConsensus().llmqTypeChainLocks, clsig.nHeight, requestId, msgHash, clsig.sig)) {
112113
LogPrintf("CChainLocksHandler::%s -- invalid CLSIG (%s), peer=%d\n", __func__, clsig.ToString(), from);
113114
if (from != -1) {
114115
LOCK(cs_main);
@@ -184,7 +185,7 @@ void CChainLocksHandler::AcceptedBlockHeader(const CBlockIndex* pindexNew)
184185
}
185186
}
186187

187-
void CChainLocksHandler::UpdatedBlockTip(const CBlockIndex* pindexNew, const CBlockIndex* pindexFork)
188+
void CChainLocksHandler::UpdatedBlockTip(const CBlockIndex* pindexNew)
188189
{
189190
// don't call TrySignChainTip directly but instead let the scheduler call it. This way we ensure that cs_main is
190191
// never locked and TrySignChainTip is not called twice in parallel. Also avoids recursive calls due to
@@ -207,15 +208,20 @@ void CChainLocksHandler::TrySignChainTip()
207208
{
208209
Cleanup();
209210

211+
if (!fMasterNode) {
212+
return;
213+
}
214+
215+
if (!g_tiertwo_sync_state.IsBlockchainSynced()) {
216+
return;
217+
}
218+
210219
const CBlockIndex* pindex;
211220
{
212221
LOCK(cs_main);
213222
pindex = chainActive.Tip();
214223
}
215224

216-
if (!fMasterNode) {
217-
return;
218-
}
219225
if (!pindex->pprev) {
220226
return;
221227
}
@@ -264,7 +270,7 @@ void CChainLocksHandler::TrySignChainTip()
264270
lastSignedMsgHash = msgHash;
265271
}
266272

267-
quorumSigningManager->AsyncSignIfMember(Params().GetConsensus().llmqChainLocks, requestId, msgHash);
273+
quorumSigningManager->AsyncSignIfMember(Params().GetConsensus().llmqTypeChainLocks, requestId, msgHash);
268274
}
269275

270276
// WARNING: cs_main and cs should not be held!
@@ -345,7 +351,7 @@ void CChainLocksHandler::HandleNewRecoveredSig(const llmq::CRecoveredSig& recove
345351

346352
clsig.nHeight = lastSignedHeight;
347353
clsig.blockHash = lastSignedMsgHash;
348-
clsig.sig = recoveredSig.sig;
354+
clsig.sig = recoveredSig.sig.Get();
349355
}
350356
ProcessNewChainLock(-1, clsig, ::SerializeHash(clsig));
351357
}
@@ -440,6 +446,10 @@ bool CChainLocksHandler::InternalHasConflictingChainLock(int nHeight, const uint
440446

441447
void CChainLocksHandler::Cleanup()
442448
{
449+
if (!g_tiertwo_sync_state.IsBlockchainSynced()) {
450+
return;
451+
}
452+
443453
{
444454
LOCK(cs);
445455
if (GetTimeMillis() - lastCleanupTime < CLEANUP_INTERVAL) {

src/llmq/quorums_chainlocks.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class CChainLocksHandler : public CRecoveredSigsListener
7474
void ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, CConnman& connman);
7575
void ProcessNewChainLock(NodeId from, const CChainLockSig& clsig, const uint256& hash);
7676
void AcceptedBlockHeader(const CBlockIndex* pindexNew);
77-
void UpdatedBlockTip(const CBlockIndex* pindexNew, const CBlockIndex* pindexFork);
77+
void UpdatedBlockTip(const CBlockIndex* pindexNew);
7878
void TrySignChainTip();
7979
void EnforceBestChainLock();
8080
virtual void HandleNewRecoveredSig(const CRecoveredSig& recoveredSig);

src/llmq/quorums_init.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ class CEvoDB;
1414
namespace llmq
1515
{
1616

17-
extern CDBWrapper* llmqDb;
18-
1917
// Init/destroy LLMQ globals
2018
void InitLLMQSystem(CEvoDB& evoDb, CScheduler* scheduler, bool unitTests);
2119
void DestroyLLMQSystem();

0 commit comments

Comments
 (0)