Skip to content

fix: consider microblock transactions in balance calculations #2277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

rafaelcr
Copy link
Collaborator

@rafaelcr rafaelcr commented May 12, 2025

The API has Stacks 2.x logic to avoid re-inserting transactions to the DB during a /new_block event when those transactions were previously inserted during a /new_microblock event. However, the new /extended/v2 balance endpoint logic only considers /new_block transactions when adding/subtracting from account balances. This is causing some old 2.x blocks to warp balances in accounts that happened to have transactions confirmed in previous microblocks.

This PR changes this behavior so these balance calculations always include all transactions regardless of microblocks. It also includes a migration that will execute a query to recompute all transaction balances to correct the issue on deployed environments.

Fixes #2267

Copy link

github-actions bot commented May 12, 2025

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

Copy link

codecov bot commented May 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@rafaelcr rafaelcr changed the title fix: balances after microblocks fix: consider microblock transactions in balance calculations May 13, 2025
@rafaelcr rafaelcr marked this pull request as ready for review May 13, 2025 15:54
@rafaelcr rafaelcr requested a review from zone117x May 13, 2025 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

new stx balance endpoint returning incorrect amounts in some cases
1 participant