#35591 [DO NOT MERGE] Erlay: bandwidth-efficient transaction relay protocol (Full implementation)

full analysis

https://github.com/bitcoin/bitcoin/pull/35591 · sr-gi · +4426/-402 in 30 files, 38 commits · labels: Needs rebase

Goal

  • Cut transaction relay bandwidth consumption across the network using set reconciliation
  • Let node operators maintain more outbound connections to resist eclipse attacks without extra overhead

This pull request provides a complete implementation of Erlay (BIP 330) transaction reconciliation. It introduces an `OUTBOUND_FULL_RECONCILIATION` connection type, protocol message handlers (`reqtxrcncl`, `sketch`, `reconcildiff`, `reqsketchext`), sketch computation and decoding logic via minisketch, connection eviction handling, and functional and benchmark tests.

Problem: Transaction announcement via flood and trickle fanout consumes significant network bandwidth and limits how many outbound peers a node can maintain without excessive overhead. Erlay replaces redundant inv announcements with set reconciliation, lowering bandwidth consumption and allowing nodes to maintain additional outbound connections to resist eclipse attacks.

Category: P2P (#10 of 65)

P2 · new feature

  • P2 because it substantially lowers bandwidth overhead for node transaction relay
  • Allows nodes to run additional outbound connections, strengthening network eclipse resistance

Erlay is a strategically important p2p protocol upgrade. It substantially improves node bandwidth efficiency during transaction relay and bolsters network partition and eclipse resistance by enabling four additional outbound reconciliation connections without proportional bandwidth penalties.

Membership: Implements BIP 330 transaction reconciliation protocol messages, new peer connection types, and peer eviction logic.

Factors: security/stability 2, bug 0, performance 2, user value 2, leverage 2

Reviewability: Stale: Needs rebase

  • Needs rebase due to merge conflicts with master
  • Intended for testing and will be split into smaller PRs before merging

The PR has merge conflicts with master and carries the 'Needs rebase' label. In addition, the author indicated this complete branch is intended for testing and validation and will be split into smaller PRs for merging.

Author status: Active; recently added eviction logic and benchmarks, though currently waiting for design feedback on sketch sizing and negotiation.

Open concerns:

  • Whether to retain the sketch extension phase or drop it in favor of slightly higher initial sketch capacity and fanout fallback.
  • Capping the maximum sketch capacity lower to mitigate quadratic minisketch decoding DoS vectors (up to 30+ seconds on large sketches).
  • Whether to negotiate reconciliation via BIP 434 feature negotiation rather than sendtxrcncl.

Resolved concerns:

  • Addressed test gaps identified by mutation testing regarding boundary conditions and transaction inventory filtering.
  • Restricted reconciliation result byte parsing to 0 or 1 per BIP 330.
  • Added eviction handling for extra reconciliation connections during v2-to-v1 downgrades.

Agreement: Positive

  • Constructive engagement on protocol design and safety
  • Raised concern over potential DoS from slow quadratic minisketch decoding on large sketches (brunoerg)
  • Reported test gaps through mutation testing on boundary limits and extensions (brunoerg)

Positive engagement; brunoerg raised DoS and eviction concerns which the author addressed or benchmarked.

Reviewer brunoerg provided detailed mutation testing reports and raised technical questions regarding decoding CPU DoS risks and connection limits during fallback. Author responded actively and implemented updates, with general consensus on the direction.

  • brunoerg reported mutation testing survivors around extension handling and boundary limits.
  • brunoerg questioned potential DoS from minisketch decoding times taking 31+ seconds on large sketches.
  • sr-gi added benchmarks confirming quadratic decode costs and proposed reducing sketch limits and removing extensions.
  • sr-gi refactored eviction logic to cover outbound reconciliation peers to resolve connection overages.

Review verdicts (DrahtBot): 0

Files

2592 lines under test/bench/ci.

  • src/test/txreconciliation_tests.cpp +1109/-24
  • src/node/txreconciliation_impl.cpp +848/-0
  • src/net_processing.cpp +465/-114
  • test/functional/test_framework/p2p_txrecon.py +330/-0
  • test/functional/p2p_txrecon_responder.py +328/-0
  • src/node/txreconciliation.h +214/-58
  • test/functional/p2p_txrecon_initiator.py +266/-0
  • src/node/txreconciliation_impl.h +231/-0
  • src/node/txreconciliation.cpp +0/-170
  • src/test/denialofservice_tests.cpp +117/-0
  • test/functional/test_framework/messages.py +113/-1
  • test/functional/p2p_reqtxrcncl.py +111/-0
  • src/bench/txreconciliation.cpp +64/-0
  • test/functional/p2p_sendtxrcncl.py +49/-2
  • test/functional/p2p_txrecon_disabled.py +51/-0
  • src/net.h +36/-13
  • src/net.cpp +20/-13
  • src/protocol.h +25/-0
  • test/functional/test_framework/p2p.py +15/-1
  • src/node/connection_types.h +10/-0
  • src/init.cpp +6/-1
  • src/rpc/net.cpp +4/-1
  • test/functional/test_runner.py +4/-0
  • src/qt/guiutil.cpp +2/-1
  • src/CMakeLists.txt +1/-1
  • src/bench/CMakeLists.txt +2/-0
  • src/node/connection_types.cpp +2/-0
  • src/test/fuzz/connman.cpp +1/-1
  • test/functional/test_framework/test_node.py +1/-1
  • src/test/util/net.h +1/-0

Card

This pull request implements the full Erlay transaction reconciliation protocol (BIP 330) along with an outbound-full-recon connection type to dramatically reduce transaction announcement bandwidth while increasing outbound connectivity against eclipse attacks. The change is strategically important (P2 in p2p) as a network-wide scaling and security enhancement. Technical review is positive, with brunoerg providing mutation test reports and raising DoS concerns regarding quadratic minisketch decode times. The PR currently needs a rebase and the author intends to carve it into smaller reviewable PRs for actual merging.

Data

dossier JSON · extract JSON · model openrouter/google/gemini-3.8-flash, generated 2026-09-17T16:19, confidence high, input hash 5d4294d46daca43c