@@ -61,9 +61,9 @@ static bool CheckSpecialTxInner(CDeterministicMNManager& dmnman, llmq::CQuorumSn
6161 case TRANSACTION_MNHF_SIGNAL:
6262 return CheckMNHFTx (chainman, qman, tx, pindexPrev, state);
6363 case TRANSACTION_ASSET_LOCK:
64- return CheckAssetLockUnlockTx (chainman. m_blockman , qman, tx, pindexPrev, indexes , state);
64+ return CheckAssetLockTx (tx , state);
6565 case TRANSACTION_ASSET_UNLOCK:
66- return CheckAssetLockUnlockTx (chainman.m_blockman , qman, tx, pindexPrev, indexes, state);
66+ return CheckAssetUnlockTx (chainman.m_blockman , qman, tx, pindexPrev, indexes, state);
6767 }
6868 } catch (const std::exception& e) {
6969 LogPrintf (" %s -- failed: %s\n " , __func__, e.what ());
@@ -95,7 +95,7 @@ bool CSpecialTxProcessor::ProcessSpecialTxsInBlock(const CBlock& block, const CB
9595 static int64_t nTimePayload = 0 ;
9696 static int64_t nTimeCreditPool = 0 ;
9797
98- int64_t nTime0 = GetTimeMicros ();
98+ int64_t nTime1 = GetTimeMicros ();
9999
100100 std::optional<CCbTx> opt_cbTx{std::nullopt };
101101 if (fCheckCbTxMerkleRoots && block.vtx .size () > 0 && block.vtx [0 ]->nType == TRANSACTION_COINBASE) {
@@ -117,29 +117,18 @@ bool CSpecialTxProcessor::ProcessSpecialTxsInBlock(const CBlock& block, const CB
117117 }
118118 }
119119
120- int64_t nTime1 = GetTimeMicros ();
121- nTimePayload += nTime1 - nTime0 ;
122- LogPrint (BCLog::BENCHMARK, " - GetTxPayload: %.2fms [%.2fs]\n " , 0.001 * (nTime1 - nTime0 ),
120+ int64_t nTime2 = GetTimeMicros ();
121+ nTimePayload += nTime2 - nTime1 ;
122+ LogPrint (BCLog::BENCHMARK, " - GetTxPayload: %.2fms [%.2fs]\n " , 0.001 * (nTime2 - nTime1 ),
123123 nTimePayload * 0.000001 );
124124
125- const CCreditPool creditPool = m_cpoolman. GetCreditPool (pindex-> pprev , m_consensus_params) ;
125+ CRangesSet indexes ;
126126 if (DeploymentActiveAt (*pindex, m_consensus_params, Consensus::DEPLOYMENT_V20)) {
127+ CCreditPool creditPool{m_cpoolman.GetCreditPool (pindex->pprev , m_consensus_params)};
127128 LogPrint (BCLog::CREDITPOOL, " CSpecialTxProcessor::%s -- CCreditPool is %s\n " , __func__, creditPool.ToString ());
129+ indexes = std::move (creditPool.indexes );
128130 }
129131
130- if (fCheckCbTxMerkleRoots && block.vtx [0 ]->nType == TRANSACTION_COINBASE) {
131- CAmount blockSubsidy = GetBlockSubsidy (pindex, m_consensus_params);
132- if (!CheckCreditPoolDiffForBlock (block, pindex, *opt_cbTx, blockSubsidy, state)) {
133- return error (" CSpecialTxProcessor: CheckCreditPoolDiffForBlock for block %s failed with %s" ,
134- pindex->GetBlockHash ().ToString (), state.ToString ());
135- }
136- }
137-
138- int64_t nTime1_1 = GetTimeMicros ();
139- nTimeCreditPool += nTime1_1 - nTime1;
140- LogPrint (BCLog::BENCHMARK, " - CheckCreditPoolDiffForBlock: %.2fms [%.2fs]\n " , 0.001 * (nTime1_1 - nTime1),
141- nTimeCreditPool * 0.000001 );
142-
143132 for (size_t i = 0 ; i < block.vtx .size (); ++i) {
144133 // we validated CCbTx above, starts from the 2nd transaction
145134 if (i == 0 && block.vtx [i]->nType == TRANSACTION_COINBASE) continue ;
@@ -148,26 +137,40 @@ bool CSpecialTxProcessor::ProcessSpecialTxsInBlock(const CBlock& block, const CB
148137 TxValidationState tx_state;
149138 // At this moment CheckSpecialTx() may fail by 2 possible ways:
150139 // consensus failures and "TX_BAD_SPECIAL"
151- if (!CheckSpecialTxInner (m_dmnman, m_qsnapman, m_chainman, m_qman, *ptr_tx, pindex->pprev , view,
152- creditPool. indexes , fCheckCbTxMerkleRoots , tx_state)) {
140+ if (!CheckSpecialTxInner (m_dmnman, m_qsnapman, m_chainman, m_qman, *ptr_tx, pindex->pprev , view, indexes,
141+ fCheckCbTxMerkleRoots , tx_state)) {
153142 assert (tx_state.GetResult () == TxValidationResult::TX_CONSENSUS || tx_state.GetResult () == TxValidationResult::TX_BAD_SPECIAL);
154143 return state.Invalid (BlockValidationResult::BLOCK_CONSENSUS, tx_state.GetRejectReason (),
155144 strprintf (" Special Transaction check failed (tx hash %s) %s" , ptr_tx->GetHash ().ToString (), tx_state.GetDebugMessage ()));
156145 }
157146 }
158147
159- int64_t nTime2 = GetTimeMicros ();
160- nTimeLoop += nTime2 - nTime1_1;
161- LogPrint (BCLog::BENCHMARK, " - Loop: %.2fms [%.2fs]\n " , 0.001 * (nTime2 - nTime1_1), nTimeLoop * 0.000001 );
148+ int64_t nTime3 = GetTimeMicros ();
149+ nTimeLoop += nTime3 - nTime2;
150+ LogPrint (BCLog::BENCHMARK, " - Loop: %.2fms [%.2fs]\n " , 0.001 * (nTime3 - nTime2), nTimeLoop * 0.000001 );
151+
152+ if (fCheckCbTxMerkleRoots && block.vtx [0 ]->nType == TRANSACTION_COINBASE) {
153+ CAmount blockSubsidy = GetBlockSubsidy (pindex, m_consensus_params);
154+ if (!CheckCreditPoolDiffForBlock (block, pindex, *opt_cbTx, blockSubsidy, state)) {
155+ return error (" CSpecialTxProcessor: CheckCreditPoolDiffForBlock for block %s failed with %s" ,
156+ pindex->GetBlockHash ().ToString (), state.ToString ());
157+ }
158+ }
159+
160+ int64_t nTime4 = GetTimeMicros ();
161+ nTimeCreditPool += nTime4 - nTime3;
162+ LogPrint (BCLog::BENCHMARK, " - CheckCreditPoolDiffForBlock: %.2fms [%.2fs]\n " , 0.001 * (nTime4 - nTime3),
163+ nTimeCreditPool * 0.000001 );
162164
163165 if (!m_qblockman.ProcessBlock (block, pindex, state, fJustCheck , fCheckCbTxMerkleRoots )) {
164166 // pass the state returned by the function above
165167 return false ;
166168 }
167169
168- int64_t nTime3 = GetTimeMicros ();
169- nTimeQuorum += nTime3 - nTime2;
170- LogPrint (BCLog::BENCHMARK, " - m_qblockman: %.2fms [%.2fs]\n " , 0.001 * (nTime3 - nTime2), nTimeQuorum * 0.000001 );
170+ int64_t nTime5 = GetTimeMicros ();
171+ nTimeQuorum += nTime5 - nTime4;
172+ LogPrint (BCLog::BENCHMARK, " - m_qblockman: %.2fms [%.2fs]\n " , 0.001 * (nTime5 - nTime4),
173+ nTimeQuorum * 0.000001 );
171174
172175
173176 CDeterministicMNList mn_list;
@@ -184,41 +187,44 @@ bool CSpecialTxProcessor::ProcessSpecialTxsInBlock(const CBlock& block, const CB
184187 }
185188 }
186189
187- int64_t nTime4 = GetTimeMicros ();
188- nTimeDMN += nTime4 - nTime3;
189- LogPrint (BCLog::BENCHMARK, " - m_dmnman: %.2fms [%.2fs]\n " , 0.001 * (nTime4 - nTime3), nTimeDMN * 0.000001 );
190+ int64_t nTime6 = GetTimeMicros ();
191+ nTimeDMN += nTime6 - nTime5;
190192
191- int64_t nTime5{nTime4};
192- if (fCheckCbTxMerkleRoots && block.vtx [0 ]->nType == TRANSACTION_COINBASE) {
193+ LogPrint (BCLog::BENCHMARK, " - m_dmnman: %.2fms [%.2fs]\n " , 0.001 * (nTime6 - nTime5), nTimeDMN * 0.000001 );
194+
195+ if (opt_cbTx.has_value ()) {
193196 if (!CheckCbTxMerkleRoots (block, *opt_cbTx, pindex, m_qblockman, CSimplifiedMNList (mn_list), state)) {
194197 // pass the state returned by the function above
195198 return false ;
196199 }
200+ }
197201
198- nTime5 = GetTimeMicros ();
199- nTimeMerkle += nTime5 - nTime4 ;
202+ int64_t nTime7 = GetTimeMicros ();
203+ nTimeMerkle += nTime7 - nTime6 ;
200204
201- LogPrint (BCLog::BENCHMARK, " - CheckCbTxMerkleRoots: %.2fms [%.2fs]\n " , 0.001 * (nTime5 - nTime4 ),
202- nTimeMerkle * 0.000001 );
205+ LogPrint (BCLog::BENCHMARK, " - CheckCbTxMerkleRoots: %.2fms [%.2fs]\n " , 0.001 * (nTime7 - nTime6 ),
206+ nTimeMerkle * 0.000001 );
203207
208+ if (opt_cbTx.has_value ()) {
204209 if (!CheckCbTxBestChainlock (*opt_cbTx, pindex, m_clhandler, state)) {
205210 // pass the state returned by the function above
206211 return false ;
207212 }
208213 }
209214
210- int64_t nTime6 = GetTimeMicros ();
211- nTimeCbTxCL += nTime6 - nTime5;
212- LogPrint (BCLog::BENCHMARK, " - CheckCbTxBestChainlock: %.2fms [%.2fs]\n " , 0.001 * (nTime6 - nTime5), nTimeCbTxCL * 0.000001 );
215+ int64_t nTime8 = GetTimeMicros ();
216+ nTimeCbTxCL += nTime8 - nTime7;
217+ LogPrint (BCLog::BENCHMARK, " - CheckCbTxBestChainlock: %.2fms [%.2fs]\n " , 0.001 * (nTime8 - nTime7),
218+ nTimeCbTxCL * 0.000001 );
213219
214220 if (!m_mnhfman.ProcessBlock (block, pindex, fJustCheck , state)) {
215221 // pass the state returned by the function above
216222 return false ;
217223 }
218224
219- int64_t nTime7 = GetTimeMicros ();
220- nTimeMnehf += nTime7 - nTime6 ;
221- LogPrint (BCLog::BENCHMARK, " - m_mnhfman: %.2fms [%.2fs]\n " , 0.001 * (nTime7 - nTime6 ), nTimeMnehf * 0.000001 );
225+ int64_t nTime9 = GetTimeMicros ();
226+ nTimeMnehf += nTime9 - nTime8 ;
227+ LogPrint (BCLog::BENCHMARK, " - m_mnhfman: %.2fms [%.2fs]\n " , 0.001 * (nTime9 - nTime8 ), nTimeMnehf * 0.000001 );
222228
223229 if (DeploymentActiveAfter (pindex, m_consensus_params, Consensus::DEPLOYMENT_V19) && bls::bls_legacy_scheme.load ()) {
224230 // NOTE: The block next to the activation is the one that is using new rules.
0 commit comments