diff options
author | Andrew Chow <github@achow101.com> | 2023-03-20 12:35:36 -0400 |
---|---|---|
committer | Andrew Chow <github@achow101.com> | 2023-03-20 12:42:24 -0400 |
commit | 60f142e395171ab8b093a5dfae59a6a9761b38ab (patch) | |
tree | 3aea1c048dc64cefe19c016ed295eb32ad46756a /src/validation.cpp | |
parent | 40e1c4d4024b8ad35f2511b2e10bf80c5531dfde (diff) | |
parent | 4b7aec2951fe4595946cdc804b0dec1921d79d05 (diff) |
Merge bitcoin/bitcoin#26531: mempool: Add mempool tracepoints
4b7aec2951fe4595946cdc804b0dec1921d79d05 Add mempool tracepoints (virtu)
Pull request description:
This PR adds multiple mempool tracepoints.
| tracepoint | description |
| ------------- | ------------- |
| `mempool:added` | Is called when a transaction enters the mempool |
| `mempool:removed` | ... when a transaction is removed from the mempool |
| `mempool:replaced` | ... when a transaction is replaced in the mempool |
| `mempool:rejected` | ... when a transaction is rejected from entering the mempool |
The tracepoints are further documented in `docs/tracing.md`. Usage is demonstrated in the example script `contrib/tracing/mempool_monitor.py`. Interface tests are provided in `test/functional/interface_usdt_mempool.py`.
The rationale for passing the removal reason as a string instead of numerically is that 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 in this instance the string does not have to be generated but is readily available.
ACKs for top commit:
0xB10C:
ACK 4b7aec2951fe4595946cdc804b0dec1921d79d05
achow101:
ACK 4b7aec2951fe4595946cdc804b0dec1921d79d05
Tree-SHA512: 6deb3ba2d1a061292fb9b0f885f7a5c4d11b109b838102d8a8f4828cd68f5cd03fa3fc64adc6fdf54a08a1eaccce261b0aa90c2b8c33cd5fd3828c8f74978958
Diffstat (limited to 'src/validation.cpp')
-rw-r--r-- | src/validation.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index 5b3a099dfc..d1b941f081 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1074,6 +1074,15 @@ bool MemPoolAccept::Finalize(const ATMPArgs& args, Workspace& ws) hash.ToString(), FormatMoney(ws.m_modified_fees - ws.m_conflicting_fees), (int)entry->GetTxSize() - (int)ws.m_conflicting_size); + TRACE7(mempool, replaced, + it->GetTx().GetHash().data(), + it->GetTxSize(), + it->GetFee(), + std::chrono::duration_cast<std::chrono::duration<std::uint64_t>>(it->GetTime()).count(), + hash.data(), + entry->GetTxSize(), + entry->GetFee() + ); ws.m_replaced_transactions.push_back(it->GetSharedTx()); } m_pool.RemoveStaged(ws.m_all_conflicting, false, MemPoolRemovalReason::REPLACED); @@ -1486,6 +1495,10 @@ MempoolAcceptResult AcceptToMemoryPool(Chainstate& active_chainstate, const CTra for (const COutPoint& hashTx : coins_to_uncache) active_chainstate.CoinsTip().Uncache(hashTx); + TRACE2(mempool, rejected, + tx->GetHash().data(), + result.m_state.GetRejectReason().c_str() + ); } // After we've (potentially) uncached entries, ensure our coins cache is still within its size limits BlockValidationState state_dummy; |