From 0c97cd5ceed5fb1279ddba09bb974fd7deffdf40 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Sat, 18 Nov 2017 12:05:27 +0100 Subject: [PATCH 01/17] Merge #11710: cli: Reject arguments to -getinfo dcfef27 cli: Reject arguments to -getinfo (Wladimir J. van der Laan) Pull request description: Currently it's possible to accidentally type e.g. bitcoin-cli -getinfo getbalance and get an answer which can be confusing; the trailing arguments are just ignored. To avoid this, throw an error if the user provides arguments to `-getinfo`. Tree-SHA512: 3603e8fa852b884d1dd3b7462db40b092fe8b3390fd4384b4ee330315d797aff711e9f62990012fd4b5a55c8678734ba8497a5488a09ee6b65cf8a99017d6eb4 --- src/dash-cli.cpp | 3 +++ test/functional/bitcoin_cli.py | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/dash-cli.cpp b/src/dash-cli.cpp index f161162c4200..b8d0b62919b8 100644 --- a/src/dash-cli.cpp +++ b/src/dash-cli.cpp @@ -226,6 +226,9 @@ class GetinfoRequestHandler: public BaseRequestHandler /** Create a simulated `getinfo` request. */ UniValue PrepareRequest(const std::string& method, const std::vector& args) override { + if (!args.empty()) { + throw std::runtime_error("-getinfo takes no arguments"); + } UniValue result(UniValue::VARR); result.push_back(JSONRPCRequestObj("getnetworkinfo", NullUniValue, ID_NETWORKINFO)); result.push_back(JSONRPCRequestObj("getblockchaininfo", NullUniValue, ID_BLOCKCHAININFO)); diff --git a/test/functional/bitcoin_cli.py b/test/functional/bitcoin_cli.py index 7fd2abecce25..819e199d08c4 100755 --- a/test/functional/bitcoin_cli.py +++ b/test/functional/bitcoin_cli.py @@ -35,8 +35,11 @@ def run_test(self): assert_equal(["foo", "bar"], self.nodes[0].cli('-rpcuser=%s' % user, '-stdin', '-stdinrpcpass', input=password + "\nfoo\nbar").echo()) assert_raises_process_error(1, "incorrect rpcuser or rpcpassword", self.nodes[0].cli('-rpcuser=%s' % user, '-stdin', '-stdinrpcpass', input="foo").echo) + self.log.info("Make sure that -getinfo with arguments fails") + assert_raises_process_error(1, "-getinfo takes no arguments", self.nodes[0].cli('-getinfo').help) + self.log.info("Compare responses from `dash-cli -getinfo` and the RPCs data is retrieved from.") - cli_get_info = self.nodes[0].cli('-getinfo').help() + cli_get_info = self.nodes[0].cli().send_cli('-getinfo') wallet_info = self.nodes[0].getwalletinfo() network_info = self.nodes[0].getnetworkinfo() blockchain_info = self.nodes[0].getblockchaininfo() From 26281c023af68d3eee1b3b1538aad0a8ceec6530 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Wed, 5 Apr 2017 11:20:19 +0200 Subject: [PATCH 02/17] Merge #10154: init: Remove redundant logging code faafa80 init: Remove redundant logging code (MarcoFalke) Tree-SHA512: 5ad0e9aba0e25a36025dd4ee5e5fddd2c0039f95bafd0f33300ea59e2f9bba807da6a1a8b4311d6aad5a360b99163edf4a4f161cb13f0f38580d8d6b504c94ad --- src/init.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index e84a166a4744..14dd276ba7e4 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -553,8 +553,6 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-debug=", strprintf(_("Output debugging information (default: %u, supplying is optional)"), 0) + ". " + _("If is not supplied or if = 1, output all debugging information.") + " " + _(" can be:") + " " + ListLogCategories() + "."); strUsage += HelpMessageOpt("-debugexclude=", strprintf(_("Exclude debugging information for a category. Can be used in conjunction with -debug=1 to output debug logs for all categories except one or more specified categories."))); - if (showDebug) - strUsage += HelpMessageOpt("-nodebug", "Turn off debugging messages, same as -debug=0"); strUsage += HelpMessageOpt("-help-debug", _("Show all debugging options (usage: --help -help-debug)")); strUsage += HelpMessageOpt("-logips", strprintf(_("Include IP addresses in debug output (default: %u)"), DEFAULT_LOGIPS)); strUsage += HelpMessageOpt("-logtimestamps", strprintf(_("Prepend debug output with timestamp (default: %u)"), DEFAULT_LOGTIMESTAMPS)); @@ -1110,12 +1108,11 @@ bool AppInitParameterInteraction() InitWarning(strprintf(_("Reducing -maxconnections from %d to %d, because of system limitations."), nUserMaxConnections, nMaxConnections)); // ********************************************************* Step 3: parameter-to-internal-flags - - if (gArgs.IsArgSet("-debug")) { + if (gArgs.IsArgSet("-debug") > 0) { // Special-case: if -debug=0/-nodebug is set, turn off debugging messages const std::vector categories = gArgs.GetArgs("-debug"); - if (!(gArgs.GetBoolArg("-nodebug", false) || find(categories.begin(), categories.end(), std::string("0")) != categories.end())) { + if (find(categories.begin(), categories.end(), std::string("0")) != categories.end())) { for (const auto& cat : categories) { uint64_t flag; if (!GetLogCategory(&flag, &cat)) { From 62987bee8c370d0ed09620c518f5880b9434cfb8 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Thu, 30 Nov 2017 09:32:35 +0100 Subject: [PATCH 03/17] Merge #11191: RPC: Improve help text and behavior of RPC-logging. c60c49b Improve help text and behavior of RPC-logging (Akio Nakamura) Pull request description: 1. It is allowed `libevent` logging to be updated during runtime, but still described that restriction in the help text. So we delete these text. 2. Add a descrption about the evaluation order of `` and `` to clarify how debug loggig categories to be set. 3. Add a description about the available logging category `"all"` which is not explained. 4. Add `"optional"` to the help text of `` and ``. 5. Add missing new lines before `"Argument:"`. 6. `"0"`,`"1"` are allowed in both array of `` and ``. `"0"` is **ignored** and `"1"` is treated **same as** `"all"`. It is confusing, so forbid them. 7. It always returns all logging categories with status. Fix the help text to match this behavior. Tree-SHA512: c2142da1a9bf714af8ebc38ac0d82394e2073fc0bd56f136372e3db7b2af3b6746f8d6b0241fe66c1698c208c124deb076be83f07dec0d0a180ad150593af415 --- src/init.cpp | 3 ++- src/rpc/misc.cpp | 39 ++++++++++++++++++++++++++++----------- src/util.cpp | 1 + 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 14dd276ba7e4..2b48d866997e 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1112,7 +1112,8 @@ bool AppInitParameterInteraction() // Special-case: if -debug=0/-nodebug is set, turn off debugging messages const std::vector categories = gArgs.GetArgs("-debug"); - if (find(categories.begin(), categories.end(), std::string("0")) != categories.end())) { + if (std::none_of(categories.begin(), categories.end(), + [](std::string cat){return cat == "0" || cat == "none";})) { for (const auto& cat : categories) { uint64_t flag; if (!GetLogCategory(&flag, &cat)) { diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 7e5a2e2847b7..723c410360f1 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -1133,6 +1133,9 @@ uint64_t getCategoryMask(UniValue cats) { if (!GetLogCategory(&flag, &cat)) { throw JSONRPCError(RPC_INVALID_PARAMETER, "unknown logging category " + cat); } + if (flag == BCLog::NONE) { + return 0; + } mask |= flag; } return mask; @@ -1142,20 +1145,34 @@ UniValue logging(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() > 2) { throw std::runtime_error( - "logging [include,...] \n" + "logging ( )\n" "Gets and sets the logging configuration.\n" - "When called without an argument, returns the list of categories that are currently being debug logged.\n" - "When called with arguments, adds or removes categories from debug logging.\n" - "The valid logging categories are: " + ListLogCategories() + ".\n" - "libevent logging is configured on startup and cannot be modified by this RPC during runtime.\n" - "There are also a few meta-categories:\n" - " - \"all\", \"1\" and \"\" activate all categories at once;\n" - " - \"dash\" activates all Dash-specific categories at once.\n" + "When called without an argument, returns the list of categories with status that are currently being debug logged or not.\n" + "When called with arguments, adds or removes categories from debug logging and return the lists above.\n" + "The arguments are evaluated in order \"include\", \"exclude\".\n" + "If an item is both included and excluded, it will thus end up being excluded.\n" + "The valid logging categories are: " + ListLogCategories() + "\n" + "In addition, the following are available as category names with special meanings:\n" + " - \"all\", \"1\" : represent all logging categories.\n" + " - \"dash\" activates all Dash-specific categories at once.\n" "To deactivate all categories at once you can specify \"all\" in .\n" + " - \"none\", \"0\" : even if other logging categories are specified, ignore all of them.\n" "\nArguments:\n" - "1. \"include\" (array of strings) add debug logging for these categories.\n" - "2. \"exclude\" (array of strings) remove debug logging for these categories.\n" - "\nResult: (string): a list of the logging categories that are active.\n" + "1. \"include\" (array of strings, optional) A json array of categories to add debug logging\n" + " [\n" + " \"category\" (string) the valid logging category\n" + " ,...\n" + " ]\n" + "2. \"exclude\" (array of strings, optional) A json array of categories to remove debug logging\n" + " [\n" + " \"category\" (string) the valid logging category\n" + " ,...\n" + " ]\n" + "\nResult:\n" + "{ (json object where keys are the logging categories, and values indicates its status\n" + " \"category\": 0|1, (numeric) if being debug logged or not. 0:inactive, 1:active\n" + " ...\n" + "}\n" "\nExamples:\n" + HelpExampleCli("logging", "\"[\\\"all\\\"]\" \"[\\\"http\\\"]\"") + HelpExampleRpc("logging", "[\"all\"], \"[libevent]\"") diff --git a/src/util.cpp b/src/util.cpp index c83805752378..e10e304035b4 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -256,6 +256,7 @@ struct CLogCategoryDesc const CLogCategoryDesc LogCategories[] = { {BCLog::NONE, "0"}, + {BCLog::NONE, "none"}, {BCLog::NET, "net"}, {BCLog::TOR, "tor"}, {BCLog::MEMPOOL, "mempool"}, From e2c7d1f55a36fd5954d3d8bc68940eefdd1a944a Mon Sep 17 00:00:00 2001 From: Pasta Date: Thu, 27 Feb 2020 21:33:44 +0000 Subject: [PATCH 04/17] add include --- src/llmq/quorums_debug.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/llmq/quorums_debug.h b/src/llmq/quorums_debug.h index d6721914edb5..3ba4422fe790 100644 --- a/src/llmq/quorums_debug.h +++ b/src/llmq/quorums_debug.h @@ -9,6 +9,7 @@ #include "sync.h" #include "univalue.h" +#include #include class CDataStream; From d8d18d66574266bccb300bb9c3937405c9324a30 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Mon, 20 Nov 2017 15:19:19 -0500 Subject: [PATCH 05/17] Merge #11714: [tests] Test that mempool rejects coinbase transactions 65e91f5ed [tests] Test that mempool rejects coinbase transactions (James O'Beirne) Pull request description: ![selection_063](https://user-images.githubusercontent.com/73197/32978622-b0fa9d70-cbfa-11e7-9a72-1997409e5ba8.png) Neither the unit nor functional tests appear to cover rejecting a transaction from acceptance to the mempool on the basis of it being a coinbase. Seems like a decent thing to have a test for. Tree-SHA512: 53af53c975cad5d7a21c443d71a1c0ced5c70a7799b75bb44d9b7dd6ab2afbcdcaab14571540efeb848f3a1daee5e1dd856530d8f2b50582595219a1c17555ff --- src/Makefile.test.include | 1 + src/test/txvalidation_tests.cpp | 61 +++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 src/test/txvalidation_tests.cpp diff --git a/src/Makefile.test.include b/src/Makefile.test.include index 5809cf58fe69..07da17c23c0a 100644 --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -95,6 +95,7 @@ BITCOIN_TESTS =\ test/timedata_tests.cpp \ test/torcontrol_tests.cpp \ test/transaction_tests.cpp \ + test/txvalidation_tests.cpp \ test/txvalidationcache_tests.cpp \ test/versionbits_tests.cpp \ test/uint256_tests.cpp \ diff --git a/src/test/txvalidation_tests.cpp b/src/test/txvalidation_tests.cpp new file mode 100644 index 000000000000..11075f6b904a --- /dev/null +++ b/src/test/txvalidation_tests.cpp @@ -0,0 +1,61 @@ +// Copyright (c) 2017 The Bitcoin Core 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