Skip to content

Conversation

rafaelcr
Copy link
Collaborator

@rafaelcr rafaelcr commented Jul 17, 2025

The current ft_balances table logic does not take into account when a microblock-confirmed transaction is reorged, which means operations can appear more than once in balance calculations for old Stacks 2.x blocks.

This PR fixes this by looking at past microblock re-orgs and recalculating balances based on their transactions.

Copy link

github-actions bot commented Jul 17, 2025

Vercel deployment URL: https://stacks-blockchain-4v5zcuqxn-hirosystems.vercel.app 🚀

@rafaelcr rafaelcr requested a review from zone117x July 17, 2025 23:04
Copy link

codecov bot commented Jul 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@rafaelcr rafaelcr marked this pull request as ready for review July 18, 2025 15:24
@rafaelcr rafaelcr requested a review from tippenein July 18, 2025 15:33
Copy link
Contributor

@tippenein tippenein left a comment

Choose a reason for hiding this comment

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

sql looks good to me. Will the CTE be a performance issue? I'm sure devops can handle it, just noting it since it seems likely to be slow

@rafaelcr rafaelcr merged commit 911c620 into master Jul 18, 2025
25 checks passed
@rafaelcr rafaelcr deleted the fix/mb-reorg-balances branch July 18, 2025 16:03
hirosystems-release-bot bot added a commit that referenced this pull request Jul 18, 2025
## [8.11.5](v8.11.4...v8.11.5) (2025-07-18)

### Bug Fixes

* discount re-orged microblock transactions from ft_balances table ([#2322](#2322)) ([911c620](911c620))
@hirosystems-release-bot
Copy link
Contributor

🎉 This PR is included in version 8.11.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

incorrect balance entries in ft_balances table for some accounts

2 participants