HomePhabricator

script: Enhance validations in utxo_snapshot.sh

Description

script: Enhance validations in utxo_snapshot.sh

Summary:

  • Ensure that the snapshot height is higher than the pruned block height when the node is pruned.
  • Validate the correctness of the file path and check if the file already exists.
  • Make network activity disablement optional for the user.
  • Ensure the reconsiderblock command is triggered on exit, even in the case of user interruption (Ctrl-C).
  • Fix block height out of range
  • Fix hash_serialized_2 -> hash_serialized

This is a backport of core#28852, core#30690

Test Plan:
Backup the datadir.
Start bitcoind in a different terminal and monitor it while the script is running.

$ ./contrib/devtools/utxo_snapshot.sh 888000 ../utxo.dat ./build/src/bitcoin-cli
Do you want to disable network activity (setnetworkactive false) before running invalidateblock? (Y/n): Y
Disabling network activity
false
Rewinding chain back to height 888000 (by invalidating 00000000000000001e72f6310cc606c4a47d71d5168f55b6f96b6a6f61f9f616); this may take a while
Generating UTXO snapshot...
{
  "coins_written": 38780572,
  "base_hash": "00000000000000002b218d995a292c34bc4c0244bb4bbdad18f3a97e88ccb567",
  "base_height": 888000,
  "path": "/data0/ecashd/../utxo.dat",
  "txoutset_hash": "50493f6218661a189654dbad816821a656b519454190c63daf376610e4fa0a7e",
  "nchaintx": 299158458
}
Restoring chain to original height; this may take a while
Restoring network activity
true

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D17855

Details

Provenance
pablomartin4btc <pablomartin4btc@gmail.com>Authored on Oct 13 2023, 03:53
PiRKCommitted on Tue, Mar 25, 22:52
PiRKPushed on Tue, Mar 25, 22:53
Reviewer
Restricted Project
Differential Revision
D17855: script: Enhance validations in utxo_snapshot.sh
Parents
rABC396a501ae4d5: [chronik] Amend broadcast_tx and broadcast_txs in bitcoinsuite-chronik-client
Branches
Unknown
Tags
Unknown