net: always complete all initial private broadcast connections #36277

Manually merged
andrewtoth merged 2 commits from always_send into master 2026-10-06 07:53:25 +00:00 AGit
andrewtoth commented 2026-09-16 16:47:37 +00:00 (Migrated from github.com)

Make sure we send out all three connections when initiating a private broadcast.

Use MarkResolved instead of Remove to mark a tx as having been received back or mempool-conflicted. Prevent additional stale retry connections by tracking disconnects and explicitly granting new connections with TryGrantRetry.

Intended as an alternative to #34707, addressing the theoretical timing attack described in https://github.com/bitcoin/bitcoin/pull/34707#issuecomment-5603256702. Also fixes theoretical timing attacks described in https://github.com/bitcoin/bitcoin/pull/29415#discussion_r2035693786. This is based on the idea described in https://github.com/bitcoin/bitcoin/pull/29415#discussion_r2037527330:

always send 3 times regardless if the tx is received in our mempool or is otherwise invalid

Make sure we send out all three connections when initiating a private broadcast. Use `MarkResolved` instead of `Remove` to mark a tx as having been received back or mempool-conflicted. Prevent additional stale retry connections by tracking disconnects and explicitly granting new connections with `TryGrantRetry`. Intended as an alternative to #34707, addressing the theoretical timing attack described in https://github.com/bitcoin/bitcoin/pull/34707#issuecomment-5603256702. Also fixes theoretical timing attacks described in https://github.com/bitcoin/bitcoin/pull/29415#discussion_r2035693786. This is based on the idea described in https://github.com/bitcoin/bitcoin/pull/29415#discussion_r2037527330: > always send 3 times regardless if the tx is received in our mempool or is otherwise invalid
DrahtBot commented 2026-09-16 16:47:47 +00:00 (Migrated from github.com)

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
ACK vasild, mzumsande, sedited
Concept ACK optout21, danielabrozzoni

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #36429 (Delayed transaction broadcast, minimal by optout21)
  • #35502 (refactor: extract per-message helpers from ProcessMessage (move-only) by w0xlt)
  • #34707 (net: keep finished private broadcast txs in memory by andrewtoth)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36277 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36277.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36277#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | ACK | [vasild](https://github.com/bitcoin/bitcoin/pull/36277#pullrequestreview-5415903141), [mzumsande](https://github.com/bitcoin/bitcoin/pull/36277#pullrequestreview-5416048399), [sedited](https://github.com/bitcoin/bitcoin/pull/36277#pullrequestreview-5425274885) | | Concept ACK | [optout21](https://github.com/bitcoin/bitcoin/pull/36277#pullrequestreview-5336334514), [danielabrozzoni](https://github.com/bitcoin/bitcoin/pull/36277#pullrequestreview-5424308465) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#36429](https://github.com/bitcoin/bitcoin/pull/36429) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36429.svg"></sub> (Delayed transaction broadcast, minimal by optout21) * [#35502](https://github.com/bitcoin/bitcoin/pull/35502) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35502.svg"></sub> (refactor: extract per-message helpers from ProcessMessage (move-only) by w0xlt) * [#34707](https://github.com/bitcoin/bitcoin/pull/34707) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/34707.svg"></sub> (net: keep finished private broadcast txs in memory by andrewtoth) If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. <!--5faf32d7da4f0f540f40219e4f7537a3-->
vasild commented 2026-09-16 17:07:58 +00:00 (Migrated from github.com)

Concept ACK, will review

Concept ACK, will review
vasild (Migrated from github.com) reviewed 2026-09-18 17:19:18 +00:00
vasild (Migrated from github.com) left a comment

Approach ACK e4204baff7

The code looks solid. It introduces a rigid number of times a transaction will be broadcast, regardless of whether it is received back or not. It starts at 3 and may be incremented if the transaction is stale in order to induce a new broadcast.

It also tracks when the connections are closed so that it does not remove a transaction from the list in the middle of a connection.

I did not review the tests yet. Will review them for a full ACK.

Thanks!

Show Signature
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Approach ACK e4204baff71dfef93597ce5c92ee8111b5b380b0

The code looks solid. It introduces a rigid number of times a transaction will be broadcast, regardless of whether it is received back or not. It starts at 3 and may be incremented if the transaction is stale in order to induce a new broadcast.

It also tracks when the connections are closed so that it does not remove a transaction from the list in the middle of a connection.

I did not review the tests yet. Will review them for a full ACK.

Thanks!
-----BEGIN PGP SIGNATURE-----

iQRPBAEBCAA5FiEE5k2NRWFNsHVF2czBVN8G9ktVy78FAmqtcfUbFIAAAAAABAAO
bWFudTIsMi41KzEuMTIsMiwzAAoJEFTfBvZLVcu/mJwf/jA0KM2pZZ4MF7NrK6Vh
BVpc344gxh1913MWk9U4ArzFtKhgU9oreZ99UiZAcOZRaYrwvYwN5nP/v8MKneO9
2S6WoilOcWdTo4GuKbtqFlasXc8L/VQNjlczWY2kBJrsCsDu4POH5EHmY9dIZbnA
8Y1ZvX+RUNQnIYY11KBjVWg6+cwocYRdlOdkz8fij4d4rI5Bpek6oAWJY8Cb6a8v
lqjEFfkp9bx9oGkuktJlNubIABXO/e/jyYB1+1+dA4y09LS0R4qfXE0Z7PSjBoQB
AJpYkVwFasGB3H5NuxjffKfLXFKdbxv7M+vl8zxmIiIiDcWic/7o6EHCYUrp7NxA
fdZQvoWqwbteWHAWNLbSavprq2ftqVOOzyPhfEyXu7uklpU8M3HzRNFm+ocB7XNb
VZULG69A+p7wfSbBBQScNm8a7RSnF05zp8v8ONsgNIKS6C0Cdi4HqWXEFt3PKQFg
bcqT4ze0pz3VxkdTnEW2G25kJnnCyfYw3ILt606N8TfU1PAXOrG24aahQnU5EsVD
b4qNTi32YWIOoHcjpLOYojPJ0DC3LSuJbK9V9/fvFo1V+9OtKH0uo7yz4mDZsaN2
3IrWYQbWXlwY8v3SmoRdeNKaQO46cZheliL5ni5KFLpLbfwgGbXIMUGA18GbB2cg
6qTfo5lwJ0rVRxNNi4xfuX0no6S4fXZiM4rx9wXAbF4UJNfoW2z+VCkNbqqDzk2/
qqOKiY6lvNHN7R33lDWj9WKJnh9p2CZTpNynd8s0cz0OVVAuP2Q/L7Ci+wXty+eG
NVeD/HSqmSGb+jwepQJXfJ4TMMyOKt/c0vphzpID17BZnsH48iSZ8axX4w/LR8ef
VLigikN2oxnqT4BFQPNh0u5GET8lOS5bkUdpMCFyfGb7uCUbLnd93qW75LYJcRVp
SodDVfYpgVM/3JVK/eXfVvfQtNW1iZYQwxlnn7bfrIsSOtz8hwaOnZ2cQJDW7VUD
Riv9xqnU7aEEMKs8QPkvnhXV1tgP9RLhP7ECDc+VoqF77wjvu7SVkstDxkeCngcO
E2A0GOcXbuLzE0Vp7irlHMjGwJWNp+D1dHpXsf1Lk5Z/48At/z+GAdVcQijsWMbH
3TiUWg0VYdyVhmEMnTwqBaI/MN9cUmC+Gh8l/5Id3UwL8Wsedc88/rtM3dph/TSc
0k/+07QRhLtJ2ELOh9emua2CSAua2iPcMmH0uHws0TB8MjayCmU/kDzE+FpAOAxN
oiXeda3qrX8zGp3qzwJtuadkjG1oMtGzHJGEPAQ8HV3E6uPk6wZloHp7Y2GIV0g/
H32YRC73S3zTF4W273Q/2jihs2ealLqFa/SZt0vwMi/oPfz6Zi8IVOtgNz8bka+w
o0M=
=9DC2
-----END PGP SIGNATURE-----

vasild's public key is on openpgp.org

