1414#include < deploymentstatus.h>
1515#include < logging.h>
1616#include < util/time.h>
17+ #include < validation.h>
1718
1819namespace llmq {
1920ActiveDKGSessionHandler::ActiveDKGSessionHandler (
@@ -41,6 +42,8 @@ ActiveDKGSessionHandler::~ActiveDKGSessionHandler() = default;
4142
4243void ActiveDKGSessionHandler::UpdatedBlockTip (const CBlockIndex* pindexNew)
4344{
45+ if (m_chainman.IsSnapshotActiveAndUnvalidated ()) return ;
46+
4447 // AssertLockNotHeld(cs_main);
4548 // Indexed quorums (greater than 0) are enabled with Quorum Rotation
4649 if (quorumIndex > 0 && !IsQuorumRotationEnabled (params, pindexNew)) {
@@ -76,6 +79,10 @@ std::pair<QuorumPhase, uint256> ActiveDKGSessionHandler::GetPhaseAndQuorumHash()
7679
7780bool ActiveDKGSessionHandler::InitNewQuorum (gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex)
7881{
82+ if (m_chainman.IsSnapshotActiveAndUnvalidated ()) {
83+ LogPrint (BCLog::LLMQ_DKG , " %s -- refusing DKG participation while snapshot background validation is incomplete\n " , __func__);
84+ return false ;
85+ }
7986 if (!DeploymentDIP0003Enforced (pQuorumBaseBlockIndex->nHeight , Params ().GetConsensus ())) {
8087 return false ;
8188 }
@@ -100,6 +107,10 @@ void ActiveDKGSessionHandler::WaitForNextPhase(std::optional<QuorumPhase> curPha
100107 LogPrint (BCLog::LLMQ_DKG , " ActiveDKGSessionHandler::%s -- %s qi[%d] - starting, curPhase=%d, nextPhase=%d\n " , __func__, params.name , quorumIndex, curPhase.has_value () ? std23::to_underlying (*curPhase) : -1 , std23::to_underlying (nextPhase));
101108
102109 while (true ) {
110+ if (m_chainman.IsSnapshotActiveAndUnvalidated ()) {
111+ LogPrint (BCLog::LLMQ_DKG , " ActiveDKGSessionHandler::%s -- %s qi[%d] - aborting because snapshot background validation is incomplete\n " , __func__, params.name , quorumIndex);
112+ throw AbortPhaseException ();
113+ }
103114 if (stopRequested) {
104115 LogPrint (BCLog::LLMQ_DKG , " ActiveDKGSessionHandler::%s -- %s qi[%d] - aborting due to stop/shutdown requested\n " , __func__, params.name , quorumIndex);
105116 throw AbortPhaseException ();
@@ -139,6 +150,10 @@ void ActiveDKGSessionHandler::WaitForNewQuorum(const uint256& oldQuorumHash) con
139150 LogPrint (BCLog::LLMQ_DKG , " ActiveDKGSessionHandler::%s -- %s qi[%d]- starting\n " , __func__, params.name , quorumIndex);
140151
141152 while (true ) {
153+ if (m_chainman.IsSnapshotActiveAndUnvalidated ()) {
154+ LogPrint (BCLog::LLMQ_DKG , " ActiveDKGSessionHandler::%s -- %s qi[%d] - aborting because snapshot background validation is incomplete\n " , __func__, params.name , quorumIndex);
155+ throw AbortPhaseException ();
156+ }
142157 if (stopRequested) {
143158 LogPrint (BCLog::LLMQ_DKG , " ActiveDKGSessionHandler::%s -- %s qi[%d] - aborting due to stop/shutdown requested\n " , __func__, params.name , quorumIndex);
144159 throw AbortPhaseException ();
@@ -186,6 +201,10 @@ void ActiveDKGSessionHandler::SleepBeforePhase(QuorumPhase curPhase, const uint2
186201 LogPrint (BCLog::LLMQ_DKG , " ActiveDKGSessionHandler::%s -- %s qi[%d] - starting sleep for %d ms, curPhase=%d\n " , __func__, params.name , quorumIndex, sleepTime, std23::to_underlying (curPhase));
187202
188203 while (SteadyClock::now () < endTime) {
204+ if (m_chainman.IsSnapshotActiveAndUnvalidated ()) {
205+ LogPrint (BCLog::LLMQ_DKG , " ActiveDKGSessionHandler::%s -- %s qi[%d] - aborting because snapshot background validation is incomplete\n " , __func__, params.name , quorumIndex);
206+ throw AbortPhaseException ();
207+ }
189208 if (stopRequested) {
190209 LogPrint (BCLog::LLMQ_DKG , " ActiveDKGSessionHandler::%s -- %s qi[%d] - aborting due to stop/shutdown requested\n " , __func__, params.name , quorumIndex);
191210 throw AbortPhaseException ();
@@ -220,6 +239,10 @@ void ActiveDKGSessionHandler::HandlePhase(QuorumPhase curPhase, QuorumPhase next
220239 LogPrint (BCLog::LLMQ_DKG , " ActiveDKGSessionHandler::%s -- %s qi[%d] - starting, curPhase=%d, nextPhase=%d\n " , __func__, params.name , quorumIndex, std23::to_underlying (curPhase), std23::to_underlying (nextPhase));
221240
222241 SleepBeforePhase (curPhase, expectedQuorumHash, randomSleepFactor, runWhileWaiting);
242+ if (m_chainman.IsSnapshotActiveAndUnvalidated ()) {
243+ LogPrint (BCLog::LLMQ_DKG , " %s -- refusing DKG participation while snapshot background validation is incomplete\n " , __func__);
244+ throw AbortPhaseException ();
245+ }
223246 startPhaseFunc ();
224247 WaitForNextPhase (curPhase, nextPhase, expectedQuorumHash, runWhileWaiting);
225248
0 commit comments