aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-07-14 16:14:29 +0200
committerMarcoFalke <falke.marco@gmail.com>2020-07-14 16:15:07 +0200
commitb26d62c49acb68d9fe2a2f09e803d05671d0422c (patch)
treeebb1abc3ab5dbce6d0ef4bd8006bd887602ea7ee
parent1a655e89cb4dbdf6c9b47626aff2f06fa4fa4dee (diff)
parentfa9f20b6477a206adf5089398803b45d1a114b6f (diff)
downloadbitcoin-b26d62c49acb68d9fe2a2f09e803d05671d0422c.tar.xz
Merge #18990: log: Properly log txs rejected from mempool
fa9f20b6477a206adf5089398803b45d1a114b6f log: Properly log txs rejected from mempool (MarcoFalke) Pull request description: Currently `CheckTxInputs` rejections from the mempool are the only rejections that log directly and unconditionally to debug.log instead of leaving it to the caller. This has multiple issues: * A rejected RPC transaction will log a redundant failure reason to debug log. All other failures are merely reported to the RPC user. * A rejected p2p transaction will log the failure twice. Once with the `MEMPOOLREJ` flag, and once unconditionally. * A rejected orphan transaction will log no failure. Fix all issues by simply returning the state to the caller, like it is done for all other rejections. The patch includes whitespace fixups to highlight relevant parts of the codebase and simplify review. ACKs for top commit: naumenkogs: utACK fa9f20b6477a206adf5089398803b45d1a114b6f rajarshimaitra: Concept ACK. Compiled and ran tests. `fa9f20b` jnewbery: code review ACK fa9f20b6477a206adf5089398803b45d1a114b6f Tree-SHA512: 86cc17b2a9239c01c4fc3f254ad48ee1d3883266966b9811030176338b9ac3deaea7ea5babfb8bbf739d7440154e30011fede8f9313175f199d4a062af6494f7
-rw-r--r--src/net_processing.cpp8
-rw-r--r--src/validation.cpp5
2 files changed, 8 insertions, 5 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index a776fdb214..089cf2bdb6 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -1989,7 +1989,10 @@ void static ProcessOrphanTx(CConnman* connman, CTxMemPool& mempool, std::set<uin
if (MaybePunishNodeForTx(fromPeer, orphan_state)) {
setMisbehaving.insert(fromPeer);
}
- LogPrint(BCLog::MEMPOOL, " invalid orphan tx %s\n", orphanHash.ToString());
+ LogPrint(BCLog::MEMPOOL, " invalid orphan tx %s from peer=%d. %s\n",
+ orphanHash.ToString(),
+ fromPeer,
+ orphan_state.ToString());
}
// Has inputs but not accepted to mempool
// Probably non-standard or insufficient fee
@@ -2946,8 +2949,7 @@ void ProcessMessage(
// peer simply for relaying a tx that our recentRejects has caught,
// regardless of false positives.
- if (state.IsInvalid())
- {
+ if (state.IsInvalid()) {
LogPrint(BCLog::MEMPOOLREJ, "%s from peer=%d was not accepted: %s\n", tx.GetHash().ToString(),
pfrom.GetId(),
state.ToString());
diff --git a/src/validation.cpp b/src/validation.cpp
index edc623b205..b90ff440be 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -573,8 +573,9 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
CAmount& nConflictingFees = ws.m_conflicting_fees;
size_t& nConflictingSize = ws.m_conflicting_size;
- if (!CheckTransaction(tx, state))
+ if (!CheckTransaction(tx, state)) {
return false; // state filled in by CheckTransaction
+ }
// Coinbase is only valid in a block, not as a loose transaction
if (tx.IsCoinBase())
@@ -684,7 +685,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
CAmount nFees = 0;
if (!Consensus::CheckTxInputs(tx, state, m_view, GetSpendHeight(m_view), nFees)) {
- return error("%s: Consensus::CheckTxInputs: %s, %s", __func__, tx.GetHash().ToString(), state.ToString());
+ return false; // state filled in by CheckTxInputs
}
// Check for non-standard pay-to-script-hash in inputs