diff --git a/doc/release-notes.md b/doc/release-notes.md --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -6,3 +6,7 @@ This release includes the following features and fixes: - Add an extra 64 bits of entropy in the initial version message. + - The `setexcessiveblock` RPC is deprecated and will be removed in a future + version. The `-excessiveblocksize` option should be used instead. Use the + `-deprecatedrpc=setexcessiveblock` option to continue using the + `setexcessiveblock` RPC. diff --git a/src/rpc/abc.cpp b/src/rpc/abc.cpp --- a/src/rpc/abc.cpp +++ b/src/rpc/abc.cpp @@ -34,9 +34,9 @@ const JSONRPCRequest &request) { RPCHelpMan{ "setexcessiveblock", - "Set the excessive block size. Excessive blocks will not be used in " - "the active chain or relayed. This discourages the propagation of " - "blocks that you consider excessively large.", + "DEPRECATED. Set the excessive block size. Excessive blocks will not " + "be used in the active chain or relayed. This discourages the " + "propagation of blocks that you consider excessively large.", { {"blockSize", RPCArg::Type::NUM, RPCArg::Optional::NO, "Excessive block size in bytes. Must be greater than " + @@ -48,6 +48,16 @@ } .Check(request); + if (!IsDeprecatedRPCEnabled(gArgs, "setexcessiveblock")) { + // setexcessiveblock is deprecated in v0.22.12 for removal in v0.23 + throw JSONRPCError( + RPC_METHOD_DEPRECATED, + std::string( + "The setexcessiveblock RPC is deprecated and will be removed " + "in a future version. Use the -deprecatedrpc=setexcessiveblock " + "option to continue using it.")); + } + if (!request.params[0].isNum()) { throw JSONRPCError( RPC_INVALID_PARAMETER, diff --git a/src/test/excessiveblock_tests.cpp b/src/test/excessiveblock_tests.cpp --- a/src/test/excessiveblock_tests.cpp +++ b/src/test/excessiveblock_tests.cpp @@ -19,6 +19,10 @@ class ExcessiveBlockTestingSetup : public TestingSetup { public: + ExcessiveBlockTestingSetup() + : TestingSetup(CBaseChainParams::MAIN, + {"-deprecatedrpc=setexcessiveblock"}){}; + UniValue CallRPC(const std::string &args) { const util::Ref context{m_node}; return ::CallRPC(args, context); diff --git a/test/functional/abc_rpc_excessiveblock.py b/test/functional/abc_rpc_excessiveblock.py --- a/test/functional/abc_rpc_excessiveblock.py +++ b/test/functional/abc_rpc_excessiveblock.py @@ -25,6 +25,7 @@ self.num_nodes = 1 self.tip = None self.setup_clean_chain = True + self.extra_args = [["-deprecatedrpc=setexcessiveblock"]] def check_subversion(self, pattern_str): # Check that the subversion is set as expected @@ -84,7 +85,6 @@ self.check_subversion(r"/Bitcoin ABC:.*\(EB13\.1; .*\)/") def run_test(self): - self.genesis_hash = int(self.nodes[0].getbestblockhash(), 16) self.test_excessiveblock() diff --git a/test/functional/rpc_deprecated.py b/test/functional/rpc_deprecated.py --- a/test/functional/rpc_deprecated.py +++ b/test/functional/rpc_deprecated.py @@ -3,14 +3,17 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. """Test deprecation of RPC calls.""" +from test_framework.cdefs import DEFAULT_MAX_BLOCK_SIZE from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import assert_raises_rpc_error class DeprecatedRpcTest(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 2 self.setup_clean_chain = True - self.extra_args = [[], ["-deprecatedrpc=banscore"]] + self.extra_args = [[], ["-deprecatedrpc=banscore", + "-deprecatedrpc=setexcessiveblock"]] def run_test(self): # This test should be used to verify correct behaviour of deprecated @@ -28,6 +31,13 @@ assert 'banscore' not in self.nodes[0].getpeerinfo()[0] assert 'banscore' in self.nodes[1].getpeerinfo()[0] + self.log.info("Test deprecated setexcessiveblock RPC") + assert_raises_rpc_error(-32, + 'The setexcessiveblock RPC is deprecated', + self.nodes[0].setexcessiveblock, + DEFAULT_MAX_BLOCK_SIZE) + self.nodes[1].setexcessiveblock(DEFAULT_MAX_BLOCK_SIZE) + if __name__ == '__main__': DeprecatedRpcTest().main()