Repository navigation
friglet: broadcast to several peers, confirm via an unrelated peer (SNB-856) - #86
Open
setavenger wants to merge 3 commits into
Open
setavenger wants to merge 3 commits into
setavenger wants to merge 3 commits into
Conversation
- `PeerAddr::netgroup()` / `NetGroup`: Bitcoin Core's default netgroups (/16 for IPv4, /32 for IPv6; an IPv4-mapped address is its IPv4). - `PeerSource::next_outside(purpose, exclude, groups)`: `next` that also passes over peers in the given groups, resting fallback included. - `PeerEvent::NoTxRelay`: a peer whose version says it relays no transactions (blocks-only) is never handed out for relay again this session; blocks may still come from it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…NB-856) Without an own node, a broadcast no longer rests on one random peer's word (new `electrum/net_broadcast.rs`): - 3 observers first: relay=true connections, settled, to peers whose version relays transactions; then 2 senders: relay=false, no getaddr or feefilter, inv -> getdata -> tx -> ping/pong, then they only listen. All peers of a broadcast are in distinct netgroups (/16, /32). - Success only when an observer serves the transaction (getdata poll every 2 s, or at once after its inv). Nothing a sender says counts. - Rejected only when every sender that got it gave the same signal: all asked for a parent (bad-txns-inputs-missingorspent) or all dropped it before the pong. Otherwise "not confirmed" after the 25 s budget, with Sparrow's fee wording when the fee is below the median of the observers' feefilters, which now feed the relay fee quorum. No observer reachable: error code 2, nothing sent. - Pending broadcasts remember the peers they were handed to (`sent_to`, at most 16); a recheck asks 2 other peers and hands a lost one to one of them on a sender connection. A resend after an inconclusive wait asks one non-sender. - Own node: `relay::broadcast`/`recheck` and their wording unchanged. Tests: FakePeer gets a relay flag, announcements, echo_inv and a shared FakeNet mempool on 127.N.0.1; the plan's scenario table runs against it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A sender checks the stop token before announcing and before handing the transaction over, so a broadcast that has ended (deadline, error) never leaves a peer holding the transaction that is missing from `sent_to`. - Every sender dropping the connection is reported as before but kept inconclusive (a resend looks again): a peer can also just go away, and Bitcoin Core 30+ no longer disconnects for invalid transactions. - No early "not confirmed" when observers go away: replacements are launched and the wait runs to the budget. - A recheck whose sent_to peers rule out every network group the pool knows asks peers in those groups (never the peers themselves). - README: the observers learn this IP asks for the transaction too. - Tests: a stopped sender hands nothing over; the recheck group fallback; the own node's fee-shortfall wording, word for word. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
setavenger
force-pushed
the
snb-855-peer-pool
branch
from
November 1, 2026 15:53
46f04ed to
f8bad29
Compare
setavenger
force-pushed
the
snb-856-broadcast
branch
from
November 1, 2026 15:53
17bbbeb to
951c312
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #85 (SNB-855). Implements SNB-856.
What / why
Without an own node, a broadcast used to rest on one random peer's word: the peer that got the transaction was also the one asked whether it took it. Now (
friglet/src/electrum/net_broadcast.rs):versionsays they relay transactions (blocks-only peers are refused and never handed out for relay again:PeerEvent::NoTxRelay).getaddr/feefilter;inv→getdata→tx→ping/pong, then they only listen for a parent request or a disconnect.PeerAddr::netgroupandPeerSource::next_outsideinblindbit-lib/src/net.inv). Nothing a sender says counts.bad-txns-inputs-missingorspent…, Sparrow's prefix, final). All dropping it before the pong gives the "disconnected right after receiving" error but stays inconclusive, so a resend looks again. Otherwise "not confirmed" after the 25 s budget, with Sparrow'smempool min fee not met, X < Ywording when the fee is below the median of the observers' feefilters (which now feed the 855 relay-fee quorum). No observer reachable → code 2, nothing sent.PendingTx.sent_to(serde default, ≤ 16). A recheck asks 2 peers outsidesent_to(and their netgroups); a lost tx is handed to one of them on a sender connection and added tosent_to. A resend after an inconclusive wait asks one non-sender.relay::broadcast/in_mempool/recheck, same wording;with_relay_peerbecame own-node-onlywith_own_node).Deviations from the plan
sent_topeers rule out every netgroup the pool knows falls back to excluding only those peers.Findings worth knowing
getdata. The own-node check has always behaved the same; the tx is confirmed, so the answer is harmless.Verification
Debug builds,
CARGO_BUILD_JOBS=3:cargo build --workspaceok;cargo test --workspace: 301 passed, 0 failed (before the rebase onto integration 929419b, which adds 10 testkit tests; CI passes after it);cargo clippy --no-deps -p friglet -p friglet-ipc -p friglet-tray --all-targets -- -D warningsclean;cargo fmt --all -- --checkclean.net::tests).net_broadcast::tests,electrum::tests::discovered): unrelated peer announces → InMempool; observer only answers getdata → InMempool; sender echoes inv, serves it, then drops, observers silent → not confirmed; no observer reachable → code 2, nothing sent; all senders ask for a parent → rejected (missing inputs); one sender asks for a parent, an observer serves it → InMempool; blocks-only peer → never sender or observer, asked once per session; recheck → senders never contacted; relayfee from observers 1000/2000/2000/2000/100000 → 2000 sat/kvB, no extra connection; resend after an inconclusive wait → asks a non-sender; a sender that connects after the broadcast ended hands nothing over.inv/tx/ping/pong/notfoundon sender connections.Live signet, daemon without
p2p_node_addr, via Electrumblockchain.transaction.broadcast:confirmed_by=95.179.253.55:38333). P2P part 60–204 ms (one 5.1 s), Electrum round trip 0.10–0.89 s (one 5.2 s). These were already on the network, so no hand-over was needed; the hand-over → observer path is covered by the tests only (no funded signet wallet here).bad-txns-inputs-missingorspent: every peer friglet sent it to asked for a parent…in 7.4 s / 11.6 s. A mempool tx with an output lowered (signature broken): "25 seconds after friglet handed it to 2 peers, no other peer of the network had the transaction…" (the peers did not disconnect). Never success.152.53.151.148:38333: 5 mempool txs accepted in 5.3–11.6 s (hand-over + mempool poll, as before); the old confirmed tx rejected with the unchanged own-node wording in 6.7 s.sent_tonamed 4 peers: the recheck asked175.110.114.74:38333, 78.34.61.210:38333(not_asked=4), and handed the one tx neither had to the first on a relay=false connection, adding it tosent_to. (sent_towas seeded by editing the pending file, since (a) needed no hand-over.)