From 041a1c26d091e5623e510f0716872289e8e59510 Mon Sep 17 00:00:00 2001 From: Alexander Block Date: Wed, 6 Mar 2019 07:58:27 +0100 Subject: [PATCH] Move safe TX checks into TestForBlock and TestPackageTransactions Otherwise we'll miss checks for ancestors. --- src/miner.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 64fd4fc93f..c4c8490693 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -287,11 +287,15 @@ bool BlockAssembler::TestPackage(uint64_t packageSize, unsigned int packageSigOp // Perform transaction-level checks before adding to block: // - transaction finality (locktime) +// - safe TXs in regard to ChainLocks bool BlockAssembler::TestPackageTransactions(const CTxMemPool::setEntries& package) { BOOST_FOREACH (const CTxMemPool::txiter it, package) { if (!IsFinalTx(it->GetTx(), nHeight, nLockTimeCutoff)) return false; + if (!llmq::chainLocksHandler->IsTxSafeForMining(it->GetTx().GetHash())) { + return false; + } } return true; } @@ -333,6 +337,10 @@ bool BlockAssembler::TestForBlock(CTxMemPool::txiter iter) if (!IsFinalTx(iter->GetTx(), nHeight, nLockTimeCutoff)) return false; + if (!llmq::chainLocksHandler->IsTxSafeForMining(iter->GetTx().GetHash())) { + return false; + } + return true; } @@ -454,12 +462,6 @@ void BlockAssembler::addPackageTxs(int &nPackagesSelected, int &nDescendantsUpda continue; } - if (mi != mempool.mapTx.get().end() && - !llmq::chainLocksHandler->IsTxSafeForMining(mi->GetTx().GetHash())) { - ++mi; - continue; - } - // Now that mi is not stale, determine which transaction to evaluate: // the next entry from mapTx, or the best from mapModifiedTx? bool fUsingModified = false; @@ -530,7 +532,7 @@ void BlockAssembler::addPackageTxs(int &nPackagesSelected, int &nDescendantsUpda onlyUnconfirmed(ancestors); ancestors.insert(iter); - // Test if all tx's are Final + // Test if all tx's are Final and safe if (!TestPackageTransactions(ancestors)) { if (fUsingModified) { mapModifiedTx.get().erase(modit); @@ -608,10 +610,6 @@ void BlockAssembler::addPriorityTxs() continue; } - if (!llmq::chainLocksHandler->IsTxSafeForMining(iter->GetTx().GetHash())) { - continue; - } - // If this tx fits in the block add it, otherwise keep looping if (TestForBlock(iter)) { AddToBlock(iter);