Start9Labs / bitcoind-startos

wrapper for building bitcoind.s9pk
Other
14 stars 20 forks source link

[feat]: Automatically detect and delete corrupt peers.dat #98

Open gStart9 opened 2 years ago

gStart9 commented 2 years ago

Prerequisites

Describe the Feature Request

Some of our users (including me) are still experiencing this. This feature will allow bitcoind to get out of its endless restart loop. If peers.dat is corrupt when bitcoin starts, it shuts down (presumably usually caused by a power outage/unplugging of the pi while peers.dat is being written). Since embassyd trys to restart stopped containers, bitcoind just goes into and endless restart loop:

Log excerpt from restart loop:

2022-10-14T18:21:38+00:00 2022-10-14T18:21:38Z Bitcoin Core version v23.0.0 (release build) 2022-10-14T18:21:38+00:00 2022-10-14T18:21:38Z InitParameterInteraction: parameter interaction: -proxy set -> setting -upnp=0 2022-10-14T18:21:38+00:00 2022-10-14T18:21:38Z InitParameterInteraction: parameter interaction: -proxy set -> setting -natpmp=0 2022-10-14T18:21:38+00:00 2022-10-14T18:21:38Z InitParameterInteraction: parameter interaction: -proxy set -> setting -discover=0 2022-10-14T18:21:38+00:00 2022-10-14T18:21:38Z Assuming ancestors of block 000000000000000000052d314a259755ca65944e68df6b12a067ea8f1f5a7091 have valid signatures. 2022-10-14T18:21:38+00:00 2022-10-14T18:21:38Z Setting nMinimumChainWork=00000000000000000000000000000000000000002927cdceccbd5209e81e80db 2022-10-14T18:21:38+00:00 2022-10-14T18:21:38Z Using the 'standard' SHA256 implementation 2022-10-14T18:21:38+00:00 2022-10-14T18:21:38Z Default data directory /root/.bitcoin 2022-10-14T18:21:38+00:00 2022-10-14T18:21:38Z Using data directory /root/.bitcoin 2022-10-14T18:21:38+00:00 2022-10-14T18:21:38Z Config file: /root/.bitcoin/bitcoin.conf ... 2022-10-14T18:21:38+00:00 2022-10-14T18:21:38Z Command-line arg: conf="/root/.bitcoin/bitcoin.conf" 2022-10-14T18:21:38+00:00 2022-10-14T18:21:38Z Command-line arg: datadir="/root/.bitcoin" 2022-10-14T18:21:38+00:00 2022-10-14T18:21:38Z Command-line arg: externalip="myreallylong.onion" 2022-10-14T18:21:38+00:00 2022-10-14T18:21:38Z Command-line arg: onion="172.18.0.1:9050" 2022-10-14T18:21:38+00:00 2022-10-14T18:21:38Z Command-line arg: proxy="172.18.0.1:9050" 2022-10-14T18:21:38+00:00 2022-10-14T18:21:38Z Using at most 125 automatic connections (1048576 file descriptors available) 2022-10-14T18:21:38+00:00 2022-10-14T18:21:38Z Using 16 MiB out of 32/2 requested for signature cache, able to store 524288 elements 2022-10-14T18:21:38+00:00 2022-10-14T18:21:38Z Using 16 MiB out of 32/2 requested for script execution cache, able to store 524288 elements 2022-10-14T18:21:38+00:00 2022-10-14T18:21:38Z Script verification uses 3 additional threads 2022-10-14T18:21:38+00:00 2022-10-14T18:21:38Z scheduler thread start 2022-10-14T18:21:38+00:00 2022-10-14T18:21:38Z WARNING: the RPC server is not safe to expose to untrusted networks such as the public internet 2022-10-14T18:21:38+00:00 2022-10-14T18:21:38Z HTTP: creating work queue of depth 64 2022-10-14T18:21:38+00:00 2022-10-14T18:21:38Z Config options rpcuser and rpcpassword will soon be deprecated. Locally-run instances may remove rpcuser to use cookie-based auth, or may be replaced with rpcauth. Please see share/rpcauth for rpcauth auth generation. 2022-10-14T18:21:38+00:00 2022-10-14T18:21:38Z HTTP: starting 16 worker threads 2022-10-14T18:21:38+00:00 2022-10-14T18:21:38Z Using wallet directory /root/.bitcoin 2022-10-14T18:21:38+00:00 2022-10-14T18:21:38Z init message: Verifying wallet(s)… 2022-10-14T18:21:38+00:00 2022-10-14T18:21:38Z Using /16 prefix for IP bucketing 2022-10-14T18:21:38+00:00 2022-10-14T18:21:38Z init message: Loading P2P addresses… 2022-10-14T18:21:40+00:00 2022-10-14T18:21:40Z Error: Invalid or corrupt peers.dat (Checksum mismatch, data corrupted). If you believe this is a bug, please report it to https://github.com/bitcoin/bitcoin/issues. As a workaround, you can move the file ("/root/.bitcoin/peers.dat") out of the way (rename, move, or delete) to have a new one created on the next start. 2022-10-14T18:21:40+00:00 Error: Invalid or corrupt peers.dat (Checksum mismatch, data corrupted). If you believe this is a bug, please report it to https://github.com/bitcoin/bitcoin/issues. As a workaround, you can move the file ("/root/.bitcoin/peers.dat") out of the way (rename, move, or delete) to have a new one created on the next start. 2022-10-14T18:21:40+00:00 2022-10-14T18:21:40Z Shutdown: In progress... 2022-10-14T18:21:41+00:00 2022-10-14T18:21:41Z scheduler thread exit 2022-10-14T18:21:41+00:00 2022-10-14T18:21:41Z Shutdown: done

Describe the Use Case

Bitcoin and all other services dependent on bitcoin are dead in the water until peers.dat is deleted and bitcoin can start syncing again.

Describe Preferred Solution

Detect the corrupt peers.dat in the log file, and automatically delete it if it's corrupt. This will require less human intervention and attention, so it's much better than the alternative solution.

Describe Alternatives

"Delete peers.dat" option under Services > Bitcoin Core > Actions

gStart9 commented 2 years ago

Tagged support people in case you guys have input. Added Matt for sanity checking / alternative viability / scoping / prior knowledge / further assignment purposes.

kn0wmad commented 2 years ago

Tagged support people in case you guys have input. Added Matt for sanity checking / alternative viability / scoping / prior knowledge / further assignment purposes.

At this time, protocol is to assign the service owner, in this case @dr-bonez I believe, and then you can pass the link on for comment. We want to avoid having multiple assignees. I think this is slated for the v24 update / refresh.