mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 10:50:37 +00:00
WIP: Reimplement private broadcast as node state-less jobs + package relay support #36608
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!36608
Loading…
Reference in a new issue
No description provided.
Delete branch "privbcast-4-package"
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?
Goals
Goal 1: Remove reliance on, and probes about, internal node state from private broadcast
Goal 2: Specify observable behavior to aid reimplementation and reduce profile fingerprints across versions
Layout
Four parts, each starting with an empty marker commit:
For the v33 release, I think 1 through 3 should be the goal, but the roadmap could be trimmed down to remove tool-only code if the conceptual support for the standalone tool is not there.
The tool itself introduces about 600 loc of logic, and also necessitates some of the prep move-only commits putting things in common. The vast majority is the shared Job machinery.
Node-less state
The primary failure mode of the in-master private broadcast is that it relies on node state for operation, and this has led to a number of "careful coding" fixes:
There are many other sources of fingerprints as well, some harder than others to exploit, and to fix. The solution: remove reliance on node state entirely to drive attempts. The spec states the goals as:
Jobs, slots and opportunities
The times are drawn at job start, and each opportunity's candidate is fixed when discovery ends, before any peer is contacted. Nothing a peer does moves them (C1–C4). A job makes at most 24 connections, at most 6 of them at once.
Differences at a glance
bitcoindonlybitcoind -privatebroadcast, or the standalonebitcoin-privbcastwith no node; the same job either way (U3), with a JSON report of every connectionaddrman.Select()over onion, I2P, and IPv4/IPv6 through the proxy; networks follow-onlynetCConnmanpeers of typePRIVATE_BROADCAST, visible ingetpeerinfosubmitpackagewith one parent and one child: announce the child, serve the parent on requestNo addrman
Under master, the node's private broadcast destinations are drawn from the node's addrman. Other parties write to that table through addr gossip, which makes it a unique fingerprint vector, and inherently attacker influenced. This rules out drawing recipients from anything the node or its peers can write to.
Its replacement is querying DNS seeds in a predetermined way under a static profile. This is inherently less robust than the p2p network in terms of liveness, but leaves no fingerprint within a release. The marginal fingerprint is the set of DNS seeds per release, which affects who is queried and exactly how. Each RESOLVE returns one address and exits cache answers, so each seed is asked through several exits: 4 Tor circuits, each querying all 7 seeds, for up to 28 results, which are assigned to the 6x4 opportunities before any dialing happens. A circuit per query, 28 in all, kept Tor busy enough that overlapping discoveries lost answers.
If the list shrinks, grows, or is modified, the release is revealed to the Tor exits carrying the queries, which see every seed name queried. A DNS seed learns only that it is on the list, and only when the exit has no cached answer.
The fingerprint potential also precludes fixed seeds, which change greatly each release, and which degrade in connectivity over time regardless.
Minimal release fingerprint
Once a release is cut, behavior profiles are intended to be identical per user. This precludes user knobs and per-instance parameters, and requires a constant user agent and VERSION.
Across releases, the reimplemented p2p message state machine allows better control of unnecessary profile breaks going forward.
Specification
doc/design/private-broadcast-tool.mdcomes before any code in part 2. It has goals, a threat model per party (recipient, exit, seed, network observer, guard), 54 numbered invariants (A–U, N), parameters, interface, assumptions, non-goals and a rationale. Code comments and tests cite the invariant IDs, so review can check code against a stated property. Concept review of the goals, threat model and non-goals is most useful first, then review of the implementation against the invariants.This implementation is actually the second implementation, initially implemented solely via the spec and black box tests, which were handed to an otherwise blind agent.
Tradeoffs
getprivatebroadcastinfonow reports jobs, and the connections no longer show ingetpeerinfo.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.
A summary of reviews will appear here.
Conflicts
Reviewers, this pull request conflicts with the following ones:
CAmounta class by hodlinator)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.
LLM Linter (✨ experimental)
Possible places where named args for integral literals may be used (e.g.
func(x, /*named_arg=*/0)in C++, andfunc(x, named_arg=0)in Python):src/test/privbcast_queue_tests.cpp:CreateValidMempoolTransaction(m_coinbase_txns[0], 0, 0, coinbaseKey, script, 49 * COIN, false)src/test/privbcast_queue_tests.cpp:CreateValidMempoolTransaction(m_coinbase_txns[1], 0, 0, coinbaseKey, script, 49 * COIN, false)src/test/privbcast_queue_tests.cpp:CreateValidMempoolTransaction(m_coinbase_txns[1], 0, 0, coinbaseKey, script, 48 * COIN, false)src/test/privbcast_queue_tests.cpp:CreateValidMempoolTransaction(m_coinbase_txns[2], 0, 0, coinbaseKey, script, 49 * COIN, false)src/test/privbcast_queue_tests.cpp:CreateValidMempoolTransaction(parent, 0, 0, coinbaseKey, script, 48 * COIN, false)src/test/txpackage_tests.cpp:CreateValidMempoolTransaction(m_coinbase_txns[0], 0, 0, coinbaseKey, parent_spk, coinbase_value - 10'000)src/test/txpackage_tests.cpp:CreateValidMempoolTransaction(m_coinbase_txns[0], 0, 0, coinbaseKey, parent_spk, coinbase_value - 100'000, false)src/test/txpackage_tests.cpp:CreateValidMempoolTransaction(m_coinbase_txns[1], 0, 0, coinbaseKey, parent_spk, coinbase_value - 10'000)src/test/txpackage_tests.cpp:CreateValidMempoolTransaction(m_coinbase_txns[2], 0, 0, coinbaseKey, parent_spk, coinbase_value - 10'000, false)src/test/txpackage_tests.cpp:CreateValidMempoolTransaction(m_coinbase_txns[3], 0, 0, coinbaseKey, parent_spk, coinbase_value - 10'000)src/test/txpackage_tests.cpp:CreateValidMempoolTransaction(m_coinbase_txns[3], 0, 0, coinbaseKey, parent_spk, coinbase_value - 100'000, false)src/test/txpackage_tests.cpp:CreateValidMempoolTransaction(tx, 0, 101, parent_key, child_spk, value, false)Possible places where comparison-specific test macros should replace generic comparisons:
test/functional/tool_privbcast_package.py:assert a["parent_hold_expired_ms"] is not None and a["parent_getdata_ms"] is None→ Preferassert_equal(a["parent_getdata_ms"], None)for theis Nonecomparison.test/functional/tool_privbcast_package.py:assert a["parent_getdata_ms"] is None and a["parent_hold_expired_ms"] is not None→ Preferassert_equal(a["parent_getdata_ms"], None)for theis Nonecomparison.test/functional/tool_privbcast_package.py:assert a["getdata_ms"] is None and a["tx_written_ms"] is None→ Preferassert_equal(..., None)for each comparison.2026-10-22 17:41:53
🚧 At least one of the CI tasks failed.
Task
MSan: https://github.com/bitcoin/bitcoin/actions/runs/39798797867/job/119893347731LLM reason (✨ experimental): The build failed because Clang’s thread-safety analysis found calls to
AcceptSubPackagewithout exclusive locks oncs_mainandm_pool.csinvalidation.cpp.Hints
Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the
affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
1 minor finding · 1 suggestion · 2 previous findings
🟠 Minor
Test acceptance pools replacement checks for a parent and child
Location:
src/validation.cpp:1761(head).Under -privatebroadcast, submitpackage can queue a pair that recipients reject, or refuse a pair that sequential submission accepts, under specific replacement or fee settings.
Details and suggested fix
When the parent passes alone, AcceptPackage retests the parent and child with PackageTestEach. If either conflicts with the mempool, PackageRBFChecks evaluates both together: it aggregates their conflicting clusters and compares their summed modified fees and virtual size against all conflicts. Real submission and a recipient's 1p1c evaluation instead accept the parent alone first, then run ReplacementChecks on the child using only the child's fee and virtual size.
These checks can diverge in both directions. A parent that overpays for its own conflict can cover a child that underpays for a different conflict. submitpackage then returns success and queues a job, but recipients holding that conflict take only the parent and reject the child with “insufficient fee.” The pair can also be refused if the combined conflicts exceed MAX_REPLACEMENT_CANDIDATES, even though neither transaction does alone. Finally, when -minrelaytxfee is explicitly below -incrementalrelayfee and the child has no conflicts, the pooled check can refuse a pair that submission accepts. For example, with incremental relay fee 1 sat/vB, minimum relay fee 0.1 sat/vB, an unelevated mempool minimum fee, and two 200-vbyte transactions, a parent paying 1,200 sat replaces a transaction paying 1,000 sat, while the child pays 20 sat. Submission accepts both, but the pooled check requires a 400-sat increment and sees only 220 sat. Check the parent's conflicts using its own fee and virtual size, stage those removals, and then check the child's conflicts using its own fee and virtual size, as sequential submission does. Add txpackage tests for each direction.
🔵 Suggestion
Private broadcast transport IDs overlap node peer IDs in debug logs
Location:
src/privbcast/job.cpp:270(head).With -debug=net, transport lines for private broadcast attempts can be mistaken for lines from an unrelated peer with the same ID.
Details and suggested fix
Each Job numbers its attempt transports from 0, and every job reuses IDs 0 through 23. V2Transport logs these IDs as peer IDs under BCLog::NET, including handshake and transport-error messages. Node peers also receive IDs starting from 0, so these lines share the same debug log and can be attributed to an unrelated ordinary peer. The default log is unaffected. Use transport IDs that CConnman never assigns, such as negative IDs, or log failures under BCLog::PRIVBROADCAST with the slot, as Reap already does.
Previous findings (2)
[Minor · still present] Private submitpackage uses BIP141 size for the single-transaction maxfeerate check
A sigop-heavy transaction can exceed the maxfeerate limit in private submitpackage even though sendrawtransaction accepts it with the same limit.
This occurs when exactly one submitted transaction needs test acceptance, either because it was submitted alone or because its parent is already in the mempool. The check applies maxfeerate to the transaction's BIP141 virtual size, while sendrawtransaction applies it to validation's sigop-adjusted virtual size. A valid transaction whose sigop-adjusted size exceeds its BIP141 size and whose fee falls between the resulting limits is therefore rejected by private submitpackage with “max feerate exceeded,” but accepted by sendrawtransaction. This conflicts with the helper comment, RPC help, and spec, and the two-transaction path already uses the sigop-adjusted size. Check the fee against validation's sigop-adjusted size and test against sendrawtransaction with the same maxfeerate, including when the parent is already in the mempool. No current caller submitting such a sigop-heavy transaction was identified, so the production impact is unconfirmed.
Location:
src/rpc/mempool.cpp:1488(head).Previous reports of the same concern:
eec78ccf7d59f5b39d4525980e8e3a7fe6c60242. Last checked ateec78ccf7d59f5b39d4525980e8e3a7fe6c60242.eec78ccf7d59f5b39d4525980e8e3a7fe6c60242. Last checked ateec78ccf7d59f5b39d4525980e8e3a7fe6c60242.[Suggestion · still present] Bound retained bytes in the private-broadcast queue
The queue limit counts records, but each
JobRecordretains the full transaction and optional parent. The specification explicitly limits the number of jobs, not their size, and the submission path queues test-accepted caller-provided transactions. As a result, up to 10,000 queued records can retain memory proportional to their transaction data, with no aggregate byte budget. Add a documented retained-byte limit and refuse submissions that exceed it, or justify the worst-case memory budget. This matters because queued records can remain retained while jobs start at spaced intervals.Location:
src/node/privbcast.cpp:137(head).First reported at
eec78ccf7d59f5b39d4525980e8e3a7fe6c60242. Last checked ateec78ccf7d59f5b39d4525980e8e3a7fe6c60242.Review coverage was incomplete.
Review limitations
cancel, were taken from comments and Job::Cancelled()'s use of->load(), not from the declarations.src/rpc/mempool.cppand the new package-validation changes insrc/validation.cppwere not traced through their complete functions and callers; these could materially affect acceptance and replacement behavior.MemPoolAccept::AcceptPackageimplementation for the newtest_as_submissionpath was not inspected. Whether its per-transaction results consistently reflect package-level rejection remains unverified and could affect review of package-mode submission.Base:
0f27bed5b292· Head:eec78ccf7d59· Full review reportin draft, https://github.com/bitcoin/bitcoin/pull/36628 is the slimmed down branch to review
ralph referenced this pull request2026-10-23 17:41:58 +00:00
🐙 This pull request conflicts with the target branch and needs rebase.
not being considered at the moment, can be resurrected easily
Thanks for bringing in a fresh perspective, if not else, it's a good base for further discussions (despite that it's closed now).
I tried to expand on the comparison with the current implementation (master) from the description.
-onlynet=onionCheckTransaction, not-coinbase, weight and burn limit. No inputs, scripts, fees or standardnessFor reference, the common fallback,
mempool.space/tx/pushover Tor, validates against its own node and depends on a single provider.Also, mainnet has exactly 7 DNS seeds, and
MIN_DNS_SEEDSis 7. Losing one breaks R3 and needs a parameter and spec change. That change is itself a release fingerprint visible to exits.Design questions
I attempt to list the various dimensions in the design space:
Several of these are independent of each other. For example, separate connection code doesn't require DNS-seed targets.
Most likely direction?
To me, 36608's main benefit is that targets don't come from the node's addrman, which closes the planted-address attack (an address gossiped only to the victim). DNS seeds alone is also the most contentious part, though: liveness, the 7-of-7 seed margin, and every connection through an exit. Changes to master that seem more likely: