MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / ProcessOrphanTx

Method ProcessOrphanTx

src/net_processing.cpp:3256–3291  ·  view source on GitHub ↗

NOTE: the orphan processing used to be uninterruptible and quadratic, which could allow a peer to stall the node for hours with specially crafted transactions. See https://bitcoincore.org/en/2024/07/03/disclose-orphan-dos.

Source from the content-addressed store, hash-verified

3254// NOTE: the orphan processing used to be uninterruptible and quadratic, which could allow a peer to stall the node for
3255// hours with specially crafted transactions. See https://bitcoincore.org/en/2024/07/03/disclose-orphan-dos.
3256bool PeerManagerImpl::ProcessOrphanTx(Peer& peer)
3257{
3258 AssertLockHeld(g_msgproc_mutex);
3259 LOCK2(::cs_main, m_tx_download_mutex);
3260
3261 CTransactionRef porphanTx = nullptr;
3262
3263 while (CTransactionRef porphanTx = m_txdownloadman.GetTxToReconsider(peer.m_id)) {
3264 const MempoolAcceptResult result = m_chainman.ProcessTransaction(porphanTx);
3265 const TxValidationState& state = result.m_state;
3266 const Txid& orphanHash = porphanTx->GetHash();
3267 const Wtxid& orphan_wtxid = porphanTx->GetWitnessHash();
3268
3269 if (result.m_result_type == MempoolAcceptResult::ResultType::VALID) {
3270 LogDebug(BCLog::TXPACKAGES, " accepted orphan tx %s (wtxid=%s)\n", orphanHash.ToString(), orphan_wtxid.ToString());
3271 ProcessValidTx(peer.m_id, porphanTx, result.m_replaced_transactions);
3272 return true;
3273 } else if (state.GetResult() != TxValidationResult::TX_MISSING_INPUTS) {
3274 LogDebug(BCLog::TXPACKAGES, " invalid orphan tx %s (wtxid=%s) from peer=%d. %s\n",
3275 orphanHash.ToString(),
3276 orphan_wtxid.ToString(),
3277 peer.m_id,
3278 state.ToString());
3279
3280 if (Assume(state.IsInvalid() &&
3281 state.GetResult() != TxValidationResult::TX_UNKNOWN &&
3282 state.GetResult() != TxValidationResult::TX_NO_MEMPOOL &&
3283 state.GetResult() != TxValidationResult::TX_RESULT_UNSET)) {
3284 ProcessInvalidTx(peer.m_id, porphanTx, state, /*first_time_failure=*/false);
3285 }
3286 return true;
3287 }
3288 }
3289
3290 return false;
3291}
3292
3293bool PeerManagerImpl::PrepareBlockFilterRequest(CNode& node, Peer& peer,
3294 BlockFilterType filter_type, uint32_t start_height,

Callers

nothing calls this directly

Calls 6

ProcessTransactionMethod · 0.80
GetResultMethod · 0.80
IsInvalidMethod · 0.80
GetTxToReconsiderMethod · 0.45
GetHashMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected