Skip to content
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

p2p: Allow 1P1C to fetch parent from compact block extra_txn #30032

Closed

Conversation

instagibbs
Copy link
Member

@instagibbs instagibbs commented May 3, 2024

One relatively common pattern of 1P1C relay is receiving
a just-below-minfee parent, dropping it and marking it
as reconsiderable, then fetching it again from the peer
once the child is added to the orphanage.

A cache of dropped parents would be useful, and it turns
out we're already opportunistically storing transactions
like this for compact blocks as "extra transactions".
Use this size-limited cache to potentially fetch a
reconsiderable parent from memory, and submit for validation.

@DrahtBot
Copy link
Contributor

DrahtBot commented May 3, 2024

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

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.
A summary of reviews will appear here.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #15218 (validation: sync chainstate to disk after syncing to tip by andrewtoth)

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 DrahtBot added the P2P label May 3, 2024
@instagibbs instagibbs force-pushed the 2024-05-opportunistic-extratxn branch from 501220c to 24618bc Compare May 3, 2024 16:15
One relatively common pattern of 1P1C relay is receiving
a just-below-minfee parent, dropping it and marking it
as reconsiderable, then fetching it again from the peer
once the child is added to the orphanage.

A cache of dropped parents would be useful, and it turns
out we're already opportunistically storing transactions
like this for compact blocks as "extra transactions".
Use this size-limited cache to potentially fetch a
reconsiderable parent, and submit for validation.
@instagibbs instagibbs force-pushed the 2024-05-opportunistic-extratxn branch from 24618bc to 4fa5543 Compare May 3, 2024 17:29
@DrahtBot
Copy link
Contributor

DrahtBot commented May 3, 2024

🚧 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.

Debug: https://github.com/bitcoin/bitcoin/runs/24563145250

Copy link
Member

@glozow glozow left a comment

Choose a reason for hiding this comment

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

Nice. Have you tried running this to see how often it hits?


/** Orphan/conflicted/etc transactions that are kept for compact block reconstruction.
* The last -blockreconstructionextratxn/DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN of
* these are kept in a ring buffer */
std::vector<CTransactionRef> vExtraTxnForCompact GUARDED_BY(g_msgproc_mutex);
std::vector<NodeId> m_extra_txn_senders GUARDED_BY(g_msgproc_mutex);
Copy link
Member

Choose a reason for hiding this comment

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

needs comment

Comment on lines +1906 to +1910
const auto& maybe_parent = vExtraTxnForCompact[i];
// We stopped checking it earlier due to fee reasons, try again?
if (maybe_parent && m_recent_rejects_reconsiderable.contains(maybe_parent->GetWitnessHash().ToUint256())) {
Package maybe_cpfp_package{maybe_parent, orphan_child};
if (IsChildWithParents(maybe_cpfp_package) && !m_recent_rejects_reconsiderable.contains(GetPackageHash(maybe_cpfp_package))) {
Copy link
Member

Choose a reason for hiding this comment

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

Feels inefficient/expensive to construct a package + call these checks for every tx every time there's a missing input. Maybe parameterize by the txid of the missing parent (i.e. just 1 exists) and first check that the txid matches?

self.extra_args = [[
"-datacarriersize=100000",
"-maxmempool=5",
"-blockreconstructionextratxn=0", # require fetching parent even if cached
Copy link
Member

Choose a reason for hiding this comment

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

nice 🧠

@instagibbs
Copy link
Member Author

instagibbs commented May 3, 2024

Nice. Have you tried running this to see how often it hits?

I'll do some logging 👍 I suspect it'll be quite above non-0 because from my log-reading just-below-minfee is quite commonly a reason for missing the parent.

edit: this isn't ready for prime-time, have to more carefully think about handling the results. This new case is triggered even if we would consider continuing on failure in various cases, so I likely have bugs here.

@instagibbs
Copy link
Member Author

from my non-listening node, looks like ~3% of the time of package evaluation is being considered it triggers

@instagibbs
Copy link
Member Author

Don't think I find these results compelling vs the complexity in how we would need to handle the packages

@instagibbs instagibbs closed this May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants