From 7c6f2c5da6a02fbd73abb0da37d351e597773134 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Thu, 6 Aug 2015 10:02:12 +0200 Subject: [PATCH] Add information to errors in ConnectBlock, CheckBlock Add detailed state information to the errors, as it is no longer being logged downstream. Also add the state information to mempool rejection debug message in ProcessMessages. (cherry picked from commit bitcoin/bitcoin@66daed5e1be7932e08896794ca016ff31c71a1d4) --- src/main.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 5424ad34d..549ac23a5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3181,7 +3181,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin std::vector vChecks; bool fCacheResults = fJustCheck; /* Don't cache results if we're actually connecting blocks (still consult the cache, though) */ if (!ContextualCheckInputs(tx, state, view, fExpensiveChecks, flags, fCacheResults, txdata[i], chainparams.GetConsensus(), consensusBranchId, nScriptCheckThreads ? &vChecks : NULL)) - return false; + return error("ConnectBlock(): CheckInputs on %s failed with %s", + tx.GetHash().ToString(), FormatStateMessage(state)); control.Add(vChecks); } @@ -4585,7 +4586,9 @@ bool CheckBlock(const CBlock& block, // Check transactions for (const CTransaction& tx : block.vtx) if (!CheckTransaction(tx, state, verifier, orchardAuth)) - return error("CheckBlock(): CheckTransaction failed"); + return error("CheckBlock(): CheckTransaction of %s failed with %s", + tx.GetHash().ToString(), + FormatStateMessage(state)); unsigned int nSigOps = 0; for (const CTransaction& tx : block.vtx) @@ -6765,7 +6768,7 @@ bool static ProcessMessage(const CChainParams& chainparams, CNode* pfrom, string { LogPrint("mempool", "%s from peer=%d %s was not accepted into the memory pool: %s\n", tx.GetHash().ToString(), pfrom->id, pfrom->cleanSubVer, - state.GetRejectReason()); + FormatStateMessage(state)); if (state.GetRejectCode() < REJECT_INTERNAL) // Never send AcceptToMemoryPool's internal codes over P2P pfrom->PushMessage("reject", strCommand, state.GetRejectCode(), state.GetRejectReason().substr(0, MAX_REJECT_MESSAGE_LENGTH), inv.hash);