Skip to content

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
57 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

@glozow glozow force-pushed the 2023-11-txresult-fee branch from 7c92623 to 6b0dc66 Compare November 3, 2023 17:34
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

@glozow glozow force-pushed the 2023-11-txresult-fee branch from 0f65d69 to e9f9772 Compare November 6, 2023 14:35
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.
@glozow glozow force-pushed the 2023-11-txresult-fee branch from e9f9772 to 0150e86 Compare November 6, 2023 14:45
@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 0150e860863f95b18448e7b67f5db27017660670 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.

@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 :)

@DrahtBot DrahtBot requested a review from murchandamus November 7, 2023 12:14
@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
@glozow glozow deleted the 2023-11-txresult-fee branch November 9, 2023 09:36
Fabcien added a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jun 18, 2024
Summary:
Deduplicate code that exists in both tx processing and ProcessOrphanTx.
Additionally, this can be reused in a function that handles multiple
MempoolAcceptResults from package submission.

refactor: consolidate MempoolAcceptResult processing

```
Every time we try to ProcessTransaction (i.e. submit a tx to mempool), we use the result to update a few net processing data structures. For example, after a failure, the {wtxid, txid, both, neither} (depending on reason) should be cached in m_recent_rejects so we don't try to download/validate it again.

There are 2 current places and at least 1 future place where we need to process MempoolAcceptResult
[...]

Consolidate this code so it isn't repeated in 2 places and so we can reuse it in a future PR.
```

Backport of [[bitcoin/bitcoin#29619 | core#29619]].

Refactor only, there is no change in behavior.

Backport note: the TX_UNKNOWN validation state has not been backported and is skipped in the net_processing check for invalid txs. To this date this enum value is never used upstream so we're not missing anything (introduced in [[bitcoin/bitcoin#28785 | core#28785]]).

Test Plan:
  ninja all check-all

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Differential Revision: https://reviews.bitcoinabc.org/D16346
Fabcien added a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jul 10, 2024
…es and skipped transactions

Summary:
```
 - 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.
```

Backport of [[bitcoin/bitcoin#28785 | core#28785]], [[bitcoin/bitcoin#28764 | core#28764]] and [[bitcoin/bitcoin#28788 | core#28788]] (last too are only the test function).

Test Plan:
  ninja all check-all

Reviewers: #bitcoin_abc, roqqit

Reviewed By: roqqit

Differential Revision: https://reviews.bitcoinabc.org/D16439
roqqit pushed a commit to doged-io/doged that referenced this pull request Jul 31, 2024
Summary:
Deduplicate code that exists in both tx processing and ProcessOrphanTx.
Additionally, this can be reused in a function that handles multiple
MempoolAcceptResults from package submission.

refactor: consolidate MempoolAcceptResult processing

```
Every time we try to ProcessTransaction (i.e. submit a tx to mempool), we use the result to update a few net processing data structures. For example, after a failure, the {wtxid, txid, both, neither} (depending on reason) should be cached in m_recent_rejects so we don't try to download/validate it again.

There are 2 current places and at least 1 future place where we need to process MempoolAcceptResult
[...]

Consolidate this code so it isn't repeated in 2 places and so we can reuse it in a future PR.
```

Backport of [[bitcoin/bitcoin#29619 | core#29619]].

Refactor only, there is no change in behavior.

Backport note: the TX_UNKNOWN validation state has not been backported and is skipped in the net_processing check for invalid txs. To this date this enum value is never used upstream so we're not missing anything (introduced in [[bitcoin/bitcoin#28785 | core#28785]]).

Test Plan:
  ninja all check-all

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Differential Revision: https://reviews.bitcoinabc.org/D16346
roqqit pushed a commit to doged-io/doged that referenced this pull request Aug 1, 2024
…es and skipped transactions

Summary:
```
 - 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.
```

Backport of [[bitcoin/bitcoin#28785 | core#28785]], [[bitcoin/bitcoin#28764 | core#28764]] and [[bitcoin/bitcoin#28788 | core#28788]] (last too are only the test function).

Test Plan:
  ninja all check-all

Reviewers: #bitcoin_abc, roqqit

Reviewed By: roqqit

Differential Revision: https://reviews.bitcoinabc.org/D16439
@bitcoin bitcoin locked and limited conversation to collaborators Nov 8, 2024
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.

7 participants