Right now the loadtxoutset
RPC call treats literally all files with a minimum size of 40 bytes (=size of metadata) as potential valid snapshot candidates and the waiting loop for seeing the metadata block hash in the headers chain is always entered, e.g.:
0$ ./src/bitcoin-cli loadtxoutset ~/.vimrc
1<wait>
2
3bitcoind log:
4...
52023-10-15T14:55:45Z [snapshot] waiting to see blockheader 626174207465730a7265626d756e207465730a656c62616e65207861746e7973 in headers chain before snapshot activation
6...
There is no point in doing any further action though if we already know from the start that the UTXO snapshot loading won’t be successful. This PR adds an assumeutxo parameter check immediately after the metadata is read in, so we can fail immediately on a mismatch:
0$ ./src/bitcoin-cli loadtxoutset ~/.vimrc
1error code: -32603
2error message:
3Unable to load UTXO snapshot, assumeutxo block hash in snapshot metadata not recognized (626174207465730a7265626d756e207465730a656c62616e
465207861746e7973)
This way, users who mistakenly try to load files that are not snapshots don’t have to wait 10 minutes (=the block header waiting timeout) anymore to get a negative response. If a file is loaded which is a valid snapshot (referencing to an existing block hash), but one which doesn’t match the parameters, the feedback is also faster, as we don’t have to wait anymore to see the hash in the headers chain before getting an error.
This is also partially fixes #28621.