@@ -28,12 +28,9 @@ CFinalCommitment::CFinalCommitment(const Consensus::LLMQParams& params, const ui
2828{
2929}
3030
31- bool CFinalCommitment::VerifySignatureAsync (CDeterministicMNManager& dmnman, CQuorumSnapshotManager& qsnapman,
32- const ChainstateManager& chainman,
33- gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex,
34- CCheckQueueControl<utils::BlsCheck>* queue_control) const
31+ bool CFinalCommitment::VerifySignatureAsync (const llmq::UtilParameters& util_params, CCheckQueueControl<utils::BlsCheck>* queue_control) const
3532{
36- auto members = utils::GetAllQuorumMembers (llmqType, {dmnman, qsnapman, chainman, pQuorumBaseBlockIndex} );
33+ auto members = utils::GetAllQuorumMembers (llmqType, util_params );
3734 const auto & llmq_params_opt = Params ().GetLLMQ (llmqType);
3835 if (!llmq_params_opt.has_value ()) {
3936 LogPrint (BCLog::LLMQ, " CFinalCommitment -- q[%s] invalid llmqType=%d\n " , quorumHash.ToString (),
@@ -96,9 +93,7 @@ bool CFinalCommitment::VerifySignatureAsync(CDeterministicMNManager& dmnman, CQu
9693}
9794
9895
99- bool CFinalCommitment::Verify (CDeterministicMNManager& dmnman, CQuorumSnapshotManager& qsnapman,
100- const ChainstateManager& chainman,
101- gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex, bool checkSigs) const
96+ bool CFinalCommitment::Verify (const llmq::UtilParameters& util_params, bool checkSigs) const
10297{
10398 const auto & llmq_params_opt = Params ().GetLLMQ (llmqType);
10499 if (!llmq_params_opt.has_value ()) {
@@ -107,19 +102,19 @@ bool CFinalCommitment::Verify(CDeterministicMNManager& dmnman, CQuorumSnapshotMa
107102 }
108103 const auto & llmq_params = llmq_params_opt.value ();
109104
110- const uint16_t expected_nversion{CFinalCommitment::GetVersion (IsQuorumRotationEnabled (llmq_params, pQuorumBaseBlockIndex ),
111- DeploymentActiveAfter (pQuorumBaseBlockIndex, chainman .GetConsensus (), Consensus::DEPLOYMENT_V19))};
105+ const uint16_t expected_nversion{CFinalCommitment::GetVersion (IsQuorumRotationEnabled (llmq_params, util_params. m_base_index ),
106+ DeploymentActiveAfter (util_params. m_base_index , util_params. m_chainman .GetConsensus (), Consensus::DEPLOYMENT_V19))};
112107 if (nVersion == 0 || nVersion != expected_nversion) {
113108 LogPrint (BCLog::LLMQ, " CFinalCommitment -- q[%s] invalid nVersion=%d expected=%d\n " , quorumHash.ToString (), nVersion, expected_nversion);
114109 return false ;
115110 }
116111
117- if (pQuorumBaseBlockIndex ->GetBlockHash () != quorumHash) {
112+ if (util_params. m_base_index ->GetBlockHash () != quorumHash) {
118113 LogPrint (BCLog::LLMQ, " CFinalCommitment -- q[%s] invalid quorumHash\n " , quorumHash.ToString ());
119114 return false ;
120115 }
121116
122- if ((pQuorumBaseBlockIndex ->nHeight % llmq_params.dkgInterval ) != quorumIndex) {
117+ if ((util_params. m_base_index ->nHeight % llmq_params.dkgInterval ) != quorumIndex) {
123118 LogPrint (BCLog::LLMQ, " CFinalCommitment -- q[%s] invalid quorumIndex=%d\n " , quorumHash.ToString (), quorumIndex);
124119 return false ;
125120 }
@@ -152,7 +147,7 @@ bool CFinalCommitment::Verify(CDeterministicMNManager& dmnman, CQuorumSnapshotMa
152147 LogPrint (BCLog::LLMQ, " CFinalCommitment -- q[%s] invalid vvecSig\n " , quorumHash.ToString ());
153148 return false ;
154149 }
155- auto members = utils::GetAllQuorumMembers (llmqType, {dmnman, qsnapman, chainman, pQuorumBaseBlockIndex} );
150+ auto members = utils::GetAllQuorumMembers (llmqType, util_params );
156151 if (LogAcceptDebug (BCLog::LLMQ)) {
157152 std::stringstream ss;
158153 std::stringstream ss2;
@@ -176,7 +171,7 @@ bool CFinalCommitment::Verify(CDeterministicMNManager& dmnman, CQuorumSnapshotMa
176171
177172 // sigs are only checked when the block is processed
178173 if (checkSigs) {
179- if (!VerifySignatureAsync (dmnman, qsnapman, chainman, pQuorumBaseBlockIndex, nullptr )) {
174+ if (!VerifySignatureAsync (util_params, /* queue_control= */ nullptr )) {
180175 return false ;
181176 }
182177 }
@@ -215,20 +210,18 @@ bool CFinalCommitment::VerifySizes(const Consensus::LLMQParams& params) const
215210 return true ;
216211}
217212
218- bool CheckLLMQCommitment (CDeterministicMNManager& dmnman, CQuorumSnapshotManager& qsnapman,
219- const ChainstateManager& chainman, const CTransaction& tx,
220- gsl::not_null<const CBlockIndex*> pindexPrev, TxValidationState& state)
213+ bool CheckLLMQCommitment (const llmq::UtilParameters& util_params, const CTransaction& tx, TxValidationState& state)
221214{
222215 const auto opt_qcTx = GetTxPayload<CFinalCommitmentTxPayload>(tx);
223216 if (!opt_qcTx) {
224- LogPrint (BCLog::LLMQ, " CFinalCommitment -- h[%d] GetTxPayload LLMQCommitment failed\n " , pindexPrev ->nHeight );
217+ LogPrint (BCLog::LLMQ, " CFinalCommitment -- h[%d] GetTxPayload LLMQCommitment failed\n " , util_params. m_base_index ->nHeight );
225218 return state.Invalid (TxValidationResult::TX_CONSENSUS, " bad-qc-payload" );
226219 }
227220 auto & qcTx = *opt_qcTx;
228221
229222 const auto & llmq_params_opt = Params ().GetLLMQ (qcTx.commitment .llmqType );
230223 if (!llmq_params_opt.has_value ()) {
231- LogPrint (BCLog::LLMQ, " CFinalCommitment -- h[%d] GetLLMQ failed for llmqType[%d]\n " , pindexPrev ->nHeight , ToUnderlying (qcTx.commitment .llmqType ));
224+ LogPrint (BCLog::LLMQ, " CFinalCommitment -- h[%d] GetLLMQ failed for llmqType[%d]\n " , util_params. m_base_index ->nHeight , ToUnderlying (qcTx.commitment .llmqType ));
232225 return state.Invalid (TxValidationResult::TX_CONSENSUS, " bad-qc-commitment-type" );
233226 }
234227
@@ -242,40 +235,39 @@ bool CheckLLMQCommitment(CDeterministicMNManager& dmnman, CQuorumSnapshotManager
242235 }
243236
244237 if (qcTx.nVersion == 0 || qcTx.nVersion > CFinalCommitmentTxPayload::CURRENT_VERSION) {
245- LogPrint (BCLog::LLMQ, " CFinalCommitment -- h[%d] invalid qcTx.nVersion[%d]\n " , pindexPrev ->nHeight , qcTx.nVersion );
238+ LogPrint (BCLog::LLMQ, " CFinalCommitment -- h[%d] invalid qcTx.nVersion[%d]\n " , util_params. m_base_index ->nHeight , qcTx.nVersion );
246239 return state.Invalid (TxValidationResult::TX_CONSENSUS, " bad-qc-version" );
247240 }
248241
249- if (qcTx.nHeight != uint32_t (pindexPrev ->nHeight + 1 )) {
250- LogPrint (BCLog::LLMQ, " CFinalCommitment -- h[%d] invalid qcTx.nHeight[%d]\n " , pindexPrev ->nHeight , qcTx.nHeight );
242+ if (qcTx.nHeight != uint32_t (util_params. m_base_index ->nHeight + 1 )) {
243+ LogPrint (BCLog::LLMQ, " CFinalCommitment -- h[%d] invalid qcTx.nHeight[%d]\n " , util_params. m_base_index ->nHeight , qcTx.nHeight );
251244 return state.Invalid (TxValidationResult::TX_CONSENSUS, " bad-qc-height" );
252245 }
253246
254- const CBlockIndex* pQuorumBaseBlockIndex = WITH_LOCK (::cs_main, return chainman .m_blockman .LookupBlockIndex (qcTx.commitment .quorumHash ));
247+ const CBlockIndex* pQuorumBaseBlockIndex = WITH_LOCK (::cs_main, return util_params. m_chainman .m_blockman .LookupBlockIndex (qcTx.commitment .quorumHash ));
255248 if (pQuorumBaseBlockIndex == nullptr ) {
256249 return state.Invalid (TxValidationResult::TX_CONSENSUS, " bad-qc-quorum-hash" );
257250 }
258251
259-
260- if (pQuorumBaseBlockIndex != pindexPrev->GetAncestor (pQuorumBaseBlockIndex->nHeight )) {
252+ if (pQuorumBaseBlockIndex != util_params.m_base_index ->GetAncestor (pQuorumBaseBlockIndex->nHeight )) {
261253 // not part of active chain
262254 return state.Invalid (TxValidationResult::TX_CONSENSUS, " bad-qc-quorum-hash" );
263255 }
264256
265257 if (qcTx.commitment .IsNull ()) {
266258 if (!qcTx.commitment .VerifyNull ()) {
267- LogPrint (BCLog::LLMQ, " CFinalCommitment -- h[%d] invalid qcTx.commitment[%s] VerifyNull failed\n " , pindexPrev ->nHeight , qcTx.commitment .quorumHash .ToString ());
259+ LogPrint (BCLog::LLMQ, " CFinalCommitment -- h[%d] invalid qcTx.commitment[%s] VerifyNull failed\n " , util_params. m_base_index ->nHeight , qcTx.commitment .quorumHash .ToString ());
268260 return state.Invalid (TxValidationResult::TX_CONSENSUS, " bad-qc-invalid-null" );
269261 }
270262 return true ;
271263 }
272264
273- if (!qcTx.commitment .Verify (dmnman, qsnapman, chainman, pQuorumBaseBlockIndex, false )) {
274- LogPrint (BCLog::LLMQ, " CFinalCommitment -- h[%d] invalid qcTx.commitment[%s] Verify failed\n " , pindexPrev ->nHeight , qcTx.commitment .quorumHash .ToString ());
265+ if (!qcTx.commitment .Verify (util_params. replace_index ( pQuorumBaseBlockIndex) , false )) {
266+ LogPrint (BCLog::LLMQ, " CFinalCommitment -- h[%d] invalid qcTx.commitment[%s] Verify failed\n " , util_params. m_base_index ->nHeight , qcTx.commitment .quorumHash .ToString ());
275267 return state.Invalid (TxValidationResult::TX_CONSENSUS, " bad-qc-invalid" );
276268 }
277269
278- LogPrint (BCLog::LLMQ, " CFinalCommitment -- h[%d] CheckLLMQCommitment VALID\n " , pindexPrev ->nHeight );
270+ LogPrint (BCLog::LLMQ, " CFinalCommitment -- h[%d] CheckLLMQCommitment VALID\n " , util_params. m_base_index ->nHeight );
279271
280272 return true ;
281273}
0 commit comments