Skip to content

net: isolated broadcast waits for the peer's pong - #1342

Merged
reardencode merged 2 commits into
reardencode:masterfrom
Naomi-Gift:net/isolated-broadcast-inv-getdata-pong
Nov 3, 2026
Merged

reardencode merged 2 commits into
reardencode:masterfrom
Naomi-Gift:net/isolated-broadcast-inv-getdata-pong

Conversation

@Naomi-Gift

@Naomi-Gift Naomi-Gift commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Item 4 of #1275.

Isolated broadcast sent our tx and hung up straight away. The peer could drop it, and we never knew if it arrived.

Now it works like Bitcoin Core's private broadcast: we offer the tx, send it only when the peer asks for it, then ping and wait for the pong before hanging up. If the peer never asks, or never answers the ping, the send counts as failed.

Tested with new tests for the normal case and for a peer that never asks or never answers. I also sent a tx this way to a real Bitcoin Core 29 node, and it took it into its mempool.

@rearden-grok rearden-grok Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REQUEST_CHANGES

isolated_broadcast_needs_getdata_and_pong burns about four seconds of real timeout. The note is on Duration::from_secs(2).

Nit: the doc comment on isolated_broadcast_sends_core_private_broadcast_version still describes the post-verack exchange as only the tx.

Comment thread crates/rbitcoin-net/tests/ephemeral.rs Outdated
NetAddr::Ip(peer_addr),
Magic::REGTEST,
dummy_tx(),
Duration::from_secs(2),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isolated_broadcast_needs_getdata_and_pong waits out this 2s deadline twice, back to back, so the test is about 4s. The cases are sequential, and each one blocks in hand_over_tx until timeout_at fires (no getdata, then no pong). That is not HANDSHAKE_TIMEOUT, but it is still a new default-suite test over the 2s wall in TESTING.md, with no reason a shorter cap would miss the branch. The peer is on localhost and answers the handshake immediately; pass a few hundred milliseconds so both failures still trip and the test stays under that cap.

Naomi-Gift added a commit to Naomi-Gift/rbitcoin that referenced this pull request Nov 2, 2026
Review on reardencode#1342: isolated_broadcast_needs_getdata_and_pong waited out a
2 s limit twice, about 4 s. The peer is on localhost, so 300 ms still
trips both failures, and the test runs in about 0.6 s. The comment on
isolated_broadcast_sends_core_private_broadcast_version now names INV,
GETDATA and PING.

@rearden-grok rearden-grok Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPROVE

Both open items are fixed.

  1. Fixed. Duration::from_millis(300) is the whole handshake-plus-exchange budget, and the two cases run one after the other, so the waits are about 0.6s. commands still requires inv and no tx when the peer never asks, and inv, tx, ping when it asks but never pongs, so a deadline that expires during the handshake fails the test instead of passing for the wrong reason. The cargo test step was 160s on this head, 140s on the previous head, and 149s on master. The log has no per-test times and no stall; the +20s on that step is the same runner noise as the job times.
  2. Fixed. The comment on isolated_broadcast_sends_core_private_broadcast_version now includes the inv, the getdata, and the ping.

Isolated broadcast sent tx and closed the socket straight away. Core can
drop a message that arrives just before the close (bitcoin/bitcoin#4432),
and nothing told us whether the peer took the tx.

The one-shot now does what Core's private broadcast does: inv, wait for
a getdata naming the tx, tx, ping, and close on the matching pong. A peer
that never asks for the tx gets no tx, and a missing pong is a failed
send. The handshake and the exchange share one deadline, so one send
still takes at most HANDSHAKE_TIMEOUT.

Item 4 of reardencode#1275.
Review on reardencode#1342: isolated_broadcast_needs_getdata_and_pong waited out a
2 s limit twice, about 4 s. The peer is on localhost, so 300 ms still
trips both failures, and the test runs in about 0.6 s. The comment on
isolated_broadcast_sends_core_private_broadcast_version now names INV,
GETDATA and PING.
@rearden-grok
rearden-grok Bot force-pushed the net/isolated-broadcast-inv-getdata-pong branch from e6a272a to 9f3377c Compare November 3, 2026 19:43
@reardencode
reardencode merged commit b02330d into reardencode:master Nov 3, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants