Skip to content

Conversation

@glozow
Copy link
Member

@glozow glozow commented May 17, 2022

Please leave concept/approach feedback on the mailing list thread so that people can follow the discussion in one place. Feel free to leave a review comment if you find typos or incorrect wording.

Copy link
Member

@sdaftuar sdaftuar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! Just some initial questions to try to make sure I'm understanding this proposal right (will do my best to save broader feedback for the mailing list!).


# '''Sorted topologically.''' For every transaction t in the package, if any of t's parents are present in the package, the parent must appear somewhere in the list before t. In other words, the transactions must be sorted in ascending order of number of ancestors present in the package.

# '''Only 1 child with unconfirmed parents.''' The package must consist of one transaction and its unconfirmed parents. There must not be any other transactions in the package. Other dependency relationships may exist within the package (e.g. one parent may spend the output of another parent) provided that topological order is respected.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I overlooked when I first read this over -- by "unconfirmed parents" you mean direct parents, ie transactions which contain an outpoint being spent in the child transaction, is that right? (I was trying to figure out exactly what you meant by the 2-generation limit further down, and then I realized I might have misunderstood the language here.)

I'd suggest defining this language more explicitly somehow, since I think "unconfirmed parent" can read a lot like "unconfirmed ancestor" (and at any rate I don't think these words have meanings well defined across the developer community).

Also, if a GETDATA(PCKG1, wtxid) comes in for a transaction that has unconfirmed ancestors outside the set of unconfirmed direct parents, how is software supposed to respond?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by "unconfirmed parents" you mean direct parents, ie transactions which contain an outpoint being spent in the child transaction, is that right?

Yes, exactly.

I'd suggest defining this language more explicitly somehow, since I think "unconfirmed parent" can read a lot like "unconfirmed ancestor" (and at any rate I don't think these words have meanings well defined across the developer community).

Ah, noted. How about something like this:
"Given any two transactions Tx0 and Tx1 where Tx1 spends an output of Tx0, Tx0 is a parent of Tx1 and Tx1 is a child of Tx0. A transaction's ancestors include, recursively, its parents, the parents of its parents, etc. A transaction's descendants include, recursively, its children, the children of its children, etc."

Also, if a GETDATA(PCKG1, wtxid) comes in for a transaction that has unconfirmed ancestors outside the set of unconfirmed direct parents, how is software supposed to respond?

It should send only the direct parents, and no other ancestors.


# A new inv type (MSG_PCKG1 == 0x6) is added, for use in inv messages and getdata requests pertaining to version 1 packages.

# As an inv type, it indicates that both transaction data and version 1 package information are available for the transaction. The transaction is referenced by its wtxid. As a getdata request type, it indicates that the sender wants package information for the transaction.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does using MSG_PCKG1 as an inv-type imply that the transaction's unconfirmed ancestors are exactly equal to its unconfirmed parents? (See my other questions below)


# As an inv type, it indicates that both transaction data and version 1 package information are available for the transaction. The transaction is referenced by its wtxid. As a getdata request type, it indicates that the sender wants package information for the transaction.

# Upon receipt of a "getdata" request for "MSG_PCKG1", the node should respond with the version 1 package corresponding to the requested transaction and its current chain tip, or with NOTFOUND. The node should not assume that the sender is requesting the transaction data as well.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it permitted to send a GETDATA(MSG_PCKG1, wtxid) if the peer didn't send an INV(MSG_PCKG1, wtxid)? Ie could software use this message to reconstruct the parents of an orphan transaction?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes absolutely! This kind of "half solves" the orphan fetching use case if there's only direct parents missing, but I actually think it would make sense to create another type of package for tx-with-unconfirmed-ancestors:

image

To answer the likely question of "why wasn't v1 packages tx-with-unconfirmed-ancestors?" I have two primary reasons:

  • The mempool policy created for child-with-unconfirmed-parents packages is insufficient to ensure that a the fees of a tx-with-ancestors package would be evaluated correctly. I noticed you had some consideration for that in #16401. Probably the best algorithm is to sort topologically, then submit each transaction with its ancestor subset within the package. But it doesn't seem like anyone is asking for more than 2 generations of fee-bumping, and I haven't really figured out what RBF would look like.

  • It seems like the orphan-processing and fee-bumping use cases can be thought of separately. For instance, fee-bumping should be a sender-initiated "I'm telling you about extra info you need" and orphan-fetching is more appropriate as a receiver-initiated "hey I'm new here, so I don't know the ancestors of this transaction."

@glozow glozow force-pushed the 2022-04-package-relay branch from dee1711 to 20fe00b Compare May 17, 2022 19:06
@instagibbs
Copy link
Member

instagibbs commented May 17, 2022

Based on email discussion, I'd request that the spec makes it explicit that you do not request packages from peers when they report a different chaintip blockhash(and disconnect them right after...)

it's possible I missed it, but I keep looking and not seeing it

@glozow
Copy link
Member Author

glozow commented May 17, 2022

Based on email discussion, I'd request that the spec makes it explicit that you do not request packages from peers when they report a different chaintip blockhash(and disconnect them right after...)

Thanks @instagibbs I will add this. Also, if a peer sends us a "pckginfo1" with a blockhash that's different from ours, we should probably just drop it and re-request when they catch up (I think nowadays we usually have an accurate idea of what our peer's best block is). We're definitely not going to disconnect a peer for sending a "pckginfo1" with a different blockhash from ours.

@glozow glozow force-pushed the 2022-04-package-relay branch from 20fe00b to 66b050a Compare May 17, 2022 21:31
Copy link

@michaelfolkson michaelfolkson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First read through. Looks great thus far. Just some nits (feel free to ignore).

I know this hasn't been done in the past but in the spirit of trying to make BIPs more understandable (and precise when it comes to references to particular attacks) I wonder if a glossary of terms (e.g. pinning attacks and the different varieties of such attacks) could be a good idea (maybe footnotes rather than a glossary, they have been used in the past). I guess the top priority is to clearly go into what attacks/vulns package relay addresses (including on higher layers), what attacks/vulns package relay potentially opens up on the base layer with their introduction and how the design of package relay has minimized the scope of those attacks/vulns on the base layer. My gut feel is that the current draft is still a little light on these details but it was just a first readthrough and it clearly doesn't ignore them.

edit: Was looking at the BIP118 draft for inspiration on what a BIP should cover that is primarily targeted towards higher layer use cases (but with base layer implications). That has a Security section which may be a good idea for this BIP.


# Download and validate packages of transactions together.

# Provide information to help peers decide whether to request and/or how validate transactions which are part of a package.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: s/how validate/how to validate

once, avoid downloading transactions that are eventually rejected, and minimize storage allocated
for not-yet-validated transactions.

Consider these scenarios specifically transaction relay:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: s/specifically transaction relay/specifically for transaction relay

===P2P Message Design===

These p2p messages are added for communication efficiency and, as such, one should measure
alternative solutions based on the resources used to communicate (not necessarily trustworthy)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: s/not necessarily trustworthy/in the presence of possibly malicious peers


# The "sendpackages" message has the structure defined above, with pchCommand == "sendpackages".

# During version handshake, nodes should send a "sendpackages" message indicate they support package relay and may request packages.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits: s/During version handshake/During the version handshake, s/message indicate/ message to indicate


''Diagram: A receiver-initiated dialogue.''

Sometimes, no matter what order transactions are received by a node, validating them individually is

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: s/no matter what order transactions are received by a node/regardless of the order in which transactions are received by a node

@glozow glozow force-pushed the 2022-04-package-relay branch from 66b050a to c833fd6 Compare May 20, 2022 22:55
@glozow glozow changed the title Package Relay and child-with-unconfirmed-parents Packages Package Relay and child-with-unconfirmed-parents + tx-with-unconfirmed-ancestors Packages May 20, 2022
@glozow
Copy link
Member Author

glozow commented May 20, 2022

Added tx-with-unconfirmed-ancestors packages as a second type of package dedicated to orphan-fetching.

@glozow glozow force-pushed the 2022-04-package-relay branch from c833fd6 to 5c73c62 Compare May 24, 2022 18:24
@glozow
Copy link
Member Author

glozow commented May 24, 2022

Last push (thanks @ajtowns)

  • Count and size are implied by the version. Version 1 and Version 2 both have maximum of 25 transactions and 404KWu.
  • Announce sendpackages based on our own state. It’s ok to send “sendpackages” if they sent fRelay=false.
  • At verack, require fRelay=true and wtxidrelay if they sent sendpackages, otherwise disconnect.
  • If we get “getpckgtxns” or “pckgtxns” without having negotiated “sendpackages” ahead of time, ignore, don’t disconnect. Emphasize that the intention is to validate all of the transactions received through “pckgtxns” together.

Thanks for the feedback @michaelfolkson, I'll get to the style/wording comments later when the design is more finalized.

@flack
Copy link
Contributor

flack commented May 25, 2022

Sorry for also leaving a style nit, but as someone also mentioned on the mailing list, pkg is a much more common abbreviation than pckg (it's even mentioned on Wikipedia: https://en.wikipedia.org/wiki/PKG), so it might be nice to consider switching to that.

@glozow glozow force-pushed the 2022-04-package-relay branch from 5c73c62 to 9a85fef Compare June 7, 2022 17:41
@glozow
Copy link
Member Author

glozow commented Jun 7, 2022

Last push:

  • Renamed s/pckg/pkg everywhere, updated diagrams
  • Removed fee and weight information from pkginfo1


A version 1 or '''child-with-unconfirmed-parents''' package can be defined for any transaction that spends
unconfirmed inputs. The child can be thought of as the "representative" of the package. This package
can be uniquely identified by the transaction's wtxid and the current chain tip block hash.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The child's wtxid does not commit to the wtxids of its ancestors (just the txids), so I don't think it's correct to say that a package is uniquely identified by the child transaction's wtxid and the current chain tip. (I tried to bring this point up in the mailing list thread as well, in the context of package de-duplication.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes sorry, I think I should have said the package can be easily reconstructed using the transaction's wtxid and current chain tip block hash.

Status: Draft
Type: Standards Track
Created: 2022-04-14
License: PD
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before taking this out of draft, please license it under one of the acceptable licenses

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks will do! I'm still working on a few changes based on feedback, and then will take this out of draft.

@glozow
Copy link
Member Author

glozow commented Oct 13, 2022

Closing as the updated proposal is going to be significantly different from this one, which has no number assigned, and I think it would be confusing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants