Skip to content

Commit 11e1ac3

Browse files
author
MarcoFalke
committed
Merge #14436: doc: add comment explaining recentRejects-DoS behavior
b191c7d doc: add comment explaining recentRejects-DoS behavior (James O'Beirne) Pull request description: When we receive invalid txs for the first time, we mark the sender as misbehaving. If we receive the same tx before a new block is seen, we *don't* punish the second sender (in the same way we do the original sender). It wasn't initially clear to me that this is intentional, so add a clarifying comment. Tree-SHA512: d12c674db137ed3ad83e0b941bffe6ddcd2982238048742afa574a4235881f0e58cfc0a4a576a0503e74c5c5240c270b9520fa30221e8b43a371fb3e0b37066b
2 parents d26d15c + b191c7d commit 11e1ac3

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/net_processing.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2357,6 +2357,23 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
23572357
for (const CTransactionRef& removedTx : lRemovedTxn)
23582358
AddToCompactExtraTransactions(removedTx);
23592359

2360+
// If a tx has been detected by recentRejects, we will have reached
2361+
// this point and the tx will have been ignored. Because we haven't run
2362+
// the tx through AcceptToMemoryPool, we won't have computed a DoS
2363+
// score for it or determined exactly why we consider it invalid.
2364+
//
2365+
// This means we won't penalize any peer subsequently relaying a DoSy
2366+
// tx (even if we penalized the first peer who gave it to us) because
2367+
// we have to account for recentRejects showing false positives. In
2368+
// other words, we shouldn't penalize a peer if we aren't *sure* they
2369+
// submitted a DoSy tx.
2370+
//
2371+
// Note that recentRejects doesn't just record DoSy or invalid
2372+
// transactions, but any tx not accepted by the mempool, which may be
2373+
// due to node policy (vs. consensus). So we can't blanket penalize a
2374+
// peer simply for relaying a tx that our recentRejects has caught,
2375+
// regardless of false positives.
2376+
23602377
int nDoS = 0;
23612378
if (state.IsInvalid(nDoS))
23622379
{

0 commit comments

Comments
 (0)