Skip to content

fix: stop UpdateStatus from wiping block_hash#25

Merged
sirdeggen merged 1 commit into
mainfrom
fix/immutable-block-hash
Feb 24, 2026
Merged

fix: stop UpdateStatus from wiping block_hash#25
sirdeggen merged 1 commit into
mainfrom
fix/immutable-block-hash

Conversation

@shruggr
Copy link
Copy Markdown
Collaborator

@shruggr shruggr commented Feb 24, 2026

Summary

  • UpdateStatus unconditionally set block_hash on every status change, but no caller ever passed a BlockHash — so it always wrote NULL, wiping the value that SetMinedByBlockHash had correctly set
  • This broke the GetStatus JOIN to merkle_paths for every tx that transitioned MINED → IMMUTABLE (152 of 156 mined txs on a test instance)
  • It also prevented the reorg handler (SetStatusByBlockHash) from finding txs by block_hash to reset them, leaving orphaned txs stuck as IMMUTABLE
  • Removed block_hash from UpdateStatus SQL — it's managed exclusively by SetMinedByBlockHash (sets it) and SetStatusByBlockHash (clears on reorgs)
  • Added migration 3 to repopulate wiped block_hash values from merkle_paths joined through processed_blocks (canonical chain only)

Test plan

  • Existing tests pass
  • Verify GetStatus returns block_height and merkle_path for IMMUTABLE transactions after migration
  • Verify new MINED → IMMUTABLE transitions preserve block_hash

🤖 Generated with Claude Code

UpdateStatus unconditionally set block_hash on every status change.
No caller ever passed a BlockHash, so it always wrote NULL — wiping
the value that SetMinedByBlockHash had correctly set. This broke the
GetStatus JOIN to merkle_paths for every tx that transitioned from
MINED to IMMUTABLE, and also prevented the reorg handler from finding
those txs by block_hash to reset them.

Remove block_hash from UpdateStatus SQL since it is managed exclusively
by SetMinedByBlockHash (sets it) and SetStatusByBlockHash (clears it
on reorgs). Add migration 3 to repopulate wiped block_hash values from
merkle_paths joined through processed_blocks (canonical chain only).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@shruggr shruggr requested a review from mrz1836 as a code owner February 24, 2026 04:37
@github-actions github-actions Bot added bug-P3 Lowest rated bug, affects nearly none or low-impact size/S Small change (11–50 lines) labels Feb 24, 2026
Copy link
Copy Markdown
Contributor

@galt-tr galt-tr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. nancy check is failing but unrelated to this

@sirdeggen sirdeggen merged commit 8bf6937 into main Feb 24, 2026
47 of 49 checks passed
@github-actions github-actions Bot deleted the fix/immutable-block-hash branch February 24, 2026 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-P3 Lowest rated bug, affects nearly none or low-impact size/S Small change (11–50 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants