doc: Add documentation for ‘checklevel’ argument in ‘verifychain’ RPC… #19005

pull kcalvinalvin wants to merge 1 commits into bitcoin:master from kcalvinalvin:add-documentation-for-verifychain changing 4 files +14 −9
  1. kcalvinalvin commented at 12:24 pm on May 18, 2020: contributor

    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.

  2. fanquake added the label Docs on May 18, 2020
  3. laanwj commented at 3:12 pm on May 28, 2020: member
    Concept ACK. Though I think it would be fine to refer to the -checklevel command line documentation instead of duplicating the text here (which has a chance of becoming stale if the meanings change).
  4. MarcoFalke commented at 3:55 pm on May 28, 2020: member
    It would also be possible to make a list of the docs static const std::vector<std::string> FOO{"level 1verifies block validity", "bar"}; and then call Join(FOO, ", ") in the command line help and Join(FOO, ".\n") in the RPC help.
  5. kcalvinalvin force-pushed on May 30, 2020
  6. kcalvinalvin commented at 11:04 am on May 30, 2020: contributor
    Now using a list of the docs as suggested.
  7. in src/init.h:14 in 0c688d7001 outdated
     7@@ -8,8 +8,11 @@
     8 
     9 #include <memory>
    10 #include <string>
    11+#include <vector>
    12 #include <util/system.h>
    13 
    14+static const std::vector<std::string> CHECKLEVEL_DOC{"level 0 reads the blocks from disk", "level 1 verifies block validity", "level 2 verifies undo data", "level 3 checks disconnection of tip blocks", "level 4 tries to reconnect the blocks", "each level includes the checks of the previous levels"};
    


    MarcoFalke commented at 11:12 am on May 30, 2020:

    I think it would be slightly easier to read if each was on their own line (like before).

    0static const std::vector<std::string> CHECKLEVEL_DOC{
    1"level 0 reads the blocks from disk",
    2...
    3"each level includes the checks of the previous levels",
    4};
    

    Also, a better place to put this would be in validation.h (just the declaration) and then define it in validation.cpp.

    init.h seem an odd place to put RPC documentation.


    kcalvinalvin commented at 12:25 pm on May 30, 2020:

    I’ve changed it so that each is in their own line but wasn’t quite sure how to just declare in the .h and define in .cpp without the compiler telling me I was re-declaring it.

    At the moment CHECKLEVEL_DOC is declared and defined in validation.h

  8. MarcoFalke approved
  9. MarcoFalke commented at 11:12 am on May 30, 2020: member
    Almost-ACK
  10. kcalvinalvin force-pushed on May 30, 2020
  11. kcalvinalvin force-pushed on May 30, 2020
  12. in src/validation.h:87 in bab64b1fa5 outdated
    83@@ -83,6 +84,15 @@ static const int DEFAULT_STOPATHEIGHT = 0;
    84 static const unsigned int MIN_BLOCKS_TO_KEEP = 288;
    85 static const signed int DEFAULT_CHECKBLOCKS = 6;
    86 static const unsigned int DEFAULT_CHECKLEVEL = 3;
    87+static const std::vector<std::string> CHECKLEVEL_DOC = {
    


    MarcoFalke commented at 12:27 pm on May 30, 2020:
    0extern const std::vector<std::string> CHECKLEVEL_DOC;
    

    In the header (for expensive types, not integers) this should just be the declaration. The rest should go to the cpp file.


    kcalvinalvin commented at 12:29 pm on May 30, 2020:
    Ah ok I should use extern
  13. in src/validation.h:93 in bab64b1fa5 outdated
    88+    "level 0 reads the blocks from disk",
    89+    "level 1 verifies block validity",
    90+    "level 2 verifies undo data",
    91+    "level 3 checks disconnection of tip blocks",
    92+    "level 4 tries to reconnect the blocks",
    93+    "each level includes the checks of the previous levels"
    


    MarcoFalke commented at 12:28 pm on May 30, 2020:
    0    "each level includes the checks of the previous levels",
    

    Nit: Add a trailing comma for consistency and to make clang-format happy?


    kcalvinalvin commented at 12:36 pm on May 30, 2020:
    Addressed
  14. MarcoFalke approved
  15. MarcoFalke commented at 12:28 pm on May 30, 2020: member
    ACK, but the strings could be moved to the cpp file
  16. kcalvinalvin force-pushed on May 30, 2020
  17. kcalvinalvin force-pushed on May 30, 2020
  18. kcalvinalvin force-pushed on May 30, 2020
  19. kcalvinalvin force-pushed on May 30, 2020
  20. kcalvinalvin commented at 2:57 pm on May 30, 2020: contributor
    Rebased and the changes requested were applied.
  21. DrahtBot commented at 11:02 pm on May 30, 2020: member

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Conflicts

    No conflicts as of last run.

  22. DrahtBot added the label Needs rebase on Jun 3, 2020
  23. kcalvinalvin force-pushed on Jun 4, 2020
  24. DrahtBot removed the label Needs rebase on Jun 4, 2020
  25. kcalvinalvin commented at 7:13 am on June 4, 2020: contributor
    rebased
  26. in src/validation.cpp:86 in 8ec2f1407a outdated
    81+    "level 0 reads the blocks from disk",
    82+    "level 1 verifies block validity",
    83+    "level 2 verifies undo data",
    84+    "level 3 checks disconnection of tip blocks",
    85+    "level 4 tries to reconnect the blocks",
    86+    "each level includes the checks of the previous levels,"
    


    jonatack commented at 12:42 pm on June 6, 2020:
    Should there be a comma at the end of this documentation? Perhaps: s/,"/",/

    kcalvinalvin commented at 6:22 am on June 7, 2020:
    Fixed
  27. in src/validation.cpp:80 in 8ec2f1407a outdated
    76@@ -77,6 +77,14 @@ static constexpr std::chrono::hours DATABASE_WRITE_INTERVAL{1};
    77 static constexpr std::chrono::hours DATABASE_FLUSH_INTERVAL{24};
    78 /** Maximum age of our tip for us to be considered current for fee estimation */
    79 static constexpr std::chrono::hours MAX_FEE_ESTIMATION_TIP_AGE{3};
    80+extern const std::vector<std::string> CHECKLEVEL_DOC = {
    


    jonatack commented at 12:45 pm on June 6, 2020:
    No need for extern here in the .cpp file, extern in the .h file should be enough, if I’m not mistaken.

    MarcoFalke commented at 6:53 pm on June 6, 2020:
    0const std::vector<std::string> CHECKLEVEL_DOC{
    

    nit: no need for the =


    kcalvinalvin commented at 6:21 am on June 7, 2020:
    addressed

    kcalvinalvin commented at 6:22 am on June 7, 2020:
    removed
  28. jonatack commented at 12:47 pm on June 6, 2020: member
    Is validation.h/cpp the best place to put CHECKLEVEL_DOC?
  29. MarcoFalke commented at 1:13 pm on June 6, 2020: member

    Is validation.h/cpp the best place to put CHECKLEVEL_DOC?

    checklevel is a validation setting, so where else would you put the documentation?

  30. in src/validation.h:154 in 8ec2f1407a outdated
    150@@ -150,6 +151,8 @@ extern bool fPruneMode;
    151 /** Number of MiB of block files that we're trying to stay below. */
    152 extern uint64_t nPruneTarget;
    153 
    154+extern const std::vector<std::string> CHECKLEVEL_DOC;
    


    jonatack commented at 1:26 pm on June 6, 2020:
    A doxygen comment at line 153 might be nice.

    kcalvinalvin commented at 6:21 am on June 7, 2020:
    Doxygen comment added
  31. jonatack commented at 1:27 pm on June 6, 2020: member

    Is validation.h/cpp the best place to put CHECKLEVEL_DOC?

    checklevel is a validation setting, so where else would you put the documentation?

    Yup, bad grep on my part.

  32. MarcoFalke approved
  33. MarcoFalke commented at 6:54 pm on June 6, 2020: member
    ACK after fixing the nits
  34. kcalvinalvin force-pushed on Jun 7, 2020
  35. in src/rpc/blockchain.cpp:1099 in 292ed3c381 outdated
    1094@@ -1095,7 +1095,8 @@ static UniValue verifychain(const JSONRPCRequest& request)
    1095             RPCHelpMan{"verifychain",
    1096                 "\nVerifies blockchain database.\n",
    1097                 {
    1098-                    {"checklevel", RPCArg::Type::NUM, /* default */ strprintf("%d, range=0-4", DEFAULT_CHECKLEVEL), "How thorough the block verification is."},
    1099+                    {"checklevel", RPCArg::Type::NUM, /* default */ strprintf("%d, range=0-4", DEFAULT_CHECKLEVEL),
    1100+                        strprintf("How thorough the block verification is:\n %s", Join(CHECKLEVEL_DOC, ".\n"))},
    


    jonatack commented at 6:57 am on June 7, 2020:

    suggestion:

    0- strprintf("How thorough the block verification is:\n %s", Join(CHECKLEVEL_DOC, ".\n"))},
    1+ strprintf("How thorough the block verification is:\n - %s", Join(CHECKLEVEL_DOC, "\n- "))},
    

    which would improve the output from

    01. checklevel    (numeric, optional, default=3, range=0-4) How thorough the block verification is:
    1                 level 0 reads the blocks from disk.
    2                 level 1 verifies block validity.
    3                 level 2 verifies undo data.
    4                 level 3 checks disconnection of tip blocks.
    5                 level 4 tries to reconnect the blocks.
    6                 each level includes the checks of the previous levels
    72. nblocks       (numeric, optional, default=6, 0=all) The number of blocks to check.
    

    to

    01. checklevel    (numeric, optional, default=3, range=0-4) How thorough the block verification is:
    1                 - level 0 reads the blocks from disk
    2                 - level 1 verifies block validity
    3                 - level 2 verifies undo data
    4                 - level 3 checks disconnection of tip blocks
    5                 - level 4 tries to reconnect the blocks
    6                 - each level includes the checks of the previous levels
    72. nblocks       (numeric, optional, default=6, 0=all) The number of blocks to check.
    

    kcalvinalvin commented at 9:05 am on June 7, 2020:
    Change applied :)
  36. jonatack commented at 7:01 am on June 7, 2020: member

    Thanks for fixing this issue.

    ACK 292ed3c3810c4ca613c3edc5cb711c9843628fcc modulo suggestion below, happy to re-ACK if you take the suggestion. Verified the bitcoind checklevel help is unchanged and the RPC verifychain help is augmented.

    0$ bitcoind -regtest -help-debug | grep -A6 checklevel
    1  -checklevel=<n>
    2       How thorough the block verification of -checkblocks is: level 0 reads
    3       the blocks from disk, level 1 verifies block validity, level 2
    4       verifies undo data, level 3 checks disconnection of tip blocks,
    5       level 4 tries to reconnect the blocks, each level includes the
    6       checks of the previous levels (0-4, default: 3)
    
  37. doc: Add documentation for 'checklevel' argument in 'verifychain' RPC call 501e6ab4e7
  38. kcalvinalvin force-pushed on Jun 7, 2020
  39. jonatack commented at 9:39 am on June 7, 2020: member
    ACK 501e6ab4e778d8f4e95fdc807eeb8644df16203b git diff 292ed3c 501e6ab shows only change since last review is the verifychain RPCHelpMan edit; rebuild and retested manually anyway
  40. MarcoFalke commented at 10:40 am on June 7, 2020: member

    ACK 501e6ab4e778d8f4e95fdc807eeb8644df16203b 🚝

    Signature:

     0-----BEGIN PGP SIGNED MESSAGE-----
     1Hash: SHA512
     2
     3ACK 501e6ab4e778d8f4e95fdc807eeb8644df16203b 🚝
     4-----BEGIN PGP SIGNATURE-----
     5
     6iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
     7pUjXMgv+L0HtUWgGV37oAs6lbrPfM8FnucZRCR88E9knckuvVA/uBsRso96E7b68
     8jxmnCi7Ay7EGYeFVj3PCO/NvW1xMcwuU0GOQkCnfaPVGwDPZW4bJzxJz3fmIXJFL
     9aoPy8C7erguDYzG5c8Y1Hx7LepCzaqmV/+0oQhp6AthIcRj2L/TKefXmj+RnJj4q
    10WhfZTc6228eDi4ymZpjsJET/veYHllV7NoIQFF8lL7YHO6jvEleFRA4iWGAMy+SB
    117TKmqL8G7+Ye9WJPHobmaAgaBc+wuerwvYI7rw/kcBjm/YfmrSg+2s+kdYzDei4A
    12xr1XZR+vLKYlEZrnRShpagAkIUkiS4ovlhk64YSSm5CKxum/lKp0e5rJW0n+ClVg
    134eJ84l1wS2Wn+/F2f3yq+5mKZYTNl5lS6CxEUu/a0UhE3iw102YbY9P9AN0pk6iL
    14n4yQoVITjwsh9DGoUkymbhpWjyBWaYkgJ08oODWRXBxwtQERoGxqDZXz1P7Y6CKq
    15p+a2uevd
    16=ae1b
    17-----END PGP SIGNATURE-----
    

    Timestamp of file with hash 401273e51463f483d4eab16695a4f04b81f42ac918c61babfed48abdc8e8baa6 -

  41. MarcoFalke merged this on Jun 7, 2020
  42. MarcoFalke closed this on Jun 7, 2020

  43. laanwj commented at 12:27 pm on June 9, 2020: member
    Posthumous ACK 501e6ab4e778d8f4e95fdc807eeb8644df16203b Thanks for factoring the documentatin out.
  44. Fabcien referenced this in commit ea64418dcb on Mar 1, 2021
  45. DrahtBot locked this on Feb 15, 2022
  46. kcalvinalvin deleted the branch on Jul 13, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-22 03:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me