diff --git a/doc/release-notes.md b/doc/release-notes.md --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -8,3 +8,5 @@ - Add a new option `-networkactive` to enable all P2P network activity (default 1). To start a node offline, you can provide `-networkactive=0` or `-nonetworkactive`. + - The deprecated `setexcessiveblock` RPC has been removed and is no longer + available. The `-excessiveblocksize` option should be used instead. diff --git a/src/rpc/abc.cpp b/src/rpc/abc.cpp --- a/src/rpc/abc.cpp +++ b/src/rpc/abc.cpp @@ -30,73 +30,12 @@ return ret; } -static UniValue setexcessiveblock(Config &config, - const JSONRPCRequest &request) { - RPCHelpMan{ - "setexcessiveblock", - "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 " + - ToString(LEGACY_MAX_BLOCK_SIZE) + "."}, - }, - RPCResult{RPCResult::Type::NUM, "", "excessive block size in bytes"}, - RPCExamples{HelpExampleCli("setexcessiveblock", "25000000") + - HelpExampleRpc("setexcessiveblock", "25000000")}, - } - .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, - std::string( - "Invalid parameter, excessiveblock must be an integer")); - } - - int64_t ebs = request.params[0].get_int64(); - - // Do not allow maxBlockSize to be set below historic 1MB limit - if (ebs <= int64_t(LEGACY_MAX_BLOCK_SIZE)) { - throw JSONRPCError( - RPC_INVALID_PARAMETER, - std::string( - "Invalid parameter, excessiveblock must be larger than ") + - ToString(LEGACY_MAX_BLOCK_SIZE)); - } - - // Set the new max block size. - { - LOCK(cs_main); - if (!config.SetMaxBlockSize(ebs)) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Unexpected error"); - } - } - - // settingsToUserAgentString(); - std::ostringstream ret; - ret << "Excessive Block set to " << ebs << " bytes."; - return UniValue(ret.str()); -} - void RegisterABCRPCCommands(CRPCTable &t) { // clang-format off static const CRPCCommand commands[] = { // category name actor (function) argNames // ------------------- ------------------------ ---------------------- ---------- { "network", "getexcessiveblock", getexcessiveblock, {}}, - { "network", "setexcessiveblock", setexcessiveblock, {"maxBlockSize"}}, }; // clang-format on diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -164,8 +164,6 @@ {"buildavalancheproof", 0, "sequence"}, {"buildavalancheproof", 1, "expiration"}, {"buildavalancheproof", 3, "stakes"}, - // ABC specific RPC - {"setexcessiveblock", 0, "blockSize"}, }; class CRPCConvertTable { diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -152,7 +152,6 @@ descriptor_tests.cpp dnsseeds_tests.cpp dstencode_tests.cpp - excessiveblock_tests.cpp feerate_tests.cpp finalization_tests.cpp flatfile_tests.cpp diff --git a/src/test/excessiveblock_tests.cpp b/src/test/excessiveblock_tests.cpp deleted file mode 100644 --- a/src/test/excessiveblock_tests.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) 2017-2020 The Bitcoin developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include - -extern UniValue CallRPC(const std::string &args, const util::Ref &context); - -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); - } -}; - -BOOST_FIXTURE_TEST_SUITE(excessiveblock_tests, ExcessiveBlockTestingSetup) - -BOOST_AUTO_TEST_CASE(excessiveblock_rpc) { - BOOST_CHECK_NO_THROW(CallRPC("getexcessiveblock")); - - BOOST_CHECK_THROW(CallRPC("setexcessiveblock"), std::runtime_error); - BOOST_CHECK_THROW(CallRPC("setexcessiveblock not_uint"), - std::runtime_error); - BOOST_CHECK_THROW(CallRPC("setexcessiveblock 1000000 not_uint"), - std::runtime_error); - BOOST_CHECK_THROW(CallRPC("setexcessiveblock 1000000 1"), - std::runtime_error); - BOOST_CHECK_THROW(CallRPC("setexcessiveblock -1"), std::runtime_error); - - BOOST_CHECK_THROW(CallRPC("setexcessiveblock 0"), std::runtime_error); - BOOST_CHECK_THROW(CallRPC("setexcessiveblock 1"), std::runtime_error); - BOOST_CHECK_THROW(CallRPC("setexcessiveblock 1000"), std::runtime_error); - BOOST_CHECK_THROW( - CallRPC(std::string("setexcessiveblock ") + ToString(ONE_MEGABYTE - 1)), - std::runtime_error); - BOOST_CHECK_THROW( - CallRPC(std::string("setexcessiveblock ") + ToString(ONE_MEGABYTE)), - std::runtime_error); - - BOOST_CHECK_NO_THROW(CallRPC(std::string("setexcessiveblock ") + - ToString(ONE_MEGABYTE + 1))); - BOOST_CHECK_NO_THROW(CallRPC(std::string("setexcessiveblock ") + - ToString(ONE_MEGABYTE + 10))); - - // Default can be higher than 1MB in future - test it too - BOOST_CHECK_NO_THROW(CallRPC(std::string("setexcessiveblock ") + - ToString(DEFAULT_MAX_BLOCK_SIZE))); - BOOST_CHECK_NO_THROW(CallRPC(std::string("setexcessiveblock ") + - ToString(DEFAULT_MAX_BLOCK_SIZE * 8))); - - BOOST_CHECK_NO_THROW( - CallRPC(std::string("setexcessiveblock ") + - ToString(std::numeric_limits::max()))); - - BOOST_CHECK_THROW( - CallRPC(std::string("setexcessiveblock ") + - ToString(uint64_t(std::numeric_limits::max()) + 1)), - std::runtime_error); - - BOOST_CHECK_THROW(CallRPC(std::string("setexcessiveblock ") + - ToString(std::numeric_limits::max())), - std::runtime_error); -} - -BOOST_AUTO_TEST_SUITE_END() 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 @@ -13,9 +13,9 @@ ONE_MEGABYTE, ) from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal, assert_raises_rpc_error +from test_framework.util import assert_equal -BLOCKSIZE_TOO_LOW = "Invalid parameter, excessiveblock must be larger than {}".format( +BLOCKSIZE_TOO_LOW = "Error: Excessive block size must be > {:,} bytes".format( LEGACY_MAX_BLOCK_SIZE) @@ -25,7 +25,7 @@ self.num_nodes = 1 self.tip = None self.setup_clean_chain = True - self.extra_args = [["-deprecatedrpc=setexcessiveblock"]] + self.extra_args = [[f"-blockmaxsize={LEGACY_MAX_BLOCK_SIZE}"]] def check_subversion(self, pattern_str): # Check that the subversion is set as expected @@ -35,50 +35,44 @@ assert pattern.match(subversion) def test_excessiveblock(self): + node = self.nodes[0] + # Check that we start with DEFAULT_MAX_BLOCK_SIZE - getsize = self.nodes[0].getexcessiveblock() + getsize = node.getexcessiveblock() ebs = getsize['excessiveBlockSize'] assert_equal(ebs, DEFAULT_MAX_BLOCK_SIZE) - # Check that setting to legacy size is ok - self.nodes[0].setexcessiveblock(LEGACY_MAX_BLOCK_SIZE + 1) - getsize = self.nodes[0].getexcessiveblock() - ebs = getsize['excessiveBlockSize'] - assert_equal(ebs, LEGACY_MAX_BLOCK_SIZE + 1) - - # Check that going below legacy size is not accepted - assert_raises_rpc_error(-8, BLOCKSIZE_TOO_LOW, - self.nodes[0].setexcessiveblock, LEGACY_MAX_BLOCK_SIZE) - getsize = self.nodes[0].getexcessiveblock() - ebs = getsize['excessiveBlockSize'] - assert_equal(ebs, LEGACY_MAX_BLOCK_SIZE + 1) + def setexcessiveblock(block_size): + self.restart_node( + 0, + self.extra_args[0] + + [f"-excessiveblocksize={block_size}"]) - # Check that a negative size returns an error - assert_raises_rpc_error(-8, BLOCKSIZE_TOO_LOW, - self.nodes[0].setexcessiveblock, -2 * LEGACY_MAX_BLOCK_SIZE) - getsize = self.nodes[0].getexcessiveblock() + # Check that setting to legacy size is ok + setexcessiveblock(LEGACY_MAX_BLOCK_SIZE + 1) + getsize = node.getexcessiveblock() ebs = getsize['excessiveBlockSize'] assert_equal(ebs, LEGACY_MAX_BLOCK_SIZE + 1) # Check setting to 2MB - self.nodes[0].setexcessiveblock(2 * ONE_MEGABYTE) - getsize = self.nodes[0].getexcessiveblock() + setexcessiveblock(2 * ONE_MEGABYTE) + getsize = node.getexcessiveblock() ebs = getsize['excessiveBlockSize'] assert_equal(ebs, 2 * ONE_MEGABYTE) # Check for EB correctness in the subver string self.check_subversion(r"/Bitcoin ABC:.*\(EB2\.0; .*\)/") # Check setting to 13MB - self.nodes[0].setexcessiveblock(13 * ONE_MEGABYTE) - getsize = self.nodes[0].getexcessiveblock() + setexcessiveblock(13 * ONE_MEGABYTE) + getsize = node.getexcessiveblock() ebs = getsize['excessiveBlockSize'] assert_equal(ebs, 13 * ONE_MEGABYTE) # Check for EB correctness in the subver string self.check_subversion(r"/Bitcoin ABC:.*\(EB13\.0; .*\)/") # Check setting to 13.14MB - self.nodes[0].setexcessiveblock(13140000) - getsize = self.nodes[0].getexcessiveblock() + setexcessiveblock(13140000) + getsize = node.getexcessiveblock() ebs = getsize['excessiveBlockSize'] assert_equal(ebs, 13.14 * ONE_MEGABYTE) # check for EB correctness in the subver string 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,17 +3,14 @@ # 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", - "-deprecatedrpc=setexcessiveblock"]] + self.extra_args = [[], ["-deprecatedrpc=banscore"]] def run_test(self): # This test should be used to verify correct behaviour of deprecated @@ -31,13 +28,6 @@ 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()