[Chain] Keep hashAccumulators more up-to-date. #963
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.