diff options
author | glozow <gloriajzhao@gmail.com> | 2023-07-24 16:09:50 +0100 |
---|---|---|
committer | glozow <gloriajzhao@gmail.com> | 2023-08-29 16:41:22 +0100 |
commit | 3b8c17838a561616fd7c933753c7b98b6c6c7c99 (patch) | |
tree | 00a5852ffc20a0c5e50b95c451d6ca0c1c4b7c4e /src | |
parent | 51b3275cd1de467933f13d8b71286bf5ebd12b4b (diff) |
[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.
Diffstat (limited to 'src')
-rw-r--r-- | src/net_processing.cpp | 10 | ||||
-rw-r--r-- | src/txorphanage.cpp | 4 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp index a0946754a0..ec8230fd68 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -2923,6 +2923,11 @@ bool PeerManagerImpl::ProcessOrphanTx(Peer& peer) if (result.m_result_type == MempoolAcceptResult::ResultType::VALID) { LogPrint(BCLog::TXPACKAGES, " accepted orphan tx %s (wtxid=%s)\n", orphanHash.ToString(), orphan_wtxid.ToString()); + LogPrint(BCLog::MEMPOOL, "AcceptToMemoryPool: peer=%d: accepted %s (wtxid=%s) (poolsz %u txn, %u kB)\n", + peer.m_id, + orphanHash.ToString(), + orphan_wtxid.ToString(), + m_mempool.size(), m_mempool.DynamicMemoryUsage() / 1000); RelayTransaction(orphanHash, porphanTx->GetWitnessHash()); m_orphanage.AddChildrenToWorkSet(*porphanTx); m_orphanage.EraseTx(orphanHash); @@ -2937,6 +2942,11 @@ bool PeerManagerImpl::ProcessOrphanTx(Peer& peer) orphan_wtxid.ToString(), peer.m_id, state.ToString()); + LogPrint(BCLog::MEMPOOLREJ, "%s (wtxid=%s) from peer=%d was not accepted: %s\n", + orphanHash.ToString(), + orphan_wtxid.ToString(), + peer.m_id, + state.ToString()); // Maybe punish peer that gave us an invalid orphan tx MaybePunishNodeForTx(peer.m_id, state); } diff --git a/src/txorphanage.cpp b/src/txorphanage.cpp index 4fed6a60ed..7455d914e8 100644 --- a/src/txorphanage.cpp +++ b/src/txorphanage.cpp @@ -84,6 +84,8 @@ int TxOrphanage::EraseTxNoLock(const uint256& txid) m_orphan_list[old_pos] = it_last; it_last->second.list_pos = old_pos; } + const auto& wtxid = it->second.tx->GetWitnessHash(); + LogPrint(BCLog::TXPACKAGES, " removed orphan tx %s (wtxid=%s)\n", txid.ToString(), wtxid.ToString()); m_orphan_list.pop_back(); m_wtxid_to_orphan_it.erase(it->second.tx->GetWitnessHash()); @@ -160,6 +162,8 @@ void TxOrphanage::AddChildrenToWorkSet(const CTransaction& tx) std::set<uint256>& orphan_work_set = m_peer_work_set.try_emplace(elem->second.fromPeer).first->second; // Add this tx to the work set orphan_work_set.insert(elem->first); + LogPrint(BCLog::TXPACKAGES, "added %s (wtxid=%s) to peer %d workset\n", + tx.GetHash().ToString(), tx.GetWitnessHash().ToString(), elem->second.fromPeer); } } } |