Skip to content

Commit 1b90a7b

Browse files
author
MarcoFalke
committed
Merge #19005: doc: Add documentation for 'checklevel' argument in 'verifychain' RPC…
501e6ab doc: Add documentation for 'checklevel' argument in 'verifychain' RPC call (Calvin Kim) Pull request description: Rationale: When ```bitcoin-cli help verifychain``` is called, the user doesn't get any documentation about the ```checklevel``` argument, leading to issues like #18995. This PR addresses that issue and adds documentation for what each level does, and that each level includes the checks of the previous levels. ACKs for top commit: jonatack: ACK 501e6ab `git diff 292ed3c 501e6ab` shows only change since last review is the verifychain RPCHelpMan edit; rebuild and retested manually anyway MarcoFalke: ACK 501e6ab 🚝 Tree-SHA512: 09239f79c25b5c3022b8eb1f76198ba681305d7e8775038e46becffe5f6a14c572e0c5d06b0723fe9d4a015ec42c9f7ca7b80a2a93df0b1b66f5a84a80eeeeb1
2 parents b1b1739 + 501e6ab commit 1b90a7b

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

src/init.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -500,14 +500,7 @@ void SetupServerArgs(NodeContext& node)
500500
#endif
501501

502502
gArgs.AddArg("-checkblocks=<n>", strprintf("How many blocks to check at startup (default: %u, 0 = all)", DEFAULT_CHECKBLOCKS), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
503-
gArgs.AddArg("-checklevel=<n>", strprintf("How thorough the block verification of -checkblocks is: "
504-
"level 0 reads the blocks from disk, "
505-
"level 1 verifies block validity, "
506-
"level 2 verifies undo data, "
507-
"level 3 checks disconnection of tip blocks, "
508-
"and level 4 tries to reconnect the blocks, "
509-
"each level includes the checks of the previous levels "
510-
"(0-4, default: %u)", DEFAULT_CHECKLEVEL), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
503+
gArgs.AddArg("-checklevel=<n>", strprintf("How thorough the block verification of -checkblocks is: %s (0-4, default: %u)", Join(CHECKLEVEL_DOC, ", "), DEFAULT_CHECKLEVEL), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
511504
gArgs.AddArg("-checkblockindex", strprintf("Do a consistency check for the block tree, chainstate, and other validation data structures occasionally. (default: %u, regtest: %u)", defaultChainParams->DefaultConsistencyChecks(), regtestChainParams->DefaultConsistencyChecks()), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
512505
gArgs.AddArg("-checkmempool=<n>", strprintf("Run checks every <n> transactions (default: %u, regtest: %u)", defaultChainParams->DefaultConsistencyChecks(), regtestChainParams->DefaultConsistencyChecks()), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
513506
gArgs.AddArg("-checkpoints", strprintf("Enable rejection of any forks from the known historical chain until block 295000 (default: %u)", DEFAULT_CHECKPOINTS_ENABLED), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);

src/rpc/blockchain.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,8 @@ static UniValue verifychain(const JSONRPCRequest& request)
10951095
RPCHelpMan{"verifychain",
10961096
"\nVerifies blockchain database.\n",
10971097
{
1098-
{"checklevel", RPCArg::Type::NUM, /* default */ strprintf("%d, range=0-4", DEFAULT_CHECKLEVEL), "How thorough the block verification is."},
1098+
{"checklevel", RPCArg::Type::NUM, /* default */ strprintf("%d, range=0-4", DEFAULT_CHECKLEVEL),
1099+
strprintf("How thorough the block verification is:\n - %s", Join(CHECKLEVEL_DOC, "\n- "))},
10991100
{"nblocks", RPCArg::Type::NUM, /* default */ strprintf("%d, 0=all", DEFAULT_CHECKBLOCKS), "The number of blocks to check."},
11001101
},
11011102
RPCResult{

src/validation.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ static constexpr std::chrono::hours DATABASE_WRITE_INTERVAL{1};
7676
static constexpr std::chrono::hours DATABASE_FLUSH_INTERVAL{24};
7777
/** Maximum age of our tip for us to be considered current for fee estimation */
7878
static constexpr std::chrono::hours MAX_FEE_ESTIMATION_TIP_AGE{3};
79+
const std::vector<std::string> CHECKLEVEL_DOC {
80+
"level 0 reads the blocks from disk",
81+
"level 1 verifies block validity",
82+
"level 2 verifies undo data",
83+
"level 3 checks disconnection of tip blocks",
84+
"level 4 tries to reconnect the blocks",
85+
"each level includes the checks of the previous levels",
86+
};
7987

8088
bool CBlockIndexWorkComparator::operator()(const CBlockIndex *pa, const CBlockIndex *pb) const {
8189
// First sort by most total work, ...

src/validation.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <memory>
3030
#include <set>
3131
#include <stdint.h>
32+
#include <string>
3233
#include <utility>
3334
#include <vector>
3435

@@ -149,6 +150,8 @@ extern bool fHavePruned;
149150
extern bool fPruneMode;
150151
/** Number of MiB of block files that we're trying to stay below. */
151152
extern uint64_t nPruneTarget;
153+
/** Documentation for argument 'checklevel'. */
154+
extern const std::vector<std::string> CHECKLEVEL_DOC;
152155

153156
/** Open a block file (blk?????.dat) */
154157
FILE* OpenBlockFile(const FlatFilePos &pos, bool fReadOnly = false);

0 commit comments

Comments
 (0)