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
This commit is contained in:
Konstantin Akimov 2024-10-10 16:03:30 +07:00
parent 1e55310232
commit 26e9813672
No known key found for this signature in database
GPG Key ID: 2176C4A5D01EA524

View File

@ -267,16 +267,20 @@ bool CSpecialTxProcessor::CheckCreditPoolDiffForBlock(const CBlock& block, const
try { try {
if (!DeploymentActiveAt(*pindex, m_consensus_params, Consensus::DEPLOYMENT_DIP0003)) return true; 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; 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); 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 (!creditPoolDiff.has_value()) return false;
// If we get there we have v20 activated and credit pool amount must be included in block CbTx // 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]; const auto& tx = *block.vtx[0];
assert(tx.IsCoinBase()); if (!tx.IsCoinBase() || !tx.IsSpecialTxVersion() || tx.nType != TRANSACTION_COINBASE) {
assert(tx.IsSpecialTxVersion()); return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-cbtx-type");
assert(tx.nType == TRANSACTION_COINBASE); }
const auto opt_cbTx = GetTxPayload<CCbTx>(tx); const auto opt_cbTx = GetTxPayload<CCbTx>(tx);
if (!opt_cbTx) { if (!opt_cbTx) {