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.
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.
#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)
#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.
sr-gi marked this as a draft
on Jun 12, 2024
sr-gi force-pushed
on Jun 12, 2024
DrahtBot added the label
CI failed
on Jun 13, 2024
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.
DrahtBot added the label
CI failed
on Jun 19, 2024
sr-gi force-pushed
on Jun 20, 2024
DrahtBot added the label
Needs rebase
on Jun 20, 2024
refactor: move m_is_inbound out of CNodeState
`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.
530148f243
refactor: remove legacy comments
These comments became irrelevant in one of the previous code changes.
They simply don't make sense anymore.
394acf9442
p2p: Functions to add/remove wtxids to tx reconciliation sets
They will be used later on.
e165e9a0d1
p2p: Make short id collision detectable when adding wtxids to tx reconciliation sets2d50c14f04
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: Martin Zumsande <mzumsande@gmail.com>
Co-authored-by: Pieter Wuille <pieter.wuille@gmail.com>
8d25b32ca5
bench: add bench for ShouldFanoutTo53fd4b8b5b
p2p: Cache fanout candidates to optimize txreconciliation
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>
31fa29dae0
p2p: Add helper to compute reconciliation tx short ids and a cache of short ids to wtxidsf30c3f589e
sr-gi force-pushed
on Jun 20, 2024
DrahtBot removed the label
Needs rebase
on Jun 20, 2024
p2p: Deal with shortid collisions for reconciliation sets
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.
ed5a0cc232
p2p: Add PeerManager method to count the amount of inbound/outbounds fanout peersc62bc09c67
p2p: Moves fanout logic to RelayTransaction and properly fanouts ancestors
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
For a subset of reconciling peers we announce transactions
via low fanout. We need to set lower intervals for that to
achieve lower relay latency.
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.
ebea3e6378
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.
540a8e5ce5
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.
f92dd4f690
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.
1dd126b267
test: functional test for reqtxrcncl4388968442
p2p: Handle reconciliation request
Store the parameters the peer sent us inside the
reconciliation request.
ab4191a06b
Add helper to see whether we should respond to recon request
For initial reconciliatin requests we track whether was the last time
we responded to them, and if it was too recent, we respond after
a small delay.
ec5839bbf7
build: Link minisketch libraries6f37a7e20c
Add helper to compute sketches for tx reconciliation69d51d5136
Respond to a reconciliation request
When the time comes, we should send a sketch of our
local reconciliation set to the reconciliation initiator.
ac92846a0b
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.
2028118a63
Use txid/uint256 in CompareInvMempoolOrder
This will help to reuse the code later on in the function
to announce transactions.
d849013318
p2p: Handle reconciliation sketch and successful decoding48bf4d4f3d
p2p: Request extension if decoding failed
If after decoding a reconciliation sketch it turned out
to be insufficient to find set difference, request extension.
6913b939a6
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.
874fd2d33a
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.
706901da9f
p2p: Keep track of announcements during txrcncl extension2fd65c65a2
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.
bc3db22ca0
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.
fa2c04ed99
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.
1c1ac7fece
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.
8bdc2af3d2
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.
I'm assuming Gleb didn't want to have transactions collisions in this
tests, but some are manifesting in CI, this is due to how coins are selected.
Fixing this plus making it a bit more idiomatic. This can be squashed to the
previous commit
417561cecf
test: Update mempool_packages.py test for reconciliation
First, extend the timeout to facilitate reconciliation
relay which might take longer than previously.
Second, since reconciliation can't guarantee that
descendants of same-degree (from the parent) are
relayed in the same order they were received, loosen
the check for descendant limit.
This is the case because, if the parent is flooded,
the children might be both flooded and reconciled,
and the decision is made independently. So even if
one arrived earlier, it can be relayed later because
flooding.
Note, it's possible to make txreconciliation.cpp be aware
of the order of adding transactions to the set, but this
won't help to solve the above issue.
6f9cbc47b4
build, msvc: Adjust MSVC project files0a7adc36a4
sr-gi force-pushed
on Jun 21, 2024
DrahtBot removed the label
CI failed
on Jun 21, 2024
DrahtBot
commented at 11:15 am on July 4, 2024:
contributor
🐙 This pull request conflicts with the target branch and needs rebase.
DrahtBot added the label
Needs rebase
on Jul 4, 2024
DrahtBot
commented at 1:24 am on October 1, 2024:
contributor
⌛ There hasn’t been much activity lately and the patch still needs rebase. What is the status here?
Is it still relevant? ➡️ Please solve the conflicts to make it ready for review and to ensure the CI passes.
Is it no longer relevant? ➡️ Please close.
Did the author lose interest or time to work on this? ➡️ Please close it and mark it ‘Up for grabs’ with the label, so that it can be picked up in the future.
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: 2024-11-23 09:12 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me