Review report

core: PR #36429

3 minor findings · 7 suggestions

Earlier concerns neither republished nor resolved: 1 minor finding · 1 suggestion. See the Run archive for their assessments.

Findings

Link

[minor] · Due entries become sendable before release-time validation

With overlapping private-broadcast activity or a concurrent abort, publishing released=true before validation can bypass the release-time drop and miscount connection requests.

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

Details and suggested fix

ReleaseDue() marks the whole due batch sendable before ReleaseDelayedPrivateBroadcast() acquires cs_main, validates each transaction, and requests connections. An outstanding connection opened for another entry can finish its handshake during this window, select a newly released transaction, and queue its INV without cs_main. If GETDATA also wins against removal, it can receive the full TX. A subsequent rejection, such as for inputs spent by a competing transaction, cannot retract that announcement. The successful connection is not replaced for the other entry, and its remaining unpicked sends prevent TryGrantRetry() from compensating. A concurrent abort can also subtract up to three requests that have not yet been added, cancelling other queued work; successful validation can later add requests for the removed entry. Collect due entries without making them sendable, validate them, then coordinate release and connection accounting with removal so only the same still-queued entries are published and counted.


Link

[minor] · Delayed mempool rebroadcasts fail the release check

A delayed rebroadcast can succeed at submission and then be discarded as a mempool duplicate, although the same request without a delay supports private rebroadcast.

Location: src/net_processing.cpp:1793 (head).

Details and suggested fix

When the txid is already in the mempool, BroadcastTransaction() skips submission-time test_accept and still calls InitiateTxBroadcastPrivate(tx, delay). The existing functional test covers this as a supported immediate rebroadcast. With a positive delay, an entry that reaches release while the transaction remains in the mempool instead fails PreChecks() with txn-already-in-mempool or txn-same-nonwitness-data-in-mempool. The release task removes it rather than requesting its broadcast connections. Eviction before release can change this outcome, so mempool membership is the trigger, not a transaction becoming invalid. Reject this delayed-mempool case explicitly at submission instead of reporting success and discarding it later, and add a delayed case beside the existing mempool-rebroadcast test.


Link

[minor] · An expired insertion deadline skips both connection-request paths

If the sampled deadline passes before Add() reads the clock, submission can succeed without requesting connections, and an otherwise idle private-broadcast queue does not automatically recover.

Location: src/net_processing.cpp:2552 (head).

Details and suggested fix

InitiateTxBroadcastPrivate() computes a deadline before calling Add(). If it expires before Add() takes its clock sample, the queue stores released=true, but the caller still sees a populated release_time and returns without requesting connections. ReleaseDue() skips the released entry, and stale retry refuses it because none of its three planned sends has been picked. Ordinary resubmission also returns AlreadyPresent. With no other private-broadcast activity, the transaction can remain unsent until the user aborts and submits it again. Have Add() report whether it actually stored a held entry, and request initial connections when it instead released the entry immediately. The smallest randomized delay is one second. No trigger beyond thread or VM suspension, or a forward system-clock step between these adjacent clock reads, was identified; production impact is unconfirmed.


Optional improvements

Link

[suggestion] · The inspection RPC omits delayed entries' release state

Held entries and released entries awaiting a connection both show empty peers and all attempts remaining, so RPC clients cannot distinguish them.

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

Details and suggested fix

GetBroadcastInfo() now supplies the randomized release_time, but getprivatebroadcastinfo omits it and has no held/released indicator. Add a documented release_time result of type NUM_TIME, carry released in the snapshot, and expose that state too. A deadline alone is insufficient because eligibility changes only when ReleaseDue() runs. The functional test currently detects this transition by scraping debug.log; assert the RPC state transition instead. These additions preserve scheduling and relay behavior.


Link

[suggestion] · Successful resubmission silently preserves the original schedule

Resubmitting a queued transaction with attempts remaining returns success without applying delay_for, so zero cannot expedite a hold and a positive value cannot postpone an existing schedule.

Location: src/rpc/mempool.cpp:125 (head).

Details and suggested fix

Add() returns AlreadyPresent before changing timing fields, and InitiateTxBroadcastPrivate() reports success. Thus, resubmitting a held entry with delay_for=0 leaves it held, while supplying a delay for an immediately queued entry does not hold it back. The header and unit test make this intentional, but the RPC help promises a minimum delay without explaining the exception. Document in the help and release note that resubmission preserves the existing schedule and does not re-randomize it. Explain that changing a pending schedule requires abortprivatebroadcast followed by resubmission, which cannot undo sends already made.


Link

[suggestion] · The jitter help can imply a five-minute minimum addition

For short delays, the sampled extra delay can be zero, but the RPC help can be read as guaranteeing at least five additional minutes.

Location: src/rpc/mempool.cpp:105 (head).

Details and suggested fix

RandomizeDelay() adds a uniformly sampled whole-second value from zero through max(50% of the requested delay, 5 minutes). Consequently, delay_for=1 can produce a total delay of one second. The phrase "up to 50% (but at least 5 minutes) is added" does not clearly distinguish the range's upper bound from the sampled addition. Say that a random extra delay, uniformly chosen in whole seconds between zero and max(50% of delay_for, 5 minutes), is added. This clarifies the existing distribution without changing behavior.


Link

[suggestion] · Wall-clock corrections change the promised minimum hold

A forward system-clock step can release a held transaction before delay_for seconds have elapsed, weakening the intended creation-time concealment.

Location: src/net_processing.cpp:2548 (head).

Details and suggested fix

The deadline and ReleaseDue() comparison both use the adjustable NodeClock. A sufficiently large forward correction can make a hold due at the next release check before the requested interval has elapsed; a backward correction prolongs it. The help's "at least this many seconds" wording does not state that assumption. Document that the minimum assumes no forward wall-clock adjustment if wall-clock scheduling is intended. If the contract instead promises elapsed time, use MockableSteadyClock for eligibility and retain separate wall-clock metadata for display. That alternative also needs functional-test clock plumbing because the current test uses setmocktime, which does not mock the steady clock.


Link

[suggestion] · The delayed-success test only requires one initial delivery

Requesting one connection instead of INITIAL_CONNECTION_COUNT at release would still satisfy the new delayed-success assertion.

Location: test/functional/p2p_private_broadcast.py:304 (head).

Details and suggested fix

After release, this case waits for any peer entry containing received and immediately aborts the transaction. Production requests three initial connections per released transaction, but the assertion would also accept a regression that requested only one. The other planned sends would remain unpicked, which prevents TryGrantRetry() from compensating. Record the destination offset before submission and reuse check_broadcasts() after release to require NUM_PRIVATE_BROADCAST_PER_TX completed deliveries before aborting. Keep mocktime frozen during that check so stale retries cannot mask missing initial sends.


Link

[suggestion] · The delay_for RPC guards lack functional rejection coverage

The functional test only supplies delay_for=60 with private broadcast enabled, leaving the range errors and positive-delay option requirement untested.

Location: test/functional/p2p_private_broadcast.py:273 (head).

Details and suggested fix

The new RPC guards reject values outside 0 through 43200 and reject positive delays without -privatebroadcast, but none of those rejection paths is exercised. The RandomizeDelay() unit tests cover helper clamping rather than RPC rejection. Using an otherwise valid transaction, assert that -1 and 43201 fail on nodes[0], and that a positive delay fails on nodes[1], where private broadcast is disabled. Check that the relevant mempools and the enabled node's private-broadcast queue remain unchanged after rejection.


Link

[suggestion] · Private-broadcast fuzzers never enter the delayed state

Both P2P initiation sites pass zero delay, and the queue-model fuzzer never supplies a deadline or calls ReleaseDue(), leaving held-state transitions outside fuzz coverage.

Location: src/test/fuzz/p2p_private_broadcast.cpp:85 (head).

Details and suggested fix

The new held state changes removal accounting, makes MarkResolved() erase entries, and gates picking, pending status, and staleness. Extend the queue model with consumed optional release times and a ReleaseDue() action driven by its existing mock-clock changes. Model that held entries are not pickable or stale, removal returns zero, resolution erases them, and AlreadyPresent preserves their schedule; include exhausted re-adds too. Consume small delays in the P2P target as well, but drive scheduled tasks if it is to cover release rather than only holding. These changes would exercise serial state and accounting invariants, not reproduce the cross-thread release/validation race.


Coverage details

Earlier concerns

Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.