change(zebra-state): When the best chain changes, scan all the blocks in the best chain fork #7934
Labels
A-blockchain-scanner
Area: Blockchain scanner of shielded transactions
A-state
Area: State / database changes
C-enhancement
Category: This is an improvement
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.
The text was updated successfully, but these errors were encountered: