Fixes #22596
When using checklevel=4, block verification fails because of duplicate coinbase transactions involving blocks 91812 and 91722. There was already a check in place within ConnectBlock
to ignore the problematic blocks, but DisconnectBlock
did not contain a similar check to ignore these blocks when called from VerifyDB
.
By ignoring these two blocks in DisconnectBlock
, the block verification process succeeds at checklevel=4.
(Note to reviewers: this is my first contribution to Bitcoin Core, so any feedback is most welcome. Thanks in advance for reviewing!)
Steps to reproduce:
Use the following bitcoin.conf file and start bitcoind. I only used block data through block ~100000 so that the verification process was much faster.
0assumevalid=0
1checkblocks=0
2checklevel=4
Without this change, you will see the following error when the blocks are verified:
02022-04-14T02:56:44Z init message: Verifying blocks…
12022-04-14T02:56:44Z Verifying last 101881 blocks at level 4
22022-04-14T02:56:44Z [0%]...[10%]...[20%]...[30%]...[40%]...ERROR: VerifyDB(): *** coin database inconsistencies found (last 10160 blocks, 142571 good transactions before that)
3
42022-04-14T02:57:01Z : Corrupted block database detected.
5Please restart with -reindex or -reindex-chainstate to recover.
6: Corrupted block database detected.
7Please restart with -reindex or -reindex-chainstate to recover.
With this change, you will see this instead:
02022-04-14T02:32:29Z init message: Verifying blocks…
12022-04-14T02:32:29Z Verifying last 101746 blocks at level 4
22022-04-14T02:32:29Z [0%]...[10%]...[20%]...[30%]...[40%]...[50%]...[60%]...[70%]...[80%]...[90%]...[DONE].
32022-04-14T02:32:48Z No coin database inconsistencies in last 101746 blocks (226126 transactions)