Skip to content

Commit 3b8c178

Browse files
committed
[log] add more logs related to orphan handling
- Whenever a tx is erased. Allows somebody to see which transactions have been erased due to expiry/overflow, not just how many. - Whenever a tx is added to a peer's workset. - AcceptToMemoryPool when a tx is accepted, mirroring the one logged for a tx received from a peer. This allows someone to see all of the transactions that are accepted to mempool just by looking for ATMP logs. - MEMPOOLREJ when a tx is rejected, mirroring the one logged for a tx received from a peer. This allows someone to see all of the transaction rejections by looking at MEMPOOLREJ logs.
1 parent 51b3275 commit 3b8c178

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/net_processing.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2923,6 +2923,11 @@ bool PeerManagerImpl::ProcessOrphanTx(Peer& peer)
29232923

29242924
if (result.m_result_type == MempoolAcceptResult::ResultType::VALID) {
29252925
LogPrint(BCLog::TXPACKAGES, " accepted orphan tx %s (wtxid=%s)\n", orphanHash.ToString(), orphan_wtxid.ToString());
2926+
LogPrint(BCLog::MEMPOOL, "AcceptToMemoryPool: peer=%d: accepted %s (wtxid=%s) (poolsz %u txn, %u kB)\n",
2927+
peer.m_id,
2928+
orphanHash.ToString(),
2929+
orphan_wtxid.ToString(),
2930+
m_mempool.size(), m_mempool.DynamicMemoryUsage() / 1000);
29262931
RelayTransaction(orphanHash, porphanTx->GetWitnessHash());
29272932
m_orphanage.AddChildrenToWorkSet(*porphanTx);
29282933
m_orphanage.EraseTx(orphanHash);
@@ -2937,6 +2942,11 @@ bool PeerManagerImpl::ProcessOrphanTx(Peer& peer)
29372942
orphan_wtxid.ToString(),
29382943
peer.m_id,
29392944
state.ToString());
2945+
LogPrint(BCLog::MEMPOOLREJ, "%s (wtxid=%s) from peer=%d was not accepted: %s\n",
2946+
orphanHash.ToString(),
2947+
orphan_wtxid.ToString(),
2948+
peer.m_id,
2949+
state.ToString());
29402950
// Maybe punish peer that gave us an invalid orphan tx
29412951
MaybePunishNodeForTx(peer.m_id, state);
29422952
}

src/txorphanage.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ int TxOrphanage::EraseTxNoLock(const uint256& txid)
8484
m_orphan_list[old_pos] = it_last;
8585
it_last->second.list_pos = old_pos;
8686
}
87+
const auto& wtxid = it->second.tx->GetWitnessHash();
88+
LogPrint(BCLog::TXPACKAGES, " removed orphan tx %s (wtxid=%s)\n", txid.ToString(), wtxid.ToString());
8789
m_orphan_list.pop_back();
8890
m_wtxid_to_orphan_it.erase(it->second.tx->GetWitnessHash());
8991

@@ -160,6 +162,8 @@ void TxOrphanage::AddChildrenToWorkSet(const CTransaction& tx)
160162
std::set<uint256>& orphan_work_set = m_peer_work_set.try_emplace(elem->second.fromPeer).first->second;
161163
// Add this tx to the work set
162164
orphan_work_set.insert(elem->first);
165+
LogPrint(BCLog::TXPACKAGES, "added %s (wtxid=%s) to peer %d workset\n",
166+
tx.GetHash().ToString(), tx.GetWitnessHash().ToString(), elem->second.fromPeer);
163167
}
164168
}
165169
}

0 commit comments

Comments
 (0)