@@ -2919,9 +2919,15 @@ bool PeerManagerImpl::ProcessOrphanTx(Peer& peer)
29192919 const MempoolAcceptResult result = m_chainman.ProcessTransaction (porphanTx);
29202920 const TxValidationState& state = result.m_state ;
29212921 const uint256& orphanHash = porphanTx->GetHash ();
2922+ const uint256& orphan_wtxid = porphanTx->GetWitnessHash ();
29222923
29232924 if (result.m_result_type == MempoolAcceptResult::ResultType::VALID) {
2924- LogPrint (BCLog::MEMPOOL, " accepted orphan tx %s\n " , orphanHash.ToString ());
2925+ LogPrint (BCLog::TXPACKAGES, " accepted orphan tx %s (wtxid=%s)\n " , orphanHash.ToString (), orphan_wtxid.ToString ());
2926+ LogPrint (BCLog::MEMPOOL, " AcceptToMemoryPool: peer=%d: accepted %s (wtxid=%s) (poolsz %u txn, %u kB)\n " ,
2927+ peer.m_id ,
2928+ orphanHash.ToString (),
2929+ orphan_wtxid.ToString (),
2930+ m_mempool.size (), m_mempool.DynamicMemoryUsage () / 1000 );
29252931 RelayTransaction (orphanHash, porphanTx->GetWitnessHash ());
29262932 m_orphanage.AddChildrenToWorkSet (*porphanTx);
29272933 m_orphanage.EraseTx (orphanHash);
@@ -2931,16 +2937,22 @@ bool PeerManagerImpl::ProcessOrphanTx(Peer& peer)
29312937 return true ;
29322938 } else if (state.GetResult () != TxValidationResult::TX_MISSING_INPUTS) {
29332939 if (state.IsInvalid ()) {
2934- LogPrint (BCLog::MEMPOOL , " invalid orphan tx %s from peer=%d. %s\n " ,
2940+ LogPrint (BCLog::TXPACKAGES , " invalid orphan tx %s (wtxid=%s) from peer=%d. %s\n " ,
29352941 orphanHash.ToString (),
2942+ orphan_wtxid.ToString (),
2943+ peer.m_id ,
2944+ state.ToString ());
2945+ LogPrint (BCLog::MEMPOOLREJ, " %s (wtxid=%s) from peer=%d was not accepted: %s\n " ,
2946+ orphanHash.ToString (),
2947+ orphan_wtxid.ToString (),
29362948 peer.m_id ,
29372949 state.ToString ());
29382950 // Maybe punish peer that gave us an invalid orphan tx
29392951 MaybePunishNodeForTx (peer.m_id , state);
29402952 }
29412953 // Has inputs but not accepted to mempool
29422954 // Probably non-standard or insufficient fee
2943- LogPrint (BCLog::MEMPOOL , " removed orphan tx %s\n " , orphanHash.ToString ());
2955+ LogPrint (BCLog::TXPACKAGES , " removed orphan tx %s (wtxid=%s) \n " , orphanHash. ToString (), orphan_wtxid .ToString ());
29442956 if (state.GetResult () != TxValidationResult::TX_WITNESS_STRIPPED) {
29452957 // We can add the wtxid of this transaction to our reject filter.
29462958 // Do not add txids of witness transactions or witness-stripped
@@ -4115,12 +4127,29 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
41154127 // permission, even if they were already in the mempool, allowing
41164128 // the node to function as a gateway for nodes hidden behind it.
41174129 if (!m_mempool.exists (GenTxid::Txid (tx.GetHash ()))) {
4118- LogPrintf (" Not relaying non-mempool transaction %s from forcerelay peer=%d\n " , tx.GetHash ().ToString (), pfrom.GetId ());
4130+ LogPrintf (" Not relaying non-mempool transaction %s (wtxid=%s) from forcerelay peer=%d\n " ,
4131+ tx.GetHash ().ToString (), tx.GetWitnessHash ().ToString (), pfrom.GetId ());
41194132 } else {
4120- LogPrintf (" Force relaying tx %s from peer=%d\n " , tx.GetHash ().ToString (), pfrom.GetId ());
4133+ LogPrintf (" Force relaying tx %s (wtxid=%s) from peer=%d\n " ,
4134+ tx.GetHash ().ToString (), tx.GetWitnessHash ().ToString (), pfrom.GetId ());
41214135 RelayTransaction (tx.GetHash (), tx.GetWitnessHash ());
41224136 }
41234137 }
4138+ // If a tx is detected by m_recent_rejects it is ignored. Because we haven't
4139+ // submitted the tx to our mempool, we won't have computed a DoS
4140+ // score for it or determined exactly why we consider it invalid.
4141+ //
4142+ // This means we won't penalize any peer subsequently relaying a DoSy
4143+ // tx (even if we penalized the first peer who gave it to us) because
4144+ // we have to account for m_recent_rejects showing false positives. In
4145+ // other words, we shouldn't penalize a peer if we aren't *sure* they
4146+ // submitted a DoSy tx.
4147+ //
4148+ // Note that m_recent_rejects doesn't just record DoSy or invalid
4149+ // transactions, but any tx not accepted by the mempool, which may be
4150+ // due to node policy (vs. consensus). So we can't blanket penalize a
4151+ // peer simply for relaying a tx that our m_recent_rejects has caught,
4152+ // regardless of false positives.
41244153 return ;
41254154 }
41264155
@@ -4137,9 +4166,10 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
41374166
41384167 pfrom.m_last_tx_time = GetTime<std::chrono::seconds>();
41394168
4140- LogPrint (BCLog::MEMPOOL, " AcceptToMemoryPool: peer=%d: accepted %s (poolsz %u txn, %u kB)\n " ,
4169+ LogPrint (BCLog::MEMPOOL, " AcceptToMemoryPool: peer=%d: accepted %s (wtxid=%s) ( poolsz %u txn, %u kB)\n " ,
41414170 pfrom.GetId (),
41424171 tx.GetHash ().ToString (),
4172+ tx.GetWitnessHash ().ToString (),
41434173 m_mempool.size (), m_mempool.DynamicMemoryUsage () / 1000 );
41444174
41454175 for (const CTransactionRef& removedTx : result.m_replaced_transactions .value ()) {
@@ -4191,7 +4221,9 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
41914221 // DoS prevention: do not allow m_orphanage to grow unbounded (see CVE-2012-3789)
41924222 m_orphanage.LimitOrphans (m_opts.max_orphan_txs );
41934223 } else {
4194- LogPrint (BCLog::MEMPOOL, " not keeping orphan with rejected parents %s\n " ,tx.GetHash ().ToString ());
4224+ LogPrint (BCLog::MEMPOOL, " not keeping orphan with rejected parents %s (wtxid=%s)\n " ,
4225+ tx.GetHash ().ToString (),
4226+ tx.GetWitnessHash ().ToString ());
41954227 // We will continue to reject this tx since it has rejected
41964228 // parents so avoid re-requesting it from other peers.
41974229 // Here we add both the txid and the wtxid, as we know that
@@ -4238,25 +4270,10 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
42384270 }
42394271 }
42404272
4241- // If a tx has been detected by m_recent_rejects, we will have reached
4242- // this point and the tx will have been ignored. Because we haven't
4243- // submitted the tx to our mempool, we won't have computed a DoS
4244- // score for it or determined exactly why we consider it invalid.
4245- //
4246- // This means we won't penalize any peer subsequently relaying a DoSy
4247- // tx (even if we penalized the first peer who gave it to us) because
4248- // we have to account for m_recent_rejects showing false positives. In
4249- // other words, we shouldn't penalize a peer if we aren't *sure* they
4250- // submitted a DoSy tx.
4251- //
4252- // Note that m_recent_rejects doesn't just record DoSy or invalid
4253- // transactions, but any tx not accepted by the mempool, which may be
4254- // due to node policy (vs. consensus). So we can't blanket penalize a
4255- // peer simply for relaying a tx that our m_recent_rejects has caught,
4256- // regardless of false positives.
4257-
42584273 if (state.IsInvalid ()) {
4259- LogPrint (BCLog::MEMPOOLREJ, " %s from peer=%d was not accepted: %s\n " , tx.GetHash ().ToString (),
4274+ LogPrint (BCLog::MEMPOOLREJ, " %s (wtxid=%s) from peer=%d was not accepted: %s\n " ,
4275+ tx.GetHash ().ToString (),
4276+ tx.GetWitnessHash ().ToString (),
42604277 pfrom.GetId (),
42614278 state.ToString ());
42624279 MaybePunishNodeForTx (pfrom.GetId (), state);
0 commit comments