-
Notifications
You must be signed in to change notification settings - Fork 37.7k
docs / fixups from RBF and packages #24310
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
cc @LarryRuane @mzumsande since you both mentioned that deduplication wasn't described in packages.md |
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 84c8123
competing package or transaction with a mutated witness, the honest package should be accepted
nit: I think it could say "package or transaction with a mutated witness, the better-feerate competing package, potentially with overlapping components, should be accepted". Just to get ride of the honesty concept in matters of mempool acceptance. I believe it's accurate to talk about dishonesty only in the context of specific second-layer attacks. Because for some (e.g LN), the "dishonest"/attacker package confirming might be a good outcome for funds safety, namely pushing forward the channel state.
(can't comment on the commit directly, GH buggy as usual)
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. |
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 84c8123
Maybe worth a regression test? For instance a simple
diff --git a/src/test/txpackage_tests.cpp b/src/test/txpackage_tests.cpp
index 560efb6b42..15bbae3455 100644
--- a/src/test/txpackage_tests.cpp
+++ b/src/test/txpackage_tests.cpp
@@ -413,6 +413,9 @@ BOOST_FIXTURE_TEST_CASE(package_witness_swap_tests, TestChain100Setup)
BOOST_CHECK(m_node.mempool->exists(GenTxid::Txid(ptx_child2->GetHash())));
BOOST_CHECK(!m_node.mempool->exists(GenTxid::Wtxid(ptx_child2->GetWitnessHash())));
+
+ ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool, {ptx_parent, ptx_child1},
+ /*test_accept=*/ false);
}
// Try submitting Package1{child2, grandchild} where child2 is same-txid-different-witness as
would fail on the assertion without the patch.
src/validation.cpp
Outdated
// that the replacement transaction pays more than its direct conflicts. | ||
// The replacement transaction must have a higher feerate than its direct conflicts. Before | ||
// ancestor packages were used in mining, this was equivalent to checking that our mining code | ||
// would prefer the replacement. Now, it serves as a fail-fast mechanism. |
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.
Now, it serves as a fail-fast mechanism.
This sentence strikes me as odd; I think it gives the idea that perhaps this check is redundant (but faster to calculate) with the check that involves all descendants, which isn't the case.
If it were me, I'd add a comment like this to the code:
The replacement transaction must have a higher feerate than its direct conflicts.
- The motivation for this check is to ensure that the replacement transaction is preferable
for block-inclusion, compared to what would be removed from the mempool.
- This logic predates ancestor feerate-based transaction selection, which is why it doesn't
consider feerates of descendants.
- Note: Ancestor feerate-based transaction selection has made this comparison insufficient
to guarantee that this is incentive-compatible for miners, because it is possible for a
descendant transaction of a direct conflict to pay a higher feerate than the transaction
that might replace them, under these rules.
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.
Thanks for writing an alternative! I've changed the comment to be this.
GetIter takes a txid, not wtxid.
…rate Co-authored-by: Suhas Daftuar <sdaftuar@gmail.com>
84c8123
to
77202f0
Compare
Thanks for the reviews! I've added the test suggested by @darosior and comment suggested by @sdaftuar.
I've clarified the doc to indicate that we just don't want the same-txid-different-witness transaction to be rejected completely, because we normally would consider it a conflict that we won't replace. I only want to document what the current code does, and it doesn't care about the fees of witnesses right now. We can change it later if the code 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.
LGTM, ACK 77202f0
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 77202f0
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 77202f0
@@ -413,6 +413,17 @@ BOOST_FIXTURE_TEST_CASE(package_witness_swap_tests, TestChain100Setup) | |||
|
|||
BOOST_CHECK(m_node.mempool->exists(GenTxid::Txid(ptx_child2->GetHash()))); | |||
BOOST_CHECK(!m_node.mempool->exists(GenTxid::Wtxid(ptx_child2->GetWitnessHash()))); | |||
|
|||
// Deduplication should work when wtxid != txid. Submit package with the already-in-mempool |
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.
when wtxid != txid
(nonblocking:) This confused me; can this be stated more clearly? wtxid
can never equal txid
.
// Deduplication should work when wtxid != txid. Submit package with the already-in-mempool | |
// Deduplication should work when existing wtxid != package wtxid. Submit package with the already-in-mempool |
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.
The wtxid
of a transaction is equal to its txid
when there is no witness data. This is precisely what this commit fixes and why this test didn't catch the bug earlier: ptx_parent
is submitted multiple times, but its txid
is equal to its wtxid
. Otherwise it would have failed the assertion.
77202f0 [doc] package deduplication (glozow) d35a3cb [doc] clarify inaccurate comment about replacements paying higher feerate (glozow) 5ae187f [validation] look up transaction by txid (glozow) Pull request description: - Use txid, not wtxid, for `mempool.GetIter()`: bitcoin#22674 (comment) - Fix a historically inaccurate comment about RBF during the refactors: bitcoin#22855 (comment) - Add a section about package deduplication to policy/packages.md: bitcoin#24152 (comment) and bitcoin#24152 (comment) (I'm intending for this to be in v23 since it's fixups for things that are already merged, which is why I split it from bitcoin#24152) ACKs for top commit: t-bast: LGTM, ACK bitcoin@77202f0 darosior: ACK 77202f0 LarryRuane: ACK 77202f0 Tree-SHA512: a428e791dfa59c359d3ccc67e8d3a4c1239815d2f6b29898e129700079271c00b3a45f091f70b65a6e54aa00a3d5b678b6da29d2a76b6cd6f946eaa7082ea696
mempool.GetIter()
: validation: mempool validation and submission for packages of 1 child + parents #22674 (comment)(I'm intending for this to be in v23 since it's fixups for things that are already merged, which is why I split it from #24152)