Skip to content

Commit 26e9813

Browse files
committed
fix: assertion in Credit Pool validation during connecting blocks
It can happen because now order of activation of hardforks v20, mn_rr, dip3 can be changed by using testactivationheight on Regtest and no more guarantee about this assertions
1 parent 1e55310 commit 26e9813

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/evo/specialtxman.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,16 +267,20 @@ bool CSpecialTxProcessor::CheckCreditPoolDiffForBlock(const CBlock& block, const
267267

268268
try {
269269
if (!DeploymentActiveAt(*pindex, m_consensus_params, Consensus::DEPLOYMENT_DIP0003)) return true;
270+
if (!DeploymentActiveAt(*pindex, m_consensus_params, Consensus::DEPLOYMENT_DIP0008)) return true;
270271
if (!DeploymentActiveAt(*pindex, m_consensus_params, Consensus::DEPLOYMENT_V20)) return true;
271272

272273
auto creditPoolDiff = GetCreditPoolDiffForBlock(m_cpoolman, m_chainman.m_blockman, m_qman, block, pindex->pprev, m_consensus_params, blockSubsidy, state);
273274
if (!creditPoolDiff.has_value()) return false;
274275

275276
// If we get there we have v20 activated and credit pool amount must be included in block CbTx
277+
if (block.vtx.empty()) {
278+
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-missing-cbtx");
279+
}
276280
const auto& tx = *block.vtx[0];
277-
assert(tx.IsCoinBase());
278-
assert(tx.IsSpecialTxVersion());
279-
assert(tx.nType == TRANSACTION_COINBASE);
281+
if (!tx.IsCoinBase() || !tx.IsSpecialTxVersion() || tx.nType != TRANSACTION_COINBASE) {
282+
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-cbtx-type");
283+
}
280284

281285
const auto opt_cbTx = GetTxPayload<CCbTx>(tx);
282286
if (!opt_cbTx) {

0 commit comments

Comments
 (0)