Skip to content

Commit 2266eba

Browse files
committed
[p2p] don't find 1p1cs for reconsiderable txns that are AlreadyHaveTx
This is a slight behavior change: if a transaction is in both reconsiderable rejects and AlreadyHaveTx in another way, we don't try to return a 1p1c package. This is the correct thing to do, as we don't want to reconsider transactions that have multiple things wrong with them. For example, if a transaction is low feerate, and then later found to have a bad signature, we shouldn't try it again in a package.
1 parent fa7027d commit 2266eba

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/node/txdownloadman_impl.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -477,17 +477,7 @@ std::pair<bool, std::optional<PackageToValidate>> TxDownloadManagerImpl::Receive
477477
// already; and an adversary can already relay us old transactions
478478
// (older than our recency filter) if trying to DoS us, without any need
479479
// for witness malleation.
480-
if (AlreadyHaveTx(GenTxid::Wtxid(wtxid), /*include_reconsiderable=*/true)) {
481-
482-
if (RecentRejectsReconsiderableFilter().contains(wtxid)) {
483-
// When a transaction is already in m_lazy_recent_rejects_reconsiderable, we shouldn't submit
484-
// it by itself again. However, look for a matching child in the orphanage, as it is
485-
// possible that they succeed as a package.
486-
LogDebug(BCLog::TXPACKAGES, "found tx %s (wtxid=%s) in reconsiderable rejects, looking for child in orphanage\n",
487-
txid.ToString(), wtxid.ToString());
488-
return std::make_pair(false, Find1P1CPackage(ptx, nodeid));
489-
}
490-
480+
if (AlreadyHaveTx(GenTxid::Wtxid(wtxid), /*include_reconsiderable=*/false)) {
491481
// If a tx is detected by m_lazy_recent_rejects it is ignored. Because we haven't
492482
// submitted the tx to our mempool, we won't have computed a DoS
493483
// score for it or determined exactly why we consider it invalid.
@@ -504,8 +494,16 @@ std::pair<bool, std::optional<PackageToValidate>> TxDownloadManagerImpl::Receive
504494
// peer simply for relaying a tx that our m_lazy_recent_rejects has caught,
505495
// regardless of false positives.
506496
return {false, std::nullopt};
497+
} else if (RecentRejectsReconsiderableFilter().contains(wtxid)) {
498+
// When a transaction is already in m_lazy_recent_rejects_reconsiderable, we shouldn't submit
499+
// it by itself again. However, look for a matching child in the orphanage, as it is
500+
// possible that they succeed as a package.
501+
LogDebug(BCLog::TXPACKAGES, "found tx %s (wtxid=%s) in reconsiderable rejects, looking for child in orphanage\n",
502+
txid.ToString(), wtxid.ToString());
503+
return {false, Find1P1CPackage(ptx, nodeid)};
507504
}
508505

506+
509507
return {true, std::nullopt};
510508
}
511509

0 commit comments

Comments
 (0)