WIP: rpc: add testsubmitpackage for 1p1c test submissions #35286

Draft
instagibbs wants to merge 2 commits from 2026-05-testsubmitpackage_2 into master AGit
instagibbs commented 2026-05-13 18:16:36 +00:00 (Migrated from github.com)

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 https://github.com/bitcoin/bitcoin/issues/32160, hopefully addressing most of the missing functionality people are requesting.

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 https://github.com/bitcoin/bitcoin/issues/32160, hopefully addressing most of the missing functionality people are requesting.
DrahtBot commented 2026-05-13 18:16:46 +00:00 (Migrated from github.com)

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
Concept ACK ismaelsadeeq, w0xlt

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

No conflicts as of last run.

LLM Linter (✨ experimental)

Possible typos and grammar issues:

  • src/validation.cpp: Used f.e. with testsubmitpackage → Used e.g. with testsubmitpackage [f.e. is not the intended English abbreviation for “for example”]

Possible places where comparison-specific test macros should replace generic comparisons:

  • test/functional/rpc_testsubmitpackage.py: assert parent_A.txid_hex == parent_B.txid_hex → Prefer assert_equal(parent_A.txid_hex, parent_B.txid_hex).
  • test/functional/rpc_testsubmitpackage.py: assert parent_A.wtxid_hex != parent_B.wtxid_hex → Prefer assert_not_equal(parent_A.wtxid_hex, parent_B.wtxid_hex).

2026-10-21 21:06:07

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/35286 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/35286.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/35286#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | Concept ACK | [ismaelsadeeq](https://github.com/bitcoin/bitcoin/pull/35286#issuecomment-4572545699), [w0xlt](https://github.com/bitcoin/bitcoin/pull/35286#issuecomment-4792558553) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts No conflicts as of last run. <!--5faf32d7da4f0f540f40219e4f7537a3--> ### LLM Linter (✨ experimental) Possible typos and grammar issues: - `src/validation.cpp`: `Used f.e. with testsubmitpackage` → `Used e.g. with testsubmitpackage` [`f.e.` is not the intended English abbreviation for “for example”] Possible places where comparison-specific test macros should replace generic comparisons: - `test/functional/rpc_testsubmitpackage.py`: `assert parent_A.txid_hex == parent_B.txid_hex` → Prefer `assert_equal(parent_A.txid_hex, parent_B.txid_hex)`. - `test/functional/rpc_testsubmitpackage.py`: `assert parent_A.wtxid_hex != parent_B.wtxid_hex` → Prefer `assert_not_equal(parent_A.wtxid_hex, parent_B.wtxid_hex)`. <sup>2026-10-21 21:06:07</sup>
instagibbs commented 2026-05-13 18:17:07 +00:00 (Migrated from github.com)

cc @ajtowns @ismaelsadeeq as discussed, let's focus on concept / approach ACKs first, name is clearly up for debate, etc etc

cc @ajtowns @ismaelsadeeq as discussed, let's focus on concept / approach ACKs first, name is clearly up for debate, etc etc
DrahtBot commented 2026-05-13 18:49:06 +00:00 (Migrated from github.com)

🚧 At least one of the CI tasks failed.
Task Windows native, fuzz, VS: https://github.com/bitcoin/bitcoin/actions/runs/25817910490/job/75851154109
LLM reason (✨ experimental): Fuzz RPC tests failed because the RPC command testsubmitpackage was not registered in RPC_COMMANDS_SAFE_FOR_FUZZING/RPC_COMMANDS_NOT_SAFE_FOR_FUZZING (per src/test/fuzz/rpc.cpp).

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

<!--85328a0da195eb286784d51f73fa0af9--> 🚧 At least one of the CI tasks failed. <sub>Task `Windows native, fuzz, VS`: https://github.com/bitcoin/bitcoin/actions/runs/25817910490/job/75851154109</sub> <sub>LLM reason (✨ experimental): Fuzz RPC tests failed because the RPC command `testsubmitpackage` was not registered in `RPC_COMMANDS_SAFE_FOR_FUZZING`/`RPC_COMMANDS_NOT_SAFE_FOR_FUZZING` (per `src/test/fuzz/rpc.cpp`).</sub> <details><summary>Hints</summary> Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example: * Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch. * A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test. * An intermittent issue. Leave a comment here, if you need help tracking down a confusing failure. </details>
ismaelsadeeq commented 2026-05-29 08:23:20 +00:00 (Migrated from github.com)

Concept ACK, users normally test run submissions to see whether they will get through; so having testsubmitpackage rpc to test run 1p1c package is very useful.

I will review the approach and correctness.

Concept ACK, users normally test run submissions to see whether they will get through; so having `testsubmitpackage` rpc to test run 1p1c package is very useful. I will review the approach and correctness.
ismaelsadeeq (Migrated from github.com) reviewed 2026-05-29 14:54:50 +00:00
ismaelsadeeq (Migrated from github.com) left a 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.

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.
ismaelsadeeq (Migrated from github.com) commented 2026-05-29 12:56:32 +00:00

In a723ef365c88c3bcbf1f5c1ff00137d62651d6aa
This is weird to read? why is allow_sibling_eviction tied to test_accept?

In a723ef365c88c3bcbf1f5c1ff00137d62651d6aa This is weird to read? why is `allow_sibling_eviction` tied to `test_accept`?
ismaelsadeeq (Migrated from github.com) commented 2026-05-29 13:56:53 +00:00

In a723ef365c88c3bcbf1f5c1ff00137d62651d6aa

  • The loop that copies staged removals into replaced transactions is duplicated at both test_accept sites. A helper like CollectStagedRemovals() 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).
In a723ef365c88c3bcbf1f5c1ff00137d62651d6aa - The loop that copies staged removals into replaced transactions is duplicated at both `test_accept` sites. A helper like `CollectStagedRemovals() `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).
ismaelsadeeq (Migrated from github.com) commented 2026-05-29 14:22:16 +00:00

In a723ef365c88c3bcbf1f5c1ff00137d62651d6aa

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.

In a723ef365c88c3bcbf1f5c1ff00137d62651d6aa 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`.
ismaelsadeeq (Migrated from github.com) commented 2026-05-29 13:39:47 +00:00

In a723ef365c88c3bcbf1f5c1ff00137d62651d6aa

test_package_feerates is a bit hard to read?

Can you use a clearer name for this, maybe test_accept_as_package?

In a723ef365c88c3bcbf1f5c1ff00137d62651d6aa `test_package_feerates` is a bit hard to read? Can you use a clearer name for this, maybe `test_accept_as_package`?
ismaelsadeeq (Migrated from github.com) commented 2026-05-29 14:33:10 +00:00

In a723ef365c88c3bcbf1f5c1ff00137d62651d6aa

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?

In a723ef365c88c3bcbf1f5c1ff00137d62651d6aa 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?
ismaelsadeeq (Migrated from github.com) commented 2026-05-29 14:44:49 +00:00

In a723ef365c88c3bcbf1f5c1ff00137d62651d6aa

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.

In a723ef365c88c3bcbf1f5c1ff00137d62651d6aa 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.
instagibbs commented 2026-05-29 15:02:30 +00:00 (Migrated from github.com)

@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.

@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.
ismaelsadeeq commented 2026-06-16 09:43:54 +00:00 (Migrated from github.com)

Many of these projects don't even use test RPCs.

It seems LND uses testflight as a prerequisite for broadcasting.

@GeorgeTsagk mentioned

testMempoolAccept: pre-flight bumped txs before broadcasting. btcwallet.go

See https://github.com/2140-dev/bitcoin/issues/24

> Many of these projects don't even use test RPCs. It seems LND uses testflight as a prerequisite for broadcasting. @GeorgeTsagk mentioned > testMempoolAccept: pre-flight bumped txs before broadcasting. [btcwallet.go](https://github.com/lightningnetwork/lnd/blob/master/lnwallet/btcwallet/btcwallet.go#L1821) See https://github.com/2140-dev/bitcoin/issues/24
ajtowns commented 2026-06-16 21:26:44 +00:00 (Migrated from github.com)

I think it might make sense to look for more buy-in from prospective users before iterating further.

Would it be possible to somehow test txs with nSequence relative locktimes spending currently out-of-mempool txs? I guess "Assume utxo txid vout sPK amt height exists, and validate this tx against it" might be feasible? Would let you check "does this claim tx actually work with this commitment tx, or is there some subtle policy breakage that's been introduced that I didn't check?" I realise this is probably horrible scope creep :)

> I think it might make sense to look for more buy-in from prospective users before iterating further. Would it be possible to somehow test txs with nSequence relative locktimes spending currently out-of-mempool txs? I guess "Assume utxo `txid vout sPK amt height` exists, and validate this tx against it" might be feasible? Would let you check "does this claim tx actually work with this commitment tx, or is there some subtle policy breakage that's been introduced that I didn't check?" I realise this is probably horrible scope creep :)
instagibbs commented 2026-06-17 14:31:25 +00:00 (Migrated from github.com)
@ajtowns https://github.com/bitcoin/bitcoin/issues/32142 I think?
w0xlt commented 2026-06-24 18:45:15 +00:00 (Migrated from github.com)

Concept ACK

Concept ACK
dergoegge commented 2026-07-01 13:10:16 +00:00 (Migrated from github.com)

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.

I think it might make sense to look for more buy-in from prospective users before iterating further.

It's been a month since this, any update?

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. > I think it might make sense to look for more buy-in from prospective users before iterating further. It's been a month since [this](https://github.com/bitcoin/bitcoin/pull/35286#issuecomment-4576630874), any update?
DrahtBot commented 2026-07-24 23:26:31 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
DrahtBot commented 2026-10-21 00:14:46 +00:00 (Migrated from github.com)

⌛ There hasn't been much activity lately and the patch still needs rebase. What is the status here?

  • Is it still relevant? ➡️ Please solve the conflicts to make it ready for review and to ensure the CI passes.
  • Is it no longer relevant? ➡️ Please close.
  • Did the author lose interest or time to work on this? ➡️ Please close it and mark it with one of the labels 'Up for grabs' or 'Insufficient Review', so that it can be picked up in the future.
<!--13523179cfe9479db18ec6c5d236f789--> ⌛ There hasn't been much activity lately and the patch still needs rebase. What is the status here? * Is it still relevant? ➡️ Please solve the conflicts to make it ready for review and to ensure the CI passes. * Is it no longer relevant? ➡️ Please close. * Did the author lose interest or time to work on this? ➡️ Please close it and mark it with one of the labels 'Up for grabs' or 'Insufficient Review', so that it can be picked up in the future.
First-time contributor

Earlier concerns remain unresolved; see the full report for their current assessments.

🔵 Suggestion · The CPFP preflight is outside package validation

The preflight can report the wrong rejection reason when a parent exceeds the caller’s maxfeerate, and package test mode can report the child as missing inputs when the parent passes alone.

Location: src/rpc/mempool.cpp:1716 (head).

🔵 Suggestion · The new test-accept package mode lacks fuzz and unit coverage

Parity with submitpackage and the no-mutation guarantee are not checked by unit or fuzz tests for this mode.

Location: src/validation.cpp:1846 (head).

🔵 Suggestion · The parameter documentation contradicts an assertion

A future caller following the documented instruction to ignore test_package_feerates when test_accept is false would abort the node; no current caller does this.

Location: src/validation.h:283 (head).

🔵 Suggestion · The constructor comment contradicts the sibling-eviction invariant

The comment says sibling eviction may occur with package feerates, but the following assertions and constructor arguments prohibit it.

Location: src/validation.cpp:574 (head).

Review coverage was incomplete.


Reviewed: 98cdef352643 · Full review report · Previous reports

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:6f232c871bca65facadc248ad7ecd634f87b0b5f6936bc30593af890589888f1:0cfbbc826fdd30e42f35c9a5b7d389c0902089c94f2400654bb32123e69823f6 --> <!-- ralph-base:6ed5aad06111177c39f9b9f07a52634476380ae1 --> <!-- ralph-head:98cdef352643fe4411c051992992ef5b5f6119ea --> <!-- ralph-case:675f373fe9eda5223c9b6010d7497e32b8f9e16481dbeb511580f4d535502d8e --> Earlier concerns remain unresolved; see the full report for their current assessments. **🔵 Suggestion · The CPFP preflight is outside package validation** The preflight can report the wrong rejection reason when a parent exceeds the caller’s maxfeerate, and package test mode can report the child as missing inputs when the parent passes alone. Location: [`src/rpc/mempool.cpp:1716`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/98cdef352643fe4411c051992992ef5b5f6119ea/src/rpc/mempool.cpp#L1716>) (head). **🔵 Suggestion · The new test-accept package mode lacks fuzz and unit coverage** Parity with `submitpackage` and the no-mutation guarantee are not checked by unit or fuzz tests for this mode. Location: [`src/validation.cpp:1846`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/98cdef352643fe4411c051992992ef5b5f6119ea/src/validation.cpp#L1846>) (head). **🔵 Suggestion · The parameter documentation contradicts an assertion** A future caller following the documented instruction to ignore `test_package_feerates` when `test_accept` is false would abort the node; no current caller does this. Location: [`src/validation.h:283`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/98cdef352643fe4411c051992992ef5b5f6119ea/src/validation.h#L283>) (head). **🔵 Suggestion · The constructor comment contradicts the sibling-eviction invariant** The comment says sibling eviction may occur with package feerates, but the following assertions and constructor arguments prohibit it. Location: [`src/validation.cpp:574`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/98cdef352643fe4411c051992992ef5b5f6119ea/src/validation.cpp#L574>) (head). Review coverage was incomplete. <!-- Review tier: sensitive --> --- Reviewed: [`98cdef352643`](<https://git.fish.foo/bitcoin/bitcoin/commit/98cdef352643fe4411c051992992ef5b5f6119ea>) · [Full review report](<https://review.fish.foo/traces/35286-98cdef352643fe4411c051992992ef5b5f6119ea-1705-3.html>) · [Previous reports](<https://review.fish.foo/traces/35286/>)
andrewtoth commented 2026-10-21 02:29:23 +00:00 (Migrated from github.com)

I think this is relevant if we want to support private broadcast via submitpackage. Right now we have no way to test the validity before queuing the package for private broadcast. I'm not sure about consumers of the test RPC though, which is the bulk of the code here. If there is not yet indication of buy-in for the RPC, could we instead split out just the internal dry-run of ProcessNewPackage into its own change?

I think this is relevant if we want to support private broadcast via `submitpackage`. Right now we have no way to test the validity before queuing the package for private broadcast. I'm not sure about consumers of the test RPC though, which is the bulk of the code here. If there is not yet indication of buy-in for the RPC, could we instead split out just the internal dry-run of `ProcessNewPackage` into its own change?
GeorgeTsagk commented 2026-11-09 13:08:59 +00:00 (Migrated from github.com)

Many of these projects don't even use test RPCs.

It seems LND uses testflight as a prerequisite for broadcasting.

@GeorgeTsagk mentioned

testMempoolAccept: pre-flight bumped txs before broadcasting. btcwallet.go

See 2140-dev#24

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.

> > Many of these projects don't even use test RPCs. > > It seems LND uses testflight as a prerequisite for broadcasting. > > @GeorgeTsagk mentioned > > > testMempoolAccept: pre-flight bumped txs before broadcasting. [btcwallet.go](https://github.com/lightningnetwork/lnd/blob/master/lnwallet/btcwallet/btcwallet.go#L1821) > > See [2140-dev#24](https://github.com/2140-dev/bitcoin/issues/24) 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.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!35286
No description provided.