From fa8685597e7302fc136f21b6dd3a4b187fa8e251 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Tue, 1 Aug 2023 11:01:48 +0200 Subject: [PATCH] index: Drop legacy -txindex check --- src/init.cpp | 5 --- src/txdb.cpp | 33 +++++++------------ src/txdb.h | 3 -- .../feature_txindex_compatibility.py | 11 ------- 4 files changed, 12 insertions(+), 40 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index c11f100139d..3cf6471d9f8 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1550,11 +1550,6 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) // ********************************************************* Step 8: start indexers if (args.GetBoolArg("-txindex", DEFAULT_TXINDEX)) { - auto result{WITH_LOCK(cs_main, return CheckLegacyTxindex(*Assert(chainman.m_blockman.m_block_tree_db)))}; - if (!result) { - return InitError(util::ErrorString(result)); - } - g_txindex = std::make_unique(interfaces::MakeChain(node), cache_sizes.tx_index, false, fReindex); node.indexes.emplace_back(g_txindex.get()); } diff --git a/src/txdb.cpp b/src/txdb.cpp index e5b5e0b8a12..670aaab6063 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -6,15 +6,23 @@ #include #include +#include +#include +#include #include #include +#include #include +#include +#include #include #include #include #include -#include +#include +#include +#include static constexpr uint8_t DB_COIN{'C'}; static constexpr uint8_t DB_BLOCK_FILES{'f'}; @@ -28,26 +36,9 @@ static constexpr uint8_t DB_LAST_BLOCK{'l'}; // Keys used in previous version that might still be found in the DB: static constexpr uint8_t DB_COINS{'c'}; -static constexpr uint8_t DB_TXINDEX_BLOCK{'T'}; -// uint8_t DB_TXINDEX{'t'} - -util::Result CheckLegacyTxindex(CBlockTreeDB& block_tree_db) -{ - CBlockLocator ignored{}; - if (block_tree_db.Read(DB_TXINDEX_BLOCK, ignored)) { - return util::Error{_("The -txindex upgrade started by a previous version cannot be completed. Restart with the previous version or run a full -reindex.")}; - } - bool txindex_legacy_flag{false}; - block_tree_db.ReadFlag("txindex", txindex_legacy_flag); - if (txindex_legacy_flag) { - // Disable legacy txindex and warn once about occupied disk space - if (!block_tree_db.WriteFlag("txindex", false)) { - return util::Error{Untranslated("Failed to write block index db flag 'txindex'='0'")}; - } - return util::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.")}; - } - return {}; -} +// CBlockTreeDB::DB_TXINDEX_BLOCK{'T'}; +// CBlockTreeDB::DB_TXINDEX{'t'} +// CBlockTreeDB::ReadFlag("txindex") bool CCoinsViewDB::NeedsUpgrade() { diff --git a/src/txdb.h b/src/txdb.h index 6405437be93..d773f01b505 100644 --- a/src/txdb.h +++ b/src/txdb.h @@ -11,7 +11,6 @@ #include #include #include -#include #include #include @@ -105,6 +104,4 @@ public: EXCLUSIVE_LOCKS_REQUIRED(::cs_main); }; -[[nodiscard]] util::Result CheckLegacyTxindex(CBlockTreeDB& block_tree_db); - #endif // BITCOIN_TXDB_H diff --git a/test/functional/feature_txindex_compatibility.py b/test/functional/feature_txindex_compatibility.py index 572e12df138..939271b3851 100755 --- a/test/functional/feature_txindex_compatibility.py +++ b/test/functional/feature_txindex_compatibility.py @@ -7,7 +7,6 @@ Previous releases are required by this test, see test/README.md. """ -import os import shutil from test_framework.test_framework import BitcoinTestFramework @@ -55,10 +54,6 @@ class TxindexCompatibilityTest(BitcoinTestFramework): drop_index_chain_dir = self.nodes[1].chain_path shutil.rmtree(drop_index_chain_dir) shutil.copytree(legacy_chain_dir, drop_index_chain_dir) - self.nodes[1].assert_start_raises_init_error( - extra_args=["-txindex"], - 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.", - ) # Build txindex from scratch and check there is no error this time self.start_node(1, extra_args=["-txindex"]) self.wait_until(lambda: self.nodes[1].getindexinfo()["txindex"]["synced"] == True) @@ -66,12 +61,6 @@ class TxindexCompatibilityTest(BitcoinTestFramework): self.stop_nodes() - self.log.info("Check migrated txindex cannot be read by legacy node") - err_msg = f": You need to rebuild the database using -reindex to change -txindex.{os.linesep}Please restart with -reindex or -reindex-chainstate to recover." - shutil.rmtree(legacy_chain_dir) - shutil.copytree(drop_index_chain_dir, legacy_chain_dir) - self.nodes[0].assert_start_raises_init_error(extra_args=["-txindex"], expected_msg=err_msg) - if __name__ == "__main__": TxindexCompatibilityTest().main()