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

validation: return more helpful results for reconsiderable fee failures and skipped transactions #28785

Merged
merged 4 commits into from Nov 8, 2023

Conversation

glozow
Copy link
Member

@glozow glozow commented Nov 3, 2023

Split off from #26711 (suggested in #26711 (comment)). This is part of #27463.

  • Add 2 new TxValidationResults
    • TX_RECONSIDERABLE helps us encode transactions who have failed fee checks that can be bypassed using package validation. This is distinguished from TX_MEMPOOL_POLICY so that we re-validate a transaction if and only if it is eligible for package CPFP. In the future, we will have a separate cache for reconsiderable rejects so these transactions don't go in m_recent_rejects.
    • TX_UNKNOWN helps us communicate that we aborted package validation and didn't finish looking at this transaction: it's not valid but it's also not invalid (i.e. don't cache it as a rejected tx)
  • Return effective feerate and the wtxids of transactions used to calculate that effective feerate when the error is TX_SINGLE_FAILURE. Previously, we would only provide this information if the transaction passed. Now that we have package validation, it's much more helpful to the caller to know how the failing feerate was calculated. This can also be used to improve our submitpackage RPC result (which is currently a bit unhelpful when things fail).
  • Use the newly added CheckPackageMempoolAcceptResult for existing package validation tests. This increases test coverage and helps test the changes made in this PR.

@DrahtBot
Copy link
Contributor

DrahtBot commented Nov 3, 2023

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.

Type Reviewers
ACK instagibbs, achow101, murchandamus, ismaelsadeeq

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #28345 (Bugfix: Package relay / bytespersigop checks by luke-jr)
  • #26451 (Enforce incentive compatibility for all RBF replacements by sdaftuar)

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.

@instagibbs
Copy link
Member

so that we re-validate a transaction if and only if it is eligible for package CPFP.

and in the future we'll use this for making sure we'd re-request this transaction as part of another package at p2p, correct?

@glozow glozow mentioned this pull request Nov 3, 2023
53 tasks
@glozow
Copy link
Member Author

glozow commented Nov 3, 2023

and in the future we'll use this for making sure we'd re-request this transaction as part of another package at p2p, correct?

Correct 👍

@instagibbs
Copy link
Member

think you'll have to touch CheckATMPInvariants in the tx_pool fuzz test to add TX_SINGLE_FAILURE case

Copy link
Member

@instagibbs instagibbs left a comment

Choose a reason for hiding this comment

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

LGTM with a few suggestions 6b0dc66

src/validation.cpp Outdated Show resolved Hide resolved
src/validation.cpp Outdated Show resolved Hide resolved
src/validation.h Outdated Show resolved Hide resolved
With package validation rules, transactions that fail individually may
sometimes be eligible for reconsideration if submitted as part of a
(different) package. For now, that includes trasactions that failed for
being too low feerate.  Add a new TxValidationResult type to distinguish
these failures from others.  In the next commits, we will abort package
validation if a tx fails for any other reason. In the future, we will
also decide whether to cache failures in recent_rejects based on this
result (we won't want to reject a package containing a transaction that
was rejected previously for being low feerate).

Package validation also sometimes elects to skip some transactions when
it knows the package will not be submitted in order to quit sooner. Add
a result to specify this situation; we also don't want to cache these
as rejections.
@instagibbs
Copy link
Member

ACK 0150e86

suggested changes plus TX_RECONSIDERABLE renaming which makes sense

Copy link
Contributor

@murchandamus murchandamus left a comment

Choose a reason for hiding this comment

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

crACK 0150e86 with grain of salt:

I’m pretty new to reviewing mempool code:

  • The introduction of an explicit class for Wtxid makes sense to me
  • The introduction of TX_RECONSIDERABLE makes sense to me in the context of transactions being tested in the context of packages where they might be resubmitted with a higher resulting mining score
  • It makes sense to me that some mempool acceptance tests would now fail with TX_RECONSIDERABLE and the ones that do look reasonable to me
  • The code changes look reasonable small and targeted to the context

I cannot tell whether the changes are complete and whether they are being comprehensively tested.

src/test/fuzz/tx_pool.cpp Outdated Show resolved Hide resolved
src/test/util/txmempool.cpp Outdated Show resolved Hide resolved
@glozow glozow force-pushed the 2023-11-txresult-fee branch 2 times, most recently from 2dd76f2 to 3979f1a Compare November 7, 2023 10:16
Increases test coverage (check every result field) and makes it easier
to test the changes in the next commit.
…e feerate

With subpackage evaluation and de-duplication, it's not always the
entire package that is used in CheckFeerate. To be more helpful to the
caller, specify which transactions were included in the evaluation and
what the feerate was.

Instead of PCKG_POLICY (which is supposed to be for package-wide
errors), use PCKG_TX.
@glozow
Copy link
Member Author

glozow commented Nov 7, 2023

Addressed #28785 (review) and fixed the ci error

@DrahtBot DrahtBot removed the CI failed label Nov 7, 2023
@instagibbs
Copy link
Member

reACK 1147e00

took reconsiderable variable renames, tests using CheckPackageMempoolAcceptResult more, unsure why ci was failing though :)

@achow101
Copy link
Member

achow101 commented Nov 7, 2023

ACK 1147e00

Copy link
Contributor

@murchandamus murchandamus left a comment

Choose a reason for hiding this comment

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

reACK 1147e00

BOOST_CHECK_EQUAL(it_child->second.m_wtxids_fee_calculations.value().front(), tx_child->GetWitnessHash());
Package package_parent_child{tx_parent, tx_child};
const auto result_parent_child = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool, package_parent_child, /*test_accept=*/true);
if (auto err_parent_child{CheckPackageMempoolAcceptResult(package_parent_child, result_parent_child, /*expect_valid=*/true, nullptr)}) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I was very confused by the changes in this vein, until I realized that CheckPackageMempoolAcceptResult(…) returns an error in case of a CPMA failure, but returns nothing in the case of a success. Per the name of this function my initial expectation was that we would expect a truthy return value in case of successful acceptance.

Copy link
Member

@ismaelsadeeq ismaelsadeeq left a comment

Choose a reason for hiding this comment

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

ACK 1147e00

looks good to me.

@fanquake fanquake merged commit d690f89 into bitcoin:master Nov 8, 2023
16 checks passed
@glozow glozow deleted the 2023-11-txresult-fee branch November 9, 2023 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants