Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

p2p: Fill reconciliation sets (Erlay) attempt 2 #30116

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

sr-gi
Copy link
Member

@sr-gi sr-gi commented May 15, 2024

This is a re-attempt of #28765

The main differences from it are:

  • Most outstanding comments have been addressed (or responded to on the original PR)
  • The description of how a node is picked in IsFanoutTarget has been updated to reflect what the algorithm is doing (not how it is doing it)
  • The way hash_key is seeded in IsFanoutTarget has changed (from m_k0 to wtxid.ToUint256()). This is to prevent using m_k0 for something it is not intended to, given what data we feed to the randomizer should not matter
  • destinations/target has been renamed to n in ShouldFanoutTo/IsFanoutTarget
  • The PR has been rebased

Also, the following things have been added/changed to the approach:

  • Deal with short id collisions by fanning out both transactions
  • Deal with ancestors being present on the mempool when a children needs to be placed in the fanout or reconciliation sets (as opposed to deal with parents, which was the wrong approach)
  • Move fanout/reconcile logic from from INV creation to RelayTransaction

The differences can be easily checked via git range-diff a14dfd9c873d1e196252c77ad7a8b32bd21b6f6d...ac5dc0aa512e78a1cc90e0ab182eedaec68b0444

Erlay Project Tracking: #28646

@DrahtBot
Copy link
Contributor

DrahtBot commented May 15, 2024

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

Code Coverage

For detailed information about the code coverage, see the test coverage report.

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:

  • #29575 (net_processing: make any misbehavior trigger immediate discouragement by sipa)
  • #29415 (Broadcast own transactions only via short-lived Tor or I2P connections by vasild)
  • #27052 (test: rpc: add last block announcement time to getpeerinfo result by LarryRuane)

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.

@DrahtBot DrahtBot added the P2P label May 15, 2024
@sr-gi
Copy link
Member Author

sr-gi commented May 15, 2024

I've talked to @naumenkogs about picking this up and he was happy about it. I'm happy to close this if he changes his mind.

@sr-gi sr-gi changed the title p2p: Fill reconciliation sets (Erlay) attempt: 2 p2p: Fill reconciliation sets (Erlay) attempt 2 May 15, 2024
@sr-gi
Copy link
Member Author

sr-gi commented May 31, 2024

I've slightly extended the approach adding 3 commits to deal with short id collisions, which were not taken into account. Some of this may be squashable, I've added them separately for now so they are easy to diff/review.

This would be missing an additional commit/amend to deal with #28765 (comment), which I overlooked when addressing the outstanding comments

@DrahtBot
Copy link
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/25659971810

sr-gi and others added 7 commits June 5, 2024 13:44
`m_is_inbound` cannot be changed throughout the life of a `Peer`. However, we
are currently storing it in `CNodeState`, which requires locking `cs_main` in
order to access it. This can be moved to the outside scope and only require
`m_peer_mutex`.

This is a refactor in preparation for Erlay reworks.
These comments became irrelevant in one of the previous code changes.
They simply don't make sense anymore.
Transactions eligible for reconciliation are added to the
reconciliation sets. For the remaining txs, low-fanout is used.

Co-authored-by: Martin Zumsande <mzumsande@gmail.com>
Co-authored-by: Pieter Wuille <pieter.wuille@gmail.com>
@sr-gi sr-gi marked this pull request as draft June 7, 2024 18:19
@sr-gi
Copy link
Member Author

sr-gi commented Jun 7, 2024

I added two more commits, moving the fanout/reconciling logic to RelayTransaction instead of send message, plus dealing with ancestors in mempool, instead of descendants (which seemed to be the wrong approach).

I'm moving this to draft for now until I clean it a bit, plus get some feedback on the approach

@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 8, 2024

🚧 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/25955152377

@sr-gi sr-gi force-pushed the 2023-11-erlay2.1 branch 2 times, most recently from fa5df88 to edb0072 Compare June 10, 2024 19:12
naumenkogs and others added 5 commits June 11, 2024 14:34
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>
If a wtxid 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 reconciliation
will fail. Moreover, all descendants of the previously added transaction that were in
the recon set should also be removed and fanout.
…stors

If a transaction to be reconciled has in mempool ancestors, we need to be consistent
with the way in which we announce this transaction (either by fanning out or reconciling
all the ancestor set). In order for Erlay to work best, a minimum amount of fanout is required.
Therefore, we cannot simply reconcile with everyone in this case either. Find the subset of peers
that have the least ancestors to be reconciled and send all of them via fanout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

None yet

7 participants