blockstorage: Drop legacy -txindex check #28195

pull MarcoFalke wants to merge 5 commits into bitcoin:master from MarcoFalke:2307-test-blocks- changing 14 files +160 −179
  1. MarcoFalke commented at 10:29 am on August 1, 2023: member

    The only reason for the check was to print a warning about an increase in storage use. Now that 22.x is EOL and everyone should have migrated (or decided to not care about storage use), remove the check.

    Also, a move-only commit is included. (Rebased from #22242)

  2. DrahtBot commented at 10:29 am on August 1, 2023: contributor

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

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK TheCharlatan, stickies-v
    Concept ACK theStack

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #28392 (test: Use pathlib over os path by ns-xvrn)
    • #28311 ([WIP] BIP300 (Drivechains) consensus-level logic by luke-jr)
    • #28226 (util/blockstorage: Add TRACE_RAII, slightly faster -reindex-chainstate with CBufferedFile by martinus)
    • #28051 (Get rid of shutdown.cpp/shutdown.h, use SignalInterrupt directly by ryanofsky)
    • #24230 (indexes: Stop using node internal types and locking cs_main, improve sync logic by ryanofsky)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  3. DrahtBot renamed this:
    blockstorage: Drop legacy -txindex check
    blockstorage: Drop legacy -txindex check
    on Aug 1, 2023
  4. DrahtBot added the label Block storage on Aug 1, 2023
  5. MarcoFalke force-pushed on Aug 1, 2023
  6. DrahtBot added the label CI failed on Aug 1, 2023
  7. MarcoFalke force-pushed on Aug 1, 2023
  8. theStack commented at 1:09 pm on August 1, 2023: contributor

    Concept ACK

    There are still two instances where blocks_path can be used (sometimes it’s quite annoying that python also allows single quote strings):

    0test/functional/feature_pruning.py:        self.prunedir = os.path.join(self.nodes[2].chain_path, 'blocks', '')
    1test/functional/wallet_backup.py:            shutil.rmtree(os.path.join(self.nodes[2].chain_path, 'blocks'))
    

    With my very limited sed skills, I’d just add another line sed -i "s|].chain_path, 'blocks'|].blocks_path|g" $(git grep -l chain_path) to the scripted-diff (probably also possible with only one).

  9. scripted-diff: Use blocks_path where possible
    -BEGIN VERIFY SCRIPT-
      sed -i 's|].chain_path, .blocks.|].blocks_path|g' $(git grep -l chain_path)
    -END VERIFY SCRIPT-
    fa69148a0a
  10. index: Drop legacy -txindex check fa8685597e
  11. move-only: Move CBlockTreeDB to node/blockstorage
    The block index (CBlockTreeDB) is required to write and read blocks, so
    move it to blockstorage. This allows to drop the txdb.h include from
    `node/blockstorage.h`.
    
    Can be reviewed with:
    
    --color-moved=dimmed-zebra  --color-moved-ws=ignore-all-space
    fa65111b99
  12. Fixup style of moved code
    Can be reviewed with --word-diff-regex=.
    faf63039cc
  13. MarcoFalke force-pushed on Aug 1, 2023
  14. DrahtBot removed the label CI failed on Aug 1, 2023
  15. MarcoFalke commented at 3:00 pm on August 1, 2023: member
    Thanks, fixed up the scripted-diff
  16. fanquake commented at 3:29 pm on August 1, 2023: member
  17. scripted-diff: Rename CBlockTreeDB -> BlockTreeDB
    -BEGIN VERIFY SCRIPT-
     sed -i 's|CBlockTreeDB|BlockTreeDB|g' $( git grep -l CBlockTreeDB )
    -END VERIFY SCRIPT-
    fae405556d
  18. TheCharlatan commented at 12:17 pm on August 10, 2023: contributor

    ACK fae405556d56f6f13ce57f69a06b9ec1e825422b, though I lack historical context to really judge the second commit fa8685597e7302fc136f21b6dd3a4b187fa8e251.

    I was curious if it might be possible to easily make one of the CBlockIndex* in BlockTreeDB a CBlockIndex&, but the change became a bit sprawling.

  19. fanquake requested review from stickies-v on Aug 10, 2023
  20. MarcoFalke commented at 9:27 am on August 15, 2023: member

    though I lack historical context to really judge the second commit

    The basic idea is that the legacy txindex was stored inside the block index db. Then a new src/index/ infrastructure was added and there was migration code. Then, the migration code was removed and a warning was added that a previous version is needed (or a full -reindex) to do the migration. Now that all those previous versions are EOL, and thus there should no one be left, who needs a migration, the warning can be removed. Even if someone is left behind, the worst that can happen is they’ll be left with “dangling” db entries (using storage). And they can at any time clear the storage with a full -reindex.

  21. in test/functional/feature_txindex_compatibility.py:1 in fae405556d


    stickies-v commented at 11:32 am on August 31, 2023:
    Should we at some point sunset this test completely? Given that the txindex construction is completely separate from BlockTreeDB, I don’t think there’s really any compatibility testing happening anymore? It’s good to have the test around for this pull, but I’m not sure when it’ll be useful in the future.

    MarcoFalke commented at 11:58 am on August 31, 2023:
    Correct. Seems fine to remove it in the future.

    MarcoFalke commented at 11:59 am on August 31, 2023:
    I mean it is still checking that the dangling BlockTreeDB entries like t T, or txindex do not cause any issues, but at some point we can drop this test.

    stickies-v commented at 2:13 pm on August 31, 2023:
    Okay, thx. I quite like adding “# TODO” comments to make it easier to find future cleanup items, but I don’t really know how I’d phrase the “when” clause so no concrete suggestion.

    MarcoFalke commented at 2:17 pm on August 31, 2023:
    Maybe create an issue (after merge) to remove it after +1 release of this being merged?
  22. in test/functional/feature_txindex_compatibility.py:58 in fae405556d
    53@@ -55,23 +54,13 @@ def run_test(self):
    54         drop_index_chain_dir = self.nodes[1].chain_path
    55         shutil.rmtree(drop_index_chain_dir)
    56         shutil.copytree(legacy_chain_dir, drop_index_chain_dir)
    57-        self.nodes[1].assert_start_raises_init_error(
    58-            extra_args=["-txindex"],
    59-            expected_msg="Error: The block index db contains a legacy 'txindex'. To clear the occupied disk space, run a full -reindex, otherwise ignore this error. This error message will not be displayed again.",
    60-        )
    61         # Build txindex from scratch and check there is no error this time
    62         self.start_node(1, extra_args=["-txindex"])
    


    stickies-v commented at 11:45 am on August 31, 2023:

    Could add these lines to check that if user is upgrading from an older node, they’ll still get a helpful message on how to use txindex again (albeit without cleaning up unused space)?

    0        self.log.info("Check that \"Use -txindex\" error is thrown and -txindex works normally")
    1        self.start_node(1)
    2        assert_raises_rpc_error(-5, "Use -txindex", lambda: self.nodes[1].getrawtransaction(txid=spend_utxo["txid"]))
    3        self.restart_node(1, extra_args=["-txindex"])
    

    MarcoFalke commented at 11:56 am on August 31, 2023:

    if user is upgrading from an older node, they’ll still get a helpful message on how to use txindex again

    I don’t think your suggested test is related to this pull. IIUC you are checking that getrawtransaction recommends to set -txindex. However, if a user previously had it set, they won’t need to change it, and if a user previously had it unset, they’d have to set it in the previous version and here, unrelated of the changes here.

    There is a different test in a another file that checks this already, no?


    stickies-v commented at 2:04 pm on August 31, 2023:

    Yeah you’re right, this doesn’t add anything. I wanted to check that a user had clear instructions on how to build the new txindex, but they wouldn’t have to do anything at all, as they’re already expected to keep -txindex in startup options every time.

    Could explicitly add a check that we’re indeed building a new txindex (as opposed to somehow using the legacy one), but that doesn’t seem like a likely issue either so may not be worth testing? No strong view, so can be marked as resolved.

    0        with self.nodes[1].assert_debug_log(expected_msgs=['Syncing txindex with block chain from height 0']):
    1            self.start_node(1, extra_args=["-txindex"])
    

    MarcoFalke commented at 2:09 pm on August 31, 2023:
    Yeah, as I am not changing this line, and this seems unrelated to the changes here, I’d prefer to keep it as-is for now. Though, I am happy to review a different pull, if there is one.
  23. stickies-v approved
  24. stickies-v commented at 11:47 am on August 31, 2023: contributor

    ACK fae405556d56f6f13ce57f69a06b9ec1e825422b

    The upgrade path when coming from legacy txindex is straightforward and clear enough, no need to keep this extra check around for such an old version imo.

  25. MarcoFalke commented at 7:23 am on September 5, 2023: member
    rfm, or is anything left to be done here?
  26. fanquake merged this on Sep 5, 2023
  27. fanquake closed this on Sep 5, 2023

  28. MarcoFalke deleted the branch on Sep 5, 2023

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-07-03 10:13 UTC

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