Is there an existing issue for this?
- I have searched the existing issues
Current behaviour
I tried running invalidateblock on a block a few hundred blocks behind the chain tip. While this command was running, I also ran stop and the node apparently shut down cleanly:
02023-05-02T18:31:17Z UpdateTip: new best=00000000000000000003518599da068e68cca93b3d74bcc25e240229f7a86293 height=787853 version=0x23608000 log2_work=94.154224 tx=830684559 date='2023-05-01T19:44:33Z' progress=0.999711 cache=18.5MiB(104112txo)
12023-05-02T18:31:21Z UpdateTip: new best=00000000000000000003e3254dbe0c37627c01adf82b4582d40cdd9d40065e3b height=787852 version=0x3359c000 log2_work=94.154210 tx=830681309 date='2023-05-01T19:16:08Z' progress=0.999705 cache=19.1MiB(109976txo)
22023-05-02T18:31:27Z UpdateTip: new best=00000000000000000001722f9798d3009acf467a22b15324cbd3a730df7b81d2 height=787851 version=0x32264000 log2_work=94.154197 tx=830676978 date='2023-05-01T19:08:10Z' progress=0.999704 cache=20.2MiB(119117txo)
32023-05-02T18:31:31Z UpdateTip: new best=00000000000000000004fb8e18d4aa564406708db9dcf2e5a19841fb5243c2c5 height=787850 version=0x20000000 log2_work=94.154183 tx=830673049 date='2023-05-01T18:56:27Z' progress=0.999701 cache=21.2MiB(127290txo)
42023-05-02T18:31:32Z addcon thread exit
52023-05-02T18:31:32Z Shutdown: In progress...
62023-05-02T18:31:32Z net thread exit
72023-05-02T18:31:34Z opencon thread exit
82023-05-02T18:31:35Z UpdateTip: new best=00000000000000000003b325732590843673742d287f78699f018e4be50f72b6 height=787849 version=0x20000000 log2_work=94.154169 tx=830668665 date='2023-05-01T18:42:36Z' progress=0.999698 cache=22.4MiB(137486txo)
92023-05-02T18:31:35Z msghand thread exit
102023-05-02T18:31:35Z InvalidChainFound: invalid block=00000000000000000004fb8e18d4aa564406708db9dcf2e5a19841fb5243c2c5 height=787850 log2_work=94.154183 date=2023-05-01T18:56:27Z
112023-05-02T18:31:35Z InvalidChainFound: current best=00000000000000000003b325732590843673742d287f78699f018e4be50f72b6 height=787849 log2_work=94.154169 date=2023-05-01T18:42:36Z
122023-05-02T18:31:35Z DumpAnchors: Flush 0 outbound block-relay-only peer addresses to anchors.dat started
132023-05-02T18:31:35Z DumpAnchors: Flush 0 outbound block-relay-only peer addresses to anchors.dat completed (0.00s)
142023-05-02T18:31:35Z scheduler thread exit
152023-05-02T18:31:35Z Writing 0 unbroadcast transactions to disk.
162023-05-02T18:31:35Z Dumped mempool: 0.00475053s to copy, 0.0185962s to dump
172023-05-02T18:31:35Z Shutdown: done
However, after starting the node again, a corrupted coinstats index is detected and the node shuts down:
02023-05-02T18:31:53Z Bitcoin Core version v24.0.1 (release build)
12023-05-02T18:31:53Z InitParameterInteraction: parameter interaction: -listen=0 -> setting -upnp=0
22023-05-02T18:31:53Z InitParameterInteraction: parameter interaction: -listen=0 -> setting -natpmp=0
32023-05-02T18:31:53Z InitParameterInteraction: parameter interaction: -listen=0 -> setting -discover=0
42023-05-02T18:31:53Z InitParameterInteraction: parameter interaction: -listen=0 -> setting -listenonion=0
52023-05-02T18:31:53Z InitParameterInteraction: parameter interaction: -listen=0 -> setting -i2pacceptincoming=0
62023-05-02T18:31:53Z Using the 'x86_shani(1way,2way)' SHA256 implementation
72023-05-02T18:31:53Z Using RdSeed as an additional entropy source
82023-05-02T18:31:53Z Using RdRand as an additional entropy source
92023-05-02T18:31:53Z Default data directory /home/***/.bitcoin
102023-05-02T18:31:53Z Using data directory /home/***/.bitcoin
112023-05-02T18:31:53Z Config file: /home/***/.bitcoin/bitcoin.conf
122023-05-02T18:31:53Z Config file arg: coinstatsindex="1"
132023-05-02T18:31:53Z Config file arg: dbcache="50"
142023-05-02T18:31:53Z Config file arg: disablewallet="1"
152023-05-02T18:31:53Z Config file arg: listen="0"
162023-05-02T18:31:53Z Config file arg: maxmempool="50"
172023-05-02T18:31:53Z Config file arg: maxorphantx="10"
182023-05-02T18:31:53Z Config file arg: prune="550"
192023-05-02T18:31:53Z Config file arg: rpcauth=****
202023-05-02T18:31:53Z Config file arg: server="1"
212023-05-02T18:31:53Z Config file arg: zmqpubhashblock="tcp://127.0.0.1:28332"
222023-05-02T18:31:53Z Command-line arg: daemon=""
232023-05-02T18:31:53Z Using at most 125 automatic connections (1024 file descriptors available)
242023-05-02T18:31:53Z Using 16 MiB out of 16 MiB requested for signature cache, able to store 524288 elements
252023-05-02T18:31:53Z Using 16 MiB out of 16 MiB requested for script execution cache, able to store 524288 elements
262023-05-02T18:31:53Z Script verification uses 1 additional threads
272023-05-02T18:31:53Z Wallet disabled!
282023-05-02T18:31:53Z scheduler thread start
292023-05-02T18:31:53Z [http] creating work queue of depth 16
302023-05-02T18:31:53Z Using random cookie authentication.
312023-05-02T18:31:53Z Generated RPC authentication cookie /home/***/.bitcoin/.cookie
322023-05-02T18:31:53Z Using rpcauth authentication.
332023-05-02T18:31:53Z [http] starting 4 worker threads
342023-05-02T18:31:53Z Using /16 prefix for IP bucketing
352023-05-02T18:31:53Z init message: Loading P2P addresses…
362023-05-02T18:31:53Z Loaded 67959 addresses from peers.dat 156ms
372023-05-02T18:31:53Z init message: Loading banlist…
382023-05-02T18:31:53Z SetNetworkActive: true
392023-05-02T18:31:53Z Cache configuration:
402023-05-02T18:31:53Z * Using 2.0 MiB for block index database
412023-05-02T18:31:53Z * Using 8.0 MiB for chain state database
422023-05-02T18:31:53Z * Using 40.0 MiB for in-memory UTXO set (plus up to 47.7 MiB of unused mempool space)
432023-05-02T18:31:53Z init message: Loading block index…
442023-05-02T18:31:53Z Assuming ancestors of block 00000000000000000009c97098b5295f7e5f183ac811fb5d1534040adb93cabd have valid signatures.
452023-05-02T18:31:53Z Setting nMinimumChainWork=00000000000000000000000000000000000000003404ba0801921119f903495e
462023-05-02T18:31:53Z Prune configured to target 550 MiB on disk for block and undo files.
472023-05-02T18:31:53Z Switching active chainstate to Chainstate [ibd] @ height -1 (null)
482023-05-02T18:31:53Z Opening LevelDB in /home/***/.bitcoin/blocks/index
492023-05-02T18:31:53Z Opened LevelDB successfully
502023-05-02T18:31:53Z Using obfuscation key for /home/***/.bitcoin/blocks/index: 0000000000000000
512023-05-02T18:31:56Z LoadBlockIndexDB: last block file = 3574
522023-05-02T18:31:56Z LoadBlockIndexDB: last block file info: CBlockFileInfo(blocks=70, size=115412032, heights=787490...787975, time=2023-04-29...2023-05-02)
532023-05-02T18:31:56Z Checking all blk files are present...
542023-05-02T18:31:56Z LoadBlockIndexDB(): Block files have previously been pruned
552023-05-02T18:31:57Z Opening LevelDB in /home/***/.bitcoin/chainstate
562023-05-02T18:31:57Z Opened LevelDB successfully
572023-05-02T18:31:57Z Using obfuscation key for /home/***/.bitcoin/chainstate: 7b252df66097f97f
582023-05-02T18:31:57Z Loaded best chain: hashBestChain=00000000000000000003b325732590843673742d287f78699f018e4be50f72b6 height=787849 date=2023-05-01T18:42:36Z progress=0.999698
592023-05-02T18:31:57Z init message: Verifying blocks…
602023-05-02T18:31:57Z Verifying last 6 blocks at level 3
612023-05-02T18:31:57Z [0%]...[16%]...[33%]...[50%]...[66%]...[83%]...[99%]...[DONE].
622023-05-02T18:32:21Z No coin database inconsistencies in last 6 blocks (22146 transactions)
632023-05-02T18:32:21Z block index 27842ms
642023-05-02T18:32:21Z Opening LevelDB in /home/***/.bitcoin/indexes/coinstats/db
652023-05-02T18:32:21Z Opened LevelDB successfully
662023-05-02T18:32:21Z Using obfuscation key for /home/***/.bitcoin/indexes/coinstats/db: 0000000000000000
672023-05-02T18:32:21Z ERROR: CustomInit: Cannot read current coinstatsindex state; index may be corrupted
682023-05-02T18:32:21Z Shutdown: In progress...
692023-05-02T18:32:21Z scheduler thread exit
702023-05-02T18:32:21Z Shutdown: done
Expected behaviour
Coinstats index should not be corrupted.
Steps to reproduce
With coinstats index turned on run invalidateblock and while that’s running run stop.
Relevant log output
No response
How did you obtain Bitcoin Core
Pre-built binaries
What version of Bitcoin Core are you using?
v24.0.1
Operating system and version
Debian GNU/Linux 11 (bullseye)
Machine specifications
No response