aboutsummaryrefslogtreecommitdiff
path: root/src/net_processing.cpp
diff options
context:
space:
mode:
authorJames O'Beirne <james.obeirne@gmail.com>2018-10-08 22:19:56 -0400
committerJames O'Beirne <james.obeirne@gmail.com>2018-10-16 13:04:42 -0400
commitb191c7dfb7ede3f74edb3a32b8ac6fa2f4d6b78a (patch)
tree9b90d65e9d3586d0aca2743c40449b66320f8b84 /src/net_processing.cpp
parent4de0b5f39cc35636d499ad29ee3c63384b13fc76 (diff)
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.
Diffstat (limited to 'src/net_processing.cpp')
-rw-r--r--src/net_processing.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index a1b6e021ae..51b545efa0 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -2357,6 +2357,23 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
for (const CTransactionRef& removedTx : lRemovedTxn)
AddToCompactExtraTransactions(removedTx);
+ // If a tx has been detected by recentRejects, we will have reached
+ // this point and the tx will have been ignored. Because we haven't run
+ // the tx through AcceptToMemoryPool, we won't have computed a DoS
+ // score for it or determined exactly why we consider it invalid.
+ //
+ // This means we won't penalize any peer subsequently relaying a DoSy
+ // tx (even if we penalized the first peer who gave it to us) because
+ // we have to account for recentRejects showing false positives. In
+ // other words, we shouldn't penalize a peer if we aren't *sure* they
+ // submitted a DoSy tx.
+ //
+ // Note that recentRejects doesn't just record DoSy or invalid
+ // transactions, but any tx not accepted by the mempool, which may be
+ // due to node policy (vs. consensus). So we can't blanket penalize a
+ // peer simply for relaying a tx that our recentRejects has caught,
+ // regardless of false positives.
+
int nDoS = 0;
if (state.IsInvalid(nDoS))
{