From 9453c153612ae9b30308362048099bc53afcde6f Mon Sep 17 00:00:00 2001 From: Sjors Provoost Date: Mon, 24 Nov 2025 15:34:45 +0100 Subject: [PATCH] ipc mining: break compatibility with existing clients (version bump) This increments the field number of the `Init.makeMining` method and makes the old `makeMining` method return an error, so existing IPC mining clients not using the latest schema file will get an error and not be able to access the Mining interface. Normally, there shouldn't be a need to break compatibility this way, but the mining interface has evolved a lot since it was first introduced, with old clients using the original methods less stable and performant than newer clients. So now is a good time to introduce a cutoff, drop deprecated methods, and stop supporting old clients which can't function as well. Bumping the field number is also an opportunity to make other improvements that would be awkward to implement compatibly, so a few of these were implemented in commits immediately preceding this one. Co-authored-by: Ryan Ofsky --- src/interfaces/init.h | 1 + src/ipc/capnp/init.capnp | 5 ++++- test/functional/interface_ipc.py | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/interfaces/init.h b/src/interfaces/init.h index b909c9e6f6b..463d43e7c2e 100644 --- a/src/interfaces/init.h +++ b/src/interfaces/init.h @@ -39,6 +39,7 @@ public: virtual Ipc* ipc() { return nullptr; } virtual bool canListenIpc() { return false; } virtual const char* exeName() { return nullptr; } + virtual void makeMiningOld2() { throw std::runtime_error("Old mining interface (@2) not supported. Please update your client!"); } }; //! Return implementation of Init interface for the node process. If the argv diff --git a/src/ipc/capnp/init.capnp b/src/ipc/capnp/init.capnp index 64a7bf9b2b4..a20ef2fcaf3 100644 --- a/src/ipc/capnp/init.capnp +++ b/src/ipc/capnp/init.capnp @@ -19,5 +19,8 @@ using Mining = import "mining.capnp"; interface Init $Proxy.wrap("interfaces::Init") { construct @0 (threadMap: Proxy.ThreadMap) -> (threadMap :Proxy.ThreadMap); makeEcho @1 (context :Proxy.Context) -> (result :Echo.Echo); - makeMining @2 (context :Proxy.Context) -> (result :Mining.Mining); + makeMining @3 (context :Proxy.Context) -> (result :Mining.Mining); + + # DEPRECATED: no longer supported; server returns an error. + makeMiningOld2 @2 () -> (); } diff --git a/test/functional/interface_ipc.py b/test/functional/interface_ipc.py index f2c75f6e09f..2fc4497a426 100755 --- a/test/functional/interface_ipc.py +++ b/test/functional/interface_ipc.py @@ -68,9 +68,23 @@ class IPCInterfaceTest(BitcoinTestFramework): asyncio.run(capnp.run(async_routine())) + def run_deprecated_mining_test(self): + self.log.info("Running deprecated mining interface test") + async def async_routine(): + ctx, init = await make_capnp_init_ctx(self) + self.log.debug("Calling deprecated makeMiningOld2 should raise an error") + try: + await init.makeMiningOld2() + raise AssertionError("makeMiningOld2 unexpectedly succeeded") + except capnp.KjException as e: + assert_equal(e.description, "remote exception: std::exception: Old mining interface (@2) not supported. Please update your client!") + assert_equal(e.type, "FAILED") + asyncio.run(capnp.run(async_routine())) + def run_test(self): self.run_echo_test() self.run_mining_test() + self.run_deprecated_mining_test() if __name__ == '__main__': IPCInterfaceTest(__file__).main()