Skip to content

Commit b191c7d

Browse files
committed
doc: add comment explaining recentRejects-DoS behavior
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.
1 parent 4de0b5f commit b191c7d

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)