-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Enable fetching of orphan parents from wtxid peers #19569
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
Conversation
@ajtowns I made a few changes compared to your branch:
Let me know what you think. |
7189ef5
to
154778d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of the txrequest data structures use it, not just m_tx_process_time - this feels more obviously correct.
👍
The restriction that wtxidrelay peers can only announce using MSG_WTX invs remains - this isn't violated by txid-based orphan parent requests (which are get GETDATAs, not INVs).
Ha. I thought when I was writing that patch that removing that restriction wasn't supposed to be necessary.
Code review ACK 154778d
utACK 154778d |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 154778d code review, debug build/tests/ran node, checked test here fails on master and reverted test fails on the branch.
Reviewers: suggest reviewing 54a0936 with -w
.
968edda
to
338f80e
Compare
ACK 338f80e per |
} | ||
for (const CTxIn& txin : tx.vin) { | ||
// Here, we only have the txid (and not wtxid) of the | ||
// inputs, so we only request in txid mode, even for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strictly interpreting the BIP, the requirement for wtxid-relay on fetching is scoped to "announced transactions from that peer", and orphan parents have not been announced so we don't violate wtxid-relay policy here. Concern is on future BIP implementers on how they interpret "is required" and severing the connection for violations. Lightweight clients broadcasting a parent + CPFP tx may know issues due to this.
In the meanwhile, I share Suhas point to not commit a given handling of this behavior. Maybe we should amend the BIP to invite liberal enforcement of violations, just dropping non-complying invs/getdatas ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just did a code review and spotted one potential issue, but otherwise looks good. Will test.
338f80e
to
707d0f4
Compare
Changed the code to treat tx announcements as keyed by hash (rather than hash+wtxidness), so that txid requests for parents of unconfirmed transactions won't result in a duplicate query if a wtxid with the same hash is already in flight. This reduces the diff a bit as well, and removed the need for ToString(). |
I 100% agree with this. Net processing is complicated enough as it is without having data structures hold a mixture of different types. txids and wtxids are different types that just happen to both be encoded in a uint256, which means the compiler can't protect us from bugs where we mistake one for the other. If we're going to do this, we should at least make it very clear to the programmer by adding comments to the data structures and functions that are doing this. For example, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 707d0f4
I added a few CInv tx msg type
boolean helpers on this branch to simplify ToGenTxid()
and the net processing code, if you're inclined to use any of it: https://github.com/jonatack/bitcoin/commits/add-inv-msg-booleans (EDIT: opened #19590 for the parts non-specific to this branch).
@jnewbery Would it help if the various txrequest-related functions take a GenTxid argument, but where appropriate, call GetHash() on it when they really just need a txid-or-wtxid key, instead of passing those keys around as uint256s? |
Code review ACK, apart from the test change which I haven't reviewed. Will test. |
ACK 707d0f4 |
utACK 707d0f4 |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
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. |
I added 3 extra commits that introduce more |
utACK c048357 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review ACK c048357. A few comments inline.
Thanks for updating the functions to take GenTxid
s. I think that's clearer. I still think that the original version of this PR was better still, and that storing GenTxids in the various tx download data structures is easier to reason about and worth the marginal loss in efficiency, but I guess that all this is going away with #19184 so it doesn't matter too much.
Light ACK c048357 modulo Gleb's and John's feedback above. |
Based on a commit by Anthony Towns.
c048357
to
10b7a6d
Compare
Rebased and addressed comments. |
ACK 10b7a6d -- code review. Using gtxid to replace the is_txid_or_wtxid flag for the mempool functions is nice. |
utACK 10b7a6d |
ACK 10b7a6d |
Code review ACK 10b7a6d |
I have a backport of (the first 4 commits of) this to v0.20 here: https://github.com/jnewbery/bitcoin/tree/2020-07-v20-wtxid-orphan. It can be added to #19606 or PR'ed separately. Whatever is easiest for reviewers. |
10b7a6d refactor: make txmempool interface use GenTxid (Pieter Wuille) 5c124e1 refactor: make FindTxForGetData use GenTxid (Pieter Wuille) a2bfac8 refactor: use GenTxid in tx request functions (Pieter Wuille) e65d115 test: request parents of orphan from wtxid relay peer (Anthony Towns) 900d7f6 p2p: enable fetching of orphans from wtxid peers (Pieter Wuille) 9efd86a refactor: add GenTxid (=txid or wtxid) type and use it for tx request logic (Pieter Wuille) d362f19 doc: list support for BIP 339 in doc/bips.md (Pieter Wuille) Pull request description: This is based on bitcoin#18044 (comment). A new type `GenTxid` is added to protocol.h, which represents a tagged txid-or-wtxid. The tx request logic is updated to use these instead of uint256s, permitting per-announcement distinguishing of txid/wtxid (instead of assuming that everything we want to request from a wtxid peer is wtx). Then the restriction of orphan-parent requesting to non-wtxid peers is lifted. Also document BIP339 in doc/bips.md. ACKs for top commit: jnewbery: Code review ACK 10b7a6d jonatack: ACK 10b7a6d ajtowns: ACK 10b7a6d -- code review. Using gtxid to replace the is_txid_or_wtxid flag for the mempool functions is nice. naumenkogs: utACK 10b7a6d Tree-SHA512: d518d13ffd71f8d2b3c175dc905362a7259689e6022a97a0b4f14f1f9fdd87475cf5af70cb12338d1e5d31b52c12e4faaea436114056a2ae9669cb506240758b
d4a1ee8 Further improve comments around recentRejects (Suhas Daftuar) f082a13 Disconnect peers sending wtxidrelay message after VERACK (Suhas Daftuar) 22effa5 test: Use wtxid relay generally in functional tests (Fabian Jahr) e481681 test: Add tests for wtxid tx relay in segwit test (Fabian Jahr) 6be398b test: Update test framework p2p protocol version to 70016 (Fabian Jahr) e364b2a Rename AddInventoryKnown() to AddKnownTx() (Suhas Daftuar) 879a3cf Make TX_WITNESS_STRIPPED its own rejection reason (Suhas Daftuar) c1d6a10 Delay getdata requests from peers using txid-based relay (Suhas Daftuar) 181ffad Add p2p message "wtxidrelay" (Suhas Daftuar) 9382672 ignore non-wtxidrelay compliant invs (Anthony Towns) 2599277 Add support for tx-relay via wtxid (Suhas Daftuar) be1b7a8 Add wtxids to recentRejects (Suhas Daftuar) 7384521 Add wtxids of confirmed transactions to bloom filter (Suhas Daftuar) 606755b Add wtxid-index to orphan map (Suhas Daftuar) 3654937 Add a wtxid-index to mapRelay (Suhas Daftuar) f7833b5 Just pass a hash to AddInventoryKnown (Suhas Daftuar) 4df3d13 Add a wtxid-index to the mempool (Suhas Daftuar) Pull request description: We want wtxid relay to be widely deployed before taproot activation, so it should be backported to v0.20. The main difference from #18044 is removing the changes to the unbroadcast set (which was only added post-v0.20). The rest is mostly minor rebase conflicts (eg connman changed from a pointer to a reference in master, etc). We'll also want to backport #19569 after that's merged. ACKs for top commit: fjahr: re-ACK d4a1ee8 instagibbs: reACK d4a1ee8 laanwj: re-ACK d4a1ee8 hebasto: re-ACK d4a1ee8, only rebased since my [previous](#19606 (review)) review: Tree-SHA512: 1bb8725dd2313a9a03cacf8fb7317986eed3d8d1648fa627528441256c37c793bb0fae6c8c139d05ac45d0c7a86265792834e8e09cbf45286426ca6544c10cd5
Backported to 0.20 in #20317 |
This is based on #18044 (comment).
A new type
GenTxid
is added to protocol.h, which represents a tagged txid-or-wtxid. The tx request logic is updated to use these instead of uint256s, permitting per-announcement distinguishing of txid/wtxid (instead of assuming that everything we want to request from a wtxid peer is wtx). Then the restriction of orphan-parent requesting to non-wtxid peers is lifted.Also document BIP339 in doc/bips.md.