Skip to content

Commit ce63fca

Browse files
committed
[net processing] Assume that TxRelay::m_tx_inventory_to_send is empty pre-verack
This commit documents our assumption about TxRelay::m_tx_inventory_to_send being empty prior to version handshake completion. The added Assume acts as testing oracle for our fuzzing tests to potentially detect if the assumption is violated.
1 parent 845e3a3 commit ce63fca

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/net_processing.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -3435,6 +3435,20 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
34353435
}
34363436
}
34373437

3438+
if (auto tx_relay = peer->GetTxRelay()) {
3439+
// `TxRelay::m_tx_inventory_to_send` must be empty before the
3440+
// version handshake is completed as
3441+
// `TxRelay::m_next_inv_send_time` is first initialised in
3442+
// `SendMessages` after the verack is received. Any transactions
3443+
// received during the version handshake would otherwise
3444+
// immediately be advertised without random delay, potentially
3445+
// leaking the time of arrival to a spy.
3446+
Assume(WITH_LOCK(
3447+
tx_relay->m_tx_inventory_mutex,
3448+
return tx_relay->m_tx_inventory_to_send.empty() &&
3449+
tx_relay->m_next_inv_send_time == 0s));
3450+
}
3451+
34383452
pfrom.fSuccessfullyConnected = true;
34393453
return;
34403454
}

0 commit comments

Comments
 (0)