Skip to content

Commit

Permalink
ProcessOrphanTx: remove useless setMisbehaving set
Browse files Browse the repository at this point in the history
Summary:
Original commit:
> This starts empty, and is only added to if we're about to
> exit the function (so we never read from it).

In the Bitcoin ABC codebase, `setMisbehaving` was replaced with `rejectCountPerNode` in D2676, and in D6683 it stopped being used.

This is a backport of [[bitcoin/bitcoin#19498 | core#19498]] [3/5]
bitcoin/bitcoin@4763b51

Depends on D10413

Test Plan: `ninja all check-all`

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

Subscribers: majcosta

Differential Revision: https://reviews.bitcoinabc.org/D10414
  • Loading branch information
PiRK committed Nov 3, 2021
1 parent 4410964 commit e2e197f
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,6 @@ static constexpr uint32_t MAX_GETCFHEADERS_SIZE = 2000;
*/
static constexpr size_t MAX_PCT_ADDR_TO_SEND = 23;

/// How many non standard orphan do we consider from a node before ignoring it.
static constexpr uint32_t MAX_NON_STANDARD_ORPHAN_PER_NODE = 5;

struct COrphanTx {
// When modifying, adapt the copy of this definition in tests/DoS_tests.
CTransactionRef tx;
Expand Down Expand Up @@ -2540,7 +2537,6 @@ void PeerManager::ProcessOrphanTx(const Config &config,
EXCLUSIVE_LOCKS_REQUIRED(cs_main, g_cs_orphans) {
AssertLockHeld(cs_main);
AssertLockHeld(g_cs_orphans);
std::unordered_map<NodeId, uint32_t> rejectCountPerNode;
while (!orphan_work_set.empty()) {
const TxId orphanTxId = *orphan_work_set.begin();
orphan_work_set.erase(orphan_work_set.begin());
Expand All @@ -2559,12 +2555,6 @@ void PeerManager::ProcessOrphanTx(const Config &config,
// transaction).
TxValidationState orphan_state;

auto it = rejectCountPerNode.find(fromPeer);
if (it != rejectCountPerNode.end() &&
it->second > MAX_NON_STANDARD_ORPHAN_PER_NODE) {
continue;
}

if (AcceptToMemoryPool(config, m_mempool, orphan_state, porphanTx,
false /* bypass_limits */,
Amount::zero() /* nAbsurdFee */)) {
Expand All @@ -2585,12 +2575,12 @@ void PeerManager::ProcessOrphanTx(const Config &config,
} else if (orphan_state.GetResult() !=
TxValidationResult::TX_MISSING_INPUTS) {
if (orphan_state.IsInvalid()) {
// Punish peer that gave us an invalid orphan tx
MaybePunishNodeForTx(fromPeer, orphan_state);
LogPrint(BCLog::MEMPOOL,
" invalid orphan tx %s from peer=%d. %s\n",
orphanTxId.ToString(), fromPeer,
orphan_state.ToString());
// Punish peer that gave us an invalid orphan tx
MaybePunishNodeForTx(fromPeer, orphan_state);
}
// Has inputs but not accepted to mempool
// Probably non-standard or insufficient fee
Expand Down

0 comments on commit e2e197f

Please sign in to comment.