@@ -808,12 +808,6 @@ class PeerManagerImpl final : public PeerManager
808
808
/* * Stalling timeout for blocks in IBD */
809
809
std::atomic<std::chrono::seconds> m_block_stalling_timeout{BLOCK_STALLING_TIMEOUT_DEFAULT};
810
810
811
- CRollingBloomFilter& RecentRejectsReconsiderableFilter () EXCLUSIVE_LOCKS_REQUIRED(m_tx_download_mutex)
812
- {
813
- AssertLockHeld (m_tx_download_mutex);
814
- return m_txdownloadman.RecentRejectsReconsiderableFilter ();
815
- }
816
-
817
811
/* *
818
812
* For sending `inv`s to inbound peers, we use a single (exponentially
819
813
* distributed) timer for all peers. If we used a separate timer for each
@@ -4239,24 +4233,8 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
4239
4233
4240
4234
LOCK2 (cs_main, m_tx_download_mutex);
4241
4235
4242
- auto & m_txrequest = m_txdownloadman.GetTxRequestRef ();
4243
-
4244
- m_txrequest.ReceivedResponse (pfrom.GetId (), txid);
4245
- if (tx.HasWitness ()) m_txrequest.ReceivedResponse (pfrom.GetId (), wtxid);
4246
-
4247
- // We do the AlreadyHaveTx() check using wtxid, rather than txid - in the
4248
- // absence of witness malleation, this is strictly better, because the
4249
- // recent rejects filter may contain the wtxid but rarely contains
4250
- // the txid of a segwit transaction that has been rejected.
4251
- // In the presence of witness malleation, it's possible that by only
4252
- // doing the check with wtxid, we could overlook a transaction which
4253
- // was confirmed with a different witness, or exists in our mempool
4254
- // with a different witness, but this has limited downside:
4255
- // mempool validation does its own lookup of whether we have the txid
4256
- // already; and an adversary can already relay us old transactions
4257
- // (older than our recency filter) if trying to DoS us, without any need
4258
- // for witness malleation.
4259
- if (m_txdownloadman.AlreadyHaveTx (GenTxid::Wtxid (wtxid), /* include_reconsiderable=*/ true )) {
4236
+ const auto & [should_validate, package_to_validate] = m_txdownloadman.ReceivedTx (pfrom.GetId (), ptx);
4237
+ if (!should_validate) {
4260
4238
if (pfrom.HasPermission (NetPermissionFlags::ForceRelay)) {
4261
4239
// Always relay transactions received from peers with forcerelay
4262
4240
// permission, even if they were already in the mempool, allowing
@@ -4271,37 +4249,18 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
4271
4249
}
4272
4250
}
4273
4251
4274
- if (RecentRejectsReconsiderableFilter ().contains (wtxid)) {
4275
- // When a transaction is already in m_lazy_recent_rejects_reconsiderable, we shouldn't submit
4276
- // it by itself again. However, look for a matching child in the orphanage, as it is
4277
- // possible that they succeed as a package.
4278
- LogDebug (BCLog::TXPACKAGES, " found tx %s (wtxid=%s) in reconsiderable rejects, looking for child in orphanage\n " ,
4279
- txid.ToString (), wtxid.ToString ());
4280
- if (auto package_to_validate{m_txdownloadman.Find1P1CPackage (ptx, pfrom.GetId ())}) {
4281
- const auto package_result{ProcessNewPackage (m_chainman.ActiveChainstate (), m_mempool, package_to_validate->m_txns , /* test_accept=*/ false , /* client_maxfeerate=*/ std::nullopt)};
4282
- LogDebug (BCLog::TXPACKAGES, " package evaluation for %s: %s\n " , package_to_validate->ToString (),
4283
- package_result.m_state .IsValid () ? " package accepted" : " package rejected" );
4284
- ProcessPackageResult (package_to_validate.value (), package_result);
4285
- }
4252
+ if (package_to_validate) {
4253
+ const auto package_result{ProcessNewPackage (m_chainman.ActiveChainstate (), m_mempool, package_to_validate->m_txns , /* test_accept=*/ false , /* client_maxfeerate=*/ std::nullopt)};
4254
+ LogDebug (BCLog::TXPACKAGES, " package evaluation for %s: %s\n " , package_to_validate->ToString (),
4255
+ package_result.m_state .IsValid () ? " package accepted" : " package rejected" );
4256
+ ProcessPackageResult (package_to_validate.value (), package_result);
4286
4257
}
4287
- // If a tx is detected by m_lazy_recent_rejects it is ignored. Because we haven't
4288
- // submitted the tx to our mempool, we won't have computed a DoS
4289
- // score for it or determined exactly why we consider it invalid.
4290
- //
4291
- // This means we won't penalize any peer subsequently relaying a DoSy
4292
- // tx (even if we penalized the first peer who gave it to us) because
4293
- // we have to account for m_lazy_recent_rejects showing false positives. In
4294
- // other words, we shouldn't penalize a peer if we aren't *sure* they
4295
- // submitted a DoSy tx.
4296
- //
4297
- // Note that m_lazy_recent_rejects doesn't just record DoSy or invalid
4298
- // transactions, but any tx not accepted by the mempool, which may be
4299
- // due to node policy (vs. consensus). So we can't blanket penalize a
4300
- // peer simply for relaying a tx that our m_lazy_recent_rejects has caught,
4301
- // regardless of false positives.
4302
4258
return ;
4303
4259
}
4304
4260
4261
+ // ReceivedTx should not be telling us to validate the tx and a package.
4262
+ Assume (!package_to_validate.has_value ());
4263
+
4305
4264
const MempoolAcceptResult result = m_chainman.ProcessTransaction (ptx);
4306
4265
const TxValidationState& state = result.m_state ;
4307
4266
0 commit comments