Fix blockchain integrity cache advancing before DB commit#518
Draft
Copilot wants to merge 2 commits into
Draft
Conversation
…ul DB commit Co-authored-by: RohanExploit <178623867+RohanExploit@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] WIP address feedback on blockchain integrity and admin stats optimization
Fix blockchain integrity cache advancing before DB commit
Mar 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
blockchain_last_hash_cachewas updated with the newintegrity_hashbeforesave_issue_dbwas called. A failed DB commit would leave the cache pointing to a hash that was never persisted, causing subsequent issues to chain off a phantom hash and silently corrupting the blockchain integrity chain.Fix:
blockchain_last_hash_cache.set(...)to aftersave_issue_dbsucceeds — cache only advances on confirmed persistblockchain_last_hash_cache.invalidate("last_hash")in theexceptblock — forces a fresh DB lookup on the next request instead of chaining off a stale/uncommitted valueType of Change
Related Issue
Closes #
Testing Done
Screenshots (if applicable)
N/A
Checklist
Co-Authors
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.
Summary by cubic
Strengthens blockchain integrity and speeds up Admin Stats. Tightens validation, fixes the last-hash cache race, and adds fast, indexed rollups with short-lived caching to cut query load and fix incorrect counts.
Bug Fixes
Refactors
Written for commit 59daf4c. Summary will update on new commits.