Approach ACK e4204baff71dfef93597ce5c92ee8111b5b380b0 The code looks solid. It introduces a rigid number of times a transaction will be broadcast, regardless of whether it is received back or not. It starts at 3 and may be incremented if the transaction is stale in order to induce a new broadcast. It also tracks when the connections are closed so that it does not remove a transaction from the list in the middle of a connection. I did not review the tests yet. Will review them for a full ACK. Thanks! <details> <summary>Show Signature</summary> ``` -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Approach ACK e4204baff71dfef93597ce5c92ee8111b5b380b0 The code looks solid. It introduces a rigid number of times a transaction will be broadcast, regardless of whether it is received back or not. It starts at 3 and may be incremented if the transaction is stale in order to induce a new broadcast. It also tracks when the connections are closed so that it does not remove a transaction from the list in the middle of a connection. I did not review the tests yet. Will review them for a full ACK. Thanks! -----BEGIN PGP SIGNATURE----- iQRPBAE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waOnZ2cQJDW7VUD Riv9xqnU7aEEMKs8QPkvnhXV1tgP9RLhP7ECDc+VoqF77wjvu7SVkstDxkeCngcO E2A0GOcXbuLzE0Vp7irlHMjGwJWNp+D1dHpXsf1Lk5Z/48At/z+GAdVcQijsWMbH 3TiUWg0VYdyVhmEMnTwqBaI/MN9cUmC+Gh8l/5Id3UwL8Wsedc88/rtM3dph/TSc 0k/+07QRhLtJ2ELOh9emua2CSAua2iPcMmH0uHws0TB8MjayCmU/kDzE+FpAOAxN oiXeda3qrX8zGp3qzwJtuadkjG1oMtGzHJGEPAQ8HV3E6uPk6wZloHp7Y2GIV0g/ H32YRC73S3zTF4W273Q/2jihs2ealLqFa/SZt0vwMi/oPfz6Zi8IVOtgNz8bka+w o0M= =9DC2 -----END PGP SIGNATURE----- ``` vasild's public key is [on openpgp.org](https://keys.openpgp.org/vks/v1/by-fingerprint/850E138BA9C0923881DFD55FCE712013582E2230) </details>
vasild (Migrated from github.com) commented 2026-09-18 16:30:33 +00:00

DidNodeConfirmReception() is now unused, can be removed.

`DidNodeConfirmReception()` is now unused, can be removed.
vasild (Migrated from github.com) commented 2026-09-18 16:44:50 +00:00

I do not see a value in NUM_PRIVATE_BROADCAST_PER_TX now. Consider using PrivateBroadcast::INITIAL_BROADCAST_COUNT all over the place and dropping NUM_PRIVATE_BROADCAST_PER_TX.

Also the name NUM_PRIVATE_BROADCAST_PER_TX is/was a bit misleading - we could send more times than that. Should be NUM_INITIAL_PRIVATE_BROADCAST_PER_TX.

I do not see a value in `NUM_PRIVATE_BROADCAST_PER_TX` now. Consider using `PrivateBroadcast::INITIAL_BROADCAST_COUNT` all over the place and dropping `NUM_PRIVATE_BROADCAST_PER_TX`. Also the name `NUM_PRIVATE_BROADCAST_PER_TX` is/was a bit misleading - we could send more times than that. Should be `NUM_INITIAL_PRIVATE_BROADCAST_PER_TX`.
vasild (Migrated from github.com) commented 2026-09-18 17:13:57 +00:00

This increments the send_limit counter for a transaction that came from GetStale() and is acceptable in the mempool. However such a transaction might still have unused "allowance". For example: broadcast 1 times, to be sent 2 more times (send_limit is 3), not received back. Such transaction will have 2 more sends and does not need send_limit to be incremented from 3 to 4.

This increments the `send_limit` counter for a transaction that came from `GetStale()` and is acceptable in the mempool. However such a transaction might still have unused "allowance". For example: broadcast 1 times, to be sent 2 more times (`send_limit` is `3`), not received back. Such transaction will have 2 more sends and does not need `send_limit` to be incremented from `3` to `4`.
Lines 1772-1774
vasild (Migrated from github.com) commented 2026-09-18 15:26:39 +00:00

Why replace Remove() with MarkReceived() here? The transaction has not been actually received.

Why replace `Remove()` with `MarkReceived()` here? The transaction has not been actually received.
Lines 1856-1858
vasild (Migrated from github.com) commented 2026-09-18 15:31:12 +00:00

Maybe elaborate this comment to something like:

// We consider a transaction has been sent to a peer if we sent them an INV.
// Normally they should request the transaction with GETDATA, but this may
// not happen if they are already aware of the transaction.
// If we didn't send them an INV, then schedule a new connection to compensate
// for this send failure. Since whether we sent them INV or not is not readily
// available here we use fSuccessfullyConnected instead because INV is sent right
// after a successful connection.
Maybe elaborate this comment to something like: ``` // We consider a transaction has been sent to a peer if we sent them an INV. // Normally they should request the transaction with GETDATA, but this may // not happen if they are already aware of the transaction. // If we didn't send them an INV, then schedule a new connection to compensate // for this send failure. Since whether we sent them INV or not is not readily // available here we use fSuccessfullyConnected instead because INV is sent right // after a successful connection. ```
Lines 4734-4737
vasild (Migrated from github.com) commented 2026-09-18 16:08:25 +00:00

After receiving the transaction (with this PR) we may send a few times more, so drop the last part:

-                                           "network from %s; stopping private broadcast attempts",
+                                           "network from %s",
After receiving the transaction (with this PR) we may send a few times more, so drop the last part: ```diff - "network from %s; stopping private broadcast attempts", + "network from %s", ```
vasild (Migrated from github.com) commented 2026-09-18 15:59:21 +00:00

What about removing transactions from the list only when the size of the list reaches m_max_transactions? Then maybe send_status.disconnected and PrivateBroadcast::NodeDisconnected() will not be needed?

What about removing transactions from the list only when the size of the list reaches `m_max_transactions`? Then maybe `send_status.disconnected` and `PrivateBroadcast::NodeDisconnected()` will not be needed?
vasild (Migrated from github.com) commented 2026-09-18 16:10:39 +00:00

Add comments for the new functions before class PrivateBroadcast.

Add comments for the new functions before `class PrivateBroadcast`.
vasild (Migrated from github.com) commented 2026-09-18 16:42:09 +00:00

Naming nit: it is not a "limit" because we will always aim to send it this many times and will not settle for less. Maybe planned_sends?

Naming nit: it is not a "limit" because we will always aim to send it this many times and will not settle for less. Maybe `planned_sends`?
vasild (Migrated from github.com) commented 2026-09-18 16:38:29 +00:00

Naming nit: I would find it more understandable if received is called received_by_us. Because nearby send_statuses contains information whether the transaction has been received by the peers we send it to.

Naming nit: I would find it more understandable if `received` is called `received_by_us`. Because nearby `send_statuses` contains information whether the transaction has been received _by the peers_ we send it to.
andrewtoth (Migrated from github.com) reviewed 2026-09-19 14:40:57 +00:00
Lines 1772-1774
andrewtoth (Migrated from github.com) commented 2026-09-19 14:40:57 +00:00

If ReattemptPrivateBroadcast gets scheduled before we complete all connections but the transaction now conflicts with our mempool, it will be removed and won't achieve the goal of this patch.

The transaction has not been actually received.

Right but this is an easy way to make sure no more connections are scheduled for this transaction.

If `ReattemptPrivateBroadcast` gets scheduled before we complete all connections but the transaction now conflicts with our mempool, it will be removed and won't achieve the goal of this patch. > The transaction has not been actually received. Right but this is an easy way to make sure no more connections are scheduled for this transaction.
vasild (Migrated from github.com) reviewed 2026-09-20 04:19:06 +00:00
Lines 1856-1858
vasild (Migrated from github.com) commented 2026-09-20 04:19:06 +00:00

After some more thinking on this - we do not need the NumToOpenAdd(1) call here at all. It is to compensate for a failed send. IIRC the origin of this was when the "retry stale" logic was running after 10 minutes. But it was changed to run every 2-3 minutes. I think that in the unlikely event that the send fails after opening the connection, the other 2 connections will suffice for the broadcast (just 1 suffices). In the even more unlikely event that they don't either, then the "retry stale" logic will pick it up in 2-3 minutes. Right?

