There are 2 parts to this patchset, both concern the operation of ./contrib/devtools/utxo_snapshot.sh
:
- Error handling is added so that the chainstate can be automatically recovered if an error occurs
- Early exit if a file at OUTPUT_PATH already exists
The easiest way to test this is to take only the 1st part and follow these steps:
- Create a dummy file for the purpose of the test e.g.
echo "some bytes so file is not empty" > ./utxo-788440.dat
- Run bitcoind and wait for it to sync
- Run utxosnapshot.sh with some blockheight and a filepath that already exists e.g.
./contrib/devtools/utxo_snapshot.sh 788440 ./utxo-788440.dat ./src/bitcoin-cli
- Wait for chain rewind to happen, snapshot to be generated and write to disk fail
- Observe that the pivot block is now reconsidered and the chain is restored to the original height
Note that the 2nd part precludes error handling in the case that the file already exists.
For more info see #27841
UPDATE: Squashed into a single commit