@@ -46,8 +46,8 @@ static const std::string DB_MINED_COMMITMENT_BY_INVERSED_HEIGHT_Q_INDEXED = "q_m
4646
4747static const std::string DB_BEST_BLOCK_UPGRADE = " q_bbu2" ;
4848
49- CQuorumBlockProcessor::CQuorumBlockProcessor (CEvoDB& evoDb , CConnman& _connman, const std::unique_ptr<PeerManager>& peerman) :
50- m_evoDb (evoDb ), connman(_connman), m_peerman(peerman)
49+ CQuorumBlockProcessor::CQuorumBlockProcessor (CChainState& chainstate , CConnman& _connman, CEvoDB& evoDb , const std::unique_ptr<PeerManager>& peerman) :
50+ m_chainstate (chainstate ), connman(_connman), m_evoDb(evoDb ), m_peerman(peerman)
5151{
5252 utils::InitQuorumsCache (mapHasMinedCommitmentCache);
5353}
@@ -82,15 +82,15 @@ void CQuorumBlockProcessor::ProcessMessage(const CNode& peer, std::string_view m
8282 const CBlockIndex* pQuorumBaseBlockIndex;
8383 {
8484 LOCK (cs_main);
85- pQuorumBaseBlockIndex = g_chainman .m_blockman .LookupBlockIndex (qc.quorumHash );
85+ pQuorumBaseBlockIndex = m_chainstate .m_blockman .LookupBlockIndex (qc.quorumHash );
8686 if (pQuorumBaseBlockIndex == nullptr ) {
8787 LogPrint (BCLog::LLMQ, " CQuorumBlockProcessor::%s -- unknown block %s in commitment, peer=%d\n " , __func__,
8888 qc.quorumHash .ToString (), peer.GetId ());
8989 // can't really punish the node here, as we might simply be the one that is on the wrong chain or not
9090 // fully synced
9191 return ;
9292 }
93- if (:: ChainActive () .Tip ()->GetAncestor (pQuorumBaseBlockIndex->nHeight ) != pQuorumBaseBlockIndex) {
93+ if (m_chainstate. m_chain .Tip ()->GetAncestor (pQuorumBaseBlockIndex->nHeight ) != pQuorumBaseBlockIndex) {
9494 LogPrint (BCLog::LLMQ, " CQuorumBlockProcessor::%s -- block %s not in active chain, peer=%d\n " , __func__,
9595 qc.quorumHash .ToString (), peer.GetId ());
9696 // same, can't punish
@@ -103,7 +103,7 @@ void CQuorumBlockProcessor::ProcessMessage(const CNode& peer, std::string_view m
103103 m_peerman->Misbehaving (peer.GetId (), 100 );
104104 return ;
105105 }
106- if (pQuorumBaseBlockIndex->nHeight < (:: ChainActive () .Height () - llmq_params_opt->dkgInterval )) {
106+ if (pQuorumBaseBlockIndex->nHeight < (m_chainstate. m_chain .Height () - llmq_params_opt->dkgInterval )) {
107107 LogPrint (BCLog::LLMQ, " CQuorumBlockProcessor::%s -- block %s is too old, peer=%d\n " , __func__,
108108 qc.quorumHash .ToString (), peer.GetId ());
109109 // TODO: enable punishment in some future version when all/most nodes are running with this fix
@@ -171,7 +171,7 @@ bool CQuorumBlockProcessor::ProcessBlock(const CBlock& block, const CBlockIndex*
171171 // Note: must only check quorums that were enabled at the _previous_ block height to match mining logic
172172 for (const Consensus::LLMQParams& params : utils::GetEnabledQuorumParams (pindex->pprev )) {
173173 // skip these checks when replaying blocks after the crash
174- if (:: ChainActive () .Tip () == nullptr ) {
174+ if (m_chainstate. m_chain .Tip () == nullptr ) {
175175 break ;
176176 }
177177
@@ -234,7 +234,7 @@ bool CQuorumBlockProcessor::ProcessCommitment(int nHeight, const uint256& blockH
234234 nHeight, ToUnderlying (qc.llmqType ), qc.quorumIndex , quorumHash.ToString (), qc.CountSigners (), qc.CountValidMembers (), qc.quorumPublicKey .ToString (), fJustCheck );
235235
236236 // skip `bad-qc-block` checks below when replaying blocks after the crash
237- if (:: ChainActive () .Tip () == nullptr ) {
237+ if (m_chainstate. m_chain .Tip () == nullptr ) {
238238 quorumHash = qc.quorumHash ;
239239 }
240240
@@ -268,7 +268,7 @@ bool CQuorumBlockProcessor::ProcessCommitment(int nHeight, const uint256& blockH
268268 return state.Invalid (BlockValidationResult::BLOCK_CONSENSUS, " bad-qc-height" );
269269 }
270270
271- const auto * pQuorumBaseBlockIndex = g_chainman .m_blockman .LookupBlockIndex (qc.quorumHash );
271+ const auto * pQuorumBaseBlockIndex = m_chainstate .m_blockman .LookupBlockIndex (qc.quorumHash );
272272
273273 if (!qc.Verify (pQuorumBaseBlockIndex, fBLSChecks )) {
274274 LogPrint (BCLog::LLMQ, " CQuorumBlockProcessor::%s height=%d, type=%d, quorumIndex=%d, quorumHash=%s, signers=%s, validMembers=%d, quorumPublicKey=%s qc verify failed.\n " , __func__,
@@ -358,20 +358,20 @@ bool CQuorumBlockProcessor::UpgradeDB()
358358{
359359 LOCK (cs_main);
360360
361- if (:: ChainActive () .Tip () == nullptr ) {
361+ if (m_chainstate. m_chain .Tip () == nullptr ) {
362362 // should have no records
363363 return m_evoDb.IsEmpty ();
364364 }
365365
366366 uint256 bestBlock;
367- if (m_evoDb.GetRawDB ().Read (DB_BEST_BLOCK_UPGRADE, bestBlock) && bestBlock == :: ChainActive () .Tip ()->GetBlockHash ()) {
367+ if (m_evoDb.GetRawDB ().Read (DB_BEST_BLOCK_UPGRADE, bestBlock) && bestBlock == m_chainstate. m_chain .Tip ()->GetBlockHash ()) {
368368 return true ;
369369 }
370370
371371 LogPrintf (" CQuorumBlockProcessor::%s -- Upgrading DB...\n " , __func__);
372372
373- if (:: ChainActive () .Height () >= Params ().GetConsensus ().DIP0003EnforcementHeight ) {
374- const auto * pindex = :: ChainActive () [Params ().GetConsensus ().DIP0003EnforcementHeight ];
373+ if (m_chainstate. m_chain .Height () >= Params ().GetConsensus ().DIP0003EnforcementHeight ) {
374+ const auto * pindex = m_chainstate. m_chain [Params ().GetConsensus ().DIP0003EnforcementHeight ];
375375 while (pindex != nullptr ) {
376376 if (fPruneMode && ((pindex->nStatus & BLOCK_HAVE_DATA) == 0 )) {
377377 // Too late, we already pruned blocks we needed to reprocess commitments
@@ -390,7 +390,7 @@ bool CQuorumBlockProcessor::UpgradeDB()
390390 if (qc.IsNull ()) {
391391 continue ;
392392 }
393- const auto * pQuorumBaseBlockIndex = g_chainman .m_blockman .LookupBlockIndex (qc.quorumHash );
393+ const auto * pQuorumBaseBlockIndex = m_chainstate .m_blockman .LookupBlockIndex (qc.quorumHash );
394394 m_evoDb.GetRawDB ().Write (std::make_pair (DB_MINED_COMMITMENT, std::make_pair (qc.llmqType , qc.quorumHash )), std::make_pair (qc, pindex->GetBlockHash ()));
395395 const auto & llmq_params_opt = GetLLMQParams (qc.llmqType );
396396 assert (llmq_params_opt.has_value ());
@@ -403,7 +403,7 @@ bool CQuorumBlockProcessor::UpgradeDB()
403403
404404 m_evoDb.GetRawDB ().Write (DB_BEST_BLOCK_UPGRADE, pindex->GetBlockHash ());
405405
406- pindex = :: ChainActive () .Next (pindex);
406+ pindex = m_chainstate. m_chain .Next (pindex);
407407 }
408408 }
409409
@@ -479,8 +479,8 @@ size_t CQuorumBlockProcessor::GetNumCommitmentsRequired(const Consensus::LLMQPar
479479 if (!IsMiningPhase (llmqParams, nHeight)) return 0 ;
480480
481481 // Note: This function can be called for new blocks
482- assert (nHeight <= :: ChainActive () .Height () + 1 );
483- const auto *const pindex = :: ChainActive (). Height () < nHeight ? :: ChainActive (). Tip () : :: ChainActive () .Tip ()->GetAncestor (nHeight);
482+ assert (nHeight <= m_chainstate. m_chain .Height () + 1 );
483+ const auto *const pindex = m_chainstate. m_chain . Height () < nHeight ? m_chainstate. m_chain . Tip () : m_chainstate. m_chain .Tip ()->GetAncestor (nHeight);
484484
485485 bool rotation_enabled = utils::IsQuorumRotationEnabled (llmqParams, pindex);
486486 size_t quorums_num = rotation_enabled ? llmqParams.signingActiveQuorumCount : 1 ;
@@ -763,8 +763,8 @@ std::optional<std::vector<CFinalCommitment>> CQuorumBlockProcessor::GetMineableC
763763 }
764764
765765 // Note: This function can be called for new blocks
766- assert (nHeight <= :: ChainActive () .Height () + 1 );
767- const auto *const pindex = :: ChainActive (). Height () < nHeight ? :: ChainActive (). Tip () : :: ChainActive () .Tip ()->GetAncestor (nHeight);
766+ assert (nHeight <= m_chainstate. m_chain .Height () + 1 );
767+ const auto *const pindex = m_chainstate. m_chain . Height () < nHeight ? m_chainstate. m_chain . Tip () : m_chainstate. m_chain .Tip ()->GetAncestor (nHeight);
768768
769769 bool rotation_enabled = utils::IsQuorumRotationEnabled (llmqParams, pindex);
770770 bool basic_bls_enabled = utils::IsV19Active (pindex);
0 commit comments