assumevalid
(which disables script verification and therefore speeds up IBD) is not always applied in the context of a -reindex
:
The assumevalid criteria are https://github.com/bitcoin/bitcoin/blob/d73f37dda221835b5109ede1b84db2dc7c4b74a1/src/validation.cpp#L2497-L2500
meaning that our best known header needs to have at least as much work than the hard-coded minchainwork.
During normal IBD, we don’t connect blocks before having minchainwork headers (headers sync phase), so this is not a problem.
However,-reindex
deletes the block tree db and attempts to rebuild it based on local block files, without attempting to re-request headers for which we don’t have the full block yet (because we didn’t get to that point in the previous IBD).
Therefore, users that encounter an error somewhere midway through IBD and need to reindex, won’t use -assumevalid
and will rebuild the chainstate slowly.
This has also been encountered in the context of benchmarking.
Possible solutions:
- always enable assumvalid while connecting blocks in the context of reindexing
- attempt to sync remaining headers via the p2p nework after rebuilding the block tree db, but before calling
ActivateBestChain()
to start connecting blocks