diff options
author | dergoegge <n.goeggi@gmail.com> | 2022-11-28 16:37:24 +0000 |
---|---|---|
committer | dergoegge <n.goeggi@gmail.com> | 2022-11-30 12:22:05 +0000 |
commit | ce63fca13e9b500e9f687d80a457175ac967a371 (patch) | |
tree | da8471149f62e7d4679bcbb1a29899a7aade9770 | |
parent | 845e3a34c49abcc634b5a10ccdd6b10fb4fcf449 (diff) |
[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.
-rw-r--r-- | src/net_processing.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 70e7eb85d8..6d5eb3a449 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -3435,6 +3435,20 @@ 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)); + } + pfrom.fSuccessfullyConnected = true; return; } |