10 Commits

Author SHA1 Message Date
Sjors Provoost
70de5cc2d2 ipc mining: pass missing context to BlockTemplate methods (incompatible schema change)
Adding a context parameter ensures that these methods are run in
their own thread and don't block other calls. They were missing
for:

- createNewBlock()
- checkBlock()

The missing parameters were first pointed out by plebhash in
https://github.com/bitcoin/bitcoin/issues/33575#issuecomment-3383290115 and
adding them should prevent possible performance problems and lockups,
especially with #34184 which can make the createNewBlock method block for a
long time before returning. It would be straightforward to make this change in
a backward compatible way
(https://github.com/bitcoin/bitcoin/pull/34184#discussion_r2770232149) but nice
to not need to go through the trouble.

Warning: This is an intermediate, review-only commit. Binaries built from it
should not be distributed or used to connect to other clients or servers. It
makes incompatible changes to the `mining.capnp` schema without updating the
`Init.makeMining` version, causing binaries to advertise support for a schema
they do not actually implement. Mixed versions may therefore exchange garbage
requests/responses instead of producing clear errors. The final commit in this
series bumps the mining interface number to ensure mismatches are detected.

git-bisect-skip: yes

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2026-02-12 03:34:08 +01:00
Ryan Ofsky
2278f017af ipc mining: remove deprecated methods (incompatible schema change)
This change removes deprecated methods from the ipc mining interface.

Warning: This is an intermediate, review-only commit. Binaries built from it
should not be distributed or used to connect to other clients or servers. It
makes incompatible changes to the `mining.capnp` schema without updating the
`Init.makeMining` version, causing binaries to advertise support for a schema
they do not actually implement. Mixed versions may therefore exchange garbage
requests/responses instead of producing clear errors. The final commit in this
series bumps the mining interface number to ensure mismatches are detected.

git-bisect-skip: yes
2026-02-11 21:34:08 -05:00
Ryan Ofsky
c6638fa7c5 ipc mining: provide default option values (incompatible schema change)
This change copies default option values from the C++ mining interface to the
Cap'n Proto interface. Currently, no capnp default values are set, so they are
implicitly all false or 0, which is inconvenient for the rust and python
clients and inconsistent with the C++ client.

Warning: This is an intermediate, review-only commit. Binaries built from it
should not be distributed or used to connect to other clients or servers. It
makes incompatible changes to the `mining.capnp` schema without updating the
`Init.makeMining` version, causing binaries to advertise support for a schema
they do not actually implement. Mixed versions may therefore exchange garbage
requests/responses instead of producing clear errors. The final commit in this
series bumps the mining interface number to ensure mismatches are detected.

git-bisect-skip: yes
2026-02-11 21:34:08 -05:00
Ryan Ofsky
ff995b50cf ipc test: add workaround to block_reserved_weight exception test
libmultiprocess currently handles uncaught exceptions from IPC methods badly
when an `mp.Context` parameter is passed and the IPC call executes on an a
worker thread, with the uncaught exception leading to a std::terminate call.

https://github.com/bitcoin-core/libmultiprocess/pull/218 was created to fix
this, but before that change is available, update an IPC test which can trigger
this behavior to handle it and recover when mp.Context parameters are added in
the an upcoming commit.

Having this workaround makes the test a little more complicated and less strict
but reduces dependencies between pending PRs so they don't need to be reviewed
or merged in a particular order.
2026-02-11 21:34:08 -05:00
Sjors Provoost
b623fab1ba mining: enforce minimum reserved weight for IPC
Previously a lower value was silently clamped to MINIMUM_BLOCK_RESERVED_WEIGHT.
2026-02-07 13:57:33 +01:00
Sjors Provoost
d3e49528d4 mining: fix -blockreservedweight shadows IPC option
The -blockreservedweight startup option should only affect RPC code,
because IPC clients (currently) do not have a way to signal their intent
to use the node default (the BlockCreateOptions struct defaults
merely document a recommendation for client software).

Before this commit however, if the user set -blockreservedweight
then ApplyArgsManOptions would cause the block_reserved_weight
option passed by IPC clients to be ignored. Users who don't set
this value were not affected.

Fix this by making BlockCreateOptions::block_reserved_weight an
std::optional.

Internal interface users, such as the RPC call sites, don't set a
value so -blockreservedweight is used. Whereas IPC clients do set
a value which is no longer ignored.

Test coverage is added.

mining_basic.py already ensured -blockreservedweight is enforced by
mining RPC methods. This commit adds coverage for Mining interface IPC
clients. It also verifies that -blockreservedweight has no effect on
them.

Co-Authored-By: Russell Yanofsky <russ@yanofsky.org>
2026-02-07 13:57:33 +01:00
Sjors Provoost
418b7995dd test: have mining template helpers return None
Refactor the mining_create_block_template and mining_wait_next_template
helpers in ipc_util.py to return None if they time out or fail. It makes
the test easier to read and provides a more clear error message in case
of a regression.

There were a few spots that didn't use mining_wait_next_template yet,
which now do.
2026-02-07 13:13:31 +01:00
Sjors Provoost
633d183119 test: misc interface_ipc_mining.py improvements
- share miniwallet and block create options between tests
- documentation fixes
- use assert_equal instead of assert ==
2026-02-06 15:46:31 +01:00
Sjors Provoost
52ccd9215e test: split interface_ipc_mining.py into subtests
Split the Mining interface test into focused subtests.

Keep the initial tip-change pre-mine check in run_mining_interface_test.
As a result run_block_template_test no longer has newblockref.
2026-02-06 15:46:31 +01:00
Sjors Provoost
4e49fa2a68 test: add interface_ipc_mining.py
Split Mining interface tests into interface_ipc_mining.py and keep
interface_ipc.py for echo + simple inspectors.

Register the new test in test_runner.py.

The setup code around "Create Mining proxy object" is duplicated
in the new test file, but the simple insector checks below it
are not moved.
2026-02-06 15:46:31 +01:00