Fix non-atomic blockchain hash chain in create_issue#519
Draft
Copilot wants to merge 2 commits into
Draft
Conversation
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 non-atomic blockchain hash chain in create_issue
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.
The
get → compute → setsequence forlast_hashincreate_issuewas not atomic: concurrent requests could read the sameprev_hashand fork the integrity chain. Additionally, the cache was updated before the DB write, leaving it inconsistent if the commit failed.Changes
backend/routers/issues.pyimport asyncio_blockchain_lock = asyncio.Lock()to serialize the blockchain section within a single processread prev_hash → compute hash → build Issue → DB save → update cachesequence inasync with _blockchain_lock:blockchain_last_hash_cache.set(...)to aftersave_issue_dbso the cache only reflects committed stateType of Change
Related Issue
Testing Done
Screenshots (if applicable)
Checklist
Co-Authors
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.
Summary by cubic
Strengthens blockchain integrity validation and optimizes admin stats to reduce risk of chain corruption and speed up dashboard loads. Prevents concurrent request forks by making hash chain updates atomic.
Bug Fixes
asyncio.Lock, and update the cache only after a successful DB save to avoid forks and cache corruption.Refactors
Written for commit 344c39c. Summary will update on new commits.