Skip to content

Conversation

ariard
Copy link

@ariard ariard commented Jul 29, 2020

This is demo code for a sender-initiated version of package-relay. This is not proposed for merging, only to illustrate package relay design with trade-offs compared to #16401. See my update on #14895 to advance discussions on package-relay.

Few design choices of interest:

  • introduce new p2p messages, sendpackages, MSG_PACKAGE, package and new package_id identifier incorporated to the INV/GETDATA control logic : https://gist.github.com/ariard/10924249b3b7f6e239d80895372839b8
  • add a new sendpackage rpc to let a higher-application signals a chain of transactions and such start a propagation on the p2p network
  • integrate a PackageCache to internally cache the mapping package_id -> txids/wtxids, as they need to be persistent across a round-trip between upstream/downstream peers, it must be DoS resistant
  • build on Add package acceptance logic to mempool #16401 AcceptMultipleTransactions with a package policy restriction to 2-tx only, make it easier to reason on for replacement
  • allow for package replacement based on newer feerate higher that the union of feerate of all transactions conflicted, no dedup for now between conflicted set
  • don't redundantly send a transaction via INV(MSG_TX) if we know an associated package and peer signal package relay support
  • TODO: integrate package_id with overhaul transaction request/AlreadyHave to save further on bandwidth

sdaftuar and others added 15 commits July 27, 2020 12:54
Accepting a single transaction to the mempool only succeeds if (among other
things) the feerate of the transaction is greater than both the min relay fee
and the mempool min fee. Consequently, a transaction below the minimum fee
may not be accepted to the mempool, even if we later learn of a transaction
with a high relay fee that depends on it.

This commit adds a function that will accept a package of transactions to the
mempool, with the following restrictions:

- All package transactions must be direct parents of the final transaction.
  This is a simple heuristic for ensuring that a candidate list of transactions
  is in fact a package (we wouldn't want arbitrary transactions to be paying
  for random low feerate transactions)

- The feerate of the package, as a whole, exceeds the mempool min fee and the
  min relay fee.

- No transactions in the mempool conflict with any transactions in the package.
  This is a simplification that makes the logic easier to write. Without this
  requirement, we would need to do additional checks to ensure that no parent
  transaction would evict a transaction from the mempool that some other child
  depends on.

- The ancestor/descendant size limits are calculated assuming that any mempool
  ancestor of any candidate transaction is an ancestor of all the candidate
  transactions.
  This allows for doing simpler calculations to ensure that we're staying
  within the mempool's package limits. If we eliminated this, we would need to
  do much more careful package calculations for each candidate transaction and each
  in-mempool ancestor.

This commit does not include any accessor function for utilizing this logic (eg
by exposing this function at the p2p or rpc layer).
In next commit, we relax restriction on conflict replacement at package
acceptance. Package transactions may depend on conflicted ones replaced
by other package elements, thus making its evaluation expensive. To avoid
DoS risk while allowing feerate-increasing packages limit theirs composition
to 2 transactions, the latter only dependent on the former.
… checks

A package may bundle a newer CPFP with an already-in subgraph. To
evaluate replacement correctly, collect older fees of each conflicted
transactions while omitting per-transaction fee/feerate checks in
PreChecks().

For now, we don't evict conflicting duplicate, as a transaction might be in
conflict with multiple package elements.

XXX: refactor PreChecks() to dedup in AcceptMultipleTransactions ?
To reduce bandwidth consumption due to package announcement, only
announce a 32-byte package_id, sha256 of all package transactions.

To avoid this cache being a DoS risk, allocate a number of package
announcements to each upstream peer. To guarantee flush, prune old
entries after a delay (PACKAGE_CACHE_DELAY), thus requiring downstream
package round-trip to achieve before.
This new p2p message contains a serialized list of transactions, which
upon receipt feerate of the whole must determine mempool acceptance.
The hash being referenced is a package_id.
At INV sending, announce packages unknown to the processed downstream
peer. Any transaction part of a mapped package, won't be announced
redundantly.
Disallow getdata reply if this peer isn't assumed to have been
announced this package yet.
XXX: add byte flag to signal package policy enforced
This command let caller submit a bundle of transactions to the local
mempool and p2p network, ensuring their summed feerate is going to be evaluated
as a package.
@ariard ariard changed the title [RFC] Package-relay : sender-initiated [RFC] Package-relay: sender-initiated Jul 29, 2020
@DrahtBot
Copy link
Contributor

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

Conflicts

Reviewers, 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.

@DrahtBot
Copy link
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft".

@ariard ariard marked this pull request as draft August 6, 2020 19:55
@DrahtBot
Copy link
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.

1 similar comment
@DrahtBot
Copy link
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.

@maflcko
Copy link
Member

maflcko commented Mar 21, 2022

Closing for now. You can open a new pull request if you are working on this again, since this one doesn't have any discussion.

@maflcko maflcko closed this Mar 21, 2022
@ariard
Copy link
Author

ariard commented Apr 3, 2022

I confirm, this work has been superseded by the advances with package acceptance (https://gist.github.com/glozow/dc4e9d5c5b14ade7cdfac40f43adb18a). For the p2p part, the sender-initiated approach and the package ids caching might be of interest for the conceptual discussion when we introduce p2p packages. I don't have interest to keep working on that version of package relay but I'm staying interested to review any work or draft in that area.

@bitcoin bitcoin locked and limited conversation to collaborators Apr 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants