refactor: [Memory optimization] Remove stake modifier checksums #1954
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.
This is part of a series of changes that optimize the memory usage of Gridcoin's block index. According to Valgrind's heap profiler (Massif), these changes will decrease memory usage of the application by over 500 MB after the final PR merges. Because these optimizations apply to every block, memory savings will continue to accrue as the chain grows. I'm breaking-up the commits into separate PRs because the branch has become too unwieldy to review in one submission.
Gridcoin contains some code for stake modifier checksums that carried-over from Peercoin/Blackcoin. However, the checkpoints were never implemented, and I don't think the checksum function ever worked properly. This PR removes the stake modifier checksum/checkpoint system and the
nStakeModifierChecksum
field from the block index.This saves 4 bytes of memory per block and improves synchronization performance a bit.
The modifier checksum verification process that runs on start-up did produce a useful side-effect: it identified corrupt block index entries after unclean shutdowns or power failures. I re-implemented this heuristic as a formal start-up check.