diff options
author | MarcoFalke <falke.marco@gmail.com> | 2020-11-11 16:10:56 +0100 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2020-11-11 16:11:01 +0100 |
commit | d9f5132736f34f31f6e7d009015f917c9dcfec00 (patch) | |
tree | 1a2bee6fe999c83b6d4767ea88d99f906651fdee /test | |
parent | 179ece42734a126ee0b9b7b62feedb4011995eff (diff) | |
parent | 5e146022daa4336de94447e5b8e5418296286927 (diff) |
Merge #20344: wallet: fix scanning progress calculation for single block range
5e146022daa4336de94447e5b8e5418296286927 wallet: fix scanning progress calculation for single block range (Sebastian Falbesoner)
Pull request description:
If the blockchain is rescanned for a single block (i.e. start and stop hashes are equal, and with that also the estimated start/stop verification progress values) the progress calculation could lead to a NaN value caused by a division by zero (0.0/0.0), resulting in an invalid JSON result for the `getwalletinfo` RPC. This PR fixes this behaviour by setting the progress to zero in that special case. Fixes #20297.
The behaviour can easily be reproduced by continuously running single block rescans in an endless loop, e.g. via
```bash
#!/bin/bash
while true
do
bitcoin-cli rescanblockchain $(bitcoin-cli getblockcount)
done
```
and at the same time perform some `getwalletinfo` RPCs.
On the master branch, this leads to frequent invalid responses (tested on mainchain):
```
$ bitcoin-cli getwalletinfo
error: couldn't parse reply from server
$ curl --user `cat ~/.bitcoin/.cookie` --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getwalletinfo", "params": []}' -H 'content-type: text/plain;' http://127.0.0.1:8332/
{"result":{"walletname":"","walletversion":169900,"format":"bdb","balance":0.00000000,"unconfirmed_balance":0.00000000,"immature_balance":0.00000000,"txcount":0,"keypoololdest":1603677276,"keypoolsize":1000,"hdseedid":"3196e33ecb47c7130e6ca60f2f895f9259860dca","keypoolsize_hd_internal":1000,"paytxfee":0.00000000,"private_keys_enabled":true,"avoid_reuse":false,"scanning":{"duration":0,"progress":},"descriptors":false},"error":null,"id":"curltest"}
```
(note that missing value for "progress" in the JSON result).
On the PR branch, the behaviour doesn't occur anymore.
ACKs for top commit:
MarcoFalke:
review ACK 5e146022daa4336de94447e5b8e5418296286927
promag:
Core review ACK 5e146022daa4336de94447e5b8e5418296286927.
Tree-SHA512: f0e6aad5a6cd08b36c5fe820fff0ef26663229b39169a4dbe757f3c795a41cf5c69c9dc90efe7515675ae1059307f8971123781a0514d10704123a6f28b125ab
Diffstat (limited to 'test')
-rw-r--r-- | test/sanitizer_suppressions/ubsan | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/test/sanitizer_suppressions/ubsan b/test/sanitizer_suppressions/ubsan index 75257d886b..7842739523 100644 --- a/test/sanitizer_suppressions/ubsan +++ b/test/sanitizer_suppressions/ubsan @@ -1,7 +1,6 @@ # -fsanitize=undefined suppressions # ================================= float-divide-by-zero:validation.cpp -float-divide-by-zero:wallet/wallet.cpp # -fsanitize=integer suppressions # =============================== |