From cc3e718fe5c980a7111297e23f37de3c89761b16 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Thu, 10 Oct 2024 16:03:30 +0700 Subject: [PATCH] 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 --- src/evo/specialtxman.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/evo/specialtxman.cpp b/src/evo/specialtxman.cpp index e20a9e0d4f7b35..9c76b3b69324d8 100644 --- a/src/evo/specialtxman.cpp +++ b/src/evo/specialtxman.cpp @@ -266,16 +266,20 @@ bool CSpecialTxProcessor::CheckCreditPoolDiffForBlock(const CBlock& block, const try { if (!DeploymentActiveAt(*pindex, m_consensus_params, Consensus::DEPLOYMENT_DIP0003)) return true; + if (!DeploymentActiveAt(*pindex, m_consensus_params, Consensus::DEPLOYMENT_DIP0008)) return true; if (!DeploymentActiveAt(*pindex, m_consensus_params, Consensus::DEPLOYMENT_V20)) return true; auto creditPoolDiff = GetCreditPoolDiffForBlock(m_cpoolman, m_chainman.m_blockman, m_qman, block, pindex->pprev, m_consensus_params, blockSubsidy, state); if (!creditPoolDiff.has_value()) return false; // If we get there we have v20 activated and credit pool amount must be included in block CbTx + if (block.vtx.empty()) { + return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-missing-cbtx"); + } const auto& tx = *block.vtx[0]; - assert(tx.IsCoinBase()); - assert(tx.IsSpecialTxVersion()); - assert(tx.nType == TRANSACTION_COINBASE); + if (!tx.IsCoinBase() || !tx.IsSpecialTxVersion() || tx.nType != TRANSACTION_COINBASE) { + return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-cbtx-type"); + } const auto opt_cbTx = GetTxPayload(tx); if (!opt_cbTx) {