Repository navigation
rpc: add testsubmitpackage for 1p1c test submissions - #35286
instagibbs wants to merge 2 commits into
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsNo conflicts as of last run. LLM Linter (✨ experimental)Possible typos and grammar issues:
Possible places where comparison-specific test macros should replace generic comparisons:
2026-10-21 21:06:07 |
|
cc @ajtowns @ismaelsadeeq as discussed, let's focus on concept / approach ACKs first, name is clearly up for debate, etc etc |
7032df7 to
a723ef3
Compare
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
|
Concept ACK, users normally test run submissions to see whether they will get through; so having I will review the approach and correctness. |
ismaelsadeeq
left a comment
There was a problem hiding this comment.
This is simple to reason about. I suggest some improvements that will make the code easier to reason about.
Also, I think there are still opportunities to dedup things in rpc/mempool.cpp shared code of testsubmitpackage and submitpackage, in the code args collection, help text and the logic.
| /*test_accept=*/ false, | ||
| /*test_accept=*/ test_accept, | ||
| /*allow_replacement=*/ true, | ||
| /*allow_sibling_eviction=*/ false, |
There was a problem hiding this comment.
In a723ef3
This is weird to read? why is allow_sibling_eviction tied to test_accept?
| * @param[in] test_accept When true, run validation checks but don't submit to mempool. | ||
| * @param[in] client_maxfeerate If exceeded by an individual transaction, rest of (sub)package evaluation is aborted. | ||
| * Only for sanity checks against local submission of transactions. | ||
| * @param[in] test_package_feerates If true (only honored when test_accept is true), use child-with-parents |
There was a problem hiding this comment.
In a723ef3
test_package_feerates is a bit hard to read?
Can you use a clearer name for this, maybe test_accept_as_package?
| if (args.m_test_accept) { | ||
| // Populate the would-be-replaced txs from the changeset for surfacing through the result. | ||
| // In real submission FinalizeSubpackage() does this; we exit before it runs. | ||
| if (Assume(m_subpackage.m_changeset)) { |
There was a problem hiding this comment.
In a723ef3
- The loop that copies staged removals into replaced transactions is duplicated at both
test_acceptsites. A helper likeCollectStagedRemovals()would dedup things - The two sites guard the changeset access inconsistently one uses if (test_accept && Assume(changeset)), the other nests if (test_accept) { if
(Assume(changeset)). Would be nice to make them consistent ( a helper would solve this too since the two code paths are identical).
| auto result = [&]() EXCLUSIVE_LOCKS_REQUIRED(cs_main) { | ||
| AssertLockHeld(cs_main); | ||
| if (test_accept) { | ||
| if (test_package_feerates) { |
There was a problem hiding this comment.
In a723ef3
I think this is a good time to split the individual-evaluation dry-run path out of ProcessNewPackage into its own function. This removes the test_package_feerates parameter, and the branching ProcessNewPackage now always goes through AcceptPackage.
| self.test_topology_rejected() | ||
| self.test_parent_passes_individually_rejected() | ||
| self.test_basic_1p1c_cpfp() | ||
| self.test_no_mempool_mutation_on_success() |
There was a problem hiding this comment.
In a723ef3
Seems redundant to have this independent.
Can we fold test_no_mempool_mutation_on_success into test_basic_1p1c_cpfp they build the same 1p1c bundle; the mempool-unchanged check belongs alongside the
basic success assertions rather than in a separate test?
| result_ok = node.testsubmitpackage([parent["hex"], child["hex"]], maxfeerate=0) | ||
| assert_equal(result_ok["package_msg"], "success") | ||
|
|
||
| self.generate(self.wallet, 1) |
There was a problem hiding this comment.
In a723ef3
Side note? It seems like a hack to always generate a block when we want to remove a transaction or restart the node, which is much heavier. I think it's part of the reason why the tests are slow.
It is worth having evict from mempool rpc for this case and others, which could eliminate this.
Another way to do this is to also use unit tests, and remove them directly.
|
@ismaelsadeeq Interestingly I haven't had a lot of positive feedback yet on this PR. In the LN world, for example, the parent may end up having fees >=minfee, due to trimmed htlcs. Many of these projects don't even use test RPCs. I think it might make sense to look for more buy-in from prospective users before iterating further. |
It seems LND uses testflight as a prerequisite for broadcasting. @GeorgeTsagk mentioned
See 2140-dev#24 |
Would it be possible to somehow test txs with nSequence relative locktimes spending currently out-of-mempool txs? I guess "Assume utxo |
|
Concept ACK |
|
The code looks fine to me, but it'd be helpful for users that want this to say so explicitly here, to help us decide if we should maintain this.
It's been a month since this, any update? |
|
I think this is relevant if we want to support private broadcast via |
A test-only companion to submitpackage that validates a strict 1p1c [parent, child] bundle without mutating the mempool. Intended as a wallet pre-flight check for CPFP fee-bumping packages. Enables rbf and sibling eviction evaluation, just like submitblock. Diverging behaviors from submitpackage: Hard rejects packages that aren't exactly 2 txs in a child-with-parents topology, and parents that pass individual acceptance (caller should use testsubmitpackage on parent alone for that).
Two divergences from submitpackage: sibling eviction was enabled in the multi-transaction path, which never succeeds there (PackageTRUCChecks rejects a parent with a mempool descendant) and so only changed which check rejected the package; and a transaction that passed before a later one failed its scripts was reported accepted. Leave sibling eviction off and report successes only once the whole package passes.
a723ef3 to
98cdef3
Compare
ProcessNewPackage's test mode checks each transaction without package feerates or replacements, as testmempoolaccept does. With test_as_submission it runs submission's evaluation instead and stops short of the mempool, so a caller can learn whether a child pays for its parent before relaying them. A transaction that passed before another failed is reported by its own result, as submission reports it. Results do not list replaced transactions, and a parent that passes alone gives no answer for its child, which it does not stage. From bitcoin#35286, without its RPC.
ProcessNewPackage's test mode checks each transaction without package feerates or replacements, as testmempoolaccept does. With test_as_submission it runs submission's evaluation instead and stops short of the mempool, so a caller can learn whether a child pays for its parent before relaying them. A transaction that passed before another failed is reported by its own result, as submission reports it. Results do not list replaced transactions, and a parent that passes alone gives no answer for its child, which it does not stage. From bitcoin#35286, without its RPC.
ProcessNewPackage's test mode checks each transaction without package feerates or replacements, as testmempoolaccept does. With test_as_submission it runs submission's evaluation instead and stops short of the mempool, so a caller can learn whether a child pays for its parent before relaying them. A transaction that passed before another failed is reported by its own result, as submission reports it. Results do not list replaced transactions, and a parent that passes alone gives no answer for its child, which it does not stage. From bitcoin#35286, without its RPC.
A bit of a late comment here but wanted to double down on the fact that we rely on the test endpoints to prepare/shape our batch transactions before we actually submit them in LND. |

A test-only companion to submitpackage that validates a strict 1p1c [parent, child] bundle without mutating the mempool. Intended as a wallet pre-flight check for CPFP fee-bumping packages.
Enables rbf and sibling eviction evaluation, just like submitpackage.
Diverging behaviors from submitpackage:
Hard rejects packages that aren't exactly 2 txs in a child-with-parents topology, and parents that pass individual acceptance (caller should use testsubmitpackage on parent alone for that).
To do this "properly" without rejecting the self-sufficient parents (and not giving surprising results that don't match reality), we would need fairly extensive changes to mempool acceptance logic, more book-keeping to unroll test-accepted subpackage state (while risking mutating the mempool in brittle ways), and possibly other changes.
This is a partial addressing of #32160, hopefully addressing most of the missing functionality people are requesting.