Repository navigation
validation, bugfix: provide more info in *MempoolAcceptResult - #26646
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. 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. |
instagibbs
left a comment
There was a problem hiding this comment.
Liking the new interfaces significantly more so far, just naming qualms for now
139e0e1 to
c5ca075
Compare
instagibbs
left a comment
There was a problem hiding this comment.
ACK c5ca0755273597cf1d0f1d10b6b914b13a8bb37f naming nit left aside
There was a problem hiding this comment.
I'm wondering how well-defined this value is. Am I right in thinking that the calculation here is "sum(fees_of_package_transactions)/sum(size_of_package_transactions)"?
What happens in this case: we have 3 transactions A -> B, C, where C is a child of both A and B.
A has a low feerate and cannot make it in to the mempool by itself. (A+B) has a high enough feerate for acceptance, but we receive for validation (A+B+C) instead. B cannot make it in by itself, since it would be missing a parent, and we never try A+B, right? So the package feerate for C would reflect the fees and feerate of B (which could be higher than C's own feerate, I think?).
Do we require that C pay a higher feerate than any of its parents when doing package acceptance? If not, then I'm not sure this value will always make sense, ie the package feerate of a transaction with no children ought never be greater than its own feerate.
There was a problem hiding this comment.
Does this comment equally apply to package submission in master?
There was a problem hiding this comment.
I think so, but I was about to write a test using the example above, except where C is 0-fee, and see if it makes it in...
There was a problem hiding this comment.
Yes, master does not currently handle this case because we're currently doing A, B, C individually, so we'd get 1 "too low fee" and 2 "missing inputs," and then reject all of them. When I first tried to implement for 1-child-with-parents, I had incorrectly assumed this was okay and the code made it in before I realized - my apologies for that. The intention is definitely to fix it.
Requiring C pay a higher feerate than its parents is ok in the child-with-parents scenario but not generic ancestor package scenario (imagine low fee grandparent, lower fee parent, high fee child). I think we've discussed "for each tx in topological order, calculate its in-package ancestor set that hasn't made it in yet, and submit that as a package" - I have drafted this here.
Btw this test case is implemented here (it should fail on master as you expect).
There was a problem hiding this comment.
Can confirm the patch fails as expected: the entire triangle package makes it in the mempool
There was a problem hiding this comment.
Re: "I'm wondering how well-defined this value is." Last push adds the wtxids of which transactions are included in the feerate, to both MempoolAcceptResult and the testmempoolaccept/submitpackage RPCs.
Re: the problem where we don't always end up with the right transactions, might be better for another PR. I've opened #26711 to do this.
There was a problem hiding this comment.
@sdaftuar comfortable with resolving for this PR?
stickies-v
left a comment
There was a problem hiding this comment.
Concept ACK - fixes the bug as specified and imo makes the interface more clear
A few more general comments:
- commit message in b00bebbb84af10042ee623116118207b95194a02 I think should be "remove PackageMempoolAcceptResult::m_package_feerate" instead of "remove PackageMempoolAccept::m_package_feerate"
- requires a release notes file highlighting the RPC changes
- the docstring of assert_equal_package_results (rpc_packages.py) still mentions package feerate which I think is now out of date
- nit: a723541 could be split in two commits: one for rename, and one for the actual change
c5ca075 to
0d383a6
Compare
instagibbs
left a comment
There was a problem hiding this comment.
reACK 0d383a6
Doc changes, and the returning of wtxids considered for the package feerate being the major changes.
There was a problem hiding this comment.
ACK 0d383a6
My comments are just comments that included just some considerations where I do not have an answer on why it is done, I do not want to appear like an annoying person :)
0d383a6 to
48f81f2
Compare
|
ACK 48f81f2 changes are: |
stickies-v
left a comment
There was a problem hiding this comment.
Approach ACK 48f81f2 - not feeling super comfortable yet with my review so want to mull it over a bit more.
Mostly a few nits, and also I think effective-feerate being optional in the RPC isn't ideal (but I can move past it). Additionally, I think the last 3 comments from my previous review haven't been addressed yet? The missing RPC docs/release notes is probably the most important one there.
|
ACK 48f81f2 I don't have a big picture about package relay yet, but these changes are good on their own. |
…and tx result Bug: not setting package_state means package_state.IsValid() == true and the caller does not know that this failed. We won't be validating this transaction again, so it makes sense to return this failure to the caller. Rename package_state to package_state_quit_early to make it more clear what this variable is used for and what its scope is. Co-authored-by: Greg Sanders <[email protected]>
48f81f2 to
ada89cb
Compare
|
Sorry for missing a few of your review comments @stickies-v!
Added for testmempoolaccept, submitpackage is regtest-only.
This refers to the "package feerate" concept documented here, rather than the RPC result "package-feerate". So left as is, sorry for that being a bit confusing.
Done |
|
reACK ada89cb |
instagibbs
left a comment
There was a problem hiding this comment.
reACK ada89cbd4249fad5eaedfa0a173dfc911f188084
achow101
left a comment
There was a problem hiding this comment.
A few not-necessarily blocking comments, but would like to get some rationale for some decisions.
There was a problem hiding this comment.
In 92d789b090a166ea6deebbfcbf2c1069fa8cc693 "[validation] return wtxids of other transactions whose fees were used"
Since the previous commit adds the calculation for effective_feerate here depending on m_package_feerates, I would expect that the calculation for the involved wtxids would do that as well. Or the previous commit could add this Assume and just do the single tx feerate calculation. The behavior for setting the effective feerate and the involved txids should be unified to avoid bugs.
There was a problem hiding this comment.
Agree this is more bug-preventative. The downside is we end up constructing all_wtxids without using it when doing a test package mempool accept, but seems alright.
There was a problem hiding this comment.
In 57b56b7ce9ebef646d3fe3e706bf994c17864f3c "[rpc] return effective-feerate in testmempoolaccept and submitpackage"
This change doesn't seem to be meaningful? The test passes either way.
There was a problem hiding this comment.
Ended up keeping it in latest push, as the result now includes optional fields and a feerate so we need to use assert_fee_amount
There was a problem hiding this comment.
In 57b56b7ce9ebef646d3fe3e706bf994c17864f3c "[rpc] return effective-feerate in testmempoolaccept and submitpackage"
For here and in submitpackage, it's not clear to me why effective-feerate and effective-includes should be guarded by whether it is different from the base fees. The presence (or lack thereof) of this field indicates whether this transaction was validated as part of the package, but that is also more explicitly represented by effective-includes. I don't think it's harmful to provide this information for all transactions.
There was a problem hiding this comment.
Ah thanks, I think I agree. For submitpackage we should continue to gate on whether the tx was in the mempool already - in that case we wouldn't know whether package feerate was used so I wouldn't want to report a potentially inaccurate feerate. Added a comment about this as well. Since testmempoolaccept doesn't allow already-in-mempool transactions, it should always have this for successful transactions.
Base != effective is no longer a gate. Edited the optional bool for these results to reflect the status.
Some tests needed to be changed (just dropping the effective-* results there because they aren't relevant in those tests and comparing feerates isn't handled properly in assert_equal).
This value creates an extremely confusing interface as its existence is dependent upon implementation details (whether something was submitted on its own, etc). MempoolAcceptResult::m_effective_feerate is much more helpful, as it always exists for submitted transactions.
No release note for submitpackage because it is regtest-only.
This makes the interface more predictable and useful. The caller understands one or more transactions failed, and can learn what happened with each transaction. We already have this information, so we might as well return it. It doesn't make sense to do this for other PackageValidationResult values because: - PCKG_RESULT_UNSET: this means everything succeeded, so the individual failures are no longer accurate. - PCKG_MEMPOOL_ERROR: something went wrong with the mempool logic; transaction failures might not be meaningful. - PCKG_POLICY: this means something was wrong with the package as a whole. The caller should use the PackageValidationState to find the error, rather than looking at individual MempoolAcceptResults.
ada89cb to
264f9ef
Compare
There was a problem hiding this comment.
Ah thanks, I think I agree. For submitpackage we should continue to gate on whether the tx was in the mempool already - in that case we wouldn't know whether package feerate was used so I wouldn't want to report a potentially inaccurate feerate. Added a comment about this as well. Since testmempoolaccept doesn't allow already-in-mempool transactions, it should always have this for successful transactions.
Base != effective is no longer a gate. Edited the optional bool for these results to reflect the status.
Some tests needed to be changed (just dropping the effective-* results there because they aren't relevant in those tests and comparing feerates isn't handled properly in assert_equal).
There was a problem hiding this comment.
Ended up keeping it in latest push, as the result now includes optional fields and a feerate so we need to use assert_fee_amount
There was a problem hiding this comment.
Agree this is more bug-preventative. The downside is we end up constructing all_wtxids without using it when doing a test package mempool accept, but seems alright.
|
reACK 264f9ef |
| UniValue fees(UniValue::VOBJ); | ||
| fees.pushKV("base", ValueFromAmount(it->second.m_base_fees.value())); | ||
| if (tx_result.m_result_type == MempoolAcceptResult::ResultType::VALID) { | ||
| // Effective feerate is not provided for MEMPOOL_ENTRY transactions even |
There was a problem hiding this comment.
| // Effective feerate is not provided for MEMPOOL_ENTRY transactions even | |
| // Effective feerate is not provided for MEMPOOL_ENTRY(already-in-mempool) transactions even |
|
ACK 264f9ef |
|
reACK 264f9ef |
This PR fixes a bug and improves the mempool accept interface to return information more predictably.
Bug: In package validation, we first try the transactions individually (see doc/policy/packages.md for more explanation) and, if they all failed for missing inputs and policy-related (i.e. fee) reasons, we'll try package validation. Otherwise, we'll just "quit early" since, for example, if a transaction had an invalid signature, adding a child will not help make it valid. Currently, when we quit early, we're not setting the
package_stateto be invalid, so the caller might think it succeeded. Also, we're returning no results - it makes more sense to return the individual transaction failure. Thanks instagibbs for catching #25038 (comment)!Also, make the package results interface generally more useful/predictable:
CheckFeeRateinMempoolAcceptResult::m_effective_feeratewhen it was successful. This can replace the currentPackageMempoolAcceptResult::m_package_feerate, which only sometimes exists.PackageMempoolAcceptResult::m_tx_resultswhen the error isPCKG_TX.