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

pull sr-gi wants to merge 31 commits into bitcoin:master from sr-gi:202406-erlay-full-draft changing 14 files +2581 −87
  1. sr-gi commented at 5:18 pm on June 12, 2024: member

    Erlay Project Tracking: #30249


    This is a full implementation of Erlay. Its purpose is to check the integrity and correctness of the implementation against changes/additions that may originate from the review process and/or rebases on top of newer functionality.

    This is not to be merged. Functionality will be spread across multiple smaller PRs to ease the review process.

  2. DrahtBot commented at 5:18 pm on June 12, 2024: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/30277.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #32189 (refactor: Txid type safety (parent PR) by marcofleon)
    • #30116 (p2p: Fill reconciliation sets (Erlay) attempt 2 by sr-gi)
    • #29415 (Broadcast own transactions only via short-lived Tor or I2P connections by vasild)
    • #28463 (p2p: Increase inbound capacity for block-relay only connections by mzumsande)
    • #27826 (validation: log which peer sent us a header by Sjors)

    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 typos and grammar issues:

    1. In src/node/txreconciliation.cpp comment:
      “Allows to infer capacity of a reconciliation sketch based on it’s char[] representation”
      should be
      “its char[] representation”

    2. In test/functional/p2p_reqtxrcncl.py comment:
      “Each peer is reconcile every 1-nth”
      should be
      “Each peer is reconciled every 1-nth”

    3. In test/functional/p2p_reqtxrcncl.py log message:
      “REQTXRCNCL sent to an peer 1 (outbound)”
      should be
      “REQTXRCNCL sent to a peer 1 (outbound)”

    4. In test/functional/p2p_reqtxrcncl.py comment:
      “No transaction were created, so we expect the set size to be 0”
      should be
      “No transactions were created, so we expect the set size to be 0”

  3. sr-gi marked this as a draft on Jun 12, 2024
  4. sr-gi force-pushed on Jun 12, 2024
  5. DrahtBot added the label CI failed on Jun 13, 2024
  6. DrahtBot commented at 4:17 am on June 13, 2024: contributor

    🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the documentation.

    Possibly this is 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.

    Leave a comment here, if you need help tracking down a confusing failure.

    Debug: https://github.com/bitcoin/bitcoin/runs/26144314909

  7. sr-gi force-pushed on Jun 13, 2024
  8. sr-gi force-pushed on Jun 13, 2024
  9. sr-gi force-pushed on Jun 14, 2024
  10. sr-gi force-pushed on Jun 14, 2024
  11. DrahtBot removed the label CI failed on Jun 14, 2024
  12. hebasto commented at 9:22 pm on June 18, 2024: member
  13. DrahtBot added the label CI failed on Jun 19, 2024
  14. sr-gi force-pushed on Jun 20, 2024
  15. DrahtBot added the label Needs rebase on Jun 20, 2024
  16. sr-gi force-pushed on Jun 20, 2024
  17. DrahtBot removed the label Needs rebase on Jun 20, 2024
  18. sr-gi force-pushed on Jun 21, 2024
  19. DrahtBot removed the label CI failed on Jun 21, 2024
  20. DrahtBot added the label Needs rebase on Jul 4, 2024
  21. sr-gi force-pushed on Mar 26, 2025
  22. sr-gi force-pushed on Mar 26, 2025
  23. DrahtBot removed the label Needs rebase on Mar 26, 2025
  24. DrahtBot added the label CI failed on Mar 26, 2025
  25. sr-gi force-pushed on Mar 27, 2025
  26. sr-gi force-pushed on Mar 31, 2025
  27. sr-gi force-pushed on Mar 31, 2025
  28. sr-gi force-pushed on Apr 1, 2025
  29. sr-gi force-pushed on Apr 1, 2025
  30. sr-gi force-pushed on Apr 1, 2025
  31. sr-gi force-pushed on Apr 1, 2025
  32. sr-gi force-pushed on Apr 1, 2025
  33. sr-gi force-pushed on Apr 2, 2025
  34. sr-gi force-pushed on Apr 2, 2025
  35. sr-gi force-pushed on Apr 2, 2025
  36. sr-gi force-pushed on Apr 3, 2025
  37. sr-gi force-pushed on Apr 8, 2025
  38. sr-gi force-pushed on Apr 8, 2025
  39. DrahtBot removed the label CI failed on Apr 8, 2025
  40. sr-gi force-pushed on Apr 14, 2025
  41. sr-gi force-pushed on Apr 14, 2025
  42. DrahtBot added the label CI failed on Apr 14, 2025
  43. DrahtBot commented at 9:07 pm on April 14, 2025: contributor

    🚧 At least one of the CI tasks failed. Debug: https://github.com/bitcoin/bitcoin/runs/40538402994

    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.

  44. sr-gi force-pushed on Apr 14, 2025
  45. sr-gi force-pushed on Apr 15, 2025
  46. sr-gi force-pushed on Apr 15, 2025
  47. sr-gi force-pushed on Apr 15, 2025
  48. sr-gi force-pushed on Apr 16, 2025
  49. sr-gi force-pushed on Apr 16, 2025
  50. DrahtBot removed the label CI failed on Apr 16, 2025
  51. sr-gi force-pushed on Apr 18, 2025
  52. refactor: remove legacy comments
    These comments became irrelevant in one of the previous code changes.
    They simply don't make sense anymore.
    ed04f72b7b
  53. p2p: Functions to add/remove wtxids to tx reconciliation sets
    They will be used later on.
    fb7d7bf3f7
  54. p2p: Make short id collision detectable when adding wtxids to tx reconciliation sets 9582b586cf
  55. p2p: Add PeerManager method to count the amount of inbound/outbounds fanout peers 5785294ebc
  56. p2p: Cache inbound reconciling peers count
    It helps to avoid recomputing every time we consider
    a transaction for fanout/reconciliation.
    
    Co-authored-by: Sergi Delgado Segura <sergi.delgado.s@gmail.com>
    e72d48dd2c
  57. p2p: Add method to decided whether to fanout or reconcile a transactions
    Fanout or reconciliation is decided on a transaction basis, based on the following criteria:
    
    If the peer is inbound, we fanout to a pre-defined subset of peers (which is rotated periodically).
    If the peer is outbound, we will reconcile the transaction if we received it via reconciliation, or
    defer the decision to relay time otherwise. At relay time, we will fanout to outbounds until a threshold is met
    (selecting peers in the order their timers go off) and reconcile with the rest.
    
    With this approach we try to fanout when we estimate to be early in the propagation of the transaction,
    and reconcile otherwise. Notice these heuristics don't apply to inbound peers, since they would be easily
    exploitable. For inbounds we just aim for a target subset picked at random.
    ceeec346bc
  58. p2p: Add transactions to reconciliation sets
    Transactions eligible for reconciliation are added to the reconciliation sets. For the remaining txs, low-fanout is used.
    
    Co-authored-by:  Gleb Naumenko <naumenko.gs@gmail.com>
    3b6c4cfb91
  59. p2p: Add consider_fanout to RelayTransaction
    This can be squashed into the previous commit, it is split for now to ease review
    
    When scheduling the relay of a transaction (RelayTransaction) we should consider
    whether it is worth fanning it out, or only reconciling it. This depends, partially,
    on how the transaction was received.
    
    For non-Erlay peers, we always consider_fanout (in fact, we only fanout).
    For Erlay peers, if the peer is inbounds, we always consider fanout, and deffer the
    decision of to whom to relay time. If the peer is outbound, we consider fanout if the
    transaction was received via fanout, and only reconcile if it was received via reconciliation
    (who to fanout to is also deferred to relay time).
    
    Until the Erlay P2P flow is merged, consider_fanout is always true.
    92d101b67b
  60. p2p: Add helper to compute reconciliation tx short ids and a cache of short ids to wtxids b515c72604
  61. p2p: Deal with shortid collisions for reconciliation sets
    If a transaction to be added to a peer's recon set has a shot id collisions (a previously
    added wtxid maps to the same short id), both transaction should be fanout, given
    our peer may have added the opposite transaction to our recon set, and these two
    transaction won't be reconciled.
    fce87d1c90
  62. p2p: Add peers to reconciliation queue on negotiation
    When we're finalizing negotiation, we should add the peers
    for which we will initiate reconciliations to the queue.
    
    Co-authored-by: Sergi Delgado Segura <sergi.delgado.s@gmail.com>
    3642c07e1a
  63. p2p: Track reconciliation requests schedule
    We initiate reconciliation by looking at the queue periodically
    with equal intervals between peers to achieve efficiency.
    
    This will be later used to see whether it's time to initiate.
    219b1a1cd8
  64. p2p: Initiate reconciliation round
    When the time comes for the peer, we send a
    reconciliation request with the parameters which
    will help the peer to construct a (hopefully) sufficient
    reconciliation sketch for us. We will then use that
    sketch to find missing transactions.
    
    Co-authored-by: Sergi Delgado Segura <sergi.delgado.s@gmail.com>
    c55cd4456a
  65. test: functional test for reqtxrcncl
    Co-authored-by: Sergi Delgado Segura <sergi.delgado.s@gmail.com>
    7546a3d8ad
  66. p2p: Handle reconciliation request
    Store the parameters the peer sent us inside the
    reconciliation request.
    68a27d9efe
  67. Add helper to compute sketches for tx reconciliation f5f6a2c4dc
  68. sr-gi force-pushed on Apr 18, 2025
  69. sr-gi force-pushed on Apr 18, 2025
  70. DrahtBot added the label CI failed on Apr 18, 2025
  71. DrahtBot commented at 8:13 pm on April 18, 2025: contributor

    🚧 At least one of the CI tasks failed. Debug: https://github.com/bitcoin/bitcoin/runs/40799139881

    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.

  72. sr-gi force-pushed on Apr 18, 2025
  73. sr-gi force-pushed on Apr 21, 2025
  74. sr-gi force-pushed on Apr 21, 2025
  75. sr-gi force-pushed on Apr 21, 2025
  76. DrahtBot removed the label CI failed on Apr 21, 2025
  77. Respond to a reconciliation request
    When the time comes, we should send a sketch of our
    local reconciliation set to the reconciliation initiator.
    
    Co-authored-by: Sergi Delgado Segura <sergi.delgado.s@gmail.com>
    22f074214a
  78. p2p: Add a function to identify local/remote missing txs
    When the sketches from both sides are combined successfully,
    the diff is produced. Then this diff can (together with the local txs)
    be used to identified which transactions are missing locally and remotely.
    5475d7feee
  79. Use txid/uint256 in CompareInvMempoolOrder
    This will help to reuse the code later on in the function
    to announce transactions.
    541a56a4d2
  80. p2p: Handle reconciliation sketch and successful decoding
    Co-authored-by: Sergi Delgado Segura <sergi.delgado.s@gmail.com>
    d5b50f4fa4
  81. p2p: Request extension if decoding failed
    If after decoding a reconciliation sketch it turned out
    to be insufficient to find set difference, request extension.
    
    Co-authored-by: Sergi Delgado Segura <sergi.delgado.s@gmail.com>
    d5a961b520
  82. Be ready to receive sketch extension
    Store the initial sketches so that we are able to process
    extension sketch while avoiding transmitting the same data.
    
    Co-authored-by: Sergi Delgado Segura <sergi.delgado.s@gmail.com>
    8793d7c6ba
  83. p2p: Prepare for sketch extension request
    To be ready to respond to a sketch extension request
    from our peer, we should store a snapshot of our state
    and capacity of the initial sketch, so that we compute
    extension of the same size and over the exact same
    transactions.
    
    Transactions arriving during this reconciliation will
    be instead stored in the regular set.
    
    Co-authored-by: Gleb Naumenko <naumenko.gs@gmail.com>
    f60c09411c
  84. p2p: Keep track of announcements during txrcncl extension e4294d45df
  85. p2p: Handle reconciliation extension request
    If peer failed to reconcile based on our initial response sketch,
    they will ask us for a sketch extension. Store this request to respond later.
    e55497fb52
  86. p2p: Respond to sketch extension request
    Sending an extension may allow the peer to reconcile
    transactions, because now the full sketch has twice
    as much capacity.
    a4c2e75445
  87. Handle sketch extension
    If a peer sent us an extension sketch, we should
    reconstruct a full sketch from it with the snapshot
    we stored initially, and attempt to decode the difference.
    
    p2p: Handle sketch extension
    
    If a peer sent us an extension sketch, we should
    reconstruct a full sketch from it with the snapshot
    we stored initially, and attempt to decode the difference.
    0a442a3924
  88. p2p: Add a finalize incoming reconciliation function
    This currently unused function is supposed to be used once
    a reconciliation round is done. It cleans the state corresponding
    to the passed reconciliation.
    616fa3dac2
  89. Handle reconciliation finalization message
    Once a peer tells us reconciliation is done, we should behave as follows:
    - if it was successful, just respond them with the transactions they asked
      by short ID.
    - if it was a full failure, respond with all local transactions from the reconciliation
      set snapshot
    - if it was a partial failure (only low or high part was failed after a bisection),
      respond with all transactions which were asked for by short id,
      and announce local txs which belong to the failed chunk.
    463a661866
  90. p2p, test: Add tx reconciliation functional tests
    We may still need to add more tests, specially around extensions (if we keep them)
    
    Co-authored-by: Gleb Naumenko <naumenko.gs@gmail.com>
    236dd9b8bb
  91. sr-gi force-pushed on Apr 22, 2025
  92. DrahtBot added the label CI failed on Apr 22, 2025
  93. REMOVE-ME: Some small changes to try to debug CI failure b71131e1af
  94. DrahtBot removed the label CI failed on Apr 24, 2025
  95. DrahtBot commented at 11:09 pm on April 29, 2025: contributor

    🐙 This pull request conflicts with the target branch and needs rebase.

  96. DrahtBot added the label Needs rebase on Apr 29, 2025

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-05-31 03:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me