@@ -82,12 +82,13 @@ arith_uint256 calculateQuorumScore(const CDeterministicMNCPtr& dmn, const uint25
8282 return UintToArith256 (h);
8383}
8484
85- uint256 GetHashModifier (const Consensus::LLMQParams& llmqParams, gsl::not_null<const CBlockIndex*> pCycleQuorumBaseBlockIndex)
85+ uint256 GetHashModifier (const Consensus::LLMQParams& llmqParams, const Consensus::Params& consensus_params,
86+ gsl::not_null<const CBlockIndex*> pCycleQuorumBaseBlockIndex)
8687{
8788 ASSERT_IF_DEBUG (pCycleQuorumBaseBlockIndex->nHeight % llmqParams.dkgInterval == 0 );
8889 const CBlockIndex* pWorkBlockIndex = pCycleQuorumBaseBlockIndex->GetAncestor (pCycleQuorumBaseBlockIndex->nHeight - llmq::WORK_DIFF_DEPTH);
8990
90- if (DeploymentActiveAfter (pWorkBlockIndex, Params (). GetConsensus () , Consensus::DEPLOYMENT_V20)) {
91+ if (DeploymentActiveAfter (pWorkBlockIndex, consensus_params , Consensus::DEPLOYMENT_V20)) {
9192 // v20 is active: calculate modifier using the new way.
9293 auto cbcl = GetNonNullCoinbaseChainlock (pWorkBlockIndex);
9394 if (cbcl.has_value ()) {
@@ -178,7 +179,7 @@ QuorumMembers CalculateQuorum(List&& mn_list, const uint256& modifier, size_t ma
178179}
179180
180181std::vector<QuorumMembers> GetQuorumQuarterMembersBySnapshot (
181- const Consensus::LLMQParams& llmqParams, CDeterministicMNManager& dmnman,
182+ const Consensus::LLMQParams& llmqParams, CDeterministicMNManager& dmnman, const Consensus::Params& consensus_params,
182183 const CBlockIndex* pCycleQuorumBaseBlockIndex, const llmq::CQuorumSnapshot& snapshot, int nHeight)
183184{
184185 if (!llmqParams.useRotation || pCycleQuorumBaseBlockIndex->nHeight % llmqParams.dkgInterval != 0 ) {
@@ -191,7 +192,7 @@ std::vector<QuorumMembers> GetQuorumQuarterMembersBySnapshot(
191192 const CBlockIndex* pWorkBlockIndex = pCycleQuorumBaseBlockIndex->GetAncestor (
192193 pCycleQuorumBaseBlockIndex->nHeight - llmq::WORK_DIFF_DEPTH);
193194 auto mn_list = dmnman.GetListForBlock (pWorkBlockIndex);
194- const auto modifier = GetHashModifier (llmqParams, pCycleQuorumBaseBlockIndex);
195+ const auto modifier = GetHashModifier (llmqParams, consensus_params, pCycleQuorumBaseBlockIndex);
195196 auto sortedAllMns = CalculateQuorum (mn_list, modifier);
196197
197198 std::vector<CDeterministicMNCPtr> usedMNs;
@@ -278,32 +279,32 @@ std::vector<QuorumMembers> GetQuorumQuarterMembersBySnapshot(
278279 }
279280}
280281
281- QuorumMembers ComputeQuorumMembers (Consensus::LLMQType llmqType, const CDeterministicMNList& mn_list, const CBlockIndex* pQuorumBaseBlockIndex)
282+ QuorumMembers ComputeQuorumMembers (Consensus::LLMQType llmqType, const CChainParams& chainparams,
283+ const CDeterministicMNList& mn_list, const CBlockIndex* pQuorumBaseBlockIndex)
282284{
283- bool EvoOnly = (Params () .GetConsensus ().llmqTypePlatform == llmqType) && DeploymentActiveAfter (pQuorumBaseBlockIndex, Params () .GetConsensus (), Consensus::DEPLOYMENT_V19);
284- const auto & llmq_params_opt = Params () .GetLLMQ (llmqType);
285+ bool EvoOnly = (chainparams .GetConsensus ().llmqTypePlatform == llmqType) && DeploymentActiveAfter (pQuorumBaseBlockIndex, chainparams .GetConsensus (), Consensus::DEPLOYMENT_V19);
286+ const auto & llmq_params_opt = chainparams .GetLLMQ (llmqType);
285287 assert (llmq_params_opt.has_value ());
286288 if (llmq_params_opt->useRotation || pQuorumBaseBlockIndex->nHeight % llmq_params_opt->dkgInterval != 0 ) {
287289 ASSERT_IF_DEBUG (false );
288290 return {};
289291 }
290292
291- const auto modifier = GetHashModifier (llmq_params_opt.value (), pQuorumBaseBlockIndex);
293+ const auto modifier = GetHashModifier (llmq_params_opt.value (), chainparams. GetConsensus (), pQuorumBaseBlockIndex);
292294 return CalculateQuorum (mn_list, modifier, llmq_params_opt->size , EvoOnly);
293295}
294296
295- void BuildQuorumSnapshot (const Consensus::LLMQParams& llmqParams, const CDeterministicMNList& allMns,
297+ void BuildQuorumSnapshot (const Consensus::LLMQParams& llmqParams, const Consensus::Params& consensus_params, const CDeterministicMNList& allMns,
296298 const CDeterministicMNList& mnUsedAtH, std::vector<CDeterministicMNCPtr>& sortedCombinedMns,
297- llmq::CQuorumSnapshot& quorumSnapshot, int nHeight, std::vector<int >& skipList,
298- const CBlockIndex* pCycleQuorumBaseBlockIndex)
299+ llmq::CQuorumSnapshot& quorumSnapshot, std::vector<int >& skipList, const CBlockIndex* pCycleQuorumBaseBlockIndex)
299300{
300301 if (!llmqParams.useRotation || pCycleQuorumBaseBlockIndex->nHeight % llmqParams.dkgInterval != 0 ) {
301302 ASSERT_IF_DEBUG (false );
302303 return ;
303304 }
304305
305306 quorumSnapshot.activeQuorumMembers .resize (allMns.GetAllMNsCount ());
306- const auto modifier = GetHashModifier (llmqParams, pCycleQuorumBaseBlockIndex);
307+ const auto modifier = GetHashModifier (llmqParams, consensus_params, pCycleQuorumBaseBlockIndex);
307308 auto sortedAllMns = CalculateQuorum (allMns, modifier);
308309
309310 LogPrint (BCLog::LLMQ, " BuildQuorumSnapshot h[%d] numMns[%d]\n " , pCycleQuorumBaseBlockIndex->nHeight , allMns.GetAllMNsCount ());
@@ -328,11 +329,10 @@ void BuildQuorumSnapshot(const Consensus::LLMQParams& llmqParams, const CDetermi
328329 }
329330}
330331
331- std::vector<QuorumMembers> BuildNewQuorumQuarterMembers (
332- const Consensus::LLMQParams& llmqParams, llmq::CQuorumSnapshotManager& qsnapman, const CDeterministicMNList& allMns,
333- const CBlockIndex* pCycleQuorumBaseBlockIndex, const PreviousQuorumQuarters& previousQuarters)
332+ std::vector<QuorumMembers> BuildNewQuorumQuarterMembers (const Consensus::LLMQParams& llmqParams, const llmq::utils::UtilParameters& util_params,
333+ const CDeterministicMNList& allMns, const PreviousQuorumQuarters& previousQuarters)
334334{
335- if (!llmqParams.useRotation || pCycleQuorumBaseBlockIndex ->nHeight % llmqParams.dkgInterval != 0 ) {
335+ if (!llmqParams.useRotation || util_params. m_base_index ->nHeight % llmqParams.dkgInterval != 0 ) {
336336 ASSERT_IF_DEBUG (false );
337337 return {};
338338 }
@@ -342,8 +342,7 @@ std::vector<QuorumMembers> BuildNewQuorumQuarterMembers(
342342
343343 size_t quorumSize = static_cast <size_t >(llmqParams.size );
344344 auto quarterSize{quorumSize / 4 };
345- const auto modifier = GetHashModifier (llmqParams, pCycleQuorumBaseBlockIndex);
346-
345+ const auto modifier = GetHashModifier (llmqParams, util_params.m_chainman .GetConsensus (), util_params.m_base_index );
347346
348347 if (allMns.GetValidMNsCount () < quarterSize) {
349348 return quarterQuorumMembers;
@@ -352,7 +351,7 @@ std::vector<QuorumMembers> BuildNewQuorumQuarterMembers(
352351 auto MnsUsedAtH = CDeterministicMNList ();
353352 std::vector<CDeterministicMNList> MnsUsedAtHIndexed{nQuorums};
354353
355- bool skipRemovedMNs = DeploymentActiveAfter (pCycleQuorumBaseBlockIndex, Params (). GetConsensus (), Consensus::DEPLOYMENT_V19) || (Params ().NetworkIDString () == CBaseChainParams::TESTNET);
354+ bool skipRemovedMNs = DeploymentActiveAfter (util_params. m_base_index , util_params. m_chainman . GetConsensus (), Consensus::DEPLOYMENT_V19) || (util_params. m_chainman . GetParams ().NetworkIDString () == CBaseChainParams::TESTNET);
356355
357356 for (const size_t idx : irange::range (nQuorums)) {
358357 for (auto * prev_cycle : previousQuarters.GetCycles ()) {
@@ -391,7 +390,7 @@ std::vector<QuorumMembers> BuildNewQuorumQuarterMembers(
391390 }
392391
393392 if (LogAcceptDebug (BCLog::LLMQ)) {
394- LogPrint (BCLog::LLMQ, " %s h[%d] sortedCombinedMns[%s]\n " , __func__, pCycleQuorumBaseBlockIndex ->nHeight , ToString (sortedCombinedMnsList));
393+ LogPrint (BCLog::LLMQ, " %s h[%d] sortedCombinedMns[%s]\n " , __func__, util_params. m_base_index ->nHeight , ToString (sortedCombinedMnsList));
395394 }
396395
397396 std::vector<int > skipList;
@@ -436,11 +435,9 @@ std::vector<QuorumMembers> BuildNewQuorumQuarterMembers(
436435 }
437436 }
438437
439- llmq::CQuorumSnapshot quorumSnapshot = {};
440-
441- BuildQuorumSnapshot (llmqParams, allMns, MnsUsedAtH, sortedCombinedMnsList, quorumSnapshot, pCycleQuorumBaseBlockIndex->nHeight , skipList, pCycleQuorumBaseBlockIndex);
442-
443- qsnapman.StoreSnapshotForBlock (llmqParams.type , pCycleQuorumBaseBlockIndex, quorumSnapshot);
438+ llmq::CQuorumSnapshot quorumSnapshot{};
439+ BuildQuorumSnapshot (llmqParams, util_params.m_chainman .GetConsensus (), allMns, MnsUsedAtH, sortedCombinedMnsList, quorumSnapshot, skipList, util_params.m_base_index );
440+ util_params.m_qsnapman .StoreSnapshotForBlock (llmqParams.type , util_params.m_base_index , quorumSnapshot);
444441
445442 return quarterQuorumMembers;
446443}
@@ -470,11 +467,11 @@ std::vector<QuorumMembers> ComputeQuorumMembersByQuarterRotation(const Consensus
470467 // assert(false);
471468 break ;
472469 }
473- prev_cycles[idx]->m_members = GetQuorumQuarterMembersBySnapshot (llmqParams, util_params.m_dmnman , prev_cycles[idx]-> m_cycle_index ,
474- prev_cycles[idx]->m_snap , util_params.m_base_index ->nHeight );
470+ prev_cycles[idx]->m_members = GetQuorumQuarterMembersBySnapshot (llmqParams, util_params.m_dmnman , util_params. m_chainman . GetConsensus () ,
471+ prev_cycles[idx]->m_cycle_index , prev_cycles[idx]-> m_snap , util_params.m_base_index ->nHeight );
475472 }
476473
477- auto newQuarterMembers = BuildNewQuorumQuarterMembers (llmqParams, util_params. m_qsnapman , allMns, util_params. m_base_index , previousQuarters);
474+ auto newQuarterMembers = BuildNewQuorumQuarterMembers (llmqParams, util_params, allMns, previousQuarters);
478475 // TODO: Check if it is triggered from outside (P2P, block validation) and maybe throw an exception
479476 // assert (!newQuarterMembers.empty());
480477
@@ -562,7 +559,7 @@ QuorumMembers GetAllQuorumMembers(Consensus::LLMQType llmqType, const UtilParame
562559 {
563560 LOCK (cs_members);
564561 if (mapQuorumMembers.empty ()) {
565- InitQuorumsCache (mapQuorumMembers);
562+ InitQuorumsCache (mapQuorumMembers, util_params. m_chainman . GetConsensus () );
566563 }
567564 if (reset_cache) {
568565 mapQuorumMembers[llmqType].clear ();
@@ -571,13 +568,13 @@ QuorumMembers GetAllQuorumMembers(Consensus::LLMQType llmqType, const UtilParame
571568 }
572569 }
573570
574- const auto & llmq_params_opt = Params ().GetLLMQ (llmqType);
571+ const auto & llmq_params_opt = util_params. m_chainman . GetParams ().GetLLMQ (llmqType);
575572 assert (llmq_params_opt.has_value ());
576573 const auto & llmq_params = llmq_params_opt.value ();
577574
578575 if (IsQuorumRotationEnabled (llmq_params, util_params.m_base_index )) {
579576 if (LOCK (cs_indexed_members); mapIndexedQuorumMembers.empty ()) {
580- InitQuorumsCache (mapIndexedQuorumMembers);
577+ InitQuorumsCache (mapIndexedQuorumMembers, util_params. m_chainman . GetConsensus () );
581578 }
582579 /*
583580 * Quorums created with rotation are now created in a different way. All signingActiveQuorumCount are created during the period of dkgInterval.
@@ -617,11 +614,11 @@ QuorumMembers GetAllQuorumMembers(Consensus::LLMQType llmqType, const UtilParame
617614 std::move (q[i]));
618615 }
619616 } else {
620- const CBlockIndex* pWorkBlockIndex = DeploymentActiveAfter (util_params.m_base_index , Params () .GetConsensus (), Consensus::DEPLOYMENT_V20)
617+ const CBlockIndex* pWorkBlockIndex = DeploymentActiveAfter (util_params.m_base_index , util_params. m_chainman .GetConsensus (), Consensus::DEPLOYMENT_V20)
621618 ? util_params.m_base_index ->GetAncestor (util_params.m_base_index ->nHeight - WORK_DIFF_DEPTH)
622619 : util_params.m_base_index .get ();
623620 CDeterministicMNList mn_list = util_params.m_dmnman .GetListForBlock (pWorkBlockIndex);
624- quorumMembers = ComputeQuorumMembers (llmqType, mn_list, util_params.m_base_index );
621+ quorumMembers = ComputeQuorumMembers (llmqType, util_params. m_chainman . GetParams (), mn_list, util_params.m_base_index );
625622 }
626623
627624 LOCK (cs_members);
0 commit comments