diff options
author | virtu <virtu@cryptic.to> | 2022-11-18 12:56:46 +0000 |
---|---|---|
committer | virtu <virtu@cryptic.to> | 2023-03-20 15:57:31 +0100 |
commit | 4b7aec2951fe4595946cdc804b0dec1921d79d05 (patch) | |
tree | d3d1374fdf84a825671c07e7854786db4b70fa2b /src/txmempool.cpp | |
parent | 635f1900d048e41d18cc1df7e8305a5f397c87a3 (diff) | |
download | bitcoin-4b7aec2951fe4595946cdc804b0dec1921d79d05.tar.xz |
Add mempool tracepoints
Tracepoints for added, removed, replaced, and rejected transactions.
The removal reason is passed as string instead of a numeric value, since
the benefits of not having to maintain a redundant enum-string mapping
seem to outweigh the small cost of string generation. The reject reason
is passed as string as well, although here the string does not have to
be generated but is readily available.
So far, tracepoint PRs typically included two demo scripts: a naive
bpftrace script to show raw tracepoint data and a bcc script for a more
refined view. However, as some of the ongoing changes to bpftrace
introduce a certain degree of unreliability (running some of the
existing bpftrace scripts was not possible with standard kernels and
bpftrace packages on latest stable Ubuntu, Debian, and NixOS), this PR
includes only a single bcc script that fuses the functionality of former
bpftrace and bcc scripts.
Diffstat (limited to 'src/txmempool.cpp')
-rw-r--r-- | src/txmempool.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp index aa04f8a4d0..43579c0dc0 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -20,6 +20,7 @@ #include <util/result.h> #include <util/system.h> #include <util/time.h> +#include <util/trace.h> #include <util/translation.h> #include <validationinterface.h> @@ -464,6 +465,12 @@ void CTxMemPool::addUnchecked(const CTxMemPoolEntry &entry, setEntries &setAnces vTxHashes.emplace_back(tx.GetWitnessHash(), newit); newit->vTxHashesIdx = vTxHashes.size() - 1; + + TRACE3(mempool, added, + entry.GetTx().GetHash().data(), + entry.GetTxSize(), + entry.GetFee() + ); } void CTxMemPool::removeUnchecked(txiter it, MemPoolRemovalReason reason) @@ -479,6 +486,13 @@ void CTxMemPool::removeUnchecked(txiter it, MemPoolRemovalReason reason) // notification. GetMainSignals().TransactionRemovedFromMempool(it->GetSharedTx(), reason, mempool_sequence); } + TRACE5(mempool, removed, + it->GetTx().GetHash().data(), + RemovalReasonToString(reason).c_str(), + it->GetTxSize(), + it->GetFee(), + std::chrono::duration_cast<std::chrono::duration<std::uint64_t>>(it->GetTime()).count() + ); const uint256 hash = it->GetTx().GetHash(); for (const CTxIn& txin : it->GetTx().vin) |