forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge bitcoin#24236: Remove utxo db upgrade code
fa9112a Remove utxo db upgrade code (MarcoFalke) Pull request description: It is not possible to upgrade Bitcoin Core pre-segwit (pre-0.13.1) to a recent version without a full IBD from scratch after commit 19a56d1 (released in version 22.0). Any Bitcoin Core version with the new database format after commit 1088b02 (released in version 0.15), can upgrade to any version that is supported as of today. This leaves the versions 0.13.1-0.14.x. Even though those versions are unsupported, some users with an existing datadir may want to upgrade to a recent version. However, it seems reasonable to simply ask them to `-reindex` to run a full IBD from scratch. This allows us to remove the utxo db upgrade code. ACKs for top commit: Sjors: re-ACK fa9112a laanwj: Code review ACK fa9112a Tree-SHA512: 4243bb35df9ac4892f9fad30fe486d338745952bcff4160bcb0937c772d57b13b800647da14695e21e3655e85ee0d95fa3dc7789ee309d59ad84f422297fecb8
- Loading branch information
Showing
9 changed files
with
87 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (c) 2022 The Bitcoin Core developers | ||
# Distributed under the MIT software license, see the accompanying | ||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
"""Test that unsupported utxo db causes an init error. | ||
Previous releases are required by this test, see test/README.md. | ||
""" | ||
|
||
import shutil | ||
|
||
from test_framework.test_framework import BitcoinTestFramework | ||
from test_framework.util import assert_equal | ||
|
||
|
||
class UnsupportedUtxoDbTest(BitcoinTestFramework): | ||
def set_test_params(self): | ||
self.setup_clean_chain = True | ||
self.num_nodes = 2 | ||
|
||
def skip_test_if_missing_module(self): | ||
self.skip_if_no_previous_releases() | ||
|
||
def setup_network(self): | ||
self.add_nodes( | ||
self.num_nodes, | ||
versions=[ | ||
140300, # Last release with previous utxo db format | ||
None, # For MiniWallet, without migration code | ||
], | ||
) | ||
|
||
def run_test(self): | ||
self.log.info("Create previous version (v0.14.3) utxo db") | ||
self.start_node(0) | ||
block = self.generate(self.nodes[0], 1, sync_fun=self.no_op)[-1] | ||
assert_equal(self.nodes[0].getbestblockhash(), block) | ||
assert_equal(self.nodes[0].gettxoutsetinfo()["total_amount"], 50) | ||
self.stop_nodes() | ||
|
||
self.log.info("Check init error") | ||
legacy_utxos_dir = self.nodes[0].chain_path / "chainstate" | ||
legacy_blocks_dir = self.nodes[0].chain_path / "blocks" | ||
recent_utxos_dir = self.nodes[1].chain_path / "chainstate" | ||
recent_blocks_dir = self.nodes[1].chain_path / "blocks" | ||
shutil.copytree(legacy_utxos_dir, recent_utxos_dir) | ||
shutil.copytree(legacy_blocks_dir, recent_blocks_dir) | ||
self.nodes[1].assert_start_raises_init_error( | ||
expected_msg="Error: Unsupported chainstate database format found. " | ||
"Please restart with -reindex-chainstate. " | ||
"This will rebuild the chainstate database.", | ||
) | ||
|
||
self.log.info("Drop legacy utxo db") | ||
self.start_node(1, extra_args=["-reindex-chainstate"]) | ||
assert_equal(self.nodes[1].getbestblockhash(), block) | ||
assert_equal(self.nodes[1].gettxoutsetinfo()["total_amount"], 50) | ||
|
||
|
||
if __name__ == "__main__": | ||
UnsupportedUtxoDbTest().main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters