mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 12:20:38 +00:00
private broadcast: show finished transactions in getprivatebroadcastinfo #36477
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!36477
Loading…
Reference in a new issue
No description provided.
Delete branch "pb_show_concluded"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.
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.
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:
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.
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.timerecords processing time, not receipt timeMarkResolved 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 reportspermalink
I guess this is a continuation of #34707. Could you share what was added or left out compared to it?
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. ButGetStale()skips such a tx, so nothing marks it resolved.Are we getting rid of the 'retry' feature..?
If another peer sends us the same tx later, this line replaces the saved peer and time. So
received_by_usmay not show the first peer that sent it back.Should we keep the first one?
No, that was not intentional. Fixed. Please double check again, this has become non-trivial.
Right, changed it to only set
received_by_usif it is not set.bce73a17fd2754f5fad9248bdcd13b3bad0ae023...0aa81936cf2d51f55eeaca26fd036ad8d5fdc09f: rebase and address suggestions from @frankomosh and https://review.fish.foo/traces/36477-bce73a17fd2754f5fad9248bdcd13b3bad0ae023-991-2.htmlPS
I am unsure. Better review this one as a fresh new unrelated one.
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).
Performed a review pass (
0aa81936cf), looks good generally; left some comments.Related, what happens when a previously-finished transaction is requested to be private-broadcast again?
Add()sees it finished, and clearsreceived_by_usandresolvedMarkResolvedis not called again.attempts_remaining0 and noreceived_by_usIs this intended this way?
Minor inaccuracy: echoed transaction may still have
attempts_remaining > 0initially. Maybe the text should list the stored categories: transactions being actively sent, sent but not echoed back, and echoed back.This should also be updated.
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
INVit to us anymore and even if they do we wouldn't request it (withGETDATA) 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
masterright now. There may be new peers in the meantime that are unaware that we have the transaction and they willINVit 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.0aa81936cf2d51f55eeaca26fd036ad8d5fdc09f...295c961c1f156bdbbddfa0f961751d5aa371a62b: address suggestionsRight. 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.
Shortened to just:
good?
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
masteris the same, except that the "received_by_us" flag is a new addition.I can see these cases:
AlreadyHaveTxis true, so no GETDATA is sent, no TX arrives, and the TX handler (MarkResolved) is never called.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).
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.
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).Reviewed again, left some nits. I'm happy to revisit soon!
Friendly reminder one previous question of mine has not been fully addressed yet.
Nit: the expression
state.planned_sends >= m_max_send_attemptsappears 4 times, maybe it could be put into a helper method (e.g.NoMoreRetries()).Nit: "(0 if exhausted or completed)"
Minor: Comment doc should be updated.
Nit: The "Trimmed by Remove() and Add() cleanup" part is not fully correct now.
🐙 This pull request conflicts with the target branch and needs rebase.
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 globalm_max_send_attempts(1000) with a per-transaction one and whenever a transaction is re-added, bump its max from 1000 to 2000 and incrementplanned_sendswithINITIAL_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?
295c961c1f156bdbbddfa0f961751d5aa371a62b...95cc8adddec6d686f7eeea9a8da3d851a1bbde54: rebase due to conflicts and address suggestions.Still in discussion: https://github.com/bitcoin/bitcoin/pull/36477#discussion_r4367750443
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
getprivatebroadcastinfooutput 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
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. UsedPlannedSendsAtMax()as a name.Done
Done
Done
Ok, then what to do with
received_by_usin 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.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.