Skip to content
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

change(zebra-state): When the best chain changes, scan all the blocks in the best chain fork #7934

Open
Tracked by #7728
teor2345 opened this issue Nov 10, 2023 · 1 comment
Labels
A-blockchain-scanner Area: Blockchain scanner of shielded transactions A-state Area: State / database changes C-enhancement Category: This is an improvement

Comments

@teor2345
Copy link
Contributor

teor2345 commented Nov 10, 2023

Motivation

When the best chain fork changes, we need to scan the blocks in that fork.

More precisely, we need to scan any blocks in that fork we haven't already scanned. (The difference matters when we've only partially scanned the old chain.)

Since our worst-case scanning is 3 blocks per second, we can scan the 100 blocks in the new fork in 33 seconds. This is less than the 75 second target block time. So we can just re-scan the entire non-finalized chain.

Deleting Old Results

If we store the results by height, then the re-scanning will overwrite the existing entries for those blocks. But since we're storing by height and transaction index, we'll need to delete any transaction indexes that aren't present in the new chain.

The easiest way to do this is to delete all the indexes in the height range that has changed, for each key. Then clients will either get no results during re-scanning, or the latest fork's results.

@teor2345 teor2345 changed the title When the best chain changes, scan the new blocks in the best chain fork change(zebra-state): When the best chain changes, scan the new blocks in the best chain fork Nov 10, 2023
@teor2345 teor2345 added C-enhancement Category: This is an improvement P-Medium ⚡ A-state Area: State / database changes A-blockchain-scanner Area: Blockchain scanner of shielded transactions labels Nov 10, 2023
@teor2345 teor2345 changed the title change(zebra-state): When the best chain changes, scan the new blocks in the best chain fork change(zebra-state): When the best chain changes, scan all the blocks in the best chain fork Dec 4, 2023
@teor2345
Copy link
Contributor Author

teor2345 commented Dec 4, 2023

I updated this ticket based on the scanning speed in:
#7813 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-blockchain-scanner Area: Blockchain scanner of shielded transactions A-state Area: State / database changes C-enhancement Category: This is an improvement
Projects
Status: Product Backlog
Development

No branches or pull requests

2 participants