private broadcast: show finished transactions in getprivatebroadcastinfo #36477

Open
vasild wants to merge 1 commit from pb_show_concluded into master AGit
vasild commented 2026-10-08 15:16:42 +00:00 (Migrated from github.com)

For finished transactions, this allows the inspection of when and to whom the transaction was sent as well as when/if it was echoed from the network.

For finished transactions, this allows the inspection of when and to whom the transaction was sent as well as when/if it was echoed from the network.
DrahtBot commented 2026-10-08 15:16:50 +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
Concept ACK optout21

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:

  • #36607 (private broadcast: Extra guard against unintended non-private broadcast of private transactions by optout21)
  • #36429 ([RFC] Scheduled transaction broadcast, minimal by optout21)
  • #35502 (refactor: extract per-message helpers from ProcessMessage (move-only) by w0xlt)

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/36477 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36477.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36477#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 | | ---- | --------- | | Concept ACK | [optout21](https://github.com/bitcoin/bitcoin/pull/36477#issuecomment-6343001721) | 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: * [#36607](https://github.com/bitcoin/bitcoin/pull/36607) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36607.svg"></sub> (private broadcast: Extra guard against unintended non-private broadcast of private transactions by optout21) * [#36429](https://github.com/bitcoin/bitcoin/pull/36429) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36429.svg"></sub> ([RFC] Scheduled 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) 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-->
First-time contributor

Earlier concerns remain unresolved; see the full report for their current assessments.

🟠 Minor · Fuzz eviction leaves the replacement transaction without an addition time

After an eviction, the fuzz harness's GetStale model can throw std::out_of_range or reuse an obsolete timestamp, causing a false fuzz failure.

Location: src/test/fuzz/private_broadcast.cpp:160 (head).

🟠 Minor · Resolved transactions overstate remaining send attempts

With -privatebroadcast enabled, an early echo can make getprivatebroadcastinfo report 999 remaining attempts even though only two already-planned sends remain.

Location: src/private_broadcast.cpp:193 (head).

🟠 Minor · Explicit re-add can succeed without restarting an exhausted broadcast

Re-adding an exhausted entry while any recipient is still connected returns AlreadyPresent. InitiateTxBroadcastPrivate reports that as OK without scheduling connections. Base reset such entries at the attempt limit.

Location: src/private_broadcast.cpp:27 (head).

🟠 Minor · received_by_us.time records processing time, not receipt time

MarkResolved stores NodeClock::now(), even though ProcessMessage already has time_received, so received_by_us.time includes any message-processing delay. The size of that delay has not been measured.

Location: src/private_broadcast.cpp:79 (head).

🔵 Suggestion · Eviction tests do not check oldest-first ordering

The current unit and fuzz assertions do not distinguish oldest-first eviction from choosing an arbitrary finished entry.

Location: src/test/fuzz/private_broadcast.cpp:141 (head).

🔵 Suggestion · Remove the unused structured-binding element

The new fuzz IsFinished lambda binds num_picked but uses only tx and e, leaving an unused and misleading local.

Location: src/test/fuzz/private_broadcast.cpp:70 (head).

Review coverage was incomplete.


Reviewed: 95cc8adddec6 · Full review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:4d44b6ffa09c54db24f8f0ab27ae388beae06a733efcae741ca64db76bb1c938:7efd3c3ba41667382004cfa7a7db56605da7d8f9b7ab69bc483f27117390ba48 --> <!-- ralph-base:42b28c8a231a21ed53dc7235c814613b3746622b --> <!-- ralph-head:95cc8adddec6d686f7eeea9a8da3d851a1bbde54 --> <!-- ralph-case:3d6d6296986979820c43cebea810925a89176434842850beec501c3d4bad78c4 --> Earlier concerns remain unresolved; see the full report for their current assessments. **🟠 Minor · Fuzz eviction leaves the replacement transaction without an addition time** After an eviction, the fuzz harness's GetStale model can throw std::out_of_range or reuse an obsolete timestamp, causing a false fuzz failure. Location: [`src/test/fuzz/private_broadcast.cpp:160`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/95cc8adddec6d686f7eeea9a8da3d851a1bbde54/src/test/fuzz/private_broadcast.cpp#L160>) (head). **🟠 Minor · Resolved transactions overstate remaining send attempts** With -privatebroadcast enabled, an early echo can make getprivatebroadcastinfo report 999 remaining attempts even though only two already-planned sends remain. Location: [`src/private_broadcast.cpp:193`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/95cc8adddec6d686f7eeea9a8da3d851a1bbde54/src/private_broadcast.cpp#L193>) (head). **🟠 Minor · Explicit re-add can succeed without restarting an exhausted broadcast** Re-adding an exhausted entry while any recipient is still connected returns AlreadyPresent. InitiateTxBroadcastPrivate reports that as OK without scheduling connections. Base reset such entries at the attempt limit. Location: [`src/private_broadcast.cpp:27`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/95cc8adddec6d686f7eeea9a8da3d851a1bbde54/src/private_broadcast.cpp#L27>) (head). **🟠 Minor · `received_by_us.time` records processing time, not receipt time** MarkResolved stores NodeClock::now(), even though ProcessMessage already has time_received, so received_by_us.time includes any message-processing delay. The size of that delay has not been measured. Location: [`src/private_broadcast.cpp:79`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/95cc8adddec6d686f7eeea9a8da3d851a1bbde54/src/private_broadcast.cpp#L79>) (head). **🔵 Suggestion · Eviction tests do not check oldest-first ordering** The current unit and fuzz assertions do not distinguish oldest-first eviction from choosing an arbitrary finished entry. Location: [`src/test/fuzz/private_broadcast.cpp:141`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/95cc8adddec6d686f7eeea9a8da3d851a1bbde54/src/test/fuzz/private_broadcast.cpp#L141>) (head). **🔵 Suggestion · Remove the unused structured-binding element** The new fuzz IsFinished lambda binds num_picked but uses only tx and e, leaving an unused and misleading local. Location: [`src/test/fuzz/private_broadcast.cpp:70`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/95cc8adddec6d686f7eeea9a8da3d851a1bbde54/src/test/fuzz/private_broadcast.cpp#L70>) (head). Review coverage was incomplete. <!-- Review tier: sensitive --> --- Reviewed: [`95cc8adddec6`](<https://git.fish.foo/bitcoin/bitcoin/commit/95cc8adddec6d686f7eeea9a8da3d851a1bbde54>) · [Full review report](<https://review.fish.foo/traces/36477-95cc8adddec6d686f7eeea9a8da3d851a1bbde54-2232-11.html>) · [Previous reports](<https://review.fish.foo/traces/36477/>) [permalink](<https://review.fish.foo/traces/36477-95cc8adddec6d686f7eeea9a8da3d851a1bbde54-2232-11.html>)
frankomosh (Migrated from github.com) reviewed 2026-10-19 18:48:38 +00:00
frankomosh (Migrated from github.com) left a comment

I guess this is a continuation of #34707. Could you share what was added or left out compared to it?

I guess this is a continuation of #34707. Could you share what was added or left out compared to it?
frankomosh (Migrated from github.com) commented 2026-10-19 18:42:09 +00:00

A tx that used all its send attempts, but never came back from the network, can no longer be sent again. Now Add() can only restarts a tx that is resolved. But GetStale() skips such a tx, so nothing marks it resolved.

Are we getting rid of the 'retry' feature..?

A tx that used all its send attempts, but never came back from the network, can no longer be sent again. Now `Add()` can only restarts a tx that is resolved. But `GetStale()` skips such a tx, so nothing marks it resolved. Are we getting rid of the 'retry' feature..?
frankomosh (Migrated from github.com) commented 2026-10-19 18:44:34 +00:00

If another peer sends us the same tx later, this line replaces the saved peer and time. So received_by_us may not show the first peer that sent it back.

Should we keep the first one?

If another peer sends us the same tx later, this line replaces the saved peer and time. So `received_by_us` may not show the first peer that sent it back. Should we keep the first one?
vasild (Migrated from github.com) reviewed 2026-10-22 13:19:48 +00:00
vasild (Migrated from github.com) commented 2026-10-22 13:19:48 +00:00

No, that was not intentional. Fixed. Please double check again, this has become non-trivial.

No, that was not intentional. Fixed. Please double check again, this has become non-trivial.
vasild (Migrated from github.com) reviewed 2026-10-22 13:23:16 +00:00
vasild (Migrated from github.com) commented 2026-10-22 13:23:16 +00:00

Right, changed it to only set received_by_us if it is not set.

Right, changed it to only set `received_by_us` if it is not set.
vasild commented 2026-10-22 13:32:41 +00:00 (Migrated from github.com)

bce73a17fd2754f5fad9248bdcd13b3bad0ae023...0aa81936cf2d51f55eeaca26fd036ad8d5fdc09f: rebase and address suggestions from @frankomosh and https://review.fish.foo/traces/36477-bce73a17fd2754f5fad9248bdcd13b3bad0ae023-991-2.html

PS

I guess this is a continuation of https://github.com/bitcoin/bitcoin/pull/34707. Could you share what was added or left out compared to it?

I am unsure. Better review this one as a fresh new unrelated one.

`bce73a17fd2754f5fad9248bdcd13b3bad0ae023...0aa81936cf2d51f55eeaca26fd036ad8d5fdc09f`: rebase and address suggestions from @frankomosh and https://review.fish.foo/traces/36477-bce73a17fd2754f5fad9248bdcd13b3bad0ae023-991-2.html PS > I guess this is a continuation of https://github.com/bitcoin/bitcoin/pull/34707. Could you share what was added or left out compared to it? I am unsure. Better review this one as a fresh new unrelated one.
optout21 commented 2026-10-22 14:17:37 +00:00 (Migrated from github.com)

Concept ACK
Keeping info about completed transaction is useful for the user.
This info may be useful for the feature implementation as well (e.g. see #36607 for a proposal how to refuse non-private broadcast of private transactions).

Concept ACK Keeping info about completed transaction is useful for the user. This info may be useful for the feature implementation as well (e.g. see #36607 for a proposal how to refuse non-private broadcast of private transactions).
optout21 (Migrated from github.com) reviewed 2026-10-22 14:41:39 +00:00
optout21 (Migrated from github.com) left a comment

Performed a review pass (0aa81936cf), looks good generally; left some comments.

Performed a review pass (0aa81936cf2d51f55eeaca26fd036ad8d5fdc09f), looks good generally; left some comments.
optout21 (Migrated from github.com) commented 2026-10-22 14:40:03 +00:00

Related, what happens when a previously-finished transaction is requested to be private-broadcast again?

  • Add() sees it finished, and clears received_by_us and resolved
  • It is sent out again (to 3 peers)
  • It never gets re-added to our mempool, as it already there. MarkResolved is not called again.
  • The transaction may be taken as failed
  • Final state reported in RPC: attempts_remaining 0 and no received_by_us

Is this intended this way?

Related, what happens when a previously-finished transaction is requested to be private-broadcast again? - `Add()` sees it finished, and clears `received_by_us` and `resolved` - It is sent out again (to 3 peers) - It never gets re-added to our mempool, as it already there. `MarkResolved` is not called again. - The transaction may be taken as failed - Final state reported in RPC: `attempts_remaining` 0 and no `received_by_us` Is this intended this way?
Lines 184-185
optout21 (Migrated from github.com) commented 2026-10-22 14:31:39 +00:00

0aa8193 private broadcast: show finished transactions in getprivatebroadcastinfo:

Minor inaccuracy: echoed transaction may still have attempts_remaining > 0 initially. Maybe the text should list the stored categories: transactions being actively sent, sent but not echoed back, and echoed back.

> [0aa8193](https://github.com/bitcoin/bitcoin/pull/36477/changes/0aa81936cf2d51f55eeaca26fd036ad8d5fdc09f) _private broadcast: show finished transactions in getprivatebroadcastinfo_: Minor inaccuracy: echoed transaction may still have `attempts_remaining > 0` initially. Maybe the text should list the stored categories: transactions being actively sent, sent but not echoed back, and echoed back.
optout21 (Migrated from github.com) commented 2026-10-22 14:33:01 +00:00

0aa8193 private broadcast: show finished transactions in getprivatebroadcastinfo:

This should also be updated.

> [0aa8193](https://github.com/bitcoin/bitcoin/pull/36477/changes/0aa81936cf2d51f55eeaca26fd036ad8d5fdc09f) _private broadcast: show finished transactions in getprivatebroadcastinfo_: This should also be updated.
vasild (Migrated from github.com) reviewed 2026-10-23 14:50:01 +00:00
vasild (Migrated from github.com) commented 2026-10-23 14:50:01 +00:00

It never gets re-added to our mempool, as it already there. MarkResolved is not called again.

Note that MarkResolved() is called after we receive the transaction but before we try to put it in the mempool:

github.com/bitcoin/bitcoin@df0dc1e2d2/src/net_processing.cpp (L4734)

github.com/bitcoin/bitcoin@df0dc1e2d2/src/net_processing.cpp (L4770)

So, it will be marked as resolved if we receive it, even if it wouldn't enter the mempool because it is already there.

But... would we receive it (a second time)? After the initial receive we would send it to all peers. So all of them know we have it. They wouldn't INV it to us anymore and even if they do we wouldn't request it (with GETDATA) because we have it in our mempool already.

So, yes, there is no reliable way to know if the second broadcast succeeded. This is the same in master right now. There may be new peers in the meantime that are unaware that we have the transaction and they will INV it to us (if it even starts propagating a second time through the network). Something to consider, separately from this PR. I do not think this PR changes the behavior.

> It never gets re-added to our mempool, as it already there. `MarkResolved` is not called again. Note that `MarkResolved()` is called after we receive the transaction but before we try to put it in the mempool: https://github.com/bitcoin/bitcoin/blob/df0dc1e2d2059213e49a9f115fd55a9f0119d26c/src/net_processing.cpp#L4734 https://github.com/bitcoin/bitcoin/blob/df0dc1e2d2059213e49a9f115fd55a9f0119d26c/src/net_processing.cpp#L4770 So, it will be marked as resolved if we receive it, even if it wouldn't enter the mempool because it is already there. But... would we receive it (a second time)? After the initial receive we would send it to all peers. So all of them know we have it. They wouldn't `INV` it to us anymore and even if they do we wouldn't request it (with `GETDATA`) because we have it in our mempool already. So, yes, there is no reliable way to know if the second broadcast succeeded. This is the same in `master` right now. There may be new peers in the meantime that are unaware that we have the transaction and they will `INV` it to us (if it even starts propagating a second time through the network). Something to consider, separately from this PR. I do not think this PR changes the behavior.
vasild commented 2026-10-23 15:00:21 +00:00 (Migrated from github.com)

0aa81936cf2d51f55eeaca26fd036ad8d5fdc09f...295c961c1f156bdbbddfa0f961751d5aa371a62b: address suggestions

`0aa81936cf2d51f55eeaca26fd036ad8d5fdc09f...295c961c1f156bdbbddfa0f961751d5aa371a62b`: address suggestions
vasild (Migrated from github.com) reviewed 2026-10-23 15:02:28 +00:00
Lines 184-185
vasild (Migrated from github.com) commented 2026-10-23 15:02:28 +00:00

Right. This text is to explain that some transactions will remain (because all others would be removed). Now I think it is not necessary because all will remain, so no need to explain that some particular ones will remain. Dropped the sentence.

Right. This text is to explain that some transactions will remain (because all others would be removed). Now I think it is not necessary because all will remain, so no need to explain that _some_ particular ones will remain. Dropped the sentence.
vasild (Migrated from github.com) reviewed 2026-10-23 15:04:02 +00:00
vasild (Migrated from github.com) commented 2026-10-23 15:04:02 +00:00

Shortened to just:

"abortprivatebroadcast",
"Abort private broadcast of a transaction and remove it from the queue.\n"
"This method is only available when running with -privatebroadcast enabled.\n",

good?

Shortened to just: ``` "abortprivatebroadcast", "Abort private broadcast of a transaction and remove it from the queue.\n" "This method is only available when running with -privatebroadcast enabled.\n", ``` good?
optout21 (Migrated from github.com) reviewed 2026-10-24 16:35:40 +00:00
optout21 (Migrated from github.com) commented 2026-10-24 16:35:40 +00:00

True, upon a re-request there new new relay will happen. Other nodes and this node will have the TX already in their mempool. As a result, "received_by_us" will never be set, and it will be not possible to decide/observe the success of the second broadcast.

My point was, that if the TX is already in our mempool, and for some strange reason it is relayed back to us after the re-request, our node will not request GETDATA (because TX is in the mempool), the handler will not be called, and the "receive" flags will remain empty.

The behavior on master is the same, except that the "received_by_us" flag is a new addition.

I can see these cases:

  1. Already in the mempool, and no re-relay happens (the likely case): The "received_by_us" stays empty
  2. Already in the mempool, but re-relay happens: The "received_by_us" stays empty -- AlreadyHaveTx is true, so no GETDATA is sent, no TX arrives, and the TX handler (MarkResolved) is never called.
  3. Not in the mempool and re-relay happens: "received_by_us" is set.

Case 2. could be argued about, but I think it's fine. The root of the issue is that upon re-request there will be no new relay.

One idea that we could consider though: upon a re-request don't clean the "received" flag if the TX is already in the mempool (persist that info that we have received it previously; and do perform the new sendouts).

True, upon a re-request there new new relay will happen. Other nodes and this node will have the TX already in their mempool. As a result, "received_by_us" will never be set, and it will be not possible to decide/observe the success of the second broadcast. My point was, that if the TX is already in our mempool, and for some strange reason it is relayed back to us after the re-request, our node will not request GETDATA (because TX is in the mempool), the handler will not be called, and the "receive" flags will remain empty. The behavior on `master` is the same, except that the "received_by_us" flag is a new addition. I can see these cases: 1. Already in the mempool, and no re-relay happens (the likely case): The "received_by_us" stays empty 2. Already in the mempool, but re-relay happens: The "received_by_us" stays empty -- `AlreadyHaveTx` is true, so no GETDATA is sent, no TX arrives, and the TX handler (`MarkResolved`) is never called. 3. Not in the mempool and re-relay happens: "received_by_us" is set. Case 2. could be argued about, but I think it's fine. The root of the issue is that upon re-request there will be no new relay. One idea that we could consider though: upon a re-request don't clean the "received" flag if the TX is already in the mempool (persist that info that we have received it previously; and do perform the new sendouts).
frankomosh (Migrated from github.com) reviewed 2026-10-27 18:57:09 +00:00
frankomosh (Migrated from github.com) commented 2026-10-27 18:57:09 +00:00

No, that was not intentional. Fixed. Please double check again, this has become non-trivial.

Looks good now.

Also noticed a good side effect: a tx that used all its attempts can now be removed when the queue is full. Before, it blocked the queue.

> No, that was not intentional. Fixed. Please double check again, this has become non-trivial. Looks good now. Also noticed a good side effect: a tx that used all its attempts can now be removed when the queue is full. Before, it blocked the queue.
frankomosh (Migrated from github.com) reviewed 2026-10-27 19:03:21 +00:00
frankomosh (Migrated from github.com) commented 2026-10-27 19:03:21 +00:00

Checked on 295c961.., looks good.

Maybe later we could add a test for it. For now, removing && !state.received_by_us.has_value()(mutant), and all tests still unnecesarily pass (unit, fuzz and functional).

Checked on 295c961.., looks good. Maybe later we could add a test for it. For now, removing `&& !state.received_by_us.has_value()`(mutant), and all tests still unnecesarily pass (unit, fuzz and functional).
optout21 (Migrated from github.com) reviewed 2026-10-28 12:11:43 +00:00
optout21 (Migrated from github.com) left a comment

Reviewed again, left some nits. I'm happy to revisit soon!
Friendly reminder one previous question of mine has not been fully addressed yet.

Reviewed again, left some nits. I'm happy to revisit soon! Friendly reminder [one previous question](https://github.com/bitcoin/bitcoin/pull/36477#discussion_r4367750443) of mine has not been fully addressed yet.
optout21 (Migrated from github.com) commented 2026-10-28 12:07:06 +00:00

295c961 private broadcast: show finished transactions in getprivatebroadcastinfo:

Nit: the expression state.planned_sends >= m_max_send_attempts appears 4 times, maybe it could be put into a helper method (e.g. NoMoreRetries()).

> [295c961](https://github.com/bitcoin/bitcoin/pull/36477/changes/295c961c1f156bdbbddfa0f961751d5aa371a62b) _private broadcast: show finished transactions in getprivatebroadcastinfo_: Nit: the expression `state.planned_sends >= m_max_send_attempts` appears 4 times, maybe it could be put into a helper method (e.g. `NoMoreRetries()`).
optout21 (Migrated from github.com) commented 2026-10-28 12:00:50 +00:00

295c961 private broadcast: show finished transactions in getprivatebroadcastinfo:

Nit: "(0 if exhausted or completed)"

> [295c961](https://github.com/bitcoin/bitcoin/pull/36477/changes/295c961c1f156bdbbddfa0f961751d5aa371a62b) _private broadcast: show finished transactions in getprivatebroadcastinfo_: Nit: "(0 if exhausted or completed)"
optout21 (Migrated from github.com) commented 2026-10-28 11:59:13 +00:00

295c961 private broadcast: show finished transactions in getprivatebroadcastinfo:

Minor: Comment doc should be updated.

> [295c961](https://github.com/bitcoin/bitcoin/pull/36477/changes/295c961c1f156bdbbddfa0f961751d5aa371a62b) _private broadcast: show finished transactions in getprivatebroadcastinfo_: Minor: Comment doc should be updated.
optout21 (Migrated from github.com) commented 2026-10-28 12:02:59 +00:00

295c961 private broadcast: show finished transactions in getprivatebroadcastinfo:

Nit: The "Trimmed by Remove() and Add() cleanup" part is not fully correct now.

> [295c961](https://github.com/bitcoin/bitcoin/pull/36477/changes/295c961c1f156bdbbddfa0f961751d5aa371a62b) _private broadcast: show finished transactions in getprivatebroadcastinfo_: Nit: The "Trimmed by Remove() and Add() cleanup" part is not fully correct now.
DrahtBot commented 2026-10-29 16:46:43 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
vasild (Migrated from github.com) reviewed 2026-11-04 17:09:32 +00:00
vasild (Migrated from github.com) commented 2026-11-04 17:09:32 +00:00

One idea that we could consider though: upon a re-request don't clean the "received" flag if the TX is already in the mempool (persist that info that we have received it previously; and do perform the new sendouts)

I like this. However there would be inconsistency between the rest of the statuses and received_by_us. For example it would look that we have sent it to nobody and we have received it. I imagine we could keep all statuses: original time added, all peers we have sent to and the received by us. Then we would replace the global m_max_send_attempts (1000) with a per-transaction one and whenever a transaction is re-added, bump its max from 1000 to 2000 and increment planned_sends with INITIAL_CONNECTION_COUNT (3) instead of resetting it to 3.

This way all the history from before and from after the re-add will be visible. Maybe an overkill?

> One idea that we could consider though: upon a re-request don't clean the "received" flag if the TX is already in the mempool (persist that info that we have received it previously; and do perform the new sendouts) I like this. However there would be inconsistency between the rest of the statuses and `received_by_us`. For example it would look that we have sent it to nobody and we have received it. I imagine we could keep all statuses: original time added, all peers we have sent to and the received by us. Then we would replace the global `m_max_send_attempts` (1000) with a per-transaction one and whenever a transaction is re-added, bump its max from 1000 to 2000 and increment `planned_sends` with `INITIAL_CONNECTION_COUNT` (3) instead of resetting it to 3. This way all the history from before and from after the re-add will be visible. Maybe an overkill?
vasild commented 2026-11-05 13:30:14 +00:00 (Migrated from github.com)

295c961c1f156bdbbddfa0f961751d5aa371a62b...95cc8adddec6d686f7eeea9a8da3d851a1bbde54: rebase due to conflicts and address suggestions.

Still in discussion: https://github.com/bitcoin/bitcoin/pull/36477#discussion_r4367750443

`295c961c1f156bdbbddfa0f961751d5aa371a62b...95cc8adddec6d686f7eeea9a8da3d851a1bbde54`: rebase due to conflicts and address suggestions. Still in discussion: https://github.com/bitcoin/bitcoin/pull/36477#discussion_r4367750443
frankomosh (Migrated from github.com) reviewed 2026-11-05 13:30:31 +00:00
frankomosh (Migrated from github.com) commented 2026-11-05 13:30:31 +00:00

Maybe an overkill?

I tend to agree..., one cost to keep in mind: today, each tx keeps at most 1000 send records. In https://github.com/bitcoin/bitcoin/pull/35680#discussion_r3782713926 I measured the worst-case getprivatebroadcastinfo output at about 1.15 GiB.

With a limit that grows on every re-add, a tx that is re-sent many times would keep growing with no cap. So if we go this way, maybe we still need a cap on the history

> Maybe an overkill? I tend to agree..., one cost to keep in mind: today, each tx keeps at most 1000 send records. In https://github.com/bitcoin/bitcoin/pull/35680#discussion_r3782713926 I measured the worst-case `getprivatebroadcastinfo` output at about 1.15 GiB. With a limit that grows on every re-add, a tx that is re-sent many times would keep growing with no cap. So if we go this way, maybe we still need a cap on the history
vasild (Migrated from github.com) reviewed 2026-11-05 13:31:38 +00:00
vasild (Migrated from github.com) commented 2026-11-05 13:31:38 +00:00

Right, put it into a helper method. However NoMoreRetries() sounds too broad to me because we may do "no more retries" if the transaction was echoed back to us. Used PlannedSendsAtMax() as a name.

Right, put it into a helper method. However `NoMoreRetries()` sounds too broad to me because we may do "no more retries" if the transaction was echoed back to us. Used `PlannedSendsAtMax()` as a name.
vasild (Migrated from github.com) reviewed 2026-11-05 13:32:18 +00:00
vasild (Migrated from github.com) commented 2026-11-05 13:32:18 +00:00

Done

Done
vasild (Migrated from github.com) reviewed 2026-11-05 13:32:30 +00:00
vasild (Migrated from github.com) commented 2026-11-05 13:32:30 +00:00

Done

Done
vasild (Migrated from github.com) reviewed 2026-11-05 13:32:40 +00:00
vasild (Migrated from github.com) commented 2026-11-05 13:32:40 +00:00

Done

Done
vasild (Migrated from github.com) reviewed 2026-11-05 16:44:41 +00:00
vasild (Migrated from github.com) commented 2026-11-05 16:44:41 +00:00

Ok, then what to do with received_by_us in the case of re-add? I tend to lean towards resetting it as it is now in this PR because not resetting it would leave it inconsistent with the other fields.

Ok, then what to do with `received_by_us` in the case of re-add? I tend to lean towards resetting it as it is now in this PR because not resetting it would leave it inconsistent with the other fields.
optout21 (Migrated from github.com) reviewed 2026-11-10 14:30:59 +00:00
optout21 (Migrated from github.com) commented 2026-11-10 14:30:59 +00:00

After reconsidering, I'm also for keeping the current logic. My suggestion would add further complexity, and would not solve all inconsistencies. The root cause is that a submission can be repeated, but he hearing back will likely not. Resubmission is not a regular use case, but if it's done, the user has to know that the received info will only be valid since the resubmission.
So for me it's fine like this.

After reconsidering, I'm also for keeping the current logic. My suggestion would add further complexity, and would not solve all inconsistencies. The root cause is that a submission can be repeated, but he hearing back will likely not. Resubmission is not a regular use case, but if it's done, the user has to know that the received info will only be valid since the resubmission. So for me it's fine like this.
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!36477
No description provided.