-
Notifications
You must be signed in to change notification settings - Fork 123
Fix/804 #817
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
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/blockstack/stacks-blockchain-api/FVmpJsuRubSoUkYP732fipsSxNDi |
Codecov Report
@@ Coverage Diff @@
## develop #817 +/- ##
===========================================
+ Coverage 65.39% 65.40% +0.01%
===========================================
Files 90 90
Lines 9122 9142 +20
Branches 1459 1461 +2
===========================================
+ Hits 5965 5979 +14
- Misses 3152 3158 +6
Partials 5 5
Continue to review full report at Codecov.
|
Is this an issue we think might be often be a problem. The wallet could help here, right? Displaying a warning if API returns a different balance from the node? |
Historically that would result in more false positive alerts due to sync issues between the node pool and the API. The client would need to fetch the balance for a given (current) block height using @rafaelcr is working on a script we can run internally that can perform this kind of testing/validation #819 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Manually verified this PR fix balance issues with the following known addresses:
And the addresses/txs listed in issue #818 |
🎉 This PR is included in version 0.70.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Closes #804
This PR fixes a couple issues with microblock re-org handling.
It also likely fixes #624 -- confirmed transactions showing up in mempool as pending -- still need to finish testing this one.
The serious bug here resulted in the API not showing certain transactions in rare scenarios involving both a micro-reorg and anchor-block-reorg. This also resulted in other queries like account balances to be incorrect.
Only around ~30 transactions in total appear to have been affected (and incorrectly appearing as orphaned).
This was caused by a bug similar to the one addressed in #686. Immediately non-canonical anchor blocks (referring to
/new_block
payloads received by the API for blocks that already have a canonical block at the same height) would end up marking transactions as micro-orphaned, and in very rare re-org scenarios, these transactions were not restored after a re-org, i.e. they incorrectly remained orphaned.The fix for this involved A) prevent immediately-non-canonical new blocks from marking microblock data as micro-orphaned because they could be potentially shared with other blocks at the same height, and B) reverse the order of re-org handling so that txs in a given block are marked orphaned before the canonical txs are restored, fixing an issue where anchor block forks clobber over each other's microblock pointers.
So far I've tested the fix by running a query to return txs that are orphaned, and comparing the results from the old db and a db populated using these changes. This query does the job:
Then run through the txs that are missing from the old db, find ones that include a STX transfer, then use the
https://stacks-node-api.mainnet.stacks.co/v2/accounts/<address>
core-node API to verify balances are correct.A different, less serious bug resulted in an incorrect/partial list of microblock hashes in the
/block
response object for themicroblocks_accepted: []
andmicroblocks_streamed: []
arrays. It looks like this could cause display issues in the Explorer's "recent block" list during rare situations involving both a micro-reorg and anchor-block-reorg.This was fixed by removing an UPDATE query which was incorrectly identifying rows in the
microblocks
table by the cachedindex_block_hash
column: