Erlay refactored #21335

pull naumenkogs wants to merge 29 commits into bitcoin:master from naumenkogs:erlay_refactored_public changing 84 files +8450 −58
  1. naumenkogs commented at 1:17 PM on March 2, 2021: member

    I'm using this PR to get an initial review on the new structure of the Erlay PR.

  2. Add minisketch dependency 6474c9f1ed
  3. Squashed 'src/minisketch/' content from commit 80481500c
    git-subtree-dir: src/minisketch
    git-subtree-split: 80481500cdb3328adab751db30a3fa7e76fe1147
    0a495a213b
  4. Merge commit '0a495a213bbc56bc4e90070e9081371ec6ea1da7' as 'src/minisketch' fec47ad22d
  5. Announce reconciliation support
    If a peer supports wtxid our node should notify them
    that we are willing to participate in tx reconciliation.
    At this point we generate a salt for computing
    short tx IDs for reconciliations over this connection.
    f3aeaee634
  6. Count outbound tx relay peers except one
    This helper will be used to determine whether we
    should suggest our new peer reconciling with us.
    e7d1293f76
  7. Handle reconciliation support announcement
    Once we receive a message from a peer signalling
    reconciliation support, we initialize the data structures
    required to perform reconciliations. If we are planning to
    initiate reconciliations with this peer (if it's an outbound connection),
    add this peer to the reconciliation queue.
    7ca561b7cf
  8. Limit transaction flooding
    See how many flooding and how many reconciling
    outbound peers we have, which is useful to see whether our new
    peer should be using flooding or reconciliation.
    
    It helps to save bandwidth and presumably reduces privacy leak.
    ed4f3e1f9b
  9. Remove node from reconciliation queue when disconnecting f49b144f71
  10. Add a function to announce transactions after reconciliation
    Have a separate function to announce transactions to a peer (via INVs)
    considering INV message limitations.
    bcc795dbe3
  11. Prepare to distinguish transactions to flood and to reconcile
    We need assign and keep track of the way we're going to relay a transaction
    based on the connection type the transaction arrived from, to
    enable transaction reconciliation protocol.
    b41b4674c2
  12. Distinguish transactions to flood and to reconcile
    Flooding and reconciliation are two different ways to announce
    transactions to the peers.
    For transactions received from inbound links, use flooding to enable
    a rapid relay across the reachable nodes.
    
    Use reconciliation (add transactions to the reconciliation sets) for
    all transactions which were received from outbound links to enable
    an slower but more efficient relay to unreachable nodes.
    2fb3d69509
  13. Reduce tx broadcast interval
    Since reconciliation is naturally slower than flooding, and also
    since we limit the flooding aspect, we should reduce the intervals
    between broadcasts (flooding out or adding to reconciliation sets).
    Otherwise, transaction relay will be too slow
    (and probably less inefficient).
    
    Note that for privacy reasons the ratio between inbound and outbound
    delays matter much more than the actual delays. That ratio is preserved
    here, so it is not a privacy degradation.
    a28be569dd
  14. Request tx reconciliation as scheduled
    If the peer is next in the queue for reconciliation,
    and enough time is passed from the previous
    reconciliation, consider a peer for reconciliation.
    
    If there is no pending reconciliation request to the peer,
    send one, otherwise just move to the end of queue and
    update global next reconciliation request time.
    60d59a449e
  15. Process incoming reconciliation request
    Upon receiving a reconciliation request, a node stores
    it and schedules a response.
    Do not respond to a request right away as it would enable
    a DoS attack and allow monitoring of transaction a node has.
    Instead, respond to all reconciliation requests at a same time
    after a small delay.
    b0659c36b7
  16. Add helper to compute reconciliation tx short id
    Short ids are used to compute reconciliation sketches.
    5aadce7cdf
  17. Add helper to compute sketches for tx reconciliation
    Sketch is a representation of list of transaction IDs,
    which enables reconciliation (an efficient sync of lists
    between peers).
    244b59a481
  18. Respond to a reconciliation request
    When the time comes, a node computes a sketch of the
    local transactions based on the parameters sent
    in the reconciliation request, and sends that sketch
    to the requestor. Clear local state.
    0474bf7424
  19. Add a function to get wtxids by shortids
    At the end of a reconciliation round, a peer may ask us
    for transactions by their short id. Add a function for a local
    lookup short_id->wtxid.
    b13bc7f7f1
  20. Add a finalize 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.
    b99eded333
  21. 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.
    05d7e5a21f
  22. Handle reconciliation sketch and successful decoding
    Send/request missing transactions, clear the state,
    and send a finalization message.
    c498a7f0c9
  23. Request extension if decoding failed
    If after decoding a reconciliation sketch it turned out
    to be insufficient to find set difference, request extension.
    Store the initial sketches so that we are able to process
    extension sketch.
    be367b70ba
  24. 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.
    7db69870b6
  25. Prepare to responding to extension requests
    Add 2 variables tracking reconciliation state:
    (1) recon set snapshot and (2) capacity snapshot.
    (1) is used to store transactions arrived after we sent out
    an initial sketch, but before the reconciliation is over, since
    these transactions should not go into a sketch extension.
    (2) is used to set the capacity of the extended sketch because
    it provides good estimation (efficiency/failure tradeoff).
    15f9a956cd
  26. Respond to an extension request
    Compute a sketch with extra capacity and send
    those extra syndromes to the peer.
    It is safe to respond to an extension request without a delay
    because these requests are already limited by initial requests.
    5b0303a631
  27. Handle extension sketch
    If a peer responded to our request with a sketch extension,
    attempt to decode it to find missing transactions by combining
    it with the initial sketch.
    If success, share/request missing transactions.
    If failure, send all the transactions we had for the peer.
    ea6b07b84d
  28. 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.
    d578090d97
  29. tests: support (inbound) connecting to mininode b843662818
  30. Add tests for set reconciliation 108748f1eb
  31. fanquake added the label P2P on Mar 2, 2021
  32. naumenkogs closed this on Mar 2, 2021

  33. naumenkogs commented at 1:19 PM on March 2, 2021: member

    Sorry, I meant to do this in under own repo.

  34. DrahtBot locked this on Aug 16, 2022
Contributors
Labels

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: 2026-04-27 06:14 UTC

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