-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
BIP 331: Ancestor Package Relay #1382
Conversation
Assigned BIP # 331 |
0a03dbe
to
65069fc
Compare
Updated for number |
65069fc
to
112f8cc
Compare
efdae92
to
c9edbc3
Compare
I'm not a big mempool expert, but this seems like a good direction.
This example seems confusing: it violates the following rule
|
Thanks for the review @naumenkogs! yes, I think it's best to talk specifics with the actual implementation but I'll throw some quick answers for now:
One should treat this situation the same way we do for transactions that get replaced in between inv and getdata (I don't see any reason it should be different). Currently, we send "notfound". If in the future we decide to relay recently-replaced transactions, then package relay would include recently-replaced transactions as well. Though I agree this seems more like an implementation question than a spec question. In the spec, I would leave it as "the receiver may respond with notfound."
Yes it's great that Erlay orders them correctly. Note below-fee-filter transactions to the reconciliation bucket so not every case is handled. I plan to have a rebase-on-top-of-Erlay version so we can exercise the two together.
Mostly the "Is Package Erlay possible" section was to clarify that they aren't mutually exclusive.
Yeah that's an interesting idea, we could do a bitfield of 4 bytes (should cover any package since max count is 25). However this means you can only request getpkgtxns from somebody who sent an ancpkginfo (currently this is not a requirement). It also requires the sender to keep track of (allocate memory for, remember to expire) what they announced so they know what "the ith transaction from this package" means. Thoughts? |
The thing with current A requestor will get this package which doesn't pass the fees, and drop it on the floor? Or should it re-request the package? At the moment, I'm not interested in the final answer — but interested in making sure we don't miss such questions.
Not sure this anything to do with who initiates packages. Let's think about the current proposal. Imagine, upon the announcement of C, the receiver sends getdata(MSG_ANCPKGINFO, C), along with some compressed data saying that he already has 1 parent and 1 child of C (by just looking at the wtxid). Then it would save us announcing these 2 wtxids in the reverse direction.
I don't think memory allocation and stuff is a show-stopper, but it might be too much complexity if the gain is low. We should measure how much savings it allows... I think saving 28 byte per announced tx might be worthy. As for the "same peer", do you ever expect packages to be requested from a different peer from the one announced them? |
c9edbc3
to
2f65ad1
Compare
2f65ad1
to
15e9c46
Compare
@jnewbery thanks, took all suggestions CI seems to be failing on bip-0327 title being too long, so will ignore for now. |
Sorry about that, the BIP-327 title issue has been fixed, so please rebase. |
15e9c46
to
43be4d7
Compare
bip-0331.mediawiki
Outdated
|
||
A "combined hash" serves as a unique "package id" for some list of unique transactions. | ||
|
||
The combined hash of a package of transactions is equal to the hash of each transaction's wtxid, concatenated in lexicographical order. |
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.
Should we use a BIP340 tagged hash here? (I'm not sure, thinking out loud). For example, could be relevant for these rolling bloom filters that contain hashes corresponding to both txes and packages?
Thanks @jnewbery @stickies-v @willcl-ark for the feedback. I'm working on incorporating the suggestions, apologies for the delay. |
43be4d7
to
d9aac43
Compare
d9aac43
to
ddffe01
Compare
Changed the Neither of these are implemented in the branch I had linked before, so I've removed that link. Will update when I've done that. I've restructured the BIP to make the difference between "generic" (can be used in future versions of package relay) vs "ancestor info" (first defined version) parts more clear (#1382 (comment)). Also updated the diagrams and took wording suggestions. |
Maybe it's obvious or I am missing something but I couldn't see the answer in the doc: How would a node decide between sending |
@fjahr "The inv type should not be used in announcements" it's a type used for |
Hmm, ok, first insight: the inconsistencies in the message naming can be confusing. I guess it gets obvious when someone goes deeper but I did a pretty superficial pass and then tried to find an answer to this question and I guess I stumbled over that it's It seems that the name has changed before which makes researching past discussions on the mailing list harder. Maybe that could be noted somewhere (the artist formerly known as In an old ML post I found:
(from https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2022-May/020493.html) But this is now changed it seems so maybe the graphics can be updated in this regard as well and the inv messages removed? |
Yes, For example, The reason there is an "inv(PKGINFO)" there is to communicate that, while I will update the diagram to make this more clear, thanks for the feedback and sorry for the confusion! |
bip-0331.mediawiki
Outdated
suggests adding new p2p messages enabling nodes to request and share package-validation-related | ||
information with one another, resulting in a more efficient and reliable way to propagate packages. | ||
|
||
(2) Eliminate the need for txid-based transaction relay and make orphan handling more robust. |
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.
You still "need" txid-based relay for backwards compatibility.
Arguably, txid-based relay would be more efficient than the proposed protocol: if you see an orphan Z, whose parent Y does not spend any in-mempool txs, then this protocol would make three round trips:
- GETDATA wtx(Z); TZ Z
- GETDATA andpkginfo(Z); ANCPKGINFO Z, Y
- GETPKGTXNS wtx(Y); PKGTXNS Y
but you could alternatively do two round trips:
- GETDATA wtx(Z); TZ Z
- GETDATA andpkginfo(Z), tx(Y); ANCPKGINFO Z, Y; TX Y
That approach would not reduce round-trips when receiving orphans that do have an in-mempool grandparent that the receiver does not already know about (but it wouldn't increase the number of roundtrips either), and would also require storing both the child and parents while waiting for any grandparents.
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.
I suppose it's true that this protocol is not going to have fewer round trips in every possible case of orphans, but we wouldn't have a way of detecting those cases on the receiver end.
0a46f7d
to
d07535c
Compare
Updated for suggestions from @ajtowns, thanks! Major changes (still need to update implementation to reflect these):
|
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.
See the note on maybe asymmetry around “ancpkginfo"
bip-0331.mediawiki
Outdated
|
||
# The "ancpkginfo" message has the structure defined above, with pchCommand == "ancpkginfo". | ||
|
||
# The "txns" field should contain a list of wtxids which constitute the ancestor package of the last wtxid. The sender should - but is not required to - sort these wtxids in topological order. The topological sort can be achieved by sorting the transactions by mempool acceptance order (if parents are always accepted before children). Nodes should not disconnect or punish a peer who provides a list not sorted in topological order.<ref>'''Why not include feerate information to help the receiver decide whether these transactions are worth downloading?''' |
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.
Side-note, I think the feerate cannot be trusted under BIP118 ANYPREVOUTANYSCRIPT, where the spent amount are not committed in the digest and transaction child A can be attached to parent X or parent Z of different amounts (of course there is the issue to re-bind the ANYPREVOUTANYSCRIPT on a parent by scriptpubkey only…). So I think this avoid to introduce a dependency in light of potential future consensus changes.
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.
Useful extra context, though I didn't add any of this to the text.
d07535c
to
c2da2cf
Compare
I think I've addressed all comments now. |
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
nits only
c2da2cf
to
9983728
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.
Addressed the text-related comments
9983728
to
02ec218
Compare
Changed combined hash to be single instead of double sha256 |
re-ACK 02ec218 suggested textual additions and change to single-sha2 for combined hash |
@luke-jr @kallewoof is anything else needed here? |
@luke-jr pinging again, can we get this merged? |
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.
A couple of comments/nits I found when going over this
02ec218
to
92c07f5
Compare
92c07f5
to
8c41b83
Compare
8c41b83
to
632f143
Compare
pinging again, if any BIP editors are available to have a look? |
ACK 632f143 |
ML thread: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2022-May/020493.html
Supersedes #1324.