Skip to content

Commit 041a1c2

Browse files
committed
Move safe TX checks into TestForBlock and TestPackageTransactions
Otherwise we'll miss checks for ancestors.
1 parent 4d3365d commit 041a1c2

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/miner.cpp

+9-11
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,15 @@ bool BlockAssembler::TestPackage(uint64_t packageSize, unsigned int packageSigOp
287287

288288
// Perform transaction-level checks before adding to block:
289289
// - transaction finality (locktime)
290+
// - safe TXs in regard to ChainLocks
290291
bool BlockAssembler::TestPackageTransactions(const CTxMemPool::setEntries& package)
291292
{
292293
BOOST_FOREACH (const CTxMemPool::txiter it, package) {
293294
if (!IsFinalTx(it->GetTx(), nHeight, nLockTimeCutoff))
294295
return false;
296+
if (!llmq::chainLocksHandler->IsTxSafeForMining(it->GetTx().GetHash())) {
297+
return false;
298+
}
295299
}
296300
return true;
297301
}
@@ -333,6 +337,10 @@ bool BlockAssembler::TestForBlock(CTxMemPool::txiter iter)
333337
if (!IsFinalTx(iter->GetTx(), nHeight, nLockTimeCutoff))
334338
return false;
335339

340+
if (!llmq::chainLocksHandler->IsTxSafeForMining(iter->GetTx().GetHash())) {
341+
return false;
342+
}
343+
336344
return true;
337345
}
338346

@@ -454,12 +462,6 @@ void BlockAssembler::addPackageTxs(int &nPackagesSelected, int &nDescendantsUpda
454462
continue;
455463
}
456464

457-
if (mi != mempool.mapTx.get<ancestor_score>().end() &&
458-
!llmq::chainLocksHandler->IsTxSafeForMining(mi->GetTx().GetHash())) {
459-
++mi;
460-
continue;
461-
}
462-
463465
// Now that mi is not stale, determine which transaction to evaluate:
464466
// the next entry from mapTx, or the best from mapModifiedTx?
465467
bool fUsingModified = false;
@@ -530,7 +532,7 @@ void BlockAssembler::addPackageTxs(int &nPackagesSelected, int &nDescendantsUpda
530532
onlyUnconfirmed(ancestors);
531533
ancestors.insert(iter);
532534

533-
// Test if all tx's are Final
535+
// Test if all tx's are Final and safe
534536
if (!TestPackageTransactions(ancestors)) {
535537
if (fUsingModified) {
536538
mapModifiedTx.get<ancestor_score>().erase(modit);
@@ -608,10 +610,6 @@ void BlockAssembler::addPriorityTxs()
608610
continue;
609611
}
610612

611-
if (!llmq::chainLocksHandler->IsTxSafeForMining(iter->GetTx().GetHash())) {
612-
continue;
613-
}
614-
615613
// If this tx fits in the block add it, otherwise keep looping
616614
if (TestForBlock(iter)) {
617615
AddToBlock(iter);

0 commit comments

Comments
 (0)