Issue #942:
Orphaned blocks sometimes had inconsistent hashes between block index hash (generally the cached value) and the disk index hash (produced by taking a new hash of the data). On closer inspection, hashAccumulators was the only differing value.
Solution
Make sure hashAccumulators is set or copied appropriately where relevant, particularly when mapAccumulatorHashes is set but not changed. The main culprit is likely LoadBlockIndexGuts, since it would be very easy to forget to update hashAccumulators before writing it out again.
Plus we use hashAccumulators instead of recalculating the map's hash as described in #942.
Testing
On regtest, with lots of extra debug warnings in WriteBatchSync about bad hashes, minted zerocoins in forks, confirmed this makes the debug warnings go away.
Problem
Issue #942: Orphaned blocks sometimes had inconsistent hashes between block index hash (generally the cached value) and the disk index hash (produced by taking a new hash of the data). On closer inspection,
hashAccumulators
was the only differing value.Solution
Make sure
hashAccumulators
is set or copied appropriately where relevant, particularly whenmapAccumulatorHashes
is set but not changed. The main culprit is likelyLoadBlockIndexGuts
, since it would be very easy to forget to updatehashAccumulators
before writing it out again.Plus we use
hashAccumulators
instead of recalculating the map's hash as described in #942.Testing
On regtest, with lots of extra debug warnings in
WriteBatchSync
about bad hashes, minted zerocoins in forks, confirmed this makes the debug warnings go away.