2626#include < llmq/quorums.h>
2727#include < llmq/utils.h>
2828
29- static bool CheckCbTxBestChainlock (const CCbTx& cbTx , const CBlockIndex* pindex ,
30- const llmq::CChainLocksHandler& chainlock_handler , BlockValidationState& state)
29+ static bool CheckCbTxBestChainlock (const ChainstateManager& chainman , const llmq::CChainLocksHandler& clhandler ,
30+ const CCbTx& cbTx, const CBlockIndex* pindex , BlockValidationState& state)
3131{
3232 if (cbTx.nVersion < CCbTx::Version::CLSIG_AND_BALANCE) {
3333 return true ;
@@ -37,7 +37,7 @@ static bool CheckCbTxBestChainlock(const CCbTx& cbTx, const CBlockIndex* pindex,
3737 static const CBlockIndex* cached_pindex GUARDED_BY (cached_mutex){nullptr };
3838 static std::optional<std::pair<CBLSSignature, uint32_t >> cached_chainlock GUARDED_BY (cached_mutex){std::nullopt };
3939
40- auto best_clsig = chainlock_handler .GetBestChainLock ();
40+ auto best_clsig = clhandler .GetBestChainLock ();
4141 if (best_clsig.getHeight () == pindex->nHeight - 1 && cbTx.bestCLHeightDiff == 0 &&
4242 cbTx.bestCLSignature == best_clsig.getSig ()) {
4343 // matches our best clsig which still hold values for the previous block
@@ -52,7 +52,7 @@ static bool CheckCbTxBestChainlock(const CCbTx& cbTx, const CBlockIndex* pindex,
5252 prevBlockCoinbaseChainlock = cached_chainlock;
5353 }
5454 if (!prevBlockCoinbaseChainlock.has_value ()) {
55- prevBlockCoinbaseChainlock = GetNonNullCoinbaseChainlock (pindex->pprev );
55+ prevBlockCoinbaseChainlock = GetNonNullCoinbaseChainlock (chainman, pindex->pprev );
5656 }
5757 // If std::optional prevBlockCoinbaseChainlock is empty, then up to the previous block, coinbase Chainlock is null.
5858 if (prevBlockCoinbaseChainlock.has_value ()) {
@@ -77,9 +77,8 @@ static bool CheckCbTxBestChainlock(const CCbTx& cbTx, const CBlockIndex* pindex,
7777 return true ;
7878 }
7979 uint256 curBlockCoinbaseCLBlockHash = pindex->GetAncestor (curBlockCoinbaseCLHeight)->GetBlockHash ();
80- if (chainlock_handler.VerifyChainLock (
81- chainlock::ChainLockSig (curBlockCoinbaseCLHeight, curBlockCoinbaseCLBlockHash, cbTx.bestCLSignature )) !=
82- llmq::VerifyRecSigStatus::Valid) {
80+ if (clhandler.VerifyChainLock (chainlock::ChainLockSig (curBlockCoinbaseCLHeight, curBlockCoinbaseCLBlockHash,
81+ cbTx.bestCLSignature )) != llmq::VerifyRecSigStatus::Valid) {
8382 return state.Invalid (BlockValidationResult::BLOCK_CONSENSUS, " bad-cbtx-invalid-clsig" );
8483 }
8584 LOCK (cached_mutex);
@@ -104,8 +103,7 @@ static bool CheckSpecialTxInner(CDeterministicMNManager& dmnman, llmq::CQuorumSn
104103 if (!tx.HasExtraPayloadField ())
105104 return true ;
106105
107- const auto & consensusParams = Params ().GetConsensus ();
108- if (!DeploymentActiveAfter (pindexPrev, consensusParams, Consensus::DEPLOYMENT_DIP0003)) {
106+ if (!DeploymentActiveAfter (pindexPrev, chainman, Consensus::DEPLOYMENT_DIP0003)) {
109107 return state.Invalid (TxValidationResult::TX_BAD_SPECIAL, " bad-tx-type" );
110108 }
111109
@@ -205,8 +203,8 @@ bool CSpecialTxProcessor::BuildNewListFromBlock(const CBlock& block, gsl::not_nu
205203
206204 newList.DecreaseScores ();
207205
208- const bool isMNRewardReallocation{DeploymentActiveAfter (pindexPrev, m_consensus_params , Consensus::DEPLOYMENT_MN_RR)};
209- const bool is_v24_deployed{DeploymentActiveAfter (pindexPrev, m_consensus_params , Consensus::DEPLOYMENT_V24)};
206+ const bool isMNRewardReallocation{DeploymentActiveAfter (pindexPrev, m_chainman , Consensus::DEPLOYMENT_MN_RR)};
207+ const bool is_v24_deployed{DeploymentActiveAfter (pindexPrev, m_chainman , Consensus::DEPLOYMENT_V24)};
210208
211209 // we skip the coinbase
212210 for (int i = 1 ; i < (int )block.vtx .size (); i++) {
@@ -529,7 +527,7 @@ bool CSpecialTxProcessor::ProcessSpecialTxsInBlock(const CBlock& block, const CB
529527 }
530528 if (fCheckCbTxMerkleRoots ) {
531529 // To ensure that opt_cbTx is not missing when it's supposed to be
532- if (DeploymentActiveAt (*pindex, m_consensus_params , Consensus::DEPLOYMENT_DIP0003) && !opt_cbTx.has_value ()) {
530+ if (DeploymentActiveAt (*pindex, m_chainman , Consensus::DEPLOYMENT_DIP0003) && !opt_cbTx.has_value ()) {
533531 return state.Invalid (BlockValidationResult::BLOCK_CONSENSUS, " bad-cbtx-version" );
534532 }
535533 }
@@ -540,7 +538,7 @@ bool CSpecialTxProcessor::ProcessSpecialTxsInBlock(const CBlock& block, const CB
540538 nTimePayload * 0.000001 );
541539
542540 CRangesSet indexes;
543- if (DeploymentActiveAt (*pindex, m_consensus_params , Consensus::DEPLOYMENT_V20)) {
541+ if (DeploymentActiveAt (*pindex, m_chainman , Consensus::DEPLOYMENT_V20)) {
544542 CCreditPool creditPool{m_cpoolman.GetCreditPool (pindex->pprev )};
545543 LogPrint (BCLog::CREDITPOOL, " CSpecialTxProcessor::%s -- CCreditPool is %s\n " , __func__, creditPool.ToString ());
546544 indexes = std::move (creditPool.indexes );
@@ -589,7 +587,7 @@ bool CSpecialTxProcessor::ProcessSpecialTxsInBlock(const CBlock& block, const CB
589587 nTimeQuorum * 0.000001 );
590588
591589 CDeterministicMNList mn_list;
592- if (DeploymentActiveAt (*pindex, m_consensus_params , Consensus::DEPLOYMENT_DIP0003)) {
590+ if (DeploymentActiveAt (*pindex, m_chainman , Consensus::DEPLOYMENT_DIP0003)) {
593591 if (!BuildNewListFromBlock (block, pindex->pprev , view, true , state, mn_list)) {
594592 // pass the state returned by the function above
595593 return false ;
@@ -640,7 +638,7 @@ bool CSpecialTxProcessor::ProcessSpecialTxsInBlock(const CBlock& block, const CB
640638 LogPrint (BCLog::BENCHMARK, " - CalcCbTxMerkleRootQuorums: %.2fms [%.2fs]\n " ,
641639 0.001 * (nTime6_2 - nTime6_1), nTimeMerkleQuorums * 0.000001 );
642640
643- if (!CheckCbTxBestChainlock (*opt_cbTx, pindex, m_clhandler , state)) {
641+ if (!CheckCbTxBestChainlock (m_chainman, m_clhandler, *opt_cbTx, pindex, state)) {
644642 // pass the state returned by the function above
645643 return false ;
646644 }
@@ -663,7 +661,7 @@ bool CSpecialTxProcessor::ProcessSpecialTxsInBlock(const CBlock& block, const CB
663661 LogPrint (BCLog::BENCHMARK, " - m_mnhfman.ProcessBlock: %.2fms [%.2fs]\n " , 0.001 * (nTime8 - nTime7),
664662 nTimeMnehf * 0.000001 );
665663
666- if (DeploymentActiveAfter (pindex, m_consensus_params , Consensus::DEPLOYMENT_V19) && bls::bls_legacy_scheme.load ()) {
664+ if (DeploymentActiveAfter (pindex, m_chainman , Consensus::DEPLOYMENT_V19) && bls::bls_legacy_scheme.load ()) {
667665 // NOTE: The block next to the activation is the one that is using new rules.
668666 // V19 activated just activated, so we must switch to the new rules here.
669667 bls::bls_legacy_scheme.store (false );
@@ -684,7 +682,7 @@ bool CSpecialTxProcessor::UndoSpecialTxsInBlock(const CBlock& block, const CBloc
684682 auto bls_legacy_scheme = bls::bls_legacy_scheme.load ();
685683
686684 try {
687- if (!DeploymentActiveAt (*pindex, m_consensus_params , Consensus::DEPLOYMENT_V19) && !bls_legacy_scheme) {
685+ if (!DeploymentActiveAt (*pindex, m_chainman , Consensus::DEPLOYMENT_V19) && !bls_legacy_scheme) {
688686 // NOTE: The block next to the activation is the one that is using new rules.
689687 // Removing the activation block here, so we must switch back to the old rules.
690688 bls::bls_legacy_scheme.store (true );
@@ -716,8 +714,8 @@ bool CSpecialTxProcessor::CheckCreditPoolDiffForBlock(const CBlock& block, const
716714{
717715 AssertLockHeld (::cs_main);
718716
719- if (!DeploymentActiveAt (*pindex, m_consensus_params , Consensus::DEPLOYMENT_DIP0008)) return true ;
720- if (!DeploymentActiveAt (*pindex, m_consensus_params , Consensus::DEPLOYMENT_V20)) return true ;
717+ if (!DeploymentActiveAt (*pindex, m_chainman , Consensus::DEPLOYMENT_DIP0008)) return true ;
718+ if (!DeploymentActiveAt (*pindex, m_chainman , Consensus::DEPLOYMENT_V20)) return true ;
721719
722720 try {
723721 const CAmount blockSubsidy = GetBlockSubsidy (pindex, m_chainman);
0 commit comments