After some more thinking on this - we do not need the `NumToOpenAdd(1)` call here at all. It is to compensate for a failed send. IIRC the origin of this was when the "retry stale" logic was running after 10 minutes. But it was changed to run every 2-3 minutes. I think that in the unlikely event that the send fails after opening the connection, the other 2 connections will suffice for the broadcast (just 1 suffices). In the even more unlikely event that they don't either, then the "retry stale" logic will pick it up in 2-3 minutes. Right?
andrewtoth (Migrated from github.com) reviewed 2026-09-20 16:33:27 +00:00
Lines 1856-1858
andrewtoth (Migrated from github.com) commented 2026-09-20 16:33:27 +00:00

This was discussed in https://github.com/bitcoin/bitcoin/pull/29415#discussion_r2615178895. If we connect but fail the handshake (which is quite common) we do not reach PickTxForSend, so we don't increase send_statuses.size(). If we also implement your suggestion https://github.com/bitcoin/bitcoin/pull/36277#discussion_r4048983149, then we would never open a new connection and could leave a pending transaction stranded.

I think this would also just make the broadcasting less reliable, since many of the first 3 initial txs would just fail handshakes.

This was discussed in https://github.com/bitcoin/bitcoin/pull/29415#discussion_r2615178895. If we connect but fail the handshake (which is quite common) we do not reach `PickTxForSend`, so we don't increase `send_statuses.size()`. If we also implement your suggestion https://github.com/bitcoin/bitcoin/pull/36277#discussion_r4048983149, then we would never open a new connection and could leave a pending transaction stranded. I think this would also just make the broadcasting less reliable, since many of the first 3 initial txs would just fail handshakes.
andrewtoth (Migrated from github.com) reviewed 2026-09-20 20:04:13 +00:00
Lines 1772-1774
andrewtoth (Migrated from github.com) commented 2026-09-20 20:04:13 +00:00

I renamed this method to MarkResolved, to handle both cases.

I renamed this method to `MarkResolved`, to handle both cases.
andrewtoth (Migrated from github.com) reviewed 2026-09-20 20:04:31 +00:00
Lines 1856-1858
andrewtoth (Migrated from github.com) commented 2026-09-20 20:04:31 +00:00

Took the comment.

Took the comment.
andrewtoth (Migrated from github.com) reviewed 2026-09-20 20:05:01 +00:00
andrewtoth (Migrated from github.com) commented 2026-09-20 20:05:01 +00:00

Done. Removed NodeDisconnected. This simplifies it 👍.

Done. Removed `NodeDisconnected`. This simplifies it :thumbsup:.
andrewtoth (Migrated from github.com) reviewed 2026-09-20 20:05:25 +00:00
andrewtoth (Migrated from github.com) commented 2026-09-20 20:05:25 +00:00

Added a second commit that removes it.

Added a second commit that removes it.
andrewtoth (Migrated from github.com) reviewed 2026-09-20 20:05:39 +00:00
andrewtoth (Migrated from github.com) commented 2026-09-20 20:05:39 +00:00

Renamed to resolved.

Renamed to `resolved`.
andrewtoth (Migrated from github.com) reviewed 2026-09-20 20:06:09 +00:00
andrewtoth (Migrated from github.com) commented 2026-09-20 20:06:09 +00:00

Renamed to planned_sends.

Renamed to `planned_sends`.
andrewtoth (Migrated from github.com) reviewed 2026-09-20 20:10:29 +00:00
andrewtoth (Migrated from github.com) commented 2026-09-20 20:10:29 +00:00

Right, we would grant an extra connection if ReattemptPrivateBroadcast was called before all 3 initial connections were made. Fixed by also checking that the tx is no longer pending.

Right, we would grant an extra connection if `ReattemptPrivateBroadcast` was called before all 3 initial connections were made. Fixed by also checking that the tx is no longer pending.
andrewtoth commented 2026-09-20 20:29:33 +00:00 (Migrated from github.com)

Thanks @vasild for your detailed review. I have taken most of your suggestions.

  • Renamed MarkReceived -> MarkResolved.
  • Cleanup finished txs at capacity, so we can remove NodeDisconnected and related disconnected state.
  • Removed DidNodeConfirmReception.
  • Other various renames and cleanups.

github.com/bitcoin/[email protected]

Thanks @vasild for your detailed review. I have taken most of your suggestions. - Renamed `MarkReceived` -> `MarkResolved`. - Cleanup finished txs at capacity, so we can remove `NodeDisconnected` and related `disconnected` state. - Removed `DidNodeConfirmReception`. - Other various renames and cleanups. https://github.com/bitcoin/bitcoin/compare/e4204baff71dfef93597ce5c92ee8111b5b380b0..dad979bf010adeed16d9eebe9fb822f5c519b90c
vasild (Migrated from github.com) approved these changes 2026-09-21 10:40:06 +00:00
vasild (Migrated from github.com) left a comment

ACK dad979bf01 modulo weird situation for the user

Show Signature
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

ACK dad979bf010adeed16d9eebe9fb822f5c519b90c modulo [weird situation for the user](https://github.com/bitcoin/bitcoin/pull/36277#discussion_r4061032714)
-----BEGIN PGP SIGNATURE-----

iQRPBAEBCAA5FiEE5k2NRWFNsHVF2czBVN8G9ktVy78FAmqxCiQbFIAAAAAABAAO
bWFudTIsMi41KzEuMTIsMiwzAAoJEFTfBvZLVcu/UpEf/2dppxUDnxRmBfDd6QzT
6l/n1myOzK4zqZNR8ShUOe81r0fYuHolyYM40VZjCDG1vegPNItudUETnYibh7yh
3R2PX6SOy7cpShDyasUMTtxBXKEbH0VkqdJSilDfl18SpSYWlL/ADF2qc7s5Zu0A
XSR6sthhyrpFOY35OLnH8r59eUd3dRH0ehssm7DhhMt7zXKmqDTD0c12JpJ1vCkI
redrtD/ea9fhTWkPoeuCM4eBqK5DtvZTKd9ZYSaNYeDx+tS79ba3RjHGHWOGuy/8
c7qXvb80CzYksRbK1P1JgihxfoaE2cxEesGx1An3hBMS+0mQ3b+iBlGQx6MKOSl9
1mX9vfUERcnGCMQ6WM+eDJklPRPfZL2j8LTZxLateDCDEsVEvetN7SrswLnwqdxb
lzubj2dz33l9ZB3p1cpYiDGPQjadCDx0Tbv3uYAiIZU/CLBxgQ/6fcRUpSLlpUZs
zcKpIPJHgMIRKzVo3ShcdMlvUSBxJBCNax7l5gpaJccqAByt1qyD9KItY1MJ16z4
UhNyPCFn/76jBMszXan2V/56RydV+p888cVKaNug05SDnkgH+JeZ/vLH5I9uIeor
yZAzd8kn/ocves7ZctDbAmW7gcBSf/FEWD+QuqIhXIGcFXTLjsRfjPzi/tb/sMSL
n9WFE8/yIv5+EWK/TnI4dUEwAohVSvUJdP5woOG5Ofe6BcpcDn3pIzRG6CnXoshD
ZqgzWHlW1q8EO/DNn8jY9Ga/l/CXns/MM5I3yp+BlsBMk7zjfKneKpCbqy6cyP/e
f64QDxGwW2mADrG1VJXL6X09YeryzFwoHaWG9FlnYaOBFuww6I9EyMV1JDjmbNa/
2PKFV+xLaqyRRL3hBUaSUelT5+S9NSNzTMbnd6LRqgt+tGSZHgvH6fYnd5uu3mxd
OwsbPEz1nbMiup4hGQ1jvro0WHD4fPwW4uEjVKFqnGp/OTNXBpDAgexFeDkJR7o2
5XMGeeZlFsvqc157ItuqKAWekyfE8nsk2pRRwuQmtC/ucwJJZNY8OhcWD1vMLNlE
q5i13OYuqTqmtxOJg7CCxND6QuZY/o57fCaaPn4QW33ylAkgPF94mulI3QOH8YPI
2f9aA/S99eiUglbmNInN4Q75n4oMFzafJIJ2yVVfEbJrTrKACLg1IV1Y/DLJ3ABi
SkPI3+RLHCaiwtkSbL9u4TDT27ijrkg6jfDrv4ZPRDjP/3R5t+yus4GQOr3eO9B/
6YprryFW3UDmphZ36nKNqnvgvlyUfr84oyY1VsLjlDAWn1s6IeiSX3VSVEYtdjdf
tw9WjHLaKSv9HNqihr/m6piY67YBdunPJrzJ2etCQA36N+E1JPNY2pPvW4HY+NrT
cEI=
=Lwet
-----END PGP SIGNATURE-----

vasild's public key is on openpgp.org

ACK dad979bf010adeed16d9eebe9fb822f5c519b90c modulo [weird situation for the user](https://github.com/bitcoin/bitcoin/pull/36277#discussion_r4061032714) <details> <summary>Show Signature</summary> ``` -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 ACK dad979bf010adeed16d9eebe9fb822f5c519b90c modulo [weird situation for the user](https://github.com/bitcoin/bitcoin/pull/36277#discussion_r4061032714) -----BEGIN PGP SIGNATURE----- iQRPBAEBCAA5FiEE5k2NRWFNsHVF2czBVN8G9ktVy78FAmqxCiQbFIAAAAAABAAO bWFudTIsMi41KzEuMTIsMiwzAAoJEFTfBvZLVcu/UpEf/2dppxUDnxRmBfDd6QzT 6l/n1myOz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PI 2f9aA/S99eiUglbmNInN4Q75n4oMFzafJIJ2yVVfEbJrTrKACLg1IV1Y/DLJ3ABi SkPI3+RLHCaiwtkSbL9u4TDT27ijrkg6jfDrv4ZPRDjP/3R5t+yus4GQOr3eO9B/ 6YprryFW3UDmphZ36nKNqnvgvlyUfr84oyY1VsLjlDAWn1s6IeiSX3VSVEYtdjdf tw9WjHLaKSv9HNqihr/m6piY67YBdunPJrzJ2etCQA36N+E1JPNY2pPvW4HY+NrT cEI= =Lwet -----END PGP SIGNATURE----- ``` vasild's public key is [on openpgp.org](https://keys.openpgp.org/vks/v1/by-fingerprint/850E138BA9C0923881DFD55FCE712013582E2230) </details>
vasild (Migrated from github.com) commented 2026-09-21 09:16:08 +00:00

This is fine, but I am just thinking - here we allow readd/reset only if the transaction has been sent 1000 times. I do not see this actually ever happening in realistic environments. Is it not more likely that somebody may want to readd/reset (and thus send again) a transaction which has reached its planned_sends and has been marked as resolved?

What about changing this condition to:

        if (!it->second.resolved || IsPending(it->second)) return AddResult::AlreadyPresent;
This is fine, but I am just thinking - here we allow readd/reset only if the transaction has been sent 1000 times. I do not see this actually ever happening in realistic environments. Is it not more likely that somebody may want to readd/reset (and thus send again) a transaction which has reached its `planned_sends` and has been marked as resolved? What about changing this condition to: ```c++ if (!it->second.resolved || IsPending(it->second)) return AddResult::AlreadyPresent; ```
vasild (Migrated from github.com) commented 2026-09-21 07:19:36 +00:00

super naming nit: since this variable is in the context of the PrivateBroadcast class, it does not need to contain the word "broadcast". There is some redundancy and unnecessary verbosity:

PrivateBroadcast::INITIAL_BROADCAST_COUNT could be
PrivateBroadcast::INITIAL_COUNT

feel free to ignore.

super naming nit: since this variable is in the context of the `PrivateBroadcast` class, it does not need to contain the word "broadcast". There is some redundancy and unnecessary verbosity: `PrivateBroadcast::INITIAL_BROADCAST_COUNT` could be `PrivateBroadcast::INITIAL_COUNT` feel free to ignore.
vasild (Migrated from github.com) commented 2026-09-21 08:00:48 +00:00
    // Random transactions that the test generated and passed to Add(). Trimmed when Remove() is called.
```suggestion // Random transactions that the test generated and passed to Add(). Trimmed when Remove() is called. ```
vasild (Migrated from github.com) commented 2026-09-21 08:01:07 +00:00
// The values are the number of times a transaction is planned to be sent.
    std::unordered_map<CTransactionRef, size_t, CTransactionRefHash, CTransactionRefComp> planned_sends;
```suggestion // The values are the number of times a transaction is planned to be sent. std::unordered_map<CTransactionRef, size_t, CTransactionRefHash, CTransactionRefComp> planned_sends; ```
vasild (Migrated from github.com) commented 2026-09-21 09:54:14 +00:00

This test had some value. It was removed because txs[0] can no longer be used for it. Can we create another, unrelated transaction, put it in the tx_originator's mempool somehow (maybe get another peer to INV it to tx_originator edit: or directly send TX message) and keep this test?

This test had some value. It was removed because `txs[0]` can no longer be used for it. Can we create another, unrelated transaction, put it in the `tx_originator`'s mempool somehow (maybe get another peer to `INV` it to `tx_originator` _edit: or directly send `TX` message_) and keep this test?
vasild (Migrated from github.com) commented 2026-09-21 09:59:22 +00:00

This is a weird situation for the user:

  • Trying to resend a transaction is refused with "Ignoring unnecessary request to schedule an already scheduled transaction"
  • getprivatebroadcastinfo RPC does not contain the transaction
  • abortprivatebroadcast RPC errors with "Transaction not in private broadcast queue"
  • new send attempts will not be made by the system

I think would be resolved by the suggestion in https://github.com/bitcoin/bitcoin/pull/36277#discussion_r4060717644 because that would allow a forced resend (first point above will change).

This is a weird situation for the user: * Trying to resend a transaction is refused with "Ignoring unnecessary request to schedule an already scheduled transaction" * `getprivatebroadcastinfo` RPC does not contain the transaction * `abortprivatebroadcast` RPC errors with "Transaction not in private broadcast queue" * new send attempts will not be made by the system I think would be resolved by the suggestion in https://github.com/bitcoin/bitcoin/pull/36277#discussion_r4060717644 because that would allow a forced resend (first point above will change).
vasild (Migrated from github.com) commented 2026-09-21 10:24:44 +00:00

This test establishes the 3 connections and then returns the transaction and then checks that the transaction gets delivered to the existent connections.

Would be nice if we can test that new connections are established/opened as well, after receiving the transaction. Could be achieved by:

  • shut down the proxy
  • sendrawtransaction
  • will be some "connection refused" errors trying to connect to the proxy
  • receive back the transaction
  • make the proxy work
  • observe 3 proper connections come to it that deliver the transaction

Maybe not worth it if it is going to overcomplicate this test.

This test establishes the 3 connections and then returns the transaction and then checks that the transaction gets delivered to the existent connections. Would be nice if we can test that new connections are established/opened as well, after receiving the transaction. Could be achieved by: * shut down the proxy * sendrawtransaction * will be some "connection refused" errors trying to connect to the proxy * receive back the transaction * make the proxy work * observe 3 proper connections come to it that deliver the transaction Maybe not worth it if it is going to overcomplicate this test.
mzumsande (Migrated from github.com) reviewed 2026-09-21 20:50:04 +00:00
mzumsande (Migrated from github.com) left a comment

Concept ACK

(haven't looked at the test changes yet)

Concept ACK (haven't looked at the test changes yet)
mzumsande (Migrated from github.com) commented 2026-09-21 20:24:03 +00:00

Should Remove() return planned_sends - send_statuses.size()? Seems like it was wrong/brittle already before, but now a peer that completed the handshake (fDisconnect=true) but doesn't answer the pong would not get a peer_ack, but also wouldn't get a try back, so if we then call Remove() it could steal slots from other, unrelated transactions.

Should `Remove()` return `planned_sends - send_statuses.size()`? Seems like it was wrong/brittle already before, but now a peer that completed the handshake (`fDisconnect=true`) but doesn't answer the pong would not get a `peer_ack`, but also wouldn't get a try back, so if we then call `Remove()` it could steal slots from other, unrelated transactions.
mzumsande (Migrated from github.com) commented 2026-09-21 20:01:59 +00:00

in any case, the comment in line 20 should be made precise, because it is unclear what "exhausted" means, because it changed bahavior: Now the retry is basically dead code, since it will take a long time until 1000 resend attempts are reached - I think it might as well be removed. Before this change, it could be reached within minutes.

in any case, the comment in line 20 should be made precise, because it is unclear what "exhausted" means, because it changed bahavior: Now the retry is basically dead code, since it will take a long time until 1000 resend attempts are reached - I think it might as well be removed. Before this change, it could be reached within minutes.
mzumsande (Migrated from github.com) commented 2026-09-21 20:11:59 +00:00

This would lead to a potential unexpected increase in resource usage - before, we'd only keep transactions while they were in flight, and the shared pointer would be released, typically when they were mined. Now, we'll keep them forever (well, until the next restart or until the maximum limit is reached) without a real necessity, which doesn't seem ideal, if someone would send a lot of large txns with private broadcast.

This would lead to a potential unexpected increase in resource usage - before, we'd only keep transactions while they were in flight, and the shared pointer would be released, typically when they were mined. Now, we'll keep them forever (well, until the next restart or until the maximum limit is reached) without a real necessity, which doesn't seem ideal, if someone would send a lot of large txns with private broadcast.
andrewtoth (Migrated from github.com) reviewed 2026-09-21 23:50:48 +00:00
andrewtoth (Migrated from github.com) commented 2026-09-21 23:50:48 +00:00

Indeed, but the tradeoff here is that we do not need to have a third new method NodeDisconnected and track the disconnected state for each SendStatus. I'm not sure which way reviewers would prefer.

Indeed, but the tradeoff here is that we do not need to have a third new method `NodeDisconnected` and track the disconnected state for each `SendStatus`. I'm not sure which way reviewers would prefer.
vasild (Migrated from github.com) reviewed 2026-09-22 12:26:47 +00:00
vasild (Migrated from github.com) commented 2026-09-22 12:26:47 +00:00

master:

IsPending():
    return status.send_statuses.size() < m_max_send_attempts;

Add():
    if (IsPending(it->second)) return AddResult::AlreadyPresent;

PR:

Add():
    if (it->second.send_statuses.size() < m_max_send_attempts) return AddResult::AlreadyPresent;
`master`: ```cpp IsPending(): return status.send_statuses.size() < m_max_send_attempts; Add(): if (IsPending(it->second)) return AddResult::AlreadyPresent; ``` PR: ```cpp Add(): if (it->second.send_statuses.size() < m_max_send_attempts) return AddResult::AlreadyPresent; ```
vasild (Migrated from github.com) reviewed 2026-09-22 12:39:31 +00:00
vasild (Migrated from github.com) commented 2026-09-22 12:39:31 +00:00

Deleting the transactions eagerly is not a blocker for me. My preference, however, is to have a simpler interface (the public section of the PrivateBroadcast class) and simpler implementation (src/private_broadcast.cpp), which means to not track when a peer is disconnected. The queue is limited to 10k transactions. A full queue with 500bytes-sized transactions would occupy 5MB.

Some historical data on transactions' sizes:
https://bitcoinvisuals.com/chain-tx-size

Deleting the transactions eagerly is not a blocker for me. My preference, however, is to have a simpler interface (the public section of the `PrivateBroadcast` class) and simpler implementation (`src/private_broadcast.cpp`), which means to not track when a peer is disconnected. The queue is limited to 10k transactions. A full queue with 500bytes-sized transactions would occupy 5MB. Some historical data on transactions' sizes: https://bitcoinvisuals.com/chain-tx-size
andrewtoth (Migrated from github.com) reviewed 2026-09-23 02:40:36 +00:00
andrewtoth (Migrated from github.com) commented 2026-09-23 02:40:36 +00:00

I've reverted to clear resolved/exhausted entries on Add, so we reset as before. This makes this no longer relevant.

I've reverted to clear resolved/exhausted entries on `Add`, so we reset as before. This makes this no longer relevant.
andrewtoth (Migrated from github.com) reviewed 2026-09-23 02:41:01 +00:00
andrewtoth (Migrated from github.com) commented 2026-09-23 02:41:01 +00:00

I reverted the behavior back to using NodeDisconnected, so this is also no longer changed.

I reverted the behavior back to using `NodeDisconnected`, so this is also no longer changed.
andrewtoth (Migrated from github.com) reviewed 2026-09-23 02:41:41 +00:00
andrewtoth (Migrated from github.com) commented 2026-09-23 02:41:41 +00:00

Reverted to using NodeDisconnected, so this is no longer relevant.

Reverted to using `NodeDisconnected`, so this is no longer relevant.
andrewtoth (Migrated from github.com) reviewed 2026-09-23 02:41:50 +00:00
andrewtoth (Migrated from github.com) commented 2026-09-23 02:41:50 +00:00

Added the test.

Added the test.
andrewtoth (Migrated from github.com) reviewed 2026-09-23 02:43:30 +00:00
andrewtoth (Migrated from github.com) commented 2026-09-23 02:43:30 +00:00

I reverted to deleting the entries at the start of Add. This re-adds the NodeDisconnected method and disconnected state, but it resolves this concern. It was brought up as an objection to #34707 as well, so hopefully it makes this change less controversial.

I reverted to deleting the entries at the start of `Add`. This re-adds the `NodeDisconnected` method and `disconnected` state, but it resolves this concern. It was brought up as an objection to #34707 as well, so hopefully it makes this change less controversial.
andrewtoth (Migrated from github.com) reviewed 2026-09-23 02:43:40 +00:00
andrewtoth (Migrated from github.com) commented 2026-09-23 02:43:40 +00:00

Done.

Done.
andrewtoth commented 2026-09-23 02:49:04 +00:00 (Migrated from github.com)

@mzumsande @vasild thank you for your reviews.

@mzumsande @vasild thank you for your reviews. - Reverted to using `NodeDisconnected` and storing the `disconnected` state. This makes cleanup at the beginning of `Add` possible, and gets rid of the concern in https://github.com/bitcoin/bitcoin/pull/36277#discussion_r4066000330. - Fixed the accounting in `Remove` to return the difference between planned sends and current sends. - Extended the functional test to also receive the tx when the proxy is down and then ensure all 3 connections are still completed. - Various cleanups.
vasild (Migrated from github.com) approved these changes 2026-09-23 14:05:37 +00:00
vasild (Migrated from github.com) left a comment

ACK e2a6665e87

Show Signature
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

ACK e2a6665e8719ecc5ccd9ed03d3880c5543a15797
-----BEGIN PGP SIGNATURE-----

iQRPBAEBCAA5FiEE5k2NRWFNsHVF2czBVN8G9ktVy78FAmqz3HUbFIAAAAAABAAO
bWFudTIsMi41KzEuMTIsMiwzAAoJEFTfBvZLVcu/YhsgAI7HcDPk8xJtUwOQi0uJ
x7vrl8sHKHmcUzAGlrgGFCBDRH6CILxUyGbP7qseHntqk6ZbEdfvgeBtZ7g1dh7U
Kph7R/R7MwhxvImecHLethgBx233JSfM6WUcpa4QMnvD+7kmWORRwMsbkBT2HyMF
deJIwn3qbwciwn5BxzTrCkH+GhMVe2KnyYqoa5KngdMHMYj1aL8Sdr9s/oLsJMEw
fx8nB+VaJn7y9Nf5KynHsH/JAx024oqc8KuQWQNmWmoOTR+EbA/mXQGgZe6PRh2N
9vP9Yf/rsMkN8T3HNucrH0MMvZWUtVi2PM/Ex8NU0xYcoTWmADL9J9iOs+x8cHRJ
ajqRlsSki+IJzN/SRWyHHU/Nht1zUAkPxY+H83PDQAuSEXrA1FQ/plDz+2V8uG0H
aROBEF5JuFV9CfVVOgz1HMy/pS4AG46NICDak/DWgCdQZvWI6S6K70+WjUk32pVj
YnDdBmieawsntICoS2x3PqB80avAQsFtn8x67zPT3oy/djzfaF8iFJehwLtt/c0W
Ivw9pHdbgTEAGAEFVQHgdNyuBASDSDjtgwOn0RJEY+zx97cy8/JSgyx5Jt+fj84G
rTHf2eTqXKqDMnyftfza4JqyNDu13l6aq/6zYOkLFdfvhZDmziVKFiYPxOyC9Ek1
LXiGD2PLy73xfGWSg9lT90a8y1HF3jxWzrH92Sjz5Y7O5xpXbQLLbkjzfNJcvksU
1pN6e81b2D3EFSiGKbKKj6TKgzv4ivWqlUQbO5oXuF+XAYsXe2aU/iW7TY4JGYbD
A/zTTR3c5rzLfbZRbr/AsSMg0mBwKwnm0sZ0ebhNTw2dHLpe9f7daYvBl08SCvBy
/2q5/TLqI55dxSPfH4wH1b6sd+NzxLp8r0JFwPkobj0lyruwIO0WtgFNkew7mN2Q
HfLIbZUJk2gNEN7KLHeyZ0HdoGGlDWdfyUUIYYEzQxSwQLjg9F4h3t2rb4BomU2s
O6iy4nfTUfC+NcGPsstRuoiGiVpfwpr4/C7GB2nBhrHFYLZCPuBB7uwe9U7MTDb5
5iaIs5Jyi+4Dv808D3IeX+2zCcWWSZlPhQH5KFi1CoaED3Z5emtN0umKi+GXxY/b
9fZT/q9z0zYVL8QuH3z8vqoNkpa/iyBCQ+V0cuEnY09K2WguIa3OL1QIykmkDi0T
5XJoozbY7KG9UdJdPx5uQ0UWUq/0wbyMJRziBVQQ+GGjnUSaJMkdvfvmyqEXvYyX
E6DaMhu9hmAMXD1xu9W5XQRUbW0Fhyph5+/Kg9Pt7FaXnUrMpUAeiQq2prL2AhSA
R3dl/it+nX2+Nn5w87jv+4/9mjpLU8UgWQtmpJulXfOpoykWg0SXKi7pz5IVTeTd
Mgc=
=kmHn
-----END PGP SIGNATURE-----

vasild's public key is on openpgp.org

ACK e2a6665e8719ecc5ccd9ed03d3880c5543a15797 <details> <summary>Show Signature</summary> ``` -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 ACK e2a6665e8719ecc5ccd9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2gNEN7KLHeyZ0HdoGGlDWdfyUUIYYEzQxSwQLjg9F4h3t2rb4BomU2s O6iy4nfTUfC+NcGPsstRuoiGiVpfwpr4/C7GB2nBhrHFYLZCPuBB7uwe9U7MTDb5 5iaIs5Jyi+4Dv808D3IeX+2zCcWWSZlPhQH5KFi1CoaED3Z5emtN0umKi+GXxY/b 9fZT/q9z0zYVL8QuH3z8vqoNkpa/iyBCQ+V0cuEnY09K2WguIa3OL1QIykmkDi0T 5XJoozbY7KG9UdJdPx5uQ0UWUq/0wbyMJRziBVQQ+GGjnUSaJMkdvfvmyqEXvYyX E6DaMhu9hmAMXD1xu9W5XQRUbW0Fhyph5+/Kg9Pt7FaXnUrMpUAeiQq2prL2AhSA R3dl/it+nX2+Nn5w87jv+4/9mjpLU8UgWQtmpJulXfOpoykWg0SXKi7pz5IVTeTd Mgc= =kmHn -----END PGP SIGNATURE----- ``` vasild's public key is [on openpgp.org](https://keys.openpgp.org/vks/v1/by-fingerprint/850E138BA9C0923881DFD55FCE712013582E2230) </details>
vasild (Migrated from github.com) commented 2026-09-23 13:57:07 +00:00

Logically, planned_sends or m_max_send_attempts should always be bigger than send_statuses.size(). However they are updated in different places in the code and the > relationship depends on some higher level logic and not trivial to verify. It is correct now. But because we do not know how this code will be changed in the future, it would be more robust to guard against an underflow here:

const size_t planned{std::min(state.planned_sends, m_max_send_attempts);
const size_t actual{state.send_statuses.size()};
return planned > actual ? planned - actual : 0;
Logically, `planned_sends` or `m_max_send_attempts` should always be bigger than `send_statuses.size()`. However they are updated in different places in the code and the `>` relationship depends on some higher level logic and not trivial to verify. It is correct now. But because we do not know how this code will be changed in the future, it would be more robust to guard against an underflow here: ```cpp const size_t planned{std::min(state.planned_sends, m_max_send_attempts); const size_t actual{state.send_statuses.size()}; return planned > actual ? planned - actual : 0; ```
instagibbs commented 2026-09-23 14:16:10 +00:00 (Migrated from github.com)

is this intended for backport?

is this intended for backport?
andrewtoth commented 2026-09-23 14:24:52 +00:00 (Migrated from github.com)

is this intended for backport?

@instagibbs ideally this can get merged and backported before release.

> is this intended for backport? @instagibbs ideally this can get merged and backported before release.
instagibbs commented 2026-09-23 15:21:56 +00:00 (Migrated from github.com)

This PR should be merged and backported before a release or not at all imo. It's a pretty large behavioral delta which would compete for review time against a more complete fix for the issues a little further out.

Caveat: I will not be reviewing it further, just my two cents

This PR should be merged and backported before a release or not at all imo. It's a pretty large behavioral delta which would compete for review time against a more complete fix for the issues a little further out. Caveat: I will not be reviewing it further, just my two cents
andrewtoth commented 2026-09-23 15:45:24 +00:00 (Migrated from github.com)

This PR should be merged and backported before a release or not at all imo. It's a pretty large behavioral delta which would compete for review time against a more complete fix for the issues a little further out.

I somewhat agree, but it's hard to say for sure until we have a consensus on what is meant by "a more complete fix". It is a fairly large change that is already past the release cutoff. However, we agreed on language that we are providing our users "best-effort" privacy. Our best-effort would be to try and backport this change.

> This PR should be merged and backported before a release or not at all imo. It's a pretty large behavioral delta which would compete for review time against a more complete fix for the issues a little further out. I somewhat agree, but it's hard to say for sure until we have a consensus on what is meant by "a more complete fix". It is a fairly large change that is already past the release cutoff. However, we agreed on language that we are providing our users "best-effort" privacy. Our best-effort would be to try and backport this change.
vasild commented 2026-09-24 10:43:42 +00:00 (Migrated from github.com)

IMO this should be included in 32.0 and in 31.x

IMO this should be included in 32.0 and in 31.x
optout21 (Migrated from github.com) reviewed 2026-09-28 09:21:58 +00:00
optout21 (Migrated from github.com) left a comment

Concept ACK

More streamlined change than #34707 (but it also achieves less).
Left few nits.

Concept ACK More streamlined change than #34707 (but it also achieves less). Left few nits.
optout21 (Migrated from github.com) commented 2026-09-28 09:10:29 +00:00

8912547 net: always complete all initial private broadcast connections:

Nit: The expression could be moved to a separate method, e.g. ReadyForCleanup(). Can be non-public.

> [8912547](https://github.com/bitcoin/bitcoin/pull/36277/changes/89125477525df24b6e114430feee0333b859098b) _net: always complete all initial private broadcast connections_: Nit: The expression could be moved to a separate method, e.g. `ReadyForCleanup()`. Can be non-public.
optout21 (Migrated from github.com) commented 2026-09-28 09:14:23 +00:00

8912547 net: always complete all initial private broadcast connections:

Second to that, as this form is also underflow-risk-free, while the current for can technically underflow.

> [8912547](https://github.com/bitcoin/bitcoin/pull/36277/changes/89125477525df24b6e114430feee0333b859098b) _net: always complete all initial private broadcast connections_: Second to that, as this form is also underflow-risk-free, while the current for can technically underflow.
optout21 (Migrated from github.com) commented 2026-09-28 09:17:30 +00:00

8912547 net: always complete all initial private broadcast connections:

Nit: The name could be a bit more telling, e.g. INITIAL_CONNECTION_COUNT

> [8912547](https://github.com/bitcoin/bitcoin/pull/36277/changes/89125477525df24b6e114430feee0333b859098b) _net: always complete all initial private broadcast connections_: Nit: The name could be a bit more telling, e.g. `INITIAL_CONNECTION_COUNT`
First-time contributor

Base: 7988380da987c0b860885853ace8149b84ac2ee8
Head: 00c1b52ee56b9a2f067befc56c171eef27efda41

🟡 Minor

Resolved transactions with pending sends cannot be aborted (src/private_broadcast.cpp:163, head)

This filter hides resolved transactions from GetBroadcastInfo, even though MarkResolved retains them and IsPending allows their remaining planned sends to proceed. AbortPrivateBroadcast searches a GetBroadcastInfo snapshot, so an abort request after resolution cannot find or remove the transaction. The RPC reports that it is not in the queue while outstanding private-broadcast connections can still send it. Keep resolved entries available to the abort path, for example through a separate internal enumeration.

Review coverage was incomplete. The adversarial review had incomplete evidence. The adversarial_glm review had incomplete evidence.

Full review report

<!-- forgejo-review-bot:bitcoin/bitcoin --> Base: `7988380da987c0b860885853ace8149b84ac2ee8` Head: `00c1b52ee56b9a2f067befc56c171eef27efda41` ##### 🟡 Minor **Resolved transactions with pending sends cannot be aborted** (src/private_broadcast.cpp:163, head) This filter hides resolved transactions from `GetBroadcastInfo`, even though `MarkResolved` retains them and `IsPending` allows their remaining planned sends to proceed. `AbortPrivateBroadcast` searches a `GetBroadcastInfo` snapshot, so an abort request after resolution cannot find or remove the transaction. The RPC reports that it is not in the queue while outstanding private-broadcast connections can still send it. Keep resolved entries available to the abort path, for example through a separate internal enumeration. Review coverage was incomplete. The adversarial review had incomplete evidence. The adversarial_glm review had incomplete evidence. [Full review report](<https://review.fish.foo/traces/36277-00c1b52ee56b9a2f067befc56c171eef27efda41-185-1.html>)
mzumsande (Migrated from github.com) reviewed 2026-09-28 17:21:03 +00:00
mzumsande (Migrated from github.com) left a comment

Code Review ACK e2a6665e87

Code Review ACK e2a6665e8719ecc5ccd9ed03d3880c5543a15797
mzumsande (Migrated from github.com) commented 2026-09-28 15:26:38 +00:00

nit: maybe add a comment here that it deliberately ignores resolved, so that the initially scheduled connections are always completed.

nit: maybe add a comment here that it deliberately ignores `resolved`, so that the initially scheduled connections are always completed.
mzumsande (Migrated from github.com) commented 2026-09-28 15:35:03 +00:00

would be nice if the fuzz test would also call MarkResolved() and NodeDisconnected(), so it covers the actual way private broadcast works in the node. This would also require changing some assertion, as fas as I am concerned it could also be done in a follow-up.

would be nice if the fuzz test would also call `MarkResolved()` and `NodeDisconnected()`, so it covers the actual way private broadcast works in the node. This would also require changing some assertion, as fas as I am concerned it could also be done in a follow-up.
vasild (Migrated from github.com) reviewed 2026-10-01 09:05:52 +00:00
vasild (Migrated from github.com) commented 2026-10-01 09:05:52 +00:00

So that somebody does not "fix" it in the future :-D

So that somebody does not "fix" it in the future :-D
andrewtoth (Migrated from github.com) reviewed 2026-10-01 15:26:38 +00:00
andrewtoth (Migrated from github.com) commented 2026-10-01 15:26:38 +00:00

Done.

Done.
andrewtoth (Migrated from github.com) reviewed 2026-10-01 15:26:55 +00:00
andrewtoth (Migrated from github.com) commented 2026-10-01 15:26:55 +00:00

Done.

Done.
andrewtoth (Migrated from github.com) reviewed 2026-10-01 15:27:35 +00:00
andrewtoth (Migrated from github.com) commented 2026-10-01 15:27:35 +00:00

Since this is would be the single callsite, I preferred not to move this into a helper. Hope that's ok.

Since this is would be the single callsite, I preferred not to move this into a helper. Hope that's ok.
andrewtoth (Migrated from github.com) reviewed 2026-10-01 15:27:48 +00:00
andrewtoth (Migrated from github.com) commented 2026-10-01 15:27:48 +00:00

Added the comment.

Added the comment.
andrewtoth (Migrated from github.com) reviewed 2026-10-01 15:29:12 +00:00
andrewtoth (Migrated from github.com) commented 2026-10-01 15:29:12 +00:00

I added the two other methods to the fuzz test, which also required adding some more state to track. Some of the new state containers could be combined into structs, but that would be a bigger change so I would prefer to leave that cleanup to a follow-up.

I added the two other methods to the fuzz test, which also required adding some more state to track. Some of the new state containers could be combined into structs, but that would be a bigger change so I would prefer to leave that cleanup to a follow-up.
andrewtoth commented 2026-10-01 15:34:14 +00:00 (Migrated from github.com)

Thanks @mzumsande @optout21 @vasild for your reviews. I have taken most of your suggestions.

I ran the updated fuzz test overnight on 8 cores for ~10.5 hours, so ~84 hours of CPU time at a combined ~30k exec/s. No issues found.

git diff e2a6665e8719ecc5ccd9ed03d3880c5543a15797..00c1b52ee56b9a2f067befc56c171eef27efda41

Thanks @mzumsande @optout21 @vasild for your reviews. I have taken most of your suggestions. - Guard against integer underflow in `Remove` https://github.com/bitcoin/bitcoin/pull/36277#discussion_r4083240831 - Rename `INITIAL_COUNT` -> `INITIAL_CONNECTION_COUNT` https://github.com/bitcoin/bitcoin/pull/36277#discussion_r4120444347 - Add comment that ignoring `resolved` is deliberate in `IsPending` https://github.com/bitcoin/bitcoin/pull/36277#discussion_r4123978823 - Added `MarkResolved` and `NodeDisconnected` to fuzz test https://github.com/bitcoin/bitcoin/pull/36277#discussion_r4124064031 I ran the updated fuzz test overnight on 8 cores for ~10.5 hours, so ~84 hours of CPU time at a combined ~30k exec/s. No issues found. `git diff e2a6665e8719ecc5ccd9ed03d3880c5543a15797..00c1b52ee56b9a2f067befc56c171eef27efda41`
vasild (Migrated from github.com) approved these changes 2026-10-05 14:15:58 +00:00
vasild (Migrated from github.com) left a comment

ACK 00c1b52ee5

Show Signature
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

ACK 00c1b52ee56b9a2f067befc56c171eef27efda41
-----BEGIN PGP SIGNATURE-----

iQRPBAEBCAA5FiEE5k2NRWFNsHVF2czBVN8G9ktVy78FAmrDsQ8bFIAAAAAABAAO
bWFudTIsMi41KzEuMTIsMiwzAAoJEFTfBvZLVcu/0S0f/0ZDoISc72mD748/4LVk
c5J18jh5oZVvdnvUXesyZVtbz+1G5lX5Le2jVAcpxQyynQKmJwRPFN1l8FJemwo9
18ctnA4p0EH2Cvyb5/SpkQQqIiyhCoCpvWeI6XUdSXlhWQitiQ9pQE9rXdjR+ViA
Y37mQVZETJ5zUJEh5FB6NMrwBFh9PjDeiqP1B3B26Aw+Tdtzsi2nbpLD9RZ+FoMe
TNazBIu1Qhk7QjlvZzm7d21QFImuWEpbjS4ExKllOJ7qLgDtKjBmcs6mMk0AwJYm
oSg4ypWvk1f+NIolX2dNXpViI4psjnKMxoLy4Qfs+AguGzuIG5m5TGqJ4fAYG140
mZkiomcqnQ3WDsLYi9Qp9KK6DNNZ9HrugPMb7QFlNC6Tp03muiDUo9CjDxR2KFnC
47FkoiTesntaoXSBQqeOGNlyVh5O07mV3aMn4fn3FZx7yL8tuB2ZqgnCKMNZgrGr
eaB8xie4AT/uTRN8f6OCVvtep4eH0RZ8shU+FKCTGghh9cg01p+FhWvmA5cryOiR
VCuSMYAYJrDFbWtha5uVjYb/7fqQhMyc0AIPXgwJcSfbt5zXW6pKxtFRMVas4OQH
uRLMA83wHoVR9bttw9Reu9ZOttBuyiCzapHYKC1LtrmNEk7ugrzuzMvKfFdSjJIS
FTsdTWk/E8FXvY1nCHG8jA5M/us+wxYaQEJtAWOgI1aApR53hcMrALFowUXeTckK
zjWrFqX4mne8+9wG8oyhaPyEwEfqyatEL3nTGEfEFXLw/xCw1j6+RiABNF8hzygK
txxuIaOwIYGjAarrVEpKCtMjC0NYVf3fpgyZKBksIGP6B07dl4xdFiTCtbzMtMjK
o+z1TKmZcyhDFmuB87YGGe/RrehR7cCFS4YTNChi/ls/0N8JnnkUT1uK+FBT6Laq
bCWBJYr6b+YEhYCxh/T2UMEjY96qaYnh73e4wTzwRWZ6dH9xpBAnHs2ptPPXuzZ4
upOBJj8+TXXf1sMdmY3CM8ajCtHXLt2Gq/WF+RepxM/xItMnjv6tSYslqPF0pRT9
07W+5S+VA+HaJd07cfFRdtWdr2D9m+hhisFyNlccUzQE+ft584irLiyHGXUTJ4HK
2CIlenYVWb8WkW6C1FqIb2UeYfM64bYFqBiM1+6PADQ0uba6gIfas1YZCmMoIhsK
OIcBhGofo0GGRadXXkz6YCRDGsNX3myxJZ40sJiEXI0zhh0pDjK30whtSCTrVbVk
ioBd91UaBJnHzcSsf4NhzXHT6Ize02xo1G5g3UnzqIhlYZVBLALfU9Mj8/vQXzCl
NbsMOiJoHSsJcAbxaeddV+3FpwHOhnz+aD8le6oXZZto/ZvnUSPPtuClewmfAGlQ
9/8=
=CbWn
-----END PGP SIGNATURE-----

vasild's public key is on openpgp.org

ACK 00c1b52ee56b9a2f067befc56c171eef27efda41 <details> <summary>Show Signature</summary> ``` -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 ACK 00c1b52ee56b9a2f067befc56c171eef27efda41 -----BEGIN PGP SIGNATURE----- iQRPBAEBCAA5FiEE5k2NRWFNsHVF2czBVN8G9ktVy78FAmrDsQ8bFIAAAAAABAAO bWFudTIsMi41KzEuMTIsMiwzAAoJEFTfBvZLVcu/0S0f/0ZDoISc72mD748/4LVk c5J18jh5oZVvdnvUXesyZVtbz+1G5lX5Le2jVAcpxQyynQKmJwRPFN1l8FJemwo9 18ctnA4p0EH2Cvyb5/SpkQQqIiyhCoCpvWe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XXkz6YCRDGsNX3myxJZ40sJiEXI0zhh0pDjK30whtSCTrVbVk ioBd91UaBJnHzcSsf4NhzXHT6Ize02xo1G5g3UnzqIhlYZVBLALfU9Mj8/vQXzCl NbsMOiJoHSsJcAbxaeddV+3FpwHOhnz+aD8le6oXZZto/ZvnUSPPtuClewmfAGlQ 9/8= =CbWn -----END PGP SIGNATURE----- ``` vasild's public key is [on openpgp.org](https://keys.openpgp.org/vks/v1/by-fingerprint/850E138BA9C0923881DFD55FCE712013582E2230) </details>
mzumsande (Migrated from github.com) reviewed 2026-10-05 14:25:15 +00:00
mzumsande (Migrated from github.com) left a comment

Code Review ACK 00c1b52ee5

Code Review ACK 00c1b52ee56b9a2f067befc56c171eef27efda41
danielabrozzoni (Migrated from github.com) reviewed 2026-10-06 05:52:16 +00:00
danielabrozzoni (Migrated from github.com) left a comment

I haven't reviewed the code yet, I plan to do this in the next few days, but please don't hold up merge waiting for my review, I'm ok reviewing post merge, especially since the release is coming up :)


Concept ACK

As far as I understand, currently on master there are two possible leaks, and this PR is solving them both:

inv leak

We have one transaction in the private broadcast queue, we open a connection to a peer. If the connection handshake finishes after we receive the transaction back from the network, we will disconnect without sending an INV.

A sybil attacker can use this to confirm a suspicion that a transaction is ours: it can delay the VERACK, feed us the tx over another connection, complete the handshake and observe that we don't INV over the first connection.

getdata leak

The flow of messages sent over a private broadcast connection is the following:

  • handshake
  • us -- inv --> receiver
  • us < -- getdata -- receiver
  • us -- tx --> receiver
  • ping-pong to confirm tx reception

In private broadcast connections we only reply to getdata regarding the specific broadcast transaction that we INVed. In master we currently remove transactions after they are received back from the network, so if a peer sends getdata after we receive the transaction back from the network, we won't reply to it and instead disconnect.

A sybil attacker can use this to confirm a suspicion that a transaction is ours: it can delay the GETDATA, feed us the tx over another connection, send the GETDATA in the first connection and observe that we don't reply to it, and disconnect instead.

I haven't reviewed the code yet, I plan to do this in the next few days, but please don't hold up merge waiting for my review, I'm ok reviewing post merge, especially since the release is coming up :) --- Concept ACK As far as I understand, currently on master there are two possible leaks, and this PR is solving them both: ### inv leak We have one transaction in the private broadcast queue, we open a connection to a peer. If the connection handshake finishes after we receive the transaction back from the network, we will disconnect without sending an INV. A sybil attacker can use this to confirm a suspicion that a transaction is ours: it can delay the VERACK, feed us the tx over another connection, complete the handshake and observe that we don't INV over the first connection. ### getdata leak The flow of messages sent over a private broadcast connection is the following: - handshake - us -- inv --> receiver - us < -- getdata -- receiver - us -- tx --> receiver - ping-pong to confirm tx reception In private broadcast connections we only reply to getdata regarding the specific broadcast transaction that we INVed. In master we currently remove transactions after they are received back from the network, so if a peer sends getdata after we receive the transaction back from the network, we won't reply to it and instead disconnect. A sybil attacker can use this to confirm a suspicion that a transaction is ours: it can delay the GETDATA, feed us the tx over another connection, send the GETDATA in the first connection and observe that we don't reply to it, and disconnect instead.
sedited (Migrated from github.com) approved these changes 2026-10-06 07:42:14 +00:00
sedited (Migrated from github.com) left a comment

utACK 00c1b52ee5

utACK 00c1b52ee56b9a2f067befc56c171eef27efda41
optout21 (Migrated from github.com) reviewed 2026-10-06 08:51:42 +00:00
optout21 (Migrated from github.com) left a comment

Post-Merge Code Review ACK 00c1b52ee5
I've got rug-pulled, PR got merged while I was performing my review :)
(motto: nothing is final :P )

I share two concerns:

  • What happens when connections can't be opened due to some reason (e.g. Tor is down). The submitted TX will stay in the queue, but not show up in getprivatebroadcastinfo, and can't be aborted via abortprivatebroadcast. Maybe it would be more transparent if it considered in both of these RPCs.

  • What happens when a transaction gets resolved for some reason (e.g. evicted from mempool or mempool check fails with a temporary fee issue), and the transaction get resubmitted? I think no retry will happen and no error is returned.

Post-Merge Code Review ACK 00c1b52ee56b9a2f067befc56c171eef27efda41 I've got rug-pulled, PR got merged while I was performing my review :) (motto: nothing is final :P ) I share two concerns: - What happens when connections can't be opened due to some reason (e.g. Tor is down). The submitted TX will stay in the queue, but not show up in `getprivatebroadcastinfo`, and can't be aborted via `abortprivatebroadcast`. Maybe it would be more transparent if it considered in both of these RPCs. - What happens when a transaction gets resolved for some reason (e.g. evicted from mempool or mempool check fails with a temporary fee issue), and the transaction get resubmitted? I think no retry will happen and no error is returned.
optout21 (Migrated from github.com) commented 2026-10-06 08:31:34 +00:00

dc95a70 net: always complete all initial private broadcast connections:

Nit: This could be pass-by-reference (mainly for consistency).

> [dc95a70](https://github.com/bitcoin/bitcoin/pull/36277/changes/dc95a705d402d44b7092150878e33c75383a4d47) _net: always complete all initial private broadcast connections_: Nit: This could be pass-by-reference (mainly for consistency).
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36277
No description provided.