net_processing: move a debug check in VERACK processing earlier
What changed, and why it matters
This commit simply moves an internal consistency check (an `Assume()` assertion) to an earlier point in the code that handles a peer's VERACK message. The check itself and the surrounding logic are unchanged. The author explicitly states this is a non-functional change, meaning it does not alter program behavior in release builds or fix any active bug.
No security action required. Treat as a routine refactoring commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In src/net_processing.cpp, the Assume() block verifying that TxRelay::m_tx_inventory_to_send is empty and m_next_inv_send_time is zero before the version handshake completes is relocated earlier within ProcessMessage for the VERACK case. No logic is added, removed, or modified; the assertion is only repositioned so a future change for private broadcast connections can still benefit from it. Assume() is a debug-only macro in Bitcoin Core and does not affect release behavior.
Changed components
src/net_processing.cppVERACK message processingTxRelay inventory timing debug assertionInspect captured patch +14 / −14
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 9195b494..2d16f2bd 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -3719,6 +3719,20 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
LogInfo("%s", new_peer_msg());
}
+ if (auto tx_relay = peer->GetTxRelay()) {
+ // `TxRelay::m_tx_inventory_to_send` must be empty before the
+ // version handshake is completed as
+ // `TxRelay::m_next_inv_send_time` is first initialised in
+ // `SendMessages` after the verack is received. Any transactions
+ // received during the version handshake would otherwise
+ // immediately be advertised without random delay, potentially
+ // leaking the time of arrival to a spy.
+ Assume(WITH_LOCK(
+ tx_relay->m_tx_inventory_mutex,
+ return tx_relay->m_tx_inventory_to_send.empty() &&
+ tx_relay->m_next_inv_send_time == 0s));
+ }
+
if (pfrom.GetCommonVersion() >= SHORT_IDS_BLOCKS_VERSION) {
// Tell our peer we are willing to provide version 2 cmpctblocks.
// However, we do not request new block announcements using
@@ -3737,20 +3751,6 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
}
}
- if (auto tx_relay = peer->GetTxRelay()) {
- // `TxRelay::m_tx_inventory_to_send` must be empty before the
- // version handshake is completed as
- // `TxRelay::m_next_inv_send_time` is first initialised in
- // `SendMessages` after the verack is received. Any transactions
- // received during the version handshake would otherwise
- // immediately be advertised without random delay, potentially
- // leaking the time of arrival to a spy.
- Assume(WITH_LOCK(
- tx_relay->m_tx_inventory_mutex,
- return tx_relay->m_tx_inventory_to_send.empty() &&
- tx_relay->m_next_inv_send_time == 0s));
- }
-
{
LOCK2(::cs_main, m_tx_download_mutex);
const CNodeState* state = State(pfrom.GetId());
